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.google.gdt.eclipse.designer.uibinder.parser.UiBinderContext.java

/**
 * Ensures that UiBinder is configured for design time.
 *//*  w ww .  j  a v a  2s.com*/
public void runDesignTime(RunnableEx runnable) throws Exception {
    String isKey = "gwt.UiBinder.isDesignTime " + m_binderClassName.replace('$', '.');
    String resKey = "gwt.UiBinder.designTime " + m_binderResourceName;
    boolean old_designTime = Beans.isDesignTime();
    try {
        Beans.setDesignTime(true);
        // mark "Binder" as design time
        System.setProperty(isKey, "true");
        // put current document content into System, to make it available to UiBinderGenerator
        {
            String content = getContent();
            content = removeWbpNameAttributes(content);
            System.setProperty(resKey, content);
        }
        // do run
        runnable.run();
    } finally {
        m_state.getDevModeBridge().invalidateRebind(m_binderClassName);
        Beans.setDesignTime(old_designTime);
        System.clearProperty(isKey);
        System.clearProperty(resKey);
        getBroadcastSupport().getListener(AfterRunDesignTime.class).invoke();
    }
}

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

@Test
public void test() throws Exception {
    handle.clear();//  w w w.  j  a va2 s.c o m
    handle.put("timestamp", SKIPVAL);

    waitForThingsToLevelOut(30);

    del("*:*");

    // index enough docs and commit to establish frame of reference for PeerSync
    for (int i = 0; i < 100; i++) {
        indexDoc(id, docId, i1, 50, tlong, 50, t1, "document number " + docId++);
    }
    commit();
    waitForThingsToLevelOut(30);

    try {
        checkShardConsistency(false, true);

        long cloudClientDocs = cloudClient.query(new SolrQuery("*:*")).getResults().getNumFound();
        assertEquals(docId, cloudClientDocs);

        CloudJettyRunner initialLeaderJetty = shardToLeaderJetty.get("shard1");
        List<CloudJettyRunner> otherJetties = getOtherAvailableJetties(initialLeaderJetty);
        CloudJettyRunner neverLeader = otherJetties.get(otherJetties.size() - 1);
        otherJetties.remove(neverLeader);

        // first shutdown a node that will never be a leader
        forceNodeFailures(singletonList(neverLeader));

        // node failure and recovery via PeerSync
        log.info("Forcing PeerSync");
        CloudJettyRunner nodePeerSynced = forceNodeFailureAndDoPeerSync(false);

        // add a few more docs
        indexDoc(id, docId, i1, 50, tlong, 50, t1, "document number " + docId++);
        indexDoc(id, docId, i1, 50, tlong, 50, t1, "document number " + docId++);
        commit();

        cloudClientDocs = cloudClient.query(new SolrQuery("*:*")).getResults().getNumFound();
        assertEquals(docId, cloudClientDocs);

        // now shutdown all other nodes except for 'nodeShutDownForFailure'
        otherJetties.remove(nodePeerSynced);
        forceNodeFailures(otherJetties);
        waitForThingsToLevelOut(30);
        checkShardConsistency(false, true);

        // now shutdown the original leader
        log.info("Now shutting down initial leader");
        forceNodeFailures(singletonList(initialLeaderJetty));
        log.info("Updating mappings from zk");
        waitForNewLeader(cloudClient, "shard1", (Replica) initialLeaderJetty.client.info,
                new TimeOut(15, SECONDS));
        updateMappingsFromZk(jettys, clients, true);
        assertEquals("PeerSynced node did not become leader", nodePeerSynced, shardToLeaderJetty.get("shard1"));

        // bring up node that was down all along, and let it PeerSync from the node that was forced to PeerSynce  
        bringUpDeadNodeAndEnsureNoReplication(neverLeader, false);
        waitTillNodesActive();

        checkShardConsistency(false, true);

        // bring back all the nodes including initial leader 
        // (commented as reports Maximum concurrent create/delete watches above limit violation and reports thread leaks)
        /*for(int i = 0 ; i < nodesDown.size(); i++) {
          bringUpDeadNodeAndEnsureNoReplication(shardToLeaderJetty.get("shard1"), neverLeader, false);
        }
        checkShardConsistency(false, true);*/

        // make sure leader has not changed after bringing initial leader back
        assertEquals(nodePeerSynced, shardToLeaderJetty.get("shard1"));

        // assert metrics
        MetricRegistry registry = nodePeerSynced.jetty.getCoreContainer().getMetricManager()
                .registry("solr.core.collection1");
        Map<String, Metric> metrics = registry.getMetrics();
        assertTrue("REPLICATION.time present", metrics.containsKey("REPLICATION.time"));
        assertTrue("REPLICATION.errors present", metrics.containsKey("REPLICATION.errors"));
        Timer timer = (Timer) metrics.get("REPLICATION.time");
        assertEquals(1L, timer.getCount());
        Counter counter = (Counter) metrics.get("REPLICATION.errors");
        assertEquals(0L, counter.getCount());
        success = true;
    } finally {
        System.clearProperty("solr.disableFingerprint");
    }
}

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

