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.kuali.kra.s2s.service.impl.GrantsGovConnectorServiceImpl.java

/**
 * /* w w  w  .jav  a2 s  . c om*/
 * This method is to get Soap Port
 * 
 * @return ApplicantIntegrationPortType Soap port used for applicant integration.
 * @throws S2SException
 */
protected ApplicantIntegrationPortType configureApplicantIntegrationSoapPort(String alias,
        boolean mulitCampusEnabled) throws S2SException {
    System.clearProperty("java.protocol.handler.pkgs");
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();

    factory.setAddress(getS2SSoapHost());
    factory.setServiceClass(ApplicantIntegrationPortType.class);
    ApplicantIntegrationPortType applicantWebService = (ApplicantIntegrationPortType) factory.create();

    Client client = ClientProxy.getClient(applicantWebService);
    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setConnectionTimeout(0);
    httpClientPolicy.setReceiveTimeout(0);
    httpClientPolicy.setAllowChunking(false);
    HTTPConduit conduit = (HTTPConduit) client.getConduit();
    conduit.setClient(httpClientPolicy);
    TLSClientParameters tlsConfig = new TLSClientParameters();
    setPossibleCypherSuites(tlsConfig);
    configureKeyStoreAndTrustStore(tlsConfig, alias, mulitCampusEnabled);
    conduit.setTlsClientParameters(tlsConfig);
    return applicantWebService;
}

From source file:com.seleniumtests.it.core.TestSeleniumRobotTestListener.java

@Test(groups = { "it" })
public void testContextDriverBlockingBeforeTest(ITestContext testContext) throws Exception {

    try {//from  w w  w . j  a  va2  s.c  o m
        System.setProperty(SeleniumTestsContext.BROWSER, "htmlunit");
        System.setProperty("startLocation", "beforeTest");
        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.assertFalse(logs.contains("start 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("skip"), 2);
}

From source file:com.liferay.portal.search.elasticsearch.internal.connection.EmbeddedElasticsearchConnection.java

protected Node createNode(Settings settings) {
    Thread thread = Thread.currentThread();

    ClassLoader contextClassLoader = thread.getContextClassLoader();

    Class<?> clazz = getClass();

    thread.setContextClassLoader(clazz.getClassLoader());

    String jnaTmpDir = System.getProperty("jna.tmpdir");

    System.setProperty("jna.tmpdir", _jnaTmpDirName);

    try {/*from  w ww  .  j  a  va  2  s.  com*/
        NodeBuilder nodeBuilder = new NodeBuilder();

        nodeBuilder.settings(settings);

        nodeBuilder.local(true);

        Node node = nodeBuilder.build();

        if (elasticsearchConfiguration.syncSearch()) {
            Injector injector = node.injector();

            _replaceTransportRequestHandler(injector.getInstance(TransportService.class),
                    injector.getInstance(SearchService.class));
        }

        return node;
    } finally {
        thread.setContextClassLoader(contextClassLoader);

        if (jnaTmpDir == null) {
            System.clearProperty("jna.tmpdir");
        } else {
            System.setProperty("jna.tmpdir", jnaTmpDir);
        }
    }
}

From source file:org.kie.server.services.impl.AbstractKieServerImplTest.java

@Test
public void testManagementDisabledConfiguredViaCommandService() {
    System.setProperty(KieServerConstants.KIE_SERVER_MGMT_API_DISABLED, "true");
    try {/*from   ww w. j  a v  a 2  s  .c o  m*/
        kieServer.destroy();
        kieServer = new KieServerImpl(new KieServerStateFileRepository(REPOSITORY_DIR));
        kieServer.init();

        KieContainerCommandServiceImpl commandService = new KieContainerCommandServiceImpl(kieServer,
                kieServer.getServerRegistry());
        List<KieServerCommand> commands = new ArrayList<>();

        commands.add(new CreateContainerCommand());
        commands.add(new DisposeContainerCommand());
        commands.add(new UpdateScannerCommand());
        commands.add(new UpdateReleaseIdCommand());

        CommandScript commandScript = new CommandScript(commands);
        ServiceResponsesList responseList = commandService.executeScript(commandScript, MarshallingFormat.JAXB,
                null);
        assertNotNull(responseList);

        List<ServiceResponse<?>> responses = responseList.getResponses();
        assertEquals(4, responses.size());

        for (ServiceResponse<?> forbidden : responses) {

            assertForbiddenResponse(forbidden);
        }

    } finally {
        System.clearProperty(KieServerConstants.KIE_SERVER_MGMT_API_DISABLED);
    }
}

From source file:org.sonatype.nexus.apachehttpclient.Hc4ProviderImplTest.java

protected void unsetParameters() {
    System.clearProperty("nexus.apacheHttpClient4x.connectionPoolMaxSize");
    System.clearProperty("nexus.apacheHttpClient4x.connectionPoolSize");
    System.clearProperty("nexus.apacheHttpClient4x.connectionPoolKeepalive");
    System.clearProperty("nexus.apacheHttpClient4x.connectionPoolTimeout");
}

From source file:org.geotools.gce.imagemosaic.ImageMosaicPostgisIndexTest.java

@Override
protected void tearDownInternal() throws Exception {

    // clean up disk
    if (!ImageMosaicReaderTest.INTERACTIVE) {
        FileUtils.deleteDirectory(TestData.file(this, "watertemp4"));
    }/* w w w .  j  ava 2 s  .  c  o m*/

    // delete tables
    Class.forName("org.postgresql.Driver");
    Connection connection = DriverManager.getConnection(
            "jdbc:postgresql://" + fixture.getProperty("host") + ":" + fixture.getProperty("port") + "/"
                    + fixture.getProperty("database"),
            fixture.getProperty("user"), fixture.getProperty("passwd"));
    Statement st = connection.createStatement();
    st.execute("DROP TABLE IF EXISTS watertemp4");
    st.close();
    connection.close();

    System.clearProperty("org.geotools.referencing.forceXY");

    super.tearDownInternal();

}

From source file:org.datacleaner.user.UserPreferencesImpl.java

private void refreshProxySettings() {
    if (System.getProperty("http.proxyHost") != null) {
        if (!"true".equals(System.getProperty("http.proxy.setByDataCleaner"))) {
            // proxy was already configured by command line
            return;
        }//from   w  w w. ja  va 2s.com
    }

    System.setProperty("http.proxy.setByDataCleaner", "true");

    String proxyHost = getProxyHostname();
    int proxyPort = getProxyPort();
    String username = getProxyUsername();
    String password = getProxyPassword();

    if (isProxyEnabled() && proxyHost != null) {
        logger.debug("Setting proxy host={}, port={}", proxyHost, proxyPort);
        System.setProperty("http.proxyHost", proxyHost);
        System.setProperty("http.proxyPort", "" + proxyPort);
        System.setProperty("https.proxyHost", proxyHost);
        System.setProperty("https.proxyPort", "" + proxyPort);
        if (isProxyAuthenticationEnabled() && username != null && password != null) {
            logger.debug("Setting proxy username={}, password", username);

            System.setProperty("http.proxyUser", username);
            System.setProperty("http.proxyPassword", password);
            System.setProperty("https.proxyUser", username);
            System.setProperty("https.proxyPassword", password);
        } else {
            logger.debug("Clearing proxy username, password");

            System.clearProperty("http.proxyUser");
            System.clearProperty("http.proxyPassword");
            System.clearProperty("https.proxyUser");
            System.clearProperty("https.proxyPassword");
        }
    } else {
        logger.debug("Clearing proxy host, port, username, password");

        System.clearProperty("http.proxyHost");
        System.clearProperty("http.proxyPort");
        System.clearProperty("https.proxyHost");
        System.clearProperty("https.proxyPort");

        System.clearProperty("http.proxyUser");
        System.clearProperty("http.proxyPassword");
        System.clearProperty("https.proxyUser");
        System.clearProperty("https.proxyPassword");
    }
}

From source file:com.seleniumtests.it.reporter.TestSeleniumTestsReporter2.java

/**
 * Check resources referenced in header are get from local and resources files are  copied to ouput folder
 * @throws Exception/* w w w.  j  av a2  s.c  om*/
 */
@Test(groups = { "it" })
public void testReportWithResourcesFromLocal() throws Exception {

    try {
        System.setProperty("optimizeReports", "false");
        executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClass" },
                ParallelMode.METHODS, new String[] { "testAndSubActions", "testInError", "testWithException" });
    } finally {
        System.clearProperty("optimizeReports");
    }

    // check content of summary report file
    String mainReportContent = readSummaryFile();

    Assert.assertTrue(
            mainReportContent.contains("<script src=\"resources/templates/bootstrap.min.js\"></script>"));

    Assert.assertTrue(Paths.get(SeleniumTestsContextManager.getGlobalContext().getOutputDirectory(),
            "resources", "templates", "AdminLTE.min.css").toFile().exists());
    Assert.assertTrue(Paths.get(SeleniumTestsContextManager.getGlobalContext().getOutputDirectory(),
            "resources", "templates", "bootstrap.min.css").toFile().exists());
    Assert.assertTrue(Paths.get(SeleniumTestsContextManager.getGlobalContext().getOutputDirectory(),
            "resources", "templates", "fonts").toFile().exists());
}

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

@Test
public void testUpdateAcls() throws Exception {
    try {/*from  w  w w  .j  a  v a  2  s  . c  o  m*/
        System.setProperty(SolrZkClient.ZK_ACL_PROVIDER_CLASS_NAME_VM_PARAM_NAME,
                VMParamsAllAndReadonlyDigestZkACLProvider.class.getName());
        System.setProperty(
                VMParamsAllAndReadonlyDigestZkACLProvider.DEFAULT_DIGEST_READONLY_USERNAME_VM_PARAM_NAME,
                "user");
        System.setProperty(
                VMParamsAllAndReadonlyDigestZkACLProvider.DEFAULT_DIGEST_READONLY_PASSWORD_VM_PARAM_NAME,
                "pass");

        String[] args = new String[] { "-zkhost", zkServer.getZkAddress(), "-cmd", "updateacls", "/" };
        ZkCLI.main(args);
    } finally {
        // Need to clear these before we open the next SolrZkClient
        System.clearProperty(SolrZkClient.ZK_ACL_PROVIDER_CLASS_NAME_VM_PARAM_NAME);
        System.clearProperty(
                VMParamsAllAndReadonlyDigestZkACLProvider.DEFAULT_DIGEST_READONLY_USERNAME_VM_PARAM_NAME);
        System.clearProperty(
                VMParamsAllAndReadonlyDigestZkACLProvider.DEFAULT_DIGEST_READONLY_PASSWORD_VM_PARAM_NAME);
    }

    boolean excepted = false;
    try (SolrZkClient zkClient = new SolrZkClient(zkServer.getZkAddress(),
            AbstractDistribZkTestBase.DEFAULT_CONNECTION_TIMEOUT)) {
        zkClient.getData("/", null, null, true);
    } catch (KeeperException.NoAuthException e) {
        excepted = true;
    }
    assertTrue("Did not fail to read.", excepted);
}

From source file:org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl.java

/**
 * @param config/*ww  w.ja  v a 2 s  . com*/
 *          initial configuration
 */
@SuppressWarnings("deprecation")
public MiniAccumuloClusterImpl(MiniAccumuloConfigImpl config) throws IOException {

    this.config = config.initialize();

    mkdirs(config.getConfDir());
    mkdirs(config.getLogDir());
    mkdirs(config.getLibDir());
    mkdirs(config.getLibExtDir());

    if (!config.useExistingInstance()) {
        if (!config.useExistingZooKeepers())
            mkdirs(config.getZooKeeperDir());
        mkdirs(config.getAccumuloDir());
    }

    if (config.useMiniDFS()) {
        File nn = new File(config.getAccumuloDir(), "nn");
        mkdirs(nn);
        File dn = new File(config.getAccumuloDir(), "dn");
        mkdirs(dn);
        File dfs = new File(config.getAccumuloDir(), "dfs");
        mkdirs(dfs);
        Configuration conf = new Configuration();
        conf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY, nn.getAbsolutePath());
        conf.set(DFSConfigKeys.DFS_DATANODE_DATA_DIR_KEY, dn.getAbsolutePath());
        conf.set(DFSConfigKeys.DFS_REPLICATION_KEY, "1");
        conf.set(DFSConfigKeys.DFS_NAMENODE_REPLICATION_MIN_KEY, "1");
        conf.set("dfs.support.append", "true");
        conf.set("dfs.datanode.synconclose", "true");
        conf.set("dfs.datanode.data.dir.perm", MiniDFSUtil.computeDatanodeDirectoryPermission());
        String oldTestBuildData = System.setProperty("test.build.data", dfs.getAbsolutePath());
        miniDFS = new MiniDFSCluster.Builder(conf).build();
        if (oldTestBuildData == null)
            System.clearProperty("test.build.data");
        else
            System.setProperty("test.build.data", oldTestBuildData);
        miniDFS.waitClusterUp();
        InetSocketAddress dfsAddress = miniDFS.getNameNode().getNameNodeAddress();
        dfsUri = "hdfs://" + dfsAddress.getHostName() + ":" + dfsAddress.getPort();
        File coreFile = new File(config.getConfDir(), "core-site.xml");
        writeConfig(coreFile, Collections.singletonMap("fs.default.name", dfsUri).entrySet());
        File hdfsFile = new File(config.getConfDir(), "hdfs-site.xml");
        writeConfig(hdfsFile, conf);

        Map<String, String> siteConfig = config.getSiteConfig();
        siteConfig.put(Property.INSTANCE_DFS_URI.getKey(), dfsUri);
        siteConfig.put(Property.INSTANCE_DFS_DIR.getKey(), "/accumulo");
        config.setSiteConfig(siteConfig);
    } else if (config.useExistingInstance()) {
        dfsUri = config.getHadoopConfiguration().get(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY);
    } else {
        dfsUri = "file:///";
    }

    File clientConfFile = config.getClientConfFile();
    // Write only the properties that correspond to ClientConfiguration properties
    writeConfigProperties(clientConfFile,
            Maps.filterEntries(config.getSiteConfig(),
                    v -> org.apache.accumulo.core.client.ClientConfiguration.ClientProperty
                            .getPropertyByKey(v.getKey()) != null));

    Map<String, String> clientProps = config.getClientProps();
    clientProps.put(ClientProperty.INSTANCE_ZOOKEEPERS.getKey(), config.getZooKeepers());
    clientProps.put(ClientProperty.INSTANCE_NAME.getKey(), config.getInstanceName());
    if (!clientProps.containsKey(ClientProperty.AUTH_TYPE.getKey())) {
        clientProps.put(ClientProperty.AUTH_TYPE.getKey(), "password");
        clientProps.put(ClientProperty.AUTH_PRINCIPAL.getKey(), config.getRootUserName());
        clientProps.put(ClientProperty.AUTH_TOKEN.getKey(), config.getRootPassword());
    }

    File clientPropsFile = config.getClientPropsFile();
    writeConfigProperties(clientPropsFile, clientProps);

    File siteFile = new File(config.getConfDir(), "accumulo.properties");
    writeConfigProperties(siteFile, config.getSiteConfig());
    siteConfig = new SiteConfiguration(siteFile);

    if (!config.useExistingInstance() && !config.useExistingZooKeepers()) {
        zooCfgFile = new File(config.getConfDir(), "zoo.cfg");
        FileWriter fileWriter = new FileWriter(zooCfgFile);

        // zookeeper uses Properties to read its config, so use that to write in order to properly
        // escape things like Windows paths
        Properties zooCfg = new Properties();
        zooCfg.setProperty("tickTime", "2000");
        zooCfg.setProperty("initLimit", "10");
        zooCfg.setProperty("syncLimit", "5");
        zooCfg.setProperty("clientPortAddress", "127.0.0.1");
        zooCfg.setProperty("clientPort", config.getZooKeeperPort() + "");
        zooCfg.setProperty("maxClientCnxns", "1000");
        zooCfg.setProperty("dataDir", config.getZooKeeperDir().getAbsolutePath());
        zooCfg.store(fileWriter, null);

        fileWriter.close();
    }
    clusterControl = new MiniAccumuloClusterControl(this);
}