List of usage examples for java.lang System clearProperty
public static String clearProperty(String key)
From source file:com.liferay.maven.plugins.AbstractLiferayMojo.java
protected void executeTool(String toolClassName, ClassLoader classLoader, String[] args) throws Exception { Thread currentThread = Thread.currentThread(); ClassLoader contextClassLoader = currentThread.getContextClassLoader(); currentThread.setContextClassLoader(classLoader); SecurityManager currentSecurityManager = System.getSecurityManager(); // Required to prevent premature exit by DBBuilder. See LPS-7524. SecurityManager securityManager = new SecurityManager() { public void checkPermission(Permission permission) { }//from w w w. j a v a 2 s.c o m public void checkExit(int status) { throw new SecurityException(); } }; System.setSecurityManager(securityManager); try { System.setProperty("external-properties", "com/liferay/portal/tools/dependencies" + "/portal-tools.properties"); System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger"); Class<?> clazz = classLoader.loadClass(toolClassName); Method method = clazz.getMethod("main", String[].class); method.invoke(null, (Object) args); } catch (InvocationTargetException ite) { if (ite.getCause() instanceof SecurityException) { } else { throw ite; } } finally { currentThread.setContextClassLoader(contextClassLoader); System.clearProperty("org.apache.commons.logging.Log"); System.setSecurityManager(currentSecurityManager); } }
From source file:org.jboss.as.test.integration.ws.wsse.trust.WSBearerElytronSecurityPropagationTestCase.java
@Test @RunAsClient/* w w w.j ava2 s. c o m*/ @OperateOnDeployment(BEARER_SERVER_DEP) @WrapThreadContextClassLoader public void testBearer() throws Exception { // TLSv1.2 seems buggy on JDK-11 (Invalid ECDH ServerKeyExchange signature) String originalProtocols = System.getProperty("https.protocols"); System.setProperty("https.protocols", "TLSv1.1"); Bus bus = BusFactory.newInstance().createBus(); try { BusFactory.setThreadDefaultBus(bus); final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/bearerwssecuritypolicy", "BearerService"); Service service = Service.create(new URL(serviceURL + "BearerService?wsdl"), serviceName); BearerIface proxy = (BearerIface) service.getPort(BearerIface.class); WSTrustTestUtils.setupWsseAndSTSClientBearer((BindingProvider) proxy, bus); assertEquals("alice&alice", proxy.sayHello()); } finally { bus.shutdown(true); if (originalProtocols == null) { System.clearProperty("https.protocols"); } else { System.setProperty("https.protocols", originalProtocols); } } }
From source file:org.apache.solr.hadoop.MorphlineBasicMiniMRTest.java
@AfterClass public static void teardownClass() throws Exception { System.clearProperty("solr.hdfs.blockcache.enabled"); System.clearProperty("test.build.dir"); System.clearProperty("test.build.data"); System.clearProperty("test.cache.data"); if (mrCluster != null) { mrCluster.shutdown();// www . jav a 2s . c o m mrCluster = null; } if (dfsCluster != null) { dfsCluster.shutdown(); dfsCluster = null; } FileSystem.closeAll(); }
From source file:org.apache.eagle.app.environment.impl.StormExecutionRuntime.java
@Override public void start(Application<StormEnvironment, StormTopology> executor, com.typesafe.config.Config config) { String topologyName = config.getString("appId"); Preconditions.checkNotNull(topologyName, "[appId] is required by null for " + executor.getClass().getCanonicalName()); StormTopology topology = executor.execute(config, environment); LOG.info("Starting {} ({}), mode: {}", topologyName, executor.getClass().getCanonicalName(), config.getString("mode")); Config conf = getStormConfig(config); if (ApplicationEntity.Mode.CLUSTER.name().equalsIgnoreCase(config.getString("mode"))) { String jarFile = config.hasPath("jarPath") ? config.getString("jarPath") : null; if (jarFile == null) { jarFile = DynamicJarPathFinder.findPath(executor.getClass()); }/*www . j a va2s . com*/ synchronized (StormExecutionRuntime.class) { System.setProperty("storm.jar", jarFile); LOG.info("Submitting as cluster mode ..."); try { StormSubmitter.submitTopologyWithProgressBar(topologyName, conf, topology); } catch (AlreadyAliveException | InvalidTopologyException e) { LOG.error(e.getMessage(), e); throw new RuntimeException(e.getMessage(), e); } finally { System.clearProperty("storm.jar"); } } } else { LOG.info("Submitting as local mode ..."); getLocalCluster().submitTopology(topologyName, conf, topology); LOG.info("Submitted"); } LOG.info("Started {} ({})", topologyName, executor.getClass().getCanonicalName()); }
From source file:org.apache.solr.ltr.TestRerankBase.java
protected static void aftertest() throws Exception { restTestHarness.close();//from www . j a va2 s . c o m restTestHarness = null; jetty.stop(); jetty = null; FileUtils.deleteDirectory(tmpSolrHome); System.clearProperty("managed.schema.mutable"); // System.clearProperty("enable.update.log"); unchooseDefaultFeatureFormat(); }
From source file:com.seleniumtests.it.reporter.TestPerformanceReporter.java
/** * Chack that if several custom reports are specified through custom reports, they are all available * @param testContext/*from w ww .j av a 2 s . co m*/ * @throws Exception */ @Test(groups = { "it" }) public void testMultipleReportsWithSteps(ITestContext testContext) throws Exception { try { System.setProperty("customTestReports", "PERF::xml::reporter/templates/report.perf.vm,PERF2::json::ti/report.test.vm"); executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClass" }, ParallelMode.METHODS, new String[] { "testAndSubActions" }); String jmeterReport1 = FileUtils .readFileToString(Paths.get(SeleniumTestsContextManager.getGlobalContext().getOutputDirectory(), "testAndSubActions", "PERF-result.xml").toFile()); String jmeterReport2 = FileUtils .readFileToString(Paths.get(SeleniumTestsContextManager.getGlobalContext().getOutputDirectory(), "testAndSubActions", "PERF2-result.json").toFile()); Assert.assertTrue(jmeterReport1.contains( "<testsuite errors=\"0\" failures=\"0\" hostname=\"\" name=\"testAndSubActions\" tests=\"7\" time=\"15")); Assert.assertTrue(jmeterReport2.contains("\"suiteName\": \"testAndSubActions\"")); } finally { System.clearProperty("customTestReports"); } }
From source file:org.eclipse.recommenders.internal.stacktraces.rcp.LogListenerTest.java
@Test public void testNoReportIfBuildIdUnknown() { System.clearProperty(SYSPROP_ECLIPSE_BUILD_ID); Status status = new Status(IStatus.ERROR, TEST_PLUGIN_ID, "a message"); sut.logging(status, ""); verifyNoErrorReportSend();//from ww w .java 2 s . c o m }
From source file:org.apache.solr.ltr.TestLTROnSolrCloud.java
@AfterClass public static void after() throws Exception { FileUtils.deleteDirectory(tmpSolrHome); System.clearProperty("managed.schema.mutable"); }
From source file:com.seleniumtests.it.reporter.TestCustomReporter.java
@Test(groups = { "it" }, expectedExceptions = ConfigurationException.class) public void testSummaryReportDoesNotExists(ITestContext testContext) throws Exception { try {/*www . ja va2 s . com*/ System.setProperty("customSummaryReports", "SUP::json::ti/report.summary.nowhere.vm"); executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClass" }, ParallelMode.METHODS, new String[] { "testAndSubActions", "testInError", "testWithException" }); } finally { System.clearProperty("customSummaryReports"); } }
From source file:org.apache.sling.maven.jspc.JspcMojo.java
public void execute() throws MojoExecutionException { try {/* www . jav a 2 s . c o m*/ uriSourceRoot = sourceDirectory.getCanonicalPath(); } catch (Exception e) { uriSourceRoot = sourceDirectory.getAbsolutePath(); } // ensure output directory File outputDirectoryFile = new File(outputDirectory); if (!outputDirectoryFile.isDirectory()) { if (outputDirectoryFile.exists()) { throw new MojoExecutionException(outputDirectory + " exists but is not a directory"); } if (!outputDirectoryFile.mkdirs()) { throw new MojoExecutionException("Cannot create output directory " + outputDirectory); } } // have the files compiled String oldValue = System.getProperty(LogFactoryImpl.LOG_PROPERTY); try { // ensure the JSP Compiler does not try to use Log4J System.setProperty(LogFactoryImpl.LOG_PROPERTY, SimpleLog.class.getName()); executeInternal(); } catch (JasperException je) { getLog().error("Compilation Failure", je); throw new MojoExecutionException(je.getMessage(), je); } finally { if (oldValue == null) { System.clearProperty(LogFactoryImpl.LOG_PROPERTY); } else { System.setProperty(LogFactoryImpl.LOG_PROPERTY, oldValue); } } project.addCompileSourceRoot(outputDirectory); }