Example usage for java.lang System clearProperty

List of usage examples for java.lang System clearProperty

Introduction

In this page you can find the example usage for java.lang System clearProperty.

Prototype

public static String clearProperty(String key) 

Source Link

Document

Removes the system property indicated by the specified key.

Usage

From source file:org.deegree.commons.proxy.ProxySettings.java

private static void setProperty(String key, String value) {
    if (value != null) {
        System.setProperty(key, value);
    } else {//from ww w . j ava 2s . c  o  m
        System.clearProperty(key);
    }
}

From source file:org.apache.jackrabbit.core.config.RepositoryConfigTest.java

public void testAutomaticClusterNodeIdCreation() throws Exception {
    final long syncDelay = 12;

    assertNull(/*from   w  w  w  . j a va2  s  . c  o m*/
            "This test requires the system property " + ClusterNode.SYSTEM_PROPERTY_NODE_ID
                    + " not to be set; found value: " + System.getProperty(ClusterNode.SYSTEM_PROPERTY_NODE_ID)
                    + " (leftover from broken unit test?)",
            System.getProperty(ClusterNode.SYSTEM_PROPERTY_NODE_ID));
    System.setProperty("cluster.syncDelay", Long.toString(syncDelay));
    try {
        File file = new File(DIR, "cluster_node.id");
        assertFalse(file.exists());

        // Check that a new cluster node id is automatically persisted
        InputStream in = getClass().getResourceAsStream("/org/apache/jackrabbit/core/cluster/repository.xml");
        RepositoryConfig config = RepositoryConfig.create(in, DIR.getPath());

        assertTrue(file.exists());
        String id = FileUtils.readFileToString(file);

        ClusterConfig clusterConfig = config.getClusterConfig();
        assertEquals(id, clusterConfig.getId());
        assertEquals(syncDelay, clusterConfig.getSyncDelay());

        // Check that the persisted cluster node id is used when it exists
        in = getClass().getResourceAsStream("/org/apache/jackrabbit/core/cluster/repository.xml");
        config = RepositoryConfig.create(in, DIR.getPath());

        assertTrue(file.exists());
        assertEquals(id, FileUtils.readFileToString(file));

        clusterConfig = config.getClusterConfig();
        assertEquals(id, clusterConfig.getId());
        assertEquals(syncDelay, clusterConfig.getSyncDelay());
    } finally {
        System.clearProperty("cluster.syncDelay");
    }
}

From source file:org.apache.solr.hadoop.MorphlineGoLiveMiniMRTest.java

@Override
public void distribTearDown() throws Exception {
    super.distribTearDown();
    System.clearProperty("host");
    System.clearProperty("numShards");
    System.clearProperty("solr.hdfs.home");
}

From source file:org.apache.geode.internal.cache.PersistentPartitionedRegionJUnitTest.java

@Test
public void testValuesAreRecoveredForHeapLruRegionsWithRecoverValueAndRecoverLruPropertySet() {
    String oldValue = System.getProperty(DiskStoreImpl.RECOVER_VALUE_PROPERTY_NAME);
    System.setProperty(DiskStoreImpl.RECOVER_VALUE_PROPERTY_NAME, "true");

    String lruOldValue = System.getProperty(DiskStoreImpl.RECOVER_LRU_VALUES_PROPERTY_NAME);
    System.setProperty(DiskStoreImpl.RECOVER_LRU_VALUES_PROPERTY_NAME, "true");

    try {/*from ww w  .j  a  v  a2s . co  m*/
        createLRURegionAndValidateRecovery(false, true, 10, 10);
    } finally {
        if (oldValue != null) {
            System.setProperty(DiskStoreImpl.RECOVER_VALUE_PROPERTY_NAME, oldValue);
        } else {
            System.clearProperty(DiskStoreImpl.RECOVER_VALUE_PROPERTY_NAME);
        }

        if (lruOldValue != null) {
            System.setProperty(DiskStoreImpl.RECOVER_LRU_VALUES_PROPERTY_NAME, lruOldValue);
        } else {
            System.clearProperty(DiskStoreImpl.RECOVER_LRU_VALUES_PROPERTY_NAME);
        }
    }
}

From source file:com.yahoo.athenz.common.server.db.DataSourceFactoryTest.java

@Test
public void testRetrieveConfigSettingInt() {

    System.setProperty(ATHENZ_DBPOOL_PROP1, "100");
    assertEquals(DataSourceFactory.retrieveConfigSetting(ATHENZ_DBPOOL_PROP1, 20), 100);

    System.setProperty(ATHENZ_DBPOOL_PROP1, "0");
    assertEquals(DataSourceFactory.retrieveConfigSetting(ATHENZ_DBPOOL_PROP1, 20), 0);

    System.setProperty(ATHENZ_DBPOOL_PROP1, "-100");
    assertEquals(DataSourceFactory.retrieveConfigSetting(ATHENZ_DBPOOL_PROP1, 20), -100);

    System.clearProperty(ATHENZ_DBPOOL_PROP1);
}

From source file:com.yahoo.athenz.common.server.db.DataSourceFactoryTest.java

@Test
public void testRetrieveConfigSettingIntNull() {
    System.clearProperty(ATHENZ_DBPOOL_PROP1);
    assertEquals(DataSourceFactory.retrieveConfigSetting(ATHENZ_DBPOOL_PROP1, 25), 25);
}

From source file:org.apache.ode.axis2.Axis2TestBase.java

@AfterMethod
protected void tearDown() throws Exception {
    stopServer();/* w w  w. j  av a 2s .  c o m*/

    if (originalOdeConfigDir != null) {
        System.setProperty("org.apache.ode.configDir", originalOdeConfigDir);
    } else {
        System.clearProperty("org.apache.ode.configDir");
    }
    if (originalOdeConfigDir != null) {
        System.setProperty("ode.persistence", originalOdePersistence);
    } else {
        System.clearProperty("ode.persistence");
    }
    server = null;
}

From source file:com.jive.myco.seyren.core.util.graphite.GraphiteHttpClientTest.java

@Test
public void authIsUsedGettingChartFromGraphite() throws Exception {
    System.setProperty("GRAPHITE_USERNAME", "seyren");
    System.setProperty("GRAPHITE_PASSWORD", "s3yr3N");
    graphiteHttpClient = new GraphiteHttpClient(seyrenConfig(clientDriver.getBaseUrl()));

    byte[] bytes = new byte[] { 12, 12, 24, 34 };
    InputStream response = new ByteArrayInputStream(bytes);

    clientDriver.addExpectation(/* w  w w  . j  a v a 2 s.  c o  m*/
            onRequestTo("/render/").withParam("target", "hello.world").withParam("from", "-1hours")
                    .withParam("width", 300).withParam("height", 200)
                    .withParam("uniq", Pattern.compile("[0-9]+")).withParam("hideLegend", false)
                    .withParam("hideAxes", false).withHeader("Authorization", "Basic c2V5cmVuOnMzeXIzTg=="),
            giveResponseAsBytes(response, "image/png"));

    byte[] actualBytes = graphiteHttpClient.getChart("hello.world", 300, 200, "-1hours", null, LegendState.SHOW,
            AxesState.SHOW);

    assertThat(actualBytes, is(bytes));

    System.clearProperty("GRAPHITE_USERNAME");
    System.clearProperty("GRAPHITE_PASSWORD");
}

From source file:org.glowroot.tests.WebDriverSetup.java

private static CentralModule createCentralModule(int uiPort, int grpcPort) throws Exception {
    File centralDir = new File("target");
    File propsFile = new File(centralDir, "glowroot-central.properties");
    PrintWriter props = new PrintWriter(propsFile);
    props.println("cassandra.keyspace=glowroot_unit_tests");
    byte[] bytes = new byte[16];
    new SecureRandom().nextBytes(bytes);
    props.println("cassandra.symmetricEncryptionKey=" + BaseEncoding.base16().lowerCase().encode(bytes));
    props.println("grpc.httpPort=" + grpcPort);
    props.println("ui.port=" + uiPort);
    props.close();/*from   w  w  w  .  j a  va  2  s . c o m*/
    String prior = System.getProperty("glowroot.log.dir");
    try {
        System.setProperty("glowroot.log.dir", "target");
        return CentralModule.create(centralDir);
    } finally {
        if (prior == null) {
            System.clearProperty("glowroot.log.dir");
        } else {
            System.setProperty("glowroot.log.dir", prior);
        }
    }
}

From source file:org.apache.solr.cloud.TestSolrCloudWithKerberosAlt.java

@Override
public void tearDown() throws Exception {
    System.clearProperty("java.security.auth.login.config");
    System.clearProperty("cookie.domain");
    System.clearProperty("kerberos.principal");
    System.clearProperty("kerberos.keytab");
    System.clearProperty("authenticationPlugin");
    System.clearProperty("solr.kerberos.name.rules");
    System.clearProperty("solr.jaas.debug");
    kerberosTestServices.stop();/*from w w  w  .  j a  va 2s .c om*/
    super.tearDown();
}