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:net.officefloor.plugin.woof.WoofOfficeFloorSourceTest.java

@Override
protected void tearDown() throws Exception {

    // Clear property
    System.clearProperty("CHAIN.TEST");

    // Shutdown/*from   www.  ja v  a  2 s.c  om*/
    try {
        try {
            this.client.close();
        } finally {
            WoofOfficeFloorSource.stop();
        }
    } finally {
        // Disconnect from loggers
        this.sourceLoggerAssertion.disconnectFromLogger();
        this.loaderLoggerAssertion.disconnectFromLogger();
    }
}

From source file:com.streamsets.datacollector.http.SlaveWebServerTaskIT.java

@After
public void tearDown() {
    System.clearProperty("sdc.testing-mode");
}

From source file:org.eclipse.wb.tests.designer.editor.DesignerEditorTestCase.java

@Override
protected void tearDown() throws Exception {
    System.clearProperty(DesignerPalette.FLAG_NO_PALETTE);
    waitEventLoop(0);/* w  w w  .ja v  a  2  s .  c om*/
    TestUtils.closeAllEditors();
    waitEventLoop(0);
    // check for exceptions
    {
        removeExceptionsListener();
        assertNoLoggedExceptions();
    }
    // continue
    waitEventLoop(0);
    super.tearDown();
}

From source file:org.jboss.tools.foundation.core.properties.internal.VersionProviderTest.java

@Test
public void testLoadPropertiesViaSysProp() throws Exception {
    URI propertiesURI = new File("data/jbosstools-versions.properties").toURI();
    try {//from   www .j a v  a 2 s.co  m
        System.setProperty(VersionPropertiesProvider.VERSION_PROPERTIES_URI_KEY, propertiesURI.toString());
        VersionPropertiesProvider provider = new VersionPropertiesProvider((String) null, "jbosstools",
                "4.2.0");
        assertEquals("bar", provider.getValue("foo"));
    } finally {
        System.clearProperty(VersionPropertiesProvider.VERSION_PROPERTIES_URI_KEY);
    }
}

From source file:org.apache.atlas.web.service.SecureEmbeddedServerTest.java

@Test
public void testServerConfiguredUsingCredentialProvider() throws Exception {
    // setup the configuration
    final PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty(CERT_STORES_CREDENTIAL_PROVIDER_PATH, providerUrl);
    configuration.setProperty("atlas.services.enabled", false);
    configuration.setProperty("atlas.notification.embedded", "false");
    // setup the credential provider
    setupCredentials();//from  w  w  w  .  j  av  a  2s .c  o m

    String persistDir = BaseSecurityTest.writeConfiguration(configuration);
    String originalConf = System.getProperty("atlas.conf");
    System.setProperty("atlas.conf", persistDir);

    ApplicationProperties.forceReload();
    SecureEmbeddedServer secureEmbeddedServer = null;
    try {
        secureEmbeddedServer = new SecureEmbeddedServer(21443, TestUtils.getWarPath()) {
            @Override
            protected PropertiesConfiguration getConfiguration() {
                return configuration;
            }

            @Override
            protected WebAppContext getWebAppContext(String path) {
                WebAppContext application = new WebAppContext(path, "/");
                application.setDescriptor(
                        System.getProperty("projectBaseDir") + "/webapp/src/test/webapp/WEB-INF/web.xml");
                application.setClassLoader(Thread.currentThread().getContextClassLoader());
                return application;
            }

        };
        secureEmbeddedServer.server.start();

        URL url = new URL("https://localhost:21443/api/atlas/admin/status");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("GET");
        connection.connect();

        // test to see whether server is up and root page can be served
        Assert.assertEquals(connection.getResponseCode(), 200);
    } catch (Throwable e) {
        Assert.fail("War deploy failed", e);
    } finally {
        secureEmbeddedServer.server.stop();

        if (originalConf == null) {
            System.clearProperty("atlas.conf");
        } else {
            System.setProperty("atlas.conf", originalConf);
        }
    }
}