@Override
public void distribTearDown() throws Exception {
    System.clearProperty("java.security.auth.login.config");
    System.clearProperty("solr.kerberos.jaas.appname");
    System.clearProperty("solr.cookie.domain");
    System.clearProperty("solr.kerberos.principal");
    System.clearProperty("solr.kerberos.keytab");
    System.clearProperty("solr.jaas.debug");
    System.clearProperty("solr.kerberos.name.rules");
    Configuration.setConfiguration(originalConfig);
    if (kdc != null) {
        kdc.stop();/*  w  w w  .j  a v  a  2  s .c  o  m*/
    }
    //SSLTestConfig.clearSSLSystemProperties();
    Locale.setDefault(savedLocale);
    super.distribTearDown();
}

From source file:org.jolokia.backend.BackendManagerTest.java

@Test
public void agentIdSystemProperty() {
    System.setProperty("agentIdSystemProperty", "test1234");
    Configuration myConfig = new Configuration(ConfigKey.AGENT_ID, "${prop:agentIdSystemProperty}");
    BackendManager backendManager = new BackendManager(myConfig, log);
    assertEquals(backendManager.getAgentDetails().getAgentId(), "test1234");
    backendManager.destroy();//from  www  .  j a v a 2s  . c  om
    System.clearProperty("agentIdSystemProperty");
}

From source file:org.apache.sentry.tests.e2e.solr.AbstractSolrSentryTestBase.java

@After
public void tearDown() throws Exception {
    System.clearProperty("solr.hdfs.blockcache.enabled");
    System.clearProperty("solr.xml.persist");
}

From source file:com.cisco.dvbu.ps.deploytool.services.ResourceManagerImpl.java

public void executeConfiguredProcedures(String serverId, String procedureIds, String pathToResourceXML,
        String pathToServersXML) throws CompositeException {

    String prefix = "executeConfiguredProcedures";
    String outputReturnVariables = "false";
    String processedIds = null;//w ww . j  ava2 s .  c o m

    // Extract variables for the procedureIds
    procedureIds = CommonUtils.extractVariable(prefix, procedureIds, propertyFile, true);

    // Set the Module Action Objective
    String s1 = (procedureIds == null) ? "no_procedureIds" : "Ids=" + procedureIds;
    System.setProperty("MODULE_ACTION_OBJECTIVE", "EXECUTE : " + s1);

    // Validate whether the files exist or not
    if (!CommonUtils.fileExists(pathToResourceXML)) {
        throw new CompositeException("File [" + pathToResourceXML + "] does not exist.");
    }
    if (!CommonUtils.fileExists(pathToServersXML)) {
        throw new CompositeException("File [" + pathToServersXML + "] does not exist.");
    }

    List<ResourceType> resourceList = getResources(serverId, procedureIds, pathToResourceXML, pathToServersXML);

    if (resourceList != null && resourceList.size() > 0) {

        for (ResourceType resource : resourceList) {
            // Get the identifier and convert any $VARIABLES
            String resourceId = CommonUtils.extractVariable(prefix, resource.getId(), propertyFile, true);

            /**
             * Possible values for archives 
             * 1. csv string like import1,import2 (we process only resource names which are passed in)
             * 2. '*' or what ever is configured to indicate all resources (we process all resources in this case)
             * 3. csv string with '-' or what ever is configured to indicate exclude resources as prefix 
             *      like -import1,import3 (we ignore passed in resources and process rest of the in the input xml
             */
            if (DeployUtil.canProcessResource(procedureIds, resourceId)) {
                // Add to the list of processed ids
                if (processedIds == null)
                    processedIds = "";
                else
                    processedIds = processedIds + ",";
                processedIds = processedIds + resourceId;

                String arguments = "";
                if (resource.getArgument() != null) {

                    List<String> argumentList = resource.getArgument();
                    int i = 0;
                    for (String argument : argumentList) {

                        if (argument != null) {
                            // If the argument value contains $ or % then treat it as a variable and resolve the variable
                            argument = CommonUtils.extractVariable(prefix, argument, propertyFile, false);
                            if (i > 0) {
                                arguments += ",";
                            }
                            arguments += "'" + argument.trim() + "'";
                        }
                        i++;
                    }
                }
                if (resource.getOutputReturnVariables() != null)
                    outputReturnVariables = resource.getOutputReturnVariables();

                if (resource.getResourcePath() != null && resource.getResourcePath().size() > 0) {
                    for (int i = 0; i < resource.getResourcePath().size(); i++) {
                        String resourcePath = resource.getResourcePath().get(i);
                        if (logger.isInfoEnabled()) {
                            logger.info("Executing Procedure " + resourcePath + " with arguments " + arguments
                                    + "  outputReturnVariables=" + outputReturnVariables);
                        }
                        System.setProperty("RESOURCE_ID", resourceId);
                        executeProcedure(serverId, resourcePath, resource.getDataServiceName(),
                                pathToServersXML, arguments, outputReturnVariables);
                        System.clearProperty("RESOURCE_ID");
                    }
                } else {
                    if (logger.isInfoEnabled()) {
                        logger.info("No resource paths found for resourceId " + resourceId);
                    }
                }
            }
        }

        // Determine if any resourceIds were not processed and report on this
        if (processedIds != null) {
            if (logger.isInfoEnabled()) {
                logger.info("Procedure entries processed=" + processedIds);
            }
        } else {
            if (logger.isInfoEnabled()) {
                String msg = "Warning: No procedure entries were processed for the input list.  procedureIds="
                        + procedureIds;
                logger.info(msg);
                System.setProperty("MODULE_ACTION_MESSAGE", msg);
            }
        }
    } else {
        if (logger.isInfoEnabled()) {
            String msg = "Warning: No procedure entries found for Resource Module XML at path="
                    + pathToResourceXML;
            logger.info(msg);
            System.setProperty("MODULE_ACTION_MESSAGE", msg);
        }
    }
}

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

public void testRepositoryConfigWithSystemVariables() throws Exception {
    final String id = "testvalue";
    final long syncDelay = 11;

    System.setProperty(ClusterNode.SYSTEM_PROPERTY_NODE_ID, id);
    System.setProperty("cluster.syncDelay", Long.toString(syncDelay));
    try {//  www . j  a  v  a 2s. c  o  m
        InputStream in = getClass().getResourceAsStream("/org/apache/jackrabbit/core/cluster/repository.xml");
        RepositoryConfig config = RepositoryConfig.create(in, DIR.getPath());

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

From source file:org.apache.hive.jdbc.TestSSL.java

/***
 * Test SSL client with non-SSL server fails
 * @throws Exception/*  w w w  . ja  va  2s .  c  o  m*/
 */
@Test
public void testInvalidConfig() throws Exception {
    clearSslConfOverlay(confOverlay);
    // Test in binary mode
    setBinaryConfOverlay(confOverlay);
    miniHS2.start(confOverlay);
    DriverManager.setLoginTimeout(4);
    try {
        hs2Conn = DriverManager.getConnection(miniHS2.getJdbcURL("default", SSL_CONN_PARAMS),
                System.getProperty("user.name"), "bar");
        fail("SSL connection should fail with NON-SSL server");
    } catch (SQLException e) {
        // expected error
        assertEquals("08S01", e.getSQLState().trim());
    }

    System.setProperty(JAVA_TRUST_STORE_PROP, dataFileDir + File.separator + TRUST_STORE_NAME);
    System.setProperty(JAVA_TRUST_STORE_PASS_PROP, KEY_STORE_PASSWORD);
    try {
        hs2Conn = DriverManager.getConnection(miniHS2.getJdbcURL() + ";ssl=true",
                System.getProperty("user.name"), "bar");
        fail("SSL connection should fail with NON-SSL server");
    } catch (SQLException e) {
        // expected error
        assertEquals("08S01", e.getSQLState().trim());
    }
    miniHS2.stop();

    // Test in http mode with ssl properties specified in url
    System.clearProperty(JAVA_TRUST_STORE_PROP);
    System.clearProperty(JAVA_TRUST_STORE_PASS_PROP);
    setHttpConfOverlay(confOverlay);
    miniHS2.start(confOverlay);
    try {
        hs2Conn = DriverManager.getConnection(miniHS2.getJdbcURL("default", SSL_CONN_PARAMS),
                System.getProperty("user.name"), "bar");
        fail("SSL connection should fail with NON-SSL server");
    } catch (SQLException e) {
        // expected error
        assertEquals("08S01", e.getSQLState().trim());
    }
}

From source file:net.sf.jasperreports.soutils.EnvironmentUtils.java

public static void setForcedIBM(boolean forced) {
    if (forced) {
        System.setProperty(WBP_JAVA_VM_VENDOR, "Fake IBM");
    } else {//from w  w  w.ja  va 2 s  .  c  o  m
        System.clearProperty(WBP_JAVA_VM_VENDOR);
    }
}

From source file:io.cloudslang.lang.compiler.SlangSourceTest.java

@Test
public void testFromFileOverrideEncoding() throws Exception {
    // In this scenario, the source file is encoded using a single-byte Western European encoding
    // (instead of UTF-8)
    final String sourceString = "Andr Citron";
    final String filename = name + "_fr";
    File file = folder.newFile(filename);
    FileUtils.writeStringToFile(file, sourceString, "ISO-8859-1");

    // Make sure we can override the default encoding (UTF-8) with a system property
    System.setProperty("cslang.encoding", "ISO-8859-1");
    SlangSource result = SlangSource.fromFile(file);
    System.clearProperty("cslang.encoding");

    Assert.assertEquals(sourceString, result.getContent());
    Assert.assertEquals(filename, result.getName());
}