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:com.kylinolap.common.KylinConfig.java

/**
 * This method only for test case. You can get a KylinConfig instance by
 * path "/a/b/c", where "/a/b/c/kylin.properties" exists. By default, the
 * getInstanceFromEnv() should be called.
 * //w  ww  . jav a  2 s.  com
 * @param confPath
 * @return
 * @deprecated
 */
public static KylinConfig getInstanceForTest(String confPath) {
    File file = new File(confPath);
    if (!file.exists() || !file.isDirectory()) {
        throw new IllegalArgumentException(confPath + " is not a valid path");
    }

    String env = System.getProperty(KYLIN_CONF);
    System.setProperty(KYLIN_CONF, confPath);
    KylinConfig config = getInstanceFromEnv();
    if (env == null) {
        System.clearProperty(KYLIN_CONF);
    } else {
        System.setProperty(KYLIN_CONF, env);
    }
    return config;
}

From source file:org.artifactory.storage.db.itest.spring.DbTestConfigFactory.java

public String getGeneratedDbConfigLocation() {
    String generatedConfig = System.getProperty("artifactory.db.generated.config");
    // reset the value to make sure it's not propagated to other tests
    System.clearProperty("artifactory.db.generated.config");
    return generatedConfig;
}

From source file:org.jasypt.spring31.annotation.EncryptablePropertySourcePostProcessorTest.java

@Test
public void withResolvablePlaceholder() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(ConfigWithResolvablePlaceholder.class);
    System.setProperty("path.to.properties", "org/jasypt/spring31/annotation");
    ctx.refresh();//from  w  ww.  j  av a 2 s.c o m
    assertThat(ctx.getBean(TestBean.class).getName(), equalTo("p1TestBean"));
    System.clearProperty("path.to.properties");
    ctx.close();

}

From source file:org.apache.solr.cloud.api.collections.TestHdfsCloudBackupRestore.java

@AfterClass
public static void teardownClass() throws Exception {
    System.clearProperty("solr.hdfs.home");
    System.clearProperty("solr.hdfs.default.backup.path");
    System.clearProperty("test.build.data");
    System.clearProperty("test.cache.data");
    IOUtils.closeQuietly(fs);/*w  ww . ja v  a 2s .  c  o  m*/
    fs = null;
    HdfsTestUtil.teardownClass(dfsCluster);
    dfsCluster = null;
}

From source file:com.redhat.jenkins.nodesharing.NodeSharingJenkinsRule.java

public Statement apply(final Statement base, final Description description) {
    try { // Needs to be done before Jenkins is up
        configRepo = createConfigRepo();
        System.setProperty(Pool.CONFIG_REPO_PROPERTY_NAME, configRepo.getWorkTree().getRemote());
        System.setProperty(Pool.USERNAME_PROPERTY_NAME, USER);
        System.setProperty(Pool.PASSWORD_PROPERTY_NAME, USER);
    } catch (URISyntaxException | IOException e) {
        throw new Error(e);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new Error(e);
    }//ww  w  .ja  va 2s .  co m

    Statement withJenkinsUp = new Statement() {
        @Override
        public void evaluate() throws Throwable {
            jenkins.setSecurityRealm(createDummySecurityRealm());

            mas.grant(Jenkins.READ, RestEndpoint.RESERVE).everywhere().to("jerry");
            mas.grant(Jenkins.ADMINISTER, RestEndpoint.RESERVE).everywhere().to("admin");
            jenkins.setAuthorizationStrategy(mas);

            restCred = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, getRestCredentialId(),
                    "Testing node sharing credential", USER, USER);
            SystemCredentialsProvider credentialsProvider = SystemCredentialsProvider.getInstance();
            credentialsProvider.getCredentials().add(restCred);
            credentialsProvider.save();

            try {
                base.evaluate();
            } finally {
                System.clearProperty(Pool.USERNAME_PROPERTY_NAME);
                System.clearProperty(Pool.PASSWORD_PROPERTY_NAME);
                System.clearProperty(Pool.CONFIG_REPO_PROPERTY_NAME);
                configRepo.getWorkTree().deleteRecursive();
            }
        }
    };
    return super.apply(withJenkinsUp, description);
}

From source file:org.digidoc4j.main.DigiDoc4JTest.java

@Test
public void createsContainerWithSignatureProfileIsTSForBDoc() throws Exception {
    String fileName = "test1.bdoc";
    Files.deleteIfExists(Paths.get(fileName));

    String[] params = new String[] { "-in", fileName, "-type", "BDOC", "-add", "testFiles/test.txt",
            "text/plain", "-pkcs12", "testFiles/signout.p12", "test", "-profile", "LT" };

    System.setProperty("digidoc4j.mode", "TEST");
    callMainWithoutSystemExit(params);// w  ww .ja va  2s.co m

    Container container = ContainerOpener.open(fileName);
    assertEquals(SignatureProfile.LT, container.getSignature(0).getProfile());
    System.clearProperty("digidoc4j.mode");
}

From source file:com.cloudera.cdk.morphline.solr.AbstractSolrMorphlineZkTest.java

@Override
public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, String solrConfigOverride,
        String schemaOverride) throws Exception {

    JettySolrRunner jetty = new JettySolrRunner(solrHome.getAbsolutePath(), context, 0, solrConfigOverride,
            schemaOverride);// w  w  w .j  a  v a2  s  .c  o m

    jetty.setShards(shardList);

    if (System.getProperty("collection") == null) {
        System.setProperty("collection", "collection1");
    }

    jetty.start();

    System.clearProperty("collection");

    return jetty;
}

From source file:org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase.java

private final void createCache(final boolean client, final CacheFactory factory) {
    synchronized (JUnit4CacheTestCase.class) {
        try {//from   w w w  .  j a  va  2  s  .co m
            System.setProperty(GEMFIRE_PREFIX + "DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE", "true");
            InternalCache newCache;
            if (client) {
                System.setProperty(GEMFIRE_PREFIX + "locators", "");
                System.setProperty(GEMFIRE_PREFIX + MCAST_PORT, "0");
                newCache = (InternalCache) new ClientCacheFactory(getSystem().getProperties()).create();
            } else {
                if (factory == null) {
                    newCache = (InternalCache) CacheFactory.create(getSystem());
                } else {
                    Properties config = getSystem().getProperties();
                    for (Map.Entry entry : config.entrySet()) {
                        factory.set((String) entry.getKey(), (String) entry.getValue());
                    }
                    newCache = (InternalCache) factory.create();
                }
            }
            cache = newCache;

        } catch (CacheExistsException e) {
            Assert.fail("the cache already exists", e); // TODO: remove error handling

        } catch (RuntimeException ex) {
            throw ex;

        } catch (Exception ex) {
            Assert.fail("Checked exception while initializing cache??", ex);

        } finally {
            System.clearProperty(GEMFIRE_PREFIX + "DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE");
            System.clearProperty(GEMFIRE_PREFIX + "locators");
            System.clearProperty(GEMFIRE_PREFIX + MCAST_PORT);
        }
    }
}

From source file:org.eclipse.smarthome.model.core.internal.folder.FolderObserverTest.java

/**
 * The FolderObserver service have to be stopped at the end of each test
 * as most of the tests are covering assertions on its initialization actions
 *
 * @throws Exception//w  w  w .ja  va2 s . c  o m
 */
@After
public void tearDown() throws Exception {
    folderObserver.deactivate();
    FileUtils.deleteDirectory(WATCHED_DIRECTORY);
    modelRepo.clean();
    if (defaultWatchedDir != null) {
        System.setProperty(ConfigConstants.CONFIG_DIR_PROG_ARGUMENT, defaultWatchedDir);
    } else {
        System.clearProperty(ConfigConstants.CONFIG_DIR_PROG_ARGUMENT);
    }
}

From source file:org.fcrepo.audit.InternalAuditorTest.java

@Test
public void testRegister() throws RepositoryException, LoginException {
    System.setProperty(AUDIT_CONTAINER, "/audit");
    when(mockRepository.login()).thenReturn(mockSession);
    setField(testTnternalAuditor, "jcrTools", mock(JcrTools.class));
    testTnternalAuditor.register();//  w  w w .  j  a  va  2  s.  c om
    verify(mockContainerService).findOrCreate(mockSession, "/audit");
    verify(mockBus).register(any(InternalAuditor.class));
    System.clearProperty(AUDIT_CONTAINER);
}