From source file:net.officefloor.plugin.war.integrate.WarIntegrateTest.java

/**
 * Ensure can start the WAR and have it service a {@link HttpRequest}.
 * //from  ww w .  j  av  a  2  s  .co  m
 * @param officeFloorClass
 *            {@link OfficeFloorSource} {@link Class}.
 * @param officeFloorLocation
 *            Location of the {@link OfficeFloor} configuration to use.
 */
public void doWarStartAndService(Class<? extends OfficeFloorSource> officeFloorSourceClass,
        String officeFloorLocation) throws Throwable {

    final int PORT = HttpTestUtil.getAvailablePort();

    // Ensure clean system properties
    System.clearProperty(HttpApplicationLocationManagedObjectSource.PROPERTY_HTTP_PORT);

    // Obtain location of war directory
    File warDir = new File(".", "target/test-classes");
    assertTrue("Test invalid as WAR directory not available", warDir.isDirectory());

    // Obtain the password file location
    File passwordFile = this.findFile(this.getClass(), "../password.txt");

    // Open the OfficeBuilding
    this.officeBuildingManager = OfficeBuildingManager.startOfficeBuilding(null,
            OfficeBuildingPortOfficeFloorCommandParameter.DEFAULT_OFFICE_BUILDING_PORT,
            KeyStoreOfficeFloorCommandParameter.getDefaultKeyStoreFile(),
            KeyStorePasswordOfficeFloorCommandParameter.DEFAULT_KEY_STORE_PASSWORD, "admin", "password", null,
            false, new Properties(), null, null, true);

    try (CloseableHttpClient client = HttpTestUtil.createHttpClient()) {

        // Open the WAR by decoration of OfficeFloor
        OpenOfficeFloorConfiguration configuration = new OpenOfficeFloorConfiguration(officeFloorLocation);
        if (officeFloorSourceClass != null) {
            configuration.setOfficeFloorSourceClassName(officeFloorSourceClass.getName());
        }
        configuration.addClassPathEntry(warDir.getAbsolutePath());
        configuration.addOfficeFloorProperty(HttpApplicationLocationManagedObjectSource.PROPERTY_HTTP_PORT,
                String.valueOf(PORT));
        configuration.addOfficeFloorProperty("password.file.location", passwordFile.getAbsolutePath());
        this.officeBuildingManager.openOfficeFloor(configuration);

        // Allow to start
        boolean isStarted = false;
        long startTime = System.currentTimeMillis();
        do {

            // Determine if time out
            if ((System.currentTimeMillis() - startTime) > 10000) {
                fail("Timed out waiting for OfficeFloor to start");
            }

            // Check whether started
            try {
                HttpGet request = new HttpGet("http://localhost:" + PORT);
                HttpResponse response = client.execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    isStarted = true;
                }
            } catch (IOException ex) {
                // Allow trying again
            }

            // Allow some time to start
            if (!isStarted) {
                Thread.sleep(1000);
            }

        } while (!isStarted);

        // Request data from servlet
        HttpGet request = new HttpGet("http://localhost:" + PORT);
        HttpResponse response = client.execute(request);

        // Ensure valid response
        assertEquals("Response should be successful", 200, response.getStatusLine().getStatusCode());
        String body = HttpTestUtil.getEntityBody(response);
        assertEquals("Incorrect response body", "WAR", body);
    }
}

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

/**
 * Check information are present in detailed report
 * @param testContext//from   w w  w. j a  va 2  s. com
 * @throws Exception
 */
