List of usage examples for java.lang System clearProperty
public static String clearProperty(String key)
From source file:com.xebialabs.overcast.OvercastPropertiesTest.java
@Test public void testWorkDirHasPrecedenceOverProperty() throws IOException { System.setProperty("user.home", new File("src/test/resources/dir-without-conf").getAbsolutePath()); System.clearProperty("precedenceTestValue"); System.setProperty("overcast.conf.file", "src/test/resources/property-path/overcast.conf"); OvercastProperties.reloadOvercastProperties(); assertThat(OvercastProperties.getOvercastProperty("precedenceTestValue"), is("valueFromWork")); }
From source file:org.apache.solr.client.solrj.impl.HttpClientUtilTest.java
@Test public void testAuthSchemeConfiguration() { System.setProperty(Krb5HttpClientConfigurer.LOGIN_CONFIG_PROP, "test"); try {/*from w w w .jav a2s.c o m*/ HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer()); AbstractHttpClient client = (AbstractHttpClient) HttpClientUtil.createClient(null); assertEquals(1, client.getAuthSchemes().getSchemeNames().size()); assertTrue(AuthSchemes.SPNEGO.equalsIgnoreCase(client.getAuthSchemes().getSchemeNames().get(0))); } finally { //Cleanup the system property. System.clearProperty(Krb5HttpClientConfigurer.LOGIN_CONFIG_PROP); } }
From source file:org.apache.atlas.web.filters.MetadataAuthenticationKerberosFilterIT.java
@Test(enabled = false) public void testKerberosBasedLogin() throws Exception { String originalConf = System.getProperty("metadata.conf"); System.setProperty("metadata.conf", System.getProperty("user.dir")); setupKDCAndPrincipals();/*from ww w. jav a2 s.com*/ TestEmbeddedServer server = null; try { // setup the application.properties file generateKerberosTestProperties(); // need to create the web application programmatically in order to control the injection of the test // application properties server = new TestEmbeddedServer(23000, "webapp/target/apache-atlas"); startEmbeddedServer(server.getServer()); final URLConnectionFactory connectionFactory = URLConnectionFactory.DEFAULT_SYSTEM_CONNECTION_FACTORY; // attempt to hit server and get rejected URL url = new URL("http://localhost:23000/"); HttpURLConnection connection = (HttpURLConnection) connectionFactory.openConnection(url, false); connection.setRequestMethod("GET"); connection.connect(); Assert.assertEquals(connection.getResponseCode(), 401); // need to populate the ticket cache with a local user, so logging in... Subject subject = loginTestUser(); Subject.doAs(subject, new PrivilegedExceptionAction<Object>() { @Override public Object run() throws Exception { // attempt to hit server and get rejected URL url = new URL("http://localhost:23000/"); HttpURLConnection connection = (HttpURLConnection) connectionFactory.openConnection(url, true); connection.setRequestMethod("GET"); connection.connect(); Assert.assertEquals(connection.getResponseCode(), 200); return null; } }); } finally { server.getServer().stop(); kdc.stop(); if (originalConf != null) { System.setProperty("metadata.conf", originalConf); } else { System.clearProperty("metadata.conf"); } } }
From source file:org.cloudfoundry.identity.uaa.BootstrapTests.java
public void dotestOverrideYmlConfigPath(String configVariable, String configValue) throws Exception { System.setProperty(configVariable, configValue); try {//from ww w .ja va 2 s .c o m context = getServletContext("file:./src/main/webapp/WEB-INF/spring-servlet.xml", "classpath:/test/config/test-override.xml"); assertEquals("/tmp/uaa/logs", context.getBean("foo", String.class)); assertEquals("[cf, my, support]", ReflectionTestUtils .getField(context.getBean(ClientAdminBootstrap.class), "autoApproveClients").toString()); ScimUserProvisioning users = context.getBean(ScimUserProvisioning.class); assertNotNull(users.query("username eq \"paul\"", IdentityZoneHolder.get().getId()).get(0)); assertNotNull(users.query("username eq \"stefan\"", IdentityZoneHolder.get().getId()).get(0)); } finally { System.clearProperty(configVariable); } }
From source file:org.jboss.shrinkwrap.resolver.impl.maven.bootstrap.SystemPropertyPrecedenceTestCase.java
@Test public void overrideLocalRepositoryLocation() { System.setProperty(MavenSettingsBuilder.ALT_LOCAL_REPOSITORY_LOCATION, "target/syspropertyrepo"); File[] files = Maven.configureResolver().fromFile(SETTINGS_XML_PATH) .resolve("org.jboss.shrinkwrap.test:test-deps-c:1.0.0").withTransitivity().as(File.class); ValidationUtil.fromDependencyTree(new File("src/test/resources/dependency-trees/test-deps-c.tree")) .validate(true, files);// w ww . j ava 2 s .co m // Assert file was downloaded into syspropertyrepo directory File testDep = new File( "target/syspropertyrepo/org/jboss/shrinkwrap/test/test-deps-c/1.0.0/test-deps-c-1.0.0.jar"); Assert.assertTrue("Sysproperty local repository took precedence", testDep.exists()); System.clearProperty(MavenSettingsBuilder.ALT_LOCAL_REPOSITORY_LOCATION); }
From source file:com.brienwheeler.apps.main.ContextMainTest.java
@Test public void testContextDirect() throws InterruptedException { PropertiesTestUtils.clearAllTestSystemProperties(); System.clearProperty(TestDataConstants.RMAP_TEST_PROP); Assert.assertNull(System.getProperty(TestDataConstants.RMAP_TEST_PROP)); CountDownLatch latch = new CountDownLatch(1); TestContextMain main = new TestContextMain(new String[] { C, TestDataConstants.RMAP_CTX_DIRECT }, latch); TestRunner testRunner = new TestRunner(main); testRunner.start();//www . ja v a2 s . co m latch.await(); Assert.assertEquals(TestDataConstants.RMAP_TEST_VAL, System.getProperty(TestDataConstants.RMAP_TEST_PROP)); assertLaunchCount(main, 1); main.shutdown(); testRunner.join(); }
From source file:org.fcrepo.integration.http.api.FedoraTransactionsIT.java
@Test public void testCreateAndTimeoutTransaction() throws Exception { /* create a short-lived tx */ final long testTimeout = min(500, REAP_INTERVAL / 2); System.setProperty(TIMEOUT_SYSTEM_PROPERTY, Long.toString(testTimeout)); /* create a tx */ final String location = createTransaction(); final HttpGet getWithinTx = new HttpGet(location); HttpResponse resp = execute(getWithinTx); IOUtils.toString(resp.getEntity().getContent()); assertEquals(200, resp.getStatusLine().getStatusCode()); assertTrue(Iterators.any(Iterators.forArray(resp.getHeaders("Link")), new Predicate<Header>() { @Override//w w w .j a v a 2 s . c o m public boolean apply(Header input) { return input.getValue().contains("<" + serverAddress + ">;rel=\"canonical\""); } })); int statusCode = 0; sleep(REAP_INTERVAL * 2); final HttpGet getWithExpiredTx = new HttpGet(location); resp = execute(getWithExpiredTx); IOUtils.toString(resp.getEntity().getContent()); statusCode = resp.getStatusLine().getStatusCode(); try { assertEquals("Transaction did not expire", 410, statusCode); } finally { System.setProperty(TIMEOUT_SYSTEM_PROPERTY, Long.toString(DEFAULT_TIMEOUT)); System.clearProperty("fcrepo4.tx.timeout"); } }
From source file:org.apache.solr.cloud.AbstractDistribZkTestBase.java
@Override protected void createServers(int numShards) throws Exception { // give everyone there own solrhome File controlHome = new File(new File(getSolrHome()).getParentFile(), "control" + homeCount.incrementAndGet()); FileUtils.copyDirectory(new File(getSolrHome()), controlHome); setupJettySolrHome(controlHome);//from ww w. ja v a2 s . c om System.setProperty("collection", "control_collection"); String numShardsS = System.getProperty(ZkStateReader.NUM_SHARDS_PROP); System.setProperty(ZkStateReader.NUM_SHARDS_PROP, "1"); controlJetty = createJetty(controlHome, null); // let the shardId default to shard1 System.clearProperty("collection"); if (numShardsS != null) { System.setProperty(ZkStateReader.NUM_SHARDS_PROP, numShardsS); } else { System.clearProperty(ZkStateReader.NUM_SHARDS_PROP); } controlClient = createNewSolrClient(controlJetty.getLocalPort()); StringBuilder sb = new StringBuilder(); for (int i = 1; i <= numShards; i++) { if (sb.length() > 0) sb.append(','); // give everyone there own solrhome File jettyHome = new File(new File(getSolrHome()).getParentFile(), "jetty" + homeCount.incrementAndGet()); setupJettySolrHome(jettyHome); JettySolrRunner j = createJetty(jettyHome, null, "shard" + (i + 2)); jettys.add(j); clients.add(createNewSolrClient(j.getLocalPort())); sb.append(buildUrl(j.getLocalPort())); } shards = sb.toString(); // now wait till we see the leader for each shard for (int i = 1; i <= numShards; i++) { ZkStateReader zkStateReader = jettys.get(0).getCoreContainer().getZkController().getZkStateReader(); zkStateReader.getLeaderRetry("collection1", "shard" + (i + 2), 15000); } }
From source file:org.ballerinalang.plugin.maven.doc.DocerinaMojo.java
public void execute() throws MojoExecutionException { if (debugDocerina) { System.setProperty(BallerinaDocConstants.ENABLE_DEBUG_LOGS, "true"); }//from w w w. ja v a2 s .c o m if (templatesDir != null) { System.setProperty(BallerinaDocConstants.TEMPLATES_FOLDER_PATH_KEY, templatesDir); } if (outputZip != null) { System.setProperty(BallerinaDocConstants.OUTPUT_ZIP_PATH, outputZip); } if (orgName != null) { System.setProperty(BallerinaDocConstants.ORG_NAME, orgName); } ConfigRegistry.getInstance().addConfiguration(BallerinaDocConstants.GENERATE_TOC, generateTOC); Path sourceRootPath = LauncherUtils.getSourceRootPath(sourceRoot); List<String> sources; if (sourceDir == null || sourceDir.isEmpty()) { SourceDirectory srcDirectory = new FileSystemProjectDirectory(sourceRootPath); sources = srcDirectory.getSourcePackageNames(); } else { sources = Arrays.asList(sourceDir.split(",")); } try { BallerinaDocGenerator.generateApiDocs(sourceRoot, outputDir, packageFilter, nativeCode, offline, sources.toArray(new String[sources.size()])); } catch (Throwable e) { err.println(ExceptionUtils.getStackTrace(e)); } finally { System.clearProperty(BallerinaDocConstants.ENABLE_DEBUG_LOGS); System.clearProperty(BallerinaDocConstants.TEMPLATES_FOLDER_PATH_KEY); System.clearProperty(BallerinaDocConstants.OUTPUT_ZIP_PATH); System.clearProperty(BallerinaDocConstants.ORG_NAME); ConfigRegistry.getInstance().removeConfiguration(BallerinaDocConstants.GENERATE_TOC); } }
From source file:com.yahoo.athenz.common.server.db.DataSourceFactoryTest.java
@Test public void testPoolConfigSpecifiedValues() { System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_TOTAL, "10"); System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_IDLE, "20"); System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MIN_IDLE, "30"); System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_WAIT, "40"); System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_TIMEOUT, "50"); System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_INTERVAL, "60"); GenericObjectPoolConfig config = DataSourceFactory.setupPoolConfig(); assertNotNull(config);//from ww w .ja va 2 s . c o m assertEquals(config.getMaxTotal(), 10); assertEquals(config.getMaxIdle(), 20); assertEquals(config.getMinIdle(), 30); assertEquals(config.getMaxWaitMillis(), 40); assertEquals(config.getMinEvictableIdleTimeMillis(), 50); assertEquals(config.getTimeBetweenEvictionRunsMillis(), 60); assertTrue(config.getTestWhileIdle()); assertTrue(config.getTestOnBorrow()); System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_TOTAL); System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_IDLE); System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MIN_IDLE); System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_WAIT); System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_TIMEOUT); System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_INTERVAL); }