List of usage examples for java.lang System clearProperty
public static String clearProperty(String key)
From source file:com.blackducksoftware.integration.hub.rest.RestConnection.java
/** * Clears the previously set System properties I.E. https.proxyHost, * https.proxyPort, http.proxyHost, http.proxyPort, http.nonProxyHosts * *//* w ww . j a v a 2 s . c o m*/ private void cleanUpOldProxySettings() { System.clearProperty("http.proxyHost"); System.clearProperty("http.proxyPort"); System.clearProperty("http.nonProxyHosts"); AuthenticatorUtil.resetAuthenticator(); }
From source file:org.apache.zeppelin.interpreter.remote.RemoteInterpreterTest.java
@Test public void testFailToLaunchInterpreterProcess_InvalidRunner() { try {//from ww w.ja va2s. c o m System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_REMOTE_RUNNER.getVarName(), "invalid_runner"); final Interpreter interpreter1 = interpreterSetting.getInterpreter("user1", "note1", "sleep"); final InterpreterContext context1 = createDummyInterpreterContext(); // run this dummy interpret method first to launch the RemoteInterpreterProcess to avoid the // time overhead of launching the process. try { interpreter1.interpret("1", context1); fail("Should not be able to launch interpreter process"); } catch (InterpreterException e) { assertTrue(ExceptionUtils.getStackTrace(e).contains("No such file or directory")); } } finally { System.clearProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_REMOTE_RUNNER.getVarName()); } }
From source file:com.seleniumtests.it.core.TestSeleniumRobotTestListener.java
@Test(groups = { "it" }) public void testContextDriverBlockingAfterClass(ITestContext testContext) throws Exception { try {// ww w .j ava2 s. co m System.setProperty(SeleniumTestsContext.BROWSER, "htmlunit"); System.setProperty("startLocation", "afterClass"); 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.assertTrue(logs.contains("start method")); Assert.assertTrue(logs.contains("test 1")); Assert.assertTrue(logs.contains("end method")); Assert.assertFalse(logs.contains("end 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("pass"), 2); }
From source file:org.dspace.servicemanager.config.DSpaceConfigurationServiceTest.java
/** * Tests the ability of the system to properly extract system properties into the configuration. * (NOTE: This ability to load system properties is specified in the test "config-definition.xml") *//*from w w w .j a v a2 s . c o m*/ @Test public void testGetPropertiesFromSystem() { DSpaceConfigurationService dscs = new DSpaceConfigurationService(); int size = dscs.getProperties().size(); System.setProperty("dspace.system.config", "Hello"); System.setProperty("another.property", "Adios"); dscs.reloadConfig(); assertEquals(size + 2, dscs.getProperties().size()); assertEquals("Hello", dscs.getProperty("dspace.system.config")); assertEquals("Adios", dscs.getProperty("another.property")); System.clearProperty("dspace.system.config"); System.clearProperty("another.property"); dscs.clear(); dscs = null; }
From source file:com.cisco.dvbu.ps.deploytool.services.ResourceManagerImpl.java
public void renameResources(String serverId, String resourceIds, String pathToResourceXML, String pathToServersXML) throws CompositeException { String prefix = "renameResources"; String processedIds = null;/*www . j a v a 2 s . c o m*/ // 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", "RENAME : " + s1); // Validate whether the files exist or not if (!CommonUtils.fileExists(pathToResourceXML)) { throw new CompositeException("File [" + pathToResourceXML + "] does not exist."); } if (!CommonUtils.fileExists(pathToServersXML)) { throw new CompositeException("File [" + pathToServersXML + "] does not exist."); } 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); renameResource(serverId, resourcePath, pathToServersXML, resource.getNewName()); 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 resource entries found for Resource Module XML at path=" + pathToResourceXML; logger.info(msg); System.setProperty("MODULE_ACTION_MESSAGE", msg); } } }
From source file:org.apache.zeppelin.interpreter.remote.RemoteInterpreterTest.java
@Test public void testFailToLaunchInterpreterProcess_ErrorInRunner() { try {// www. ja v a2 s.c om System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_REMOTE_RUNNER.getVarName(), zeppelinHome.getAbsolutePath() + "/zeppelin-zengine/src/test/resources/bin/interpreter_invalid.sh"); final Interpreter interpreter1 = interpreterSetting.getInterpreter("user1", "note1", "sleep"); final InterpreterContext context1 = createDummyInterpreterContext(); // run this dummy interpret method first to launch the RemoteInterpreterProcess to avoid the // time overhead of launching the process. try { interpreter1.interpret("1", context1); fail("Should not be able to launch interpreter process"); } catch (InterpreterException e) { assertTrue(ExceptionUtils.getStackTrace(e).contains("invalid_command: command not found")); } } finally { System.clearProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_REMOTE_RUNNER.getVarName()); } }
From source file:org.apache.solr.cloud.BaseCdcrDistributedZkTest.java
/** * Restart a server./*from ww w . j a v a2s .com*/ */ protected void restartServer(CloudJettyRunner server) throws Exception { // it seems we need to set the collection property to have the jetty properly restarted System.setProperty("collection", server.collection); JettySolrRunner jetty = server.jetty; ChaosMonkey.stop(jetty); ChaosMonkey.start(jetty); System.clearProperty("collection"); waitForRecoveriesToFinish(server.collection, true); updateMappingsFromZk(server.collection); // must update the mapping as the core node name might have changed }
From source file:org.apache.stratos.integration.common.StratosTestServerManager.java
public synchronized void serverShutdown(int portOffset) throws AutomationFrameworkException { if (this.process != null) { log.info("Shutting down server.."); if (ClientConnectionUtil.isPortOpen(Integer.parseInt("9443") + portOffset)) { int e = defaultHttpsPort + portOffset; String url = null;// www. j a va2s.c o m try { url = this.automationContext.getContextUrls().getBackEndUrl(); } catch (XPathExpressionException var10) { throw new AutomationFrameworkException("Get context failed", var10); } String backendURL = url.replaceAll("(:\\d+)", ":" + e); try { ClientConnectionUtil.sendForcefulShutDownRequest(backendURL, this.automationContext.getSuperTenant().getContextUser().getUserName(), this.automationContext.getSuperTenant().getContextUser().getPassword()); } catch (AutomationFrameworkException var8) { throw new AutomationFrameworkException("Get context failed", var8); } catch (XPathExpressionException var9) { throw new AutomationFrameworkException("Get context failed", var9); } long time = System.currentTimeMillis() + 300000L; while (!this.inputStreamHandler.getOutput().contains("Halting JVM") && System.currentTimeMillis() < time) { ; } log.info("Server stopped successfully..."); } this.inputStreamHandler.stop(); this.errorStreamHandler.stop(); this.process.destroy(); this.process = null; if (this.isCoverageEnable) { try { log.info("Generating Jacoco code coverage..."); this.generateCoverageReport(new File(this.carbonHome + File.separator + "repository" + File.separator + "components" + File.separator + "plugins" + File.separator)); } catch (IOException var7) { log.error("Failed to generate code coverage ", var7); throw new AutomationFrameworkException("Failed to generate code coverage ", var7); } } if (portOffset == 0) { System.clearProperty("carbon.home"); } } }
From source file:org.geotools.gce.imagemosaic.ImageMosaicPostgisIndexOnlineTest.java
@Override protected void tearDownInternal() throws Exception { // delete tables dropTables(new String[] { tempFolderName1, tempFolderName2, noGeomLast, noGeomFirst, tempFolderName3 }); System.clearProperty("org.geotools.referencing.forceXY"); // clean up disk if (!ImageMosaicReaderTest.INTERACTIVE) { File parent = TestData.file(this, "."); File directory = new File(parent, tempFolderName1); if (directory.isDirectory() && directory.exists()) { FileUtils.deleteDirectory(directory); }//from ww w.ja v a 2 s . co m directory = new File(parent, tempFolderName2); if (directory.isDirectory() && directory.exists()) { FileUtils.deleteDirectory(directory); } directory = new File(parent, tempFolderName3); if (directory.isDirectory() && directory.exists()) { FileUtils.deleteDirectory(directory); } } super.tearDownInternal(); }
From source file:dk.statsbiblioteket.util.XPropertiesTest.java
public void testEnvironment() throws Exception { new Properties(null); Properties sysProps = new Properties(); sysProps.setProperty("XProperty:foo", "bar"); sysProps.setProperty("XProperty:int", "87"); sysProps.setProperty("XProperty:negative", "-43"); sysProps.setProperty("XProperty:double", "12.13"); sysProps.setProperty("XProperty:negdouble", "-14.0"); sysProps.setProperty("XProperty:true", "true"); sysProps.setProperty("XProperty:false", "false"); sysProps.setProperty("XProperty:sub/int", "88"); sysProps.setProperty("XProperty:uboat/deep/s", "flam"); System.getProperties().putAll(sysProps); XProperties properties = new XProperties(); assertEquals("Should contain imported sysprops", sysProps.size(), properties.size()); assertEquals("Environment-specified Strings should work", "bar", properties.getString("foo")); assertEquals("Environment-specified ints should work", 87, properties.getInteger("int")); assertEquals("Environment-specified negative ints should work", -43, properties.getInteger("negative")); assertEquals("Environment-specified doubles should work", 12.13, properties.getDouble("double")); assertEquals("Environment-specified negative doubles should work", -14.0, properties.getDouble("negdouble")); assertEquals("Environment-specified true should work", true, properties.getBoolean("true")); assertEquals("Environment-specified false should work", false, properties.getBoolean("false")); assertEquals("Environment-specified subproperty should work", 88, properties.getSubProperty("sub").getInteger("int")); assertEquals("Environment-specified subsubproperty should work", "flam", properties.getSubProperty("uboat").getSubProperty("deep").getString("s")); // Clean up//w w w . j av a2 s . co m for (Object prop : sysProps.keySet()) { System.clearProperty((String) prop); } assertEquals("System XProperties was not cleaned up", 0, new XProperties().size()); }