@Test(groups = { "it" })
public void testDataInReport(ITestContext testContext) throws Exception {

    try {
        System.setProperty("customTestReports", "SUP::json::ti/report.test.vm");

        executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClass" },
                ParallelMode.METHODS, new String[] { "testAndSubActions", "testInError", "testWithException" });

        // check content of the file. It should contains all fields with a value
        String detailedReportContent = FileUtils
                .readFileToString(Paths.get(SeleniumTestsContextManager.getGlobalContext().getOutputDirectory(),
                        "testAndSubActions", "SUP-result.json").toFile());
        System.out.println(detailedReportContent);
        JSONObject json = new JSONObject(detailedReportContent);

        Assert.assertEquals(json.getInt("errors"), 0);
        Assert.assertEquals(json.getInt("failures"), 0);
        Assert.assertEquals(json.getString("hostname"), "");
        Assert.assertEquals(json.getString("suiteName"), "testAndSubActions");
        Assert.assertEquals(json.getString("className"), "com.seleniumtests.it.stubclasses.StubTestClass");
        Assert.assertEquals(json.getInt("tests"), 7);
        Assert.assertTrue(Float.parseFloat(json.get("duration").toString()) > 15);
        Assert.assertTrue(json.getLong("time") > 1518709523620L);
        Assert.assertEquals(json.getJSONArray("testSteps").length(), 7);
        Assert.assertEquals(json.getJSONArray("testSteps").get(3),
                "Step step 1\\nclick button\\nsendKeys to text field\\nStep step 1.3: open page\\nclick link\\na message\\nsendKeys to password field");
        Assert.assertEquals(json.getString("browser"), "NONE");
        Assert.assertNotNull(json.get("version"));
        Assert.assertTrue(json.getJSONObject("parameters").length() > 70);
        Assert.assertEquals(json.getJSONObject("parameters").getString("testType"), "NON_GUI");
        Assert.assertEquals(json.getJSONObject("parameters").getInt("replayTimeOut"), 30);
        Assert.assertEquals(json.getJSONArray("stacktrace").length(), 0);
    } finally {
        System.clearProperty("customTestReports");
    }
}

From source file:org.apache.tinkerpop.gremlin.util.SystemUtilTest.java

@Test
public void shouldTrimSystemPropertyPrefixesAndNoMore() {
    System.setProperty("blah.a.x", "1");
    System.setProperty("blah.b.y", "true");
    System.setProperty("blah.cc.zzz", "three");
    System.setProperty("bleep.d.d", "false");
    Configuration configuration = SystemUtil.getSystemPropertiesConfiguration("blah", true);
    assertEquals(3, IteratorUtils.count(configuration.getKeys()));
    assertEquals(1, configuration.getInt("a.x"));
    assertTrue(configuration.getBoolean("b.y"));
    assertEquals("three", configuration.getProperty("cc.zzz"));
    assertFalse(configuration.containsKey("d") || configuration.containsKey("bleep.d"));
    assertFalse(configuration.containsKey("d.d") || configuration.containsKey("bleep.d.d"));
    System.clearProperty("blah.a.x");
    System.clearProperty("blah.b.y");
    System.clearProperty("blah.cc.zzz");
    System.clearProperty("bleep.d.d");
}

From source file:org.nuxeo.runtime.AbstractRuntimeService.java

protected AbstractRuntimeService(DefaultRuntimeContext context, Map<String, String> properties) {
    this.context = context;
    context.setRuntime(this);
    if (properties != null) {
        this.properties.putAll(properties);
    }/*w  ww.  j  a v a2s.c o  m*/
    // get errors set by NuxeoDeployer
    String errs = System.getProperty("org.nuxeo.runtime.deployment.errors");
    if (errs != null) {
        warnings.addAll(Arrays.asList(errs.split("\n")));
        System.clearProperty("org.nuxeo.runtime.deployment.errors");
    }
}

From source file:ddf.catalog.source.solr.SolrProviderTestCase.java

@AfterClass
public static void teardown() {
    if (threadPoolSize != null) {
        System.setProperty("org.codice.ddf.system.threadPoolSize", threadPoolSize);
    }/*from  w w w.  j ava 2 s .com*/
    if (cipherSuites != null) {
        System.setProperty("https.cipherSuites", cipherSuites);
    } else {
        System.clearProperty("https.cipherSuites");
    }
    if (protocols != null) {
        System.setProperty("https.protocols", protocols);
    } else {
        System.clearProperty("https.protocols");
    }
}