List of usage examples for java.lang System clearProperty
public static String clearProperty(String key)
From source file:org.apache.solr.cloud.AbstractDistribZkTestBase.java
@Override public void distribTearDown() throws Exception { System.clearProperty(ZK_HOST); System.clearProperty("collection"); System.clearProperty(ENABLE_UPDATE_LOG); System.clearProperty(REMOVE_VERSION_FIELD); System.clearProperty("solr.directoryFactory"); System.clearProperty("solr.test.sys.prop1"); System.clearProperty("solr.test.sys.prop2"); System.clearProperty(ZOOKEEPER_FORCE_SYNC); System.clearProperty(MockDirectoryFactory.SOLR_TESTS_ALLOW_READING_FILES_STILL_OPEN_FOR_WRITE); resetExceptionIgnores();//www . j a v a 2s . c o m try { super.distribTearDown(); } finally { zkServer.shutdown(); } }
From source file:com.seleniumtests.it.core.TestSeleniumRobotTestListener.java
@Test(groups = { "it" }) public void testContextDriverBlockingBeforeClass(ITestContext testContext) throws Exception { try {//from w w w.j av a 2 s .co m System.setProperty(SeleniumTestsContext.BROWSER, "htmlunit"); System.setProperty("startLocation", "beforeClass"); executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClassForListener5.test1Listener5", "com.seleniumtests.it.stubclasses.StubTestClassForListener5.test2Listener5" }, "", "stub1"); } finally { System.clearProperty(SeleniumTestsContext.BROWSER); } String detailedReportContent1 = readTestMethodResultFile("test1Listener5"); Assert.assertTrue(detailedReportContent1.contains(DRIVER_BLOCKED_MSG)); String logs = readSeleniumRobotLogFile(); Assert.assertTrue(logs.contains("start suite")); Assert.assertTrue(logs.contains("start test")); Assert.assertFalse(logs.contains("start class")); String outDir = new File(SeleniumTestsContextManager.getGlobalContext().getOutputDirectory()) .getAbsolutePath(); JSONObject jsonResult = new JSONObject( FileUtils.readFileToString(Paths.get(outDir, "results.json").toFile())); // All tests should be skipped because configuration method is skipped Assert.assertEquals(jsonResult.getInt("skip"), 2); }
From source file:org.springframework.cloud.stream.metrics.ApplicationMetricsExporterTests.java
@Test public void propertiesFromLowerPrioritySourcesOverridden() throws Exception { System.setProperty("spring.cloud.application.guid.test.metrics", "lowPriority"); try {/*from w ww. j a v a2 s. c om*/ ConfigurableApplicationContext applicationContext = SpringApplication.run( BinderExporterApplication.class, "--server.port=0", "--spring.jmx.enabled=false", "--spring.cloud.application.guid.test.metrics=highPriority", "--spring.metrics.export.delay-millis=500", "--spring.cloud.stream.bindings." + Emitter.APPLICATION_METRICS + ".destination=foo", "--spring.metrics.export.includes=integration**", "--spring.cloud.stream.metrics.properties=spring**"); Emitter emitterSource = applicationContext.getBean(Emitter.class); MessageCollector collector = applicationContext.getBean(MessageCollector.class); Message<?> message = collector.forChannel(emitterSource.applicationMetrics()).poll(10, TimeUnit.SECONDS); Assert.assertNotNull(message); ObjectMapper mapper = applicationContext.getBean(ObjectMapper.class); ApplicationMetrics applicationMetrics = mapper.readValue((String) message.getPayload(), ApplicationMetrics.class); Assert.assertTrue( contains("integration.channel.errorChannel.errorRate.mean", applicationMetrics.getMetrics())); Assertions .assertThat( applicationMetrics.getProperties().get("spring.cloud.application.guid.test.metrics")) .isEqualTo("highPriority"); applicationContext.close(); } finally { System.clearProperty("spring.cloud.application.guid.test.metrics"); } }
From source file:io.apiman.manager.test.junit.ManagerRestTester.java
/** * Resets the system properties that were set at the start of the test. */// ww w . j a v a 2 s . c o m private void resetSystemProperties() { for (String propName : resetSysProps) { System.clearProperty(propName); } resetSysProps.clear(); }
From source file:org.apache.solr.SolrTestCaseJ4.java
public static void resetFactory() throws Exception { if (!changedFactory) return;// www .j a v a 2 s . com changedFactory = false; if (savedFactory != null) { System.setProperty("solr.directoryFactory", savedFactory); } else { System.clearProperty("solr.directoryFactory"); } }
From source file:com.huawei.streaming.storm.KerberosSecurity.java
private void restoreSecurityProperties(String propertyKey) { if (Strings.isNullOrEmpty(backupSecurityConf.getProperty(propertyKey))) { System.clearProperty(propertyKey); } else {//from w w w. jav a2s .c om System.setProperty(propertyKey, backupSecurityConf.getProperty(propertyKey)); } }
From source file:org.apache.geode.management.internal.ManagementAgent.java
private void stopHttpService() { if (this.httpServer != null) { if (logger.isDebugEnabled()) { logger.debug("Stopping the HTTP service..."); }/*from www . j a va 2 s . c om*/ try { this.httpServer.stop(); } catch (Exception e) { logger.warn("Failed to stop the HTTP service because: {}", e.getMessage(), e); } finally { try { this.httpServer.destroy(); } catch (Exception ignore) { logger.error("Failed to properly release resources held by the HTTP service: {}", ignore.getMessage(), ignore); } finally { this.httpServer = null; System.clearProperty("catalina.base"); System.clearProperty("catalina.home"); } } } }
From source file:com.cisco.dvbu.ps.deploytool.services.ResourceManagerImpl.java
public void deleteResources(String serverId, String resourceIds, String pathToResourceXML, String pathToServersXML) throws CompositeException { String prefix = "deleteResources"; String processedIds = null;//www .ja va 2s .c om // Extract variables for the resourceIds resourceIds = CommonUtils.extractVariable(prefix, resourceIds, propertyFile, true); // Set the Module Action Objective String s1 = (resourceIds == null) ? "no_resourceIds" : "Ids=" + resourceIds; System.setProperty("MODULE_ACTION_OBJECTIVE", "DELETE : " + s1); List<ResourceType> resourceList = getResources(serverId, resourceIds, pathToResourceXML, pathToServersXML); if (resourceList != null && resourceList.size() > 0) { for (ResourceType resource : resourceList) { // Get the identifier and convert any $VARIABLES String resourceId = CommonUtils.extractVariable(prefix, resource.getId(), propertyFile, true); /** * Possible values for archives * 1. csv string like import1,import2 (we process only resource names which are passed in) * 2. '*' or what ever is configured to indicate all resources (we process all resources in this case) * 3. csv string with '-' or what ever is configured to indicate exclude resources as prefix * like -import1,import3 (we ignore passed in resources and process rest of the in the input xml */ if (DeployUtil.canProcessResource(resourceIds, resourceId)) { // Add to the list of processed ids if (processedIds == null) processedIds = ""; else processedIds = processedIds + ","; processedIds = processedIds + resourceId; if (resource.getResourcePath() != null && resource.getResourcePath().size() > 0) { for (int i = 0; i < resource.getResourcePath().size(); i++) { String resourcePath = resource.getResourcePath().get(i); System.setProperty("RESOURCE_ID", resourceId); deleteResource(serverId, resourcePath, pathToServersXML); System.clearProperty("RESOURCE_ID"); } } else { if (logger.isInfoEnabled()) { logger.info("No resource paths found for resourceId " + resourceId); } } } } // Determine if any resourceIds were not processed and report on this if (processedIds != null) { if (logger.isInfoEnabled()) { logger.info("Resource entries processed=" + processedIds); } } else { if (logger.isInfoEnabled()) { String msg = "Warning: No resource entries were processed for the input list. resourceIds=" + resourceIds; logger.info(msg); System.setProperty("MODULE_ACTION_MESSAGE", msg); } } } else { if (logger.isInfoEnabled()) { String msg = "Warning: No procedure entries found for Resource Module XML at path=" + pathToResourceXML; logger.info(msg); System.setProperty("MODULE_ACTION_MESSAGE", msg); } } }
From source file:com.seleniumtests.it.core.TestSeleniumRobotTestListener.java
@Test(groups = { "it" }) public void testContextDriverBlockingBeforeMethod(ITestContext testContext) throws Exception { try {/*from w w w . ja va 2 s . c om*/ System.setProperty(SeleniumTestsContext.BROWSER, "htmlunit"); System.setProperty("startLocation", "beforeMethod"); executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClassForListener5.test1Listener5", "com.seleniumtests.it.stubclasses.StubTestClassForListener5.test2Listener5" }, "", "stub1"); } finally { System.clearProperty(SeleniumTestsContext.BROWSER); } String detailedReportContent1 = readTestMethodResultFile("test1Listener5"); Assert.assertTrue(detailedReportContent1.contains(DRIVER_BLOCKED_MSG)); String logs = readSeleniumRobotLogFile(); Assert.assertTrue(logs.contains("start suite")); Assert.assertTrue(logs.contains("start test")); Assert.assertTrue(logs.contains("start class")); Assert.assertFalse(logs.contains("start method")); String outDir = new File(SeleniumTestsContextManager.getGlobalContext().getOutputDirectory()) .getAbsolutePath(); JSONObject jsonResult = new JSONObject( FileUtils.readFileToString(Paths.get(outDir, "results.json").toFile())); // All tests should be skipped because configuration method is skipped Assert.assertEquals(jsonResult.getInt("skip"), 2); }
From source file:com.kylinolap.query.test.KylinTestBase.java
protected int runSQL(File sqlFile, boolean debug, boolean explain) throws Exception { if (debug) {// ww w . j a v a 2 s . co m System.setProperty("optiq.debug", "true"); InputStream inputStream = new FileInputStream("src/test/resources/logging.properties"); LogManager.getLogManager().readConfiguration(inputStream); } String queryName = StringUtils.split(sqlFile.getName(), '.')[0]; printInfo("Testing Query " + queryName); String sql = getTextFromFile(sqlFile); if (explain) { sql = "explain plan for " + sql; } int count = executeQuery(sql, true); if (debug) { System.clearProperty("optiq.debug"); } return count; }