List of usage examples for java.lang System clearProperty
public static String clearProperty(String key)
From source file:com.seleniumtests.it.core.TestSeleniumRobotTestListener.java
@Test(groups = { "it" }) public void testContextDriverBlockingAfterTest(ITestContext testContext) throws Exception { try {/* ww w . j a v a 2 s .c om*/ System.setProperty(SeleniumTestsContext.BROWSER, "htmlunit"); System.setProperty("startLocation", "afterTest"); 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.assertTrue(logs.contains("end class")); Assert.assertFalse(logs.contains("end test")); 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.apache.hadoop.registry.client.impl.zk.RegistrySecurity.java
/** * Clear all the ZK SASL Client properties * <b>Important:</b>This is JVM-wide *//* w w w. j a v a 2 s .com*/ public static void clearZKSaslClientProperties() { disableZookeeperClientSASL(); System.clearProperty(PROP_ZK_SASL_CLIENT_CONTEXT); System.clearProperty(PROP_ZK_SASL_CLIENT_USERNAME); }
From source file:org.apache.zeppelin.interpreter.remote.RemoteInterpreterTest.java
@Test public void testFailToLaunchInterpreterProcess_Timeout() { try {// w ww .j a va2s. c o m System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_REMOTE_RUNNER.getVarName(), zeppelinHome.getAbsolutePath() + "/zeppelin-zengine/src/test/resources/bin/interpreter_timeout.sh"); System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT.getVarName(), "10000"); 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("Interpreter Process creation is time out")); } } finally { System.clearProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_REMOTE_RUNNER.getVarName()); System.clearProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT.getVarName()); } }
From source file:com.datatorrent.stram.StramRecoveryTest.java
private static String restoreSystemProperty(final String key, final String value) { return (value == null) ? System.clearProperty(key) : System.setProperty(key, value); }
From source file:org.apache.solr.cloud.BaseCdcrDistributedZkTest.java
/** * Creates and starts a given number of servers. *//* w w w .jav a2 s . c o m*/ protected List<String> startServers(int nServer) throws Exception { String temporaryCollection = "tmp_collection"; System.setProperty("collection", temporaryCollection); for (int i = 1; i <= nServer; i++) { // give everyone there own solrhome File jettyDir = createTempDir("jetty").toFile(); jettyDir.mkdirs(); setupJettySolrHome(jettyDir); JettySolrRunner jetty = createJetty(jettyDir, null, "shard" + i); jettys.add(jetty); } ZkStateReader zkStateReader = jettys.get(0).getCoreContainer().getZkController().getZkStateReader(); // now wait till we see the leader for each shard for (int i = 1; i <= shardCount; i++) { this.printLayout(); zkStateReader.getLeaderRetry(temporaryCollection, "shard" + i, 15000); } // store the node names List<String> nodeNames = new ArrayList<>(); for (Slice shard : zkStateReader.getClusterState().getCollection(temporaryCollection).getSlices()) { for (Replica replica : shard.getReplicas()) { nodeNames.add(replica.getNodeName()); } } // delete the temporary collection - we will create our own collections later this.deleteCollection(temporaryCollection); this.waitForCollectionToDisappear(temporaryCollection); System.clearProperty("collection"); return nodeNames; }
From source file:org.kie.server.services.impl.AbstractKieServerImplTest.java
@Test public void testExecutorPropertiesInStateRepository() { KieServerStateFileRepository stateRepository = new KieServerStateFileRepository(REPOSITORY_DIR); KieServerState state = stateRepository.load(KIE_SERVER_ID); String executorInterval = state.getConfiguration() .getConfigItemValue(KieServerConstants.CFG_EXECUTOR_INTERVAL); String executorRetries = state.getConfiguration() .getConfigItemValue(KieServerConstants.CFG_EXECUTOR_RETRIES); String executorPool = state.getConfiguration().getConfigItemValue(KieServerConstants.CFG_EXECUTOR_POOL); String executorTimeUnit = state.getConfiguration() .getConfigItemValue(KieServerConstants.CFG_EXECUTOR_TIME_UNIT); String executorJMSQueue = state.getConfiguration() .getConfigItemValue(KieServerConstants.CFG_EXECUTOR_JMS_QUEUE); String executorDisabled = state.getConfiguration() .getConfigItemValue(KieServerConstants.CFG_EXECUTOR_DISABLED); assertNull(executorInterval);// www .j a v a 2 s .c om assertNull(executorRetries); assertNull(executorPool); assertNull(executorTimeUnit); assertNull(executorJMSQueue); assertNull(executorDisabled); try { System.setProperty(KieServerConstants.CFG_EXECUTOR_INTERVAL, "4"); System.setProperty(KieServerConstants.CFG_EXECUTOR_RETRIES, "7"); System.setProperty(KieServerConstants.CFG_EXECUTOR_POOL, "11"); System.setProperty(KieServerConstants.CFG_EXECUTOR_TIME_UNIT, "HOURS"); System.setProperty(KieServerConstants.CFG_EXECUTOR_JMS_QUEUE, "queue/MY.OWN.QUEUE"); System.setProperty(KieServerConstants.CFG_EXECUTOR_DISABLED, "true"); stateRepository.clearCache(); state = stateRepository.load(KIE_SERVER_ID); executorInterval = state.getConfiguration() .getConfigItemValue(KieServerConstants.CFG_EXECUTOR_INTERVAL); executorRetries = state.getConfiguration().getConfigItemValue(KieServerConstants.CFG_EXECUTOR_RETRIES); executorPool = state.getConfiguration().getConfigItemValue(KieServerConstants.CFG_EXECUTOR_POOL); executorTimeUnit = state.getConfiguration() .getConfigItemValue(KieServerConstants.CFG_EXECUTOR_TIME_UNIT); executorJMSQueue = state.getConfiguration() .getConfigItemValue(KieServerConstants.CFG_EXECUTOR_JMS_QUEUE); executorDisabled = state.getConfiguration() .getConfigItemValue(KieServerConstants.CFG_EXECUTOR_DISABLED); assertNotNull(executorInterval); assertNotNull(executorRetries); assertNotNull(executorPool); assertNotNull(executorTimeUnit); assertNotNull(executorJMSQueue); assertNotNull(executorDisabled); assertEquals("4", executorInterval); assertEquals("7", executorRetries); assertEquals("11", executorPool); assertEquals("HOURS", executorTimeUnit); assertEquals("queue/MY.OWN.QUEUE", executorJMSQueue); assertEquals("true", executorDisabled); } finally { System.clearProperty(KieServerConstants.CFG_EXECUTOR_INTERVAL); System.clearProperty(KieServerConstants.CFG_EXECUTOR_RETRIES); System.clearProperty(KieServerConstants.CFG_EXECUTOR_POOL); System.clearProperty(KieServerConstants.CFG_EXECUTOR_TIME_UNIT); System.clearProperty(KieServerConstants.CFG_EXECUTOR_JMS_QUEUE); System.clearProperty(KieServerConstants.CFG_EXECUTOR_DISABLED); } }
From source file:dk.statsbiblioteket.util.XPropertiesTest.java
public void testException() throws Exception { Properties sysProps = new Properties(); sysProps.setProperty("XProperty:foo", "bar"); sysProps.setProperty("XProperty:int", "87"); sysProps.setProperty("XProperty:negative", "-43"); 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(); try {//from w w w . j a v a 2 s . c om properties.getBoolean("gnaf"); Assert.fail("Getting non-existing should throw an exception"); } catch (NullPointerException e) { // Expected } try { properties.getChar("gnaf"); Assert.fail("Getting non-existing char should throw an exception"); } catch (NullPointerException e) { // Expected } try { properties.getDouble("gnaf"); Assert.fail("Getting non-existing double should throw an exception"); } catch (NullPointerException e) { // Expected } try { properties.getInteger("gnaf"); Assert.fail("Getting non-existing int should throw an exception"); } catch (NullPointerException e) { // Expected } try { properties.getString("gnaf"); Assert.fail("Getting non-existing String should throw an exception"); } catch (NullPointerException e) { // Expected } try { properties.getSubProperty("gnaf"); Assert.fail("Getting non-existing sub-property should throw an exception"); } catch (NullPointerException e) { // Expected } // Clean up for (Object prop : sysProps.keySet()) { System.clearProperty((String) prop); } assertEquals("System XProperties was not cleaned up", 0, new XProperties().size()); }
From source file:org.apache.kylin.query.KylinTestBase.java
protected int runSQL(File sqlFile, boolean debug, boolean explain) throws Exception { if (debug) {/*from w w w . ja v a2 s .co m*/ System.setProperty("calcite.debug", "true"); InputStream inputStream = new FileInputStream("src/test/resources/logging.properties"); LogManager.getLogManager().readConfiguration(inputStream); } String queryName = StringUtils.split(sqlFile.getName(), '.')[0]; logger.info("Testing Query " + queryName); String sql = getTextFromFile(sqlFile); if (explain) { sql = "explain plan for " + sql; } int count = executeQuery(sql, true); if (debug) { System.clearProperty("calcite.debug"); } return count; }
From source file:dk.statsbiblioteket.util.XPropertiesTest.java
public void testCast() throws Exception { Properties sysProps = new Properties(); 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("Requesting a boolean as boolean should work fine", false, properties.getBoolean("false")); try {/* ww w . j a v a 2s . com*/ properties.getString("false"); Assert.fail("Requesting a boolean as a String should raise exception"); } catch (ClassCastException e) { // Expected } // Clean up for (Object prop : sysProps.keySet()) { System.clearProperty((String) prop); } assertEquals("System XProperties was not cleaned up", 0, new XProperties().size()); }
From source file:org.fcrepo.auth.webac.WebACRolesProviderTest.java
@Test public void noAclTestMalformedRdf2() throws RepositoryException { final String agent1 = "http://xmlns.com/foaf/0.1/Agent"; when(mockResource.getTriples(anyObject(), eq(PROPERTIES))) .thenReturn(new DefaultRdfStream(createURI("subject"))); when(mockResource.getTriples(anyObject(), eq(PROPERTIES))) .thenReturn(new DefaultRdfStream(createURI("subject"))); when(mockResource.getPath()).thenReturn("/"); when(mockResource.getTypes()).thenReturn(Arrays.asList(URI.create(REPOSITORY_NAMESPACE + "Resource"))); System.setProperty(ROOT_AUTHORIZATION_PROPERTY, "./target/test-classes/logback-test.xml"); final Map<String, Collection<String>> roles = roleProvider.getRoles(mockNode, true); System.clearProperty(ROOT_AUTHORIZATION_PROPERTY); assertEquals("There should be exactly one agent", 1, roles.size()); assertEquals("The agent should have zero modes", 0, roles.get(agent1).size()); }