List of usage examples for org.apache.commons.lang SystemUtils IS_JAVA_1_6
boolean IS_JAVA_1_6
To view the source code for org.apache.commons.lang SystemUtils IS_JAVA_1_6.
Click Source Link
Is true
if this is Java version 1.6 (also 1.6.x versions).
The field will return false
if #JAVA_VERSION is null
.
From source file:org.jboss.as.test.manualmode.web.ssl.HTTPSWebConnectorTestCase.java
/** * @test.tsfi tsfi.keystore.file//from w w w . ja v a2 s. co m * @test.tsfi tsfi.truststore.file * @test.objective Testing default HTTPs connector with verify-client attribute set to "want". The CLIENT-CERT * authentication (BaseCertLoginModule) is configured for this test. Trusted client is allowed to access * both secured/unsecured resource. Untrusted client can only access unprotected resources. * @test.expectedResult Trusted client has access to protected and unprotected resources. Untrusted client has only access * to unprotected resources. * @throws Exception */ @Test @InSequence(1) public void testWantVerifyConnector() throws Exception { Assume.assumeFalse( SystemUtils.IS_JAVA_1_6 && SystemUtils.JAVA_VENDOR.toUpperCase(Locale.ENGLISH).contains("IBM")); final URL printPrincipalUrl = getServletUrl(HTTPS_PORT_VERIFY_WANT, PrincipalPrintingServlet.SERVLET_PATH); final URL securedUrl = getServletUrl(HTTPS_PORT_VERIFY_WANT, SECURED_SERVLET_WITH_SESSION); final URL unsecuredUrl = getServletUrl(HTTPS_PORT_VERIFY_WANT, SimpleServlet.SERVLET_PATH); final HttpClient httpClient = getHttpClient(CLIENT_KEYSTORE_FILE); final HttpClient httpClientUntrusted = getHttpClient(UNTRUSTED_KEYSTORE_FILE); try { makeCallWithHttpClient(printPrincipalUrl, httpClientUntrusted, HttpServletResponse.SC_FORBIDDEN); final String principal = makeCallWithHttpClient(printPrincipalUrl, httpClient, HttpServletResponse.SC_OK); assertEquals("Unexpected principal", "cn=client", principal.toLowerCase()); String responseBody = makeCallWithHttpClient(unsecuredUrl, httpClient, HttpServletResponse.SC_OK); assertEquals("Unsecured page was not reached", SimpleSecuredServlet.RESPONSE_BODY, responseBody); responseBody = makeCallWithHttpClient(securedUrl, httpClient, HttpServletResponse.SC_OK); assertEquals("Secured page was not reached", SimpleSecuredServlet.RESPONSE_BODY, responseBody); responseBody = makeCallWithHttpClient(unsecuredUrl, httpClientUntrusted, HttpServletResponse.SC_OK); assertEquals("Unsecured page was not reached", SimpleServlet.RESPONSE_BODY, responseBody); makeCallWithHttpClient(securedUrl, httpClientUntrusted, HttpServletResponse.SC_FORBIDDEN); } finally { httpClient.getConnectionManager().shutdown(); httpClientUntrusted.getConnectionManager().shutdown(); } }
From source file:org.sonar.graph.CycleDetectorTest.java
@Test public void testGetCyclesWithMultipleCycles() { DirectedGraph<String, StringEdge> dcg = DirectedGraph.createStringDirectedGraph(); dcg.addEdge("A", "B").addEdge("B", "C").addEdge("C", "D").addEdge("D", "A"); dcg.addEdge("C", "A"); dcg.addEdge("B", "A"); dcg.addEdge("A", "E").addEdge("E", "C"); dcg.addEdge("E", "D"); dcg.addEdge("E", "F"); dcg.addEdge("F", "C"); CycleDetector<String> cycleDetector = new CycleDetector<String>(dcg); cycleDetector.detectCycles();/*from w w w. ja va 2 s . c om*/ assertThat(cycleDetector.getCycles()).hasSize(8); if (SystemUtils.IS_JAVA_1_6 || SystemUtils.IS_JAVA_1_7) { assertThat(cycleDetector.getSearchCyclesCalls()).isEqualTo(8); } else { // Java 8 assertThat(cycleDetector.getSearchCyclesCalls()).isEqualTo(11); } }
From source file:stg.pr.engine.CProcessRequestEngine.java
/** * Entry point of the engine It first checks whether one argument is passed. * If no argument is found an exception is thrown with an appropriate * message. If arguments are passed correctly an object of this class is * created and engine starts execution.//from www . j a va 2s . c om * * @param args * expects args array of length 1, containing the path of init * file * @throws Exception */ public static void main(String[] args) throws Exception { CProcessRequestEngine objPre = null; try { if (args.length < 2) { throw new Exception( "Usage: java stg.pr.engine.CProcessRequestEngine <prinit.properties file path> <log4j.properties file path>"); } if (!SystemUtils.IS_JAVA_1_6) { throw new Exception("Unable to start. Requires Java 1.6"); } String str = System.getProperty("pre.reboot.attempt"); int iRebtCnt = -1; if (str != null) { iRebtCnt = Integer.parseInt(str); } try { // if ("true".equalsIgnoreCase(System.getProperty("genlicreq", // "false"))) { // LicenseRequestor licenseRequestor = new LicenseRequestor(); // licenseRequestor.generateRequest(); // return; // } objPre = CProcessRequestEngine.getInstance(args[0], args[1], iRebtCnt); objPre.startEngine(); } catch (Exception e) { if (objPre != null) { if (!objPre.isReboot()) { throw e; } } else { throw e; } } } catch (Exception e) { throw e; } finally { if (objPre != null) { if (objPre.isReboot() && objPre.getRebootCounter() > objPre.getRebootMaxCounter()) { objPre.setReboot(false); } } } // System.exit(100); }
From source file:stg.pr.engine.startstop.CStartEngine.java
/** * Starts the controller./*w w w. ja v a2s.co m*/ * * Method responsible to handle start, reboot, shutdown of PRE. * * @param args */ public void start(String[] args) { if (logger_.isEnabledFor(LogLevel.FINE)) { logger_.log(LogLevel.FINE, "Initialized."); } if (!SystemUtils.IS_JAVA_1_6) { logger_.log(LogLevel.NOTICE, "Unable to start. Requires Java 1.6"); return; } boolean bStart = true; String[] cmd = null; while (bStart) { CSettings settings = null; ErrReader errReader = null; OutReader outReader = null; Process process = null; try { if (logger_.isEnabledFor(LogLevel.FINER)) { logger_.log(LogLevel.FINER, "Loading Runtime settings."); } settings = CSettings.getInstance(); settings.load(args[0]); try { iRebootMaxCounter_ = Integer.parseInt(CSettings.get("pr.rebootmaxcounter", "-1")); lRebootSleepTime_ = Long.parseLong(CSettings.get("pr.sleepbeforereboottime", "5")); } catch (NumberFormatException e) { logger_.fatal("Please check the properties 'rebootmaxcounter' and 'sleepbeforereboottime' ", e); throw e; } if (cmd == null) { cmd = buildCommand(null, args); } if (logger_.isEnabledFor(LogLevel.FINE)) { logger_.log(LogLevel.FINE, "Starting Engine..."); } disableLog4j(); process = Runtime.getRuntime().exec(cmd); BufferedReader out = new BufferedReader(new InputStreamReader(process.getInputStream())); BufferedReader err = new BufferedReader(new InputStreamReader(process.getErrorStream())); outReader = new OutReader(out); errReader = new ErrReader(err); outReader.setFlag(""); errReader.setFlag(""); outReader.start(); errReader.start(); if (outReader != null) { outReader.waitForDone(); } if (errReader != null) { errReader.waitForDone(); } outReader.shutdown(); errReader.shutdown(); out.close(); err.close(); process.waitFor(); enableLog4j(); Properties properties = getMessageFromPRE(); String strAction = properties.getProperty("action"); if (logger_.isEnabledFor(LogLevel.FINEST)) { logger_.log(LogLevel.FINEST, "Action initiated #" + strAction); } if (strAction.equals(REBOOT)) { ArrayList<String> list = new ArrayList<String>(); if (Integer.parseInt(properties.getProperty("counter")) <= 0) { iRebootCounter_ = 1; } else { iRebootCounter_++; } if (iRebootCounter_ > iRebootMaxCounter_) { logger_.log(LogLevel.NOTICE, iRebootCounter_ + " Re-boot attempt(s) failed to start the engine"); bStart = false; // shutdown } if (bStart) { list.add("-Dpre.reboot.attempt=" + iRebootCounter_); sleep(lRebootSleepTime_, "Re-booting the Engine after a wait of " + lRebootSleepTime_ + " minute(s)."); cmd = buildCommand(list, args); } } else if (strAction.equals(BOUNCE)) { logger_.log(LogLevel.NOTICE, "Process Request Engine has CRASHED. The PRE will be bounced. "); logger_.log(LogLevel.NOTICE, "Bouncing the engine"); iRebootCounter_ = 0; sleep(lRebootSleepTime_, "Bouncing the Engine after a wait of " + lRebootSleepTime_ + " minute(s)."); } else if (strAction.equals(SHUTDOWN)) { if (iRebootCounter_ > iRebootMaxCounter_) { logger_.log(LogLevel.NOTICE, iRebootCounter_ + " Re-boot attempt(s) failed to start the engine"); } if (logger_.isEnabledFor(LogLevel.FINE)) { logger_.log(LogLevel.FINE, "Shuting down the controller."); } bStart = false; } } catch (IOException e) { bStart = false; } catch (InterruptedException e) { bStart = false; } finally { if (settings != null) { enableLog4j(); if (logger_.isEnabledFor(LogLevel.FINEST)) { logger_.log(LogLevel.FINEST, "Destroying Runtime settings."); } settings.destroy(); } // if (process != null) { // process.destroy(); // } } } // end of while if (logger_.isEnabledFor(LogLevel.FINE)) { logger_.log(LogLevel.FINE, "Shutdown complete."); } disableLog4j(); }
From source file:VASSAL.tools.image.FallbackImageTypeConverter.java
private boolean tryConvertingInMemory(Reference<BufferedImage> ref) { /*//from w w w .j a v a 2s .c o m * Having an OutOfMemoryException while converting in memory is * apparently catastrophic on Apple's Java 6 JVM (and possibly also * on their Java 5 JVM as well). In-memory tiling also uses far more * memory than it should on Apple's Java 6 JVM due to * Graphics2D.drawImage making an intermediate copy of the image data. * Hence, we ensure that when using Java 5 or 6 on Mac OS X, we never * try in-memory conversion for images which can't comfortably have * three copies existing simultaneously in memory. */ return !SystemUtils.IS_OS_MAC_OSX || (!SystemUtils.IS_JAVA_1_6 && !SystemUtils.IS_JAVA_1_5) || 4 * ref.obj.getHeight() * ref.obj.getWidth() <= Runtime.getRuntime().maxMemory() / 4; }