List of usage examples for java.lang System clearProperty
public static String clearProperty(String key)
From source file:com.thoughtworks.go.util.SystemEnvironment.java
public void clearProperty(String name) { clearCachedSystemEnvironment(); System.clearProperty(name); }
From source file:com.seleniumtests.it.reporter.TestSeleniumTestsReporter2.java
/** * Check that video capture file is present in result * // www . j a v a 2 s .c o m * @throws Exception */ @Test(groups = { "it" }) public void testReportContainsVideoCapture() throws Exception { try { System.setProperty(SeleniumTestsContext.VIDEO_CAPTURE, "true"); executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClassForDriverTest" }, ParallelMode.METHODS, new String[] { "testDriver" }); // read 'testDriver' report. This contains calls to HtmlElement actions String detailedReportContent1 = readTestMethodResultFile("testDriver"); Assert.assertTrue(detailedReportContent1.contains( "<li>sendKeys on TextFieldElement Text, by={By.id: text2} with args: (true, true, [a text,], )</li>")); } finally { System.clearProperty(SeleniumTestsContext.VIDEO_CAPTURE); } }
From source file:org.apache.solr.cloud.BasicDistributedZkTest.java
private void testANewCollectionInOneInstanceWithManualShardAssignement() throws Exception { log.info("### STARTING testANewCollectionInOneInstanceWithManualShardAssignement"); System.clearProperty("numShards"); List<SolrClient> collectionClients = new ArrayList<>(); SolrClient client = clients.get(0);// www . ja v a 2 s . c om final String baseUrl = ((HttpSolrClient) client).getBaseURL().substring(0, ((HttpSolrClient) client).getBaseURL().length() - DEFAULT_COLLECTION.length() - 1); createSolrCore(oneInstanceCollection2, collectionClients, baseUrl, 1, "slice1"); createSolrCore(oneInstanceCollection2, collectionClients, baseUrl, 2, "slice2"); createSolrCore(oneInstanceCollection2, collectionClients, baseUrl, 3, "slice2"); createSolrCore(oneInstanceCollection2, collectionClients, baseUrl, 4, "slice1"); while (pending != null && pending.size() > 0) { Future<Object> future = completionService.take(); pending.remove(future); } SolrClient client1 = collectionClients.get(0); SolrClient client2 = collectionClients.get(1); SolrClient client3 = collectionClients.get(2); SolrClient client4 = collectionClients.get(3); // no one should be recovering waitForRecoveriesToFinish(oneInstanceCollection2, getCommonCloudSolrClient().getZkStateReader(), false, true); assertAllActive(oneInstanceCollection2, getCommonCloudSolrClient().getZkStateReader()); //printLayout(); // TODO: enable when we don't falsely get slice1... // solrj.getZkStateReader().getLeaderUrl(oneInstanceCollection2, "slice1", 30000); // solrj.getZkStateReader().getLeaderUrl(oneInstanceCollection2, "slice2", 30000); client2.add(getDoc(id, "1")); client3.add(getDoc(id, "2")); client4.add(getDoc(id, "3")); client1.commit(); SolrQuery query = new SolrQuery("*:*"); query.set("distrib", false); long oneDocs = client1.query(query).getResults().getNumFound(); long twoDocs = client2.query(query).getResults().getNumFound(); long threeDocs = client3.query(query).getResults().getNumFound(); long fourDocs = client4.query(query).getResults().getNumFound(); query.set("collection", oneInstanceCollection2); query.set("distrib", true); long allDocs = getCommonCloudSolrClient().query(query).getResults().getNumFound(); // System.out.println("1:" + oneDocs); // System.out.println("2:" + twoDocs); // System.out.println("3:" + threeDocs); // System.out.println("4:" + fourDocs); // System.out.println("All Docs:" + allDocs); // assertEquals(oneDocs, threeDocs); // assertEquals(twoDocs, fourDocs); // assertNotSame(oneDocs, twoDocs); assertEquals(3, allDocs); // we added a role of none on these creates - check for it ZkStateReader zkStateReader = getCommonCloudSolrClient().getZkStateReader(); zkStateReader.forceUpdateCollection(oneInstanceCollection2); Map<String, Slice> slices = zkStateReader.getClusterState().getSlicesMap(oneInstanceCollection2); assertNotNull(slices); String roles = slices.get("slice1").getReplicasMap().values().iterator().next() .getStr(ZkStateReader.ROLES_PROP); assertEquals("none", roles); ZkCoreNodeProps props = new ZkCoreNodeProps(getCommonCloudSolrClient().getZkStateReader().getClusterState() .getLeader(oneInstanceCollection2, "slice1")); // now test that unloading a core gets us a new leader try (HttpSolrClient unloadClient = getHttpSolrClient(baseUrl)) { unloadClient.setConnectionTimeout(15000); unloadClient.setSoTimeout(60000); Unload unloadCmd = new Unload(true); unloadCmd.setCoreName(props.getCoreName()); String leader = props.getCoreUrl(); unloadClient.request(unloadCmd); int tries = 50; while (leader.equals(zkStateReader.getLeaderUrl(oneInstanceCollection2, "slice1", 10000))) { Thread.sleep(100); if (tries-- == 0) { fail("Leader never changed"); } } } IOUtils.close(collectionClients); }
From source file:com.seleniumtests.it.reporter.TestSeleniumTestsReporter2.java
/** * Check that HAR capture file is present in result * /*from www .ja va2 s .c o m*/ * @throws Exception */ @Test(groups = { "it" }) public void testReportContainsHarCapture() throws Exception { try { System.setProperty(SeleniumTestsContext.CAPTURE_NETWORK, "true"); System.setProperty(SeleniumTestsContext.WEB_PROXY_TYPE, "direct"); executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClassForDriverTest" }, ParallelMode.METHODS, new String[] { "testDriver" }); // read 'testDriver' report. This contains calls to HtmlElement actions String detailedReportContent1 = readTestMethodResultFile("testDriver"); Assert.assertTrue(detailedReportContent1.contains( "<li>sendKeys on TextFieldElement Text, by={By.id: text2} with args: (true, true, [a text,], )</li>")); Assert.assertTrue( detailedReportContent1.contains("Network capture: <a href='networkCapture.har'>HAR file</a>")); Assert.assertTrue(Paths.get(SeleniumTestsContextManager.getGlobalContext().getOutputDirectory(), "testDriver", "networkCapture.har").toFile().exists()); } finally { System.clearProperty(SeleniumTestsContext.CAPTURE_NETWORK); System.clearProperty(SeleniumTestsContext.WEB_PROXY_TYPE); } }
From source file:org.fcrepo.integration.auth.webac.WebACRecipesIT.java
@Test public void testAgentAsUri() throws IOException { final String id = "/rest/" + getRandomUniqueId(); final String testObj = ingestObj(id); final String acl = ingestAcl("fedoraAdmin", "/acls/16/acl.ttl", "/acls/16/authorization.ttl"); logger.debug("Anonymous can't read (no ACL): {}", id); final HttpGet requestGet1 = getObjMethod(id); assertEquals(HttpStatus.SC_FORBIDDEN, getStatus(requestGet1)); logger.debug("Can username 'smith123' read {} (no ACL)", id); final HttpGet requestGet2 = getObjMethod(id); setAuth(requestGet2, "smith123"); assertEquals(HttpStatus.SC_FORBIDDEN, getStatus(requestGet2)); System.setProperty(USER_AGENT_BASE_URI_PROPERTY, "info:user/"); System.setProperty(GROUP_AGENT_BASE_URI_PROPERTY, "info:group/"); logger.debug("Can username 'smith123' read {} (overridden system ACL)", id); final HttpGet requestGet3 = getObjMethod(id); setAuth(requestGet3, "smith123"); assertEquals(HttpStatus.SC_FORBIDDEN, getStatus(requestGet3)); logger.debug("Can username 'group123' read {} (overridden system ACL)", id); final HttpGet requestGet4 = getObjMethod(id); setAuth(requestGet4, "group123"); assertEquals(HttpStatus.SC_FORBIDDEN, getStatus(requestGet4)); System.clearProperty(USER_AGENT_BASE_URI_PROPERTY); System.clearProperty(GROUP_AGENT_BASE_URI_PROPERTY); // Add ACL to object linkToAcl(testObj, acl);//from w ww . j av a 2 s .co m logger.debug("Anonymous still can't read (ACL present)"); final HttpGet requestGet5 = getObjMethod(id); assertEquals(HttpStatus.SC_FORBIDDEN, getStatus(requestGet5)); logger.debug("Can username 'smith123' read {} (ACL present, no system properties)", testObj); final HttpGet requestGet6 = getObjMethod(id); setAuth(requestGet6, "smith123"); assertEquals(HttpStatus.SC_FORBIDDEN, getStatus(requestGet6)); System.setProperty(USER_AGENT_BASE_URI_PROPERTY, "info:user/"); System.setProperty(GROUP_AGENT_BASE_URI_PROPERTY, "info:group/"); logger.debug("Can username 'smith123' read {} (ACL, system properties present)", id); final HttpGet requestGet7 = getObjMethod(id); setAuth(requestGet7, "smith123"); assertEquals(HttpStatus.SC_OK, getStatus(requestGet7)); logger.debug("Can groupname 'group123' read {} (ACL, system properties present)", id); final HttpGet requestGet8 = getObjMethod(id); setAuth(requestGet8, "group123"); assertEquals(HttpStatus.SC_OK, getStatus(requestGet8)); System.clearProperty(USER_AGENT_BASE_URI_PROPERTY); System.clearProperty(GROUP_AGENT_BASE_URI_PROPERTY); }
From source file:com.seleniumtests.it.reporter.TestSeleniumTestsReporter2.java
/** * Check that HAR capture file is not present in result if option is disabled * // w w w .ja v a 2s .co m * @throws Exception */ @Test(groups = { "it" }) public void testReportDoNotContainsHarCapture() throws Exception { try { System.setProperty(SeleniumTestsContext.CAPTURE_NETWORK, "false"); executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClassForDriverTest" }, ParallelMode.METHODS, new String[] { "testDriver" }); // read 'testDriver' report. This contains calls to HtmlElement actions String detailedReportContent1 = readTestMethodResultFile("testDriver"); Assert.assertTrue(detailedReportContent1.contains( "<li>sendKeys on TextFieldElement Text, by={By.id: text2} with args: (true, true, [a text,], )</li>")); Assert.assertFalse( detailedReportContent1.contains("Network capture: <a href='networkCapture.har'>HAR file</a>")); Assert.assertFalse(Paths.get(SeleniumTestsContextManager.getGlobalContext().getOutputDirectory(), "testDriver", "networkCapture.har").toFile().exists()); } finally { System.clearProperty(SeleniumTestsContext.CAPTURE_NETWORK); } }
From source file:com.thoughtworks.go.util.SystemEnvironment.java
public <T> void reset(GoSystemProperty<T> systemProperty) { System.clearProperty(systemProperty.propertyName()); if (systemProperty instanceof CachedProperty) { ((CachedProperty) systemProperty).clear(); }/*from w w w.ja va 2 s.co m*/ }
From source file:org.apache.directory.studio.connection.core.io.jndi.JNDIConnectionWrapper.java
private void doGssapiBind(final InnerRunnable innerRunnable) throws NamingException { File configFile = null;/*from w w w . ja va 2 s . c o m*/ try { Preferences preferences = ConnectionCorePlugin.getDefault().getPluginPreferences(); boolean useKrb5SystemProperties = preferences .getBoolean(ConnectionCoreConstants.PREFERENCE_USE_KRB5_SYSTEM_PROPERTIES); String krb5LoginModule = preferences.getString(ConnectionCoreConstants.PREFERENCE_KRB5_LOGIN_MODULE); if (!useKrb5SystemProperties) { // Kerberos Configuration switch (connection.getConnectionParameter().getKrb5Configuration()) { case DEFAULT: // nothing System.clearProperty("java.security.krb5.conf"); //$NON-NLS-1$ break; case FILE: // use specified krb5.conf System.setProperty("java.security.krb5.conf", connection.getConnectionParameter() //$NON-NLS-1$ .getKrb5ConfigurationFile()); break; case MANUAL: // write manual config parameters to connection specific krb5.conf file String fileName = Utils.getFilenameString(connection.getId()) + ".krb5.conf"; //$NON-NLS-1$ configFile = ConnectionCorePlugin.getDefault().getStateLocation().append(fileName).toFile(); String realm = connection.getConnectionParameter().getKrb5Realm(); String host = connection.getConnectionParameter().getKrb5KdcHost(); int port = connection.getConnectionParameter().getKrb5KdcPort(); StringBuilder sb = new StringBuilder(); sb.append("[libdefaults]").append(ConnectionCoreConstants.LINE_SEPARATOR); //$NON-NLS-1$ sb.append("default_realm = ").append(realm).append(ConnectionCoreConstants.LINE_SEPARATOR); //$NON-NLS-1$ sb.append("[realms]").append(ConnectionCoreConstants.LINE_SEPARATOR); //$NON-NLS-1$ sb.append(realm).append(" = {").append(ConnectionCoreConstants.LINE_SEPARATOR); //$NON-NLS-1$ sb.append("kdc = ").append(host).append(":").append(port).append( //$NON-NLS-1$ //$NON-NLS-2$ ConnectionCoreConstants.LINE_SEPARATOR); sb.append("}").append(ConnectionCoreConstants.LINE_SEPARATOR); //$NON-NLS-1$ try { FileUtils.writeStringToFile(configFile, sb.toString()); } catch (IOException ioe) { NamingException ne = new NamingException(); ne.setRootCause(ioe); throw ne; } System.setProperty("java.security.krb5.conf", configFile.getAbsolutePath()); //$NON-NLS-1$ } // Use our custom configuration so we don't need to mess with external configuration Configuration.setConfiguration(new InnerConfiguration(krb5LoginModule)); } // Gets the TGT, either from native ticket cache or obtain new from KDC LoginContext lc = null; try { lc = new LoginContext(this.getClass().getName(), new InnerCallbackHandler()); lc.login(); } catch (LoginException le) { NamingException ne = new NamingException(); ne.setRootCause(le); throw ne; } // Login to LDAP server, obtains a service ticket from KDC Subject.doAs(lc.getSubject(), (PrivilegedAction<Object>) () -> { try { context.reconnect(context.getConnectControls()); } catch (NamingException ne) { innerRunnable.namingException = ne; } return null; }); } finally { // delete temporary config file if (configFile != null && configFile.exists()) { configFile.delete(); } } }
From source file:com.cisco.dvbu.ps.deploytool.services.ResourceManagerImpl.java
public void doResourcesExist(String serverId, String resourceIds, String pathToResourceXML, String pathToServersXML) throws CompositeException { String prefix = "doResourcesExist"; String processedIds = null;//from w ww.j a va 2 s . c om // Extract variables for the resourceIds resourceIds = CommonUtils.extractVariable(prefix, resourceIds, propertyFile, true); // Set the Module Action Objective String s1 = (resourceIds == null) ? "no_resourceIds" : "Ids=" + resourceIds; System.setProperty("MODULE_ACTION_OBJECTIVE", "EXIST : " + s1); List<ResourceType> resourceList = getResources(serverId, resourceIds, 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(resourceIds, resourceId)) { // Add to the list of processed ids if (processedIds == null) processedIds = ""; else processedIds = processedIds + ","; processedIds = processedIds + resourceId; if (resource.getResourcePath() != null && resource.getResourcePath().size() > 0) { for (int i = 0; i < resource.getResourcePath().size(); i++) { String resourcePath = resource.getResourcePath().get(i); System.setProperty("RESOURCE_ID", resourceId); if (!doResourceExist(serverId, resourcePath, pathToServersXML)) { System.clearProperty("RESOURCE_ID"); throw new CompositeException( "Resource Id " + resourceId + " does not exist on server " + serverId); } 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("Resource entries processed=" + processedIds); } } else { if (logger.isInfoEnabled()) { String msg = "Warning: No resource entries were processed for the input list. resourceIds=" + resourceIds; logger.info(msg); System.setProperty("MODULE_ACTION_MESSAGE", msg); } } } else { if (logger.isInfoEnabled()) { String msg = "Warning: No resource entries found for Resource Module XML at path=" + pathToResourceXML; logger.info(msg); System.setProperty("MODULE_ACTION_MESSAGE", msg); } } }