List of usage examples for java.lang System clearProperty
public static String clearProperty(String key)
From source file:org.schedulesdirect.api.AiringTest.java
static private void loadAllSamples() throws Exception { SAMPLE_AIRS = new JSONArray(); final String PROP = "sdjson.capture.json-errors"; String capVal = System.setProperty(PROP, "1"); assertTrue(Config.get().captureJsonParseErrors()); int failed = 0; StringBuilder sb = new StringBuilder(); Station s = mock(Station.class); JSONArray schedArray = new JSONArray(SAMPLE_DATA); for (int i = 0; i < schedArray.length(); ++i) { JSONObject input = schedArray.getJSONObject(i); JSONArray airings = input.optJSONArray("programs"); if (airings != null) for (int j = 0; j < airings.length(); ++j) { JSONObject a = airings.getJSONObject(j); Program p = mock(Program.class); when(p.getId()).thenReturn(a.getString("programID")); try { JSONObject o = airings.getJSONObject(j); new Airing(o, p, s); SAMPLE_AIRS.put(o);// w w w. j ava 2s .c o m } catch (InvalidJsonObjectException e) { sb.append(String.format("\t(Element %d:%d) %s: %s%n", i, j, input.optString("programID", "<UNKNOWN>"), e.getMessage())); ++failed; } } } if (capVal == null) System.clearProperty(PROP); else System.setProperty(PROP, capVal); if (failed > 0) LOG.warn(String.format("%d of %d samples (%s%%) failed to load!%n%s%n", failed, schedArray.length(), String.format("%.2f", 100.0F * failed / schedArray.length()), sb)); else if (LOG.isDebugEnabled()) LOG.debug("No load failures!"); if (failed > 0 && failed >= schedArray.length() / 10) throw new IOException("Too many load failures! Halting testing now."); SAMPLE_DATA = null; }
From source file:org.apache.solr.schema.SpatialRPTFieldTypeTest.java
@After private void afterClass() throws Exception { deleteCore();/*from w ww . ja v a 2 s . com*/ System.clearProperty("managed.schema.mutable"); System.clearProperty("enable.update.log"); }
From source file:org.jboss.shrinkwrap.resolver.impl.maven.bootstrap.SystemPropertyPrecedenceTestCase.java
@Test public void overrideGlobalSettings() { System.setProperty(MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION, SETTINGS_XML_PATH); File[] files = Maven.resolver().resolve("org.jboss.shrinkwrap.test:test-deps-c:1.0.0").withTransitivity() .as(File.class); ValidationUtil.fromDependencyTree(new File("src/test/resources/dependency-trees/test-deps-c.tree")) .validate(true, files);/*from www . java2s . c o m*/ System.clearProperty(MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION); }
From source file:com.conversantmedia.mapreduce.tool.RunJobTest.java
@Before public void setup() { runJob = new RunJob(); // Ensure our system property is unset before each run System.clearProperty(RunJob.SYSPROP_DRIVER_SCAN_PACKAGES); }
From source file:org.sventon.appl.ConfigDirectoryTest.java
@Test public void testDirectoryOverrideBySettingSystemProperty() throws Exception { System.setProperty(ConfigDirectory.PROPERTY_KEY_SVENTON_DIR_SYSTEM, SEPARATOR + "override"); final ConfigDirectory configDir = new ConfigDirectory(TEMP_DIR, EXPORT_DIR, REPOSITORIES_DIR); configDir.setCreateDirectories(false); final MockServletContext servletContext = new MockServletContext(); servletContext.setContextPath(SERVLET_CONTEXT_PATH); configDir.setServletContext(servletContext); final String path = configDir.getConfigRootDirectory().getAbsolutePath(); assertTrue(path.contains(SEPARATOR + "override" + SEPARATOR)); assertTrue(path.endsWith(SERVLET_CONTEXT_PATH)); System.clearProperty(ConfigDirectory.PROPERTY_KEY_SVENTON_DIR_SYSTEM); }
From source file:edu.du.penrose.systems.util.SendMail.java
/** * NOTE VERY WELL!! The sends an ssl email, when used with Fedora libraries this throws a SSL Exception, in order to fix this * The following SSL system properties are cleared and then restored after the email is sent. l...<br> * /*w w w . j a va2s. co m*/ * System.clearProperty( "javax.net.ssl.keyStore" ); * System.clearProperty( "javax.net.ssl.keyStorePassword" ); * System.clearProperty( "javax.net.ssl.keyStoreType" ); * System.clearProperty( "javax.net.ssl.trustStore" ); * System.clearProperty( "javax.net.ssl.trustStorePassword" ); * System.clearProperty( "javax.net.ssl.trustStoreType" ); * * @param recipients * @param subject * @param message * @param from * @param smptServerHost * @param smtpUser * @param smtpPassword * @param port * @param sslEmail */ public static void postMailWithAuthenication(String recipients[], String subject, String message, String from, String smptServerHost, String smtpUser, String smtpPassword, String port, boolean sslEmail) { if (from == null || !from.contains("@")) { logger.info("Unable to send email, missing from address."); return; } String user = smtpUser.trim(); String password = smtpPassword.trim(); int numberOfValidRecipients = 0; for (int i = 0; i < recipients.length; i++) { if (recipients[i] != null && recipients[i].length() > 0 && recipients[i].contains("@")) { numberOfValidRecipients++; } } if (numberOfValidRecipients == 0) { logger.info("Unable to send email, missing recipients address."); return; } SimpleEmail email = new SimpleEmail(); email.setSSL(sslEmail); email.setSmtpPort(Integer.valueOf(port)); email.setAuthentication(user, password); email.setHostName(smptServerHost); try { for (int i = 0; i < numberOfValidRecipients; i++) { email.addTo(recipients[i]); } email.setFrom(from); email.setSubject(subject); email.setMsg(message); // System.setProperty( "javax.net.debug", "ssl" ); String keyStore = System.getProperty("javax.net.ssl.keyStore"); String keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword"); String keyStoreType = System.getProperty("javax.net.ssl.keyStoreType"); String trustStore = System.getProperty("javax.net.ssl.trustStore"); String trustStorePassword = System.getProperty("javax.net.ssl.trustStorePassword"); String trustStoreType = System.getProperty("javax.net.ssl.trustStoreType"); System.clearProperty("javax.net.ssl.keyStore"); System.clearProperty("javax.net.ssl.keyStorePassword"); System.clearProperty("javax.net.ssl.keyStoreType"); System.clearProperty("javax.net.ssl.trustStore"); System.clearProperty("javax.net.ssl.trustStorePassword"); System.clearProperty("javax.net.ssl.trustStoreType"); email.send(); System.setProperty("javax.net.ssl.keyStore", keyStore); System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword); System.setProperty("javax.net.ssl.keyStoreType", keyStoreType); System.setProperty("javax.net.ssl.trustStore", trustStore); System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword); System.setProperty("javax.net.ssl.trustStoreType", trustStoreType); } catch (Exception e) { logger.error("ERROR sending email:" + e.getLocalizedMessage()); } }
From source file:org.jboss.webapp.RestController.java
@POST @Path("/order/new") public Response newOrder(@Context HttpServletRequest request) throws JsonParseException, JsonMappingException, IOException { try {/* w w w . j a va 2 s . co m*/ String payload = IOUtils.toString(request.getInputStream()); log.info("[/order/new] Called with payload " + payload); Order order = (Order) Json.toObject(payload, Order.class); // set defaults outside of rules order.setRiskStatus("REFER"); order.setRiskReason(""); String originalKieMavenSettingsCustom = System.getProperty("kie.maven.settings.custom"); System.setProperty("kie.maven.settings.custom", System.getProperty("kie.maven.client.settings.custom")); String version = "6.0.0-SNAPSHOT"; // ensure "always" is set for the updatePolicy in settings.xml new FluentRulesService().withReleaseId("org.jboss.quickstarts.brms6", "business-rules", version) .withKieBaseName("order.risk.kb").withAgendaListener(new DroolsAgendaEventListener()) .execute(order); orders.put(order.getId(), order); if (null == originalKieMavenSettingsCustom) { System.clearProperty("kie.maven.settings.custom"); } else System.setProperty("kie.maven.settings.custom", originalKieMavenSettingsCustom); String result = Json.toJson(order); log.info("[/order/new] Returning payload [" + result + "]"); return Response.status(200).entity(result).build(); } catch (Exception e) { return Response.status(500).entity(e.getMessage()).build(); } }
From source file:org.jbpm.designer.repository.VFSRepositoryGitFileSystemTest.java
@AfterClass public static void cleanup() { System.clearProperty("org.kie.nio.git.dir"); }
From source file:net.krotscheck.jersey2.configuration.Jersey2ToolkitConfigTest.java
/** * Assert that a missing file does not throw an error. * * @throws java.io.IOException File operation errors. *///from w w w . j a v a 2s .c om @Test public void testMissingFile() throws IOException { // Move the properties file out of the way. File propFile = ResourceUtil.getFileForResource("jersey2-toolkit.properties"); File newPropFile = ResourceUtil.getFileForResource("jersey2-toolkit-mv.properties"); FileUtils.moveFile(propFile, newPropFile); Assert.assertFalse(propFile.exists()); Assert.assertTrue(newPropFile.exists()); // Add something to check System.setProperty("property3", "override3"); // If this throws an error, we've got a problem. Configuration config = new Jersey2ToolkitConfig(); Assert.assertFalse(config.containsKey("property1")); Assert.assertFalse(config.containsKey("property2")); Assert.assertTrue(config.containsKey("property3")); System.clearProperty("property3"); // Move the file back. FileUtils.moveFile(newPropFile, propFile); Assert.assertTrue(propFile.exists()); Assert.assertFalse(newPropFile.exists()); }
From source file:com.brienwheeler.apps.main.MainBaseTest.java
@Test public void testProcessBaseArgs() { String[] args = new String[] { P, TestDataConstants.PROPS_FILE1 }; Main1 main = new Main1(args); System.clearProperty(TestDataConstants.PROPS_FILE1_PROP); Assert.assertNull(System.getProperty(TestDataConstants.PROPS_FILE1_PROP)); main.run();/*from w w w . j av a2 s. com*/ Assert.assertEquals(TestDataConstants.PROPS_FILE1_VALUE, System.getProperty(TestDataConstants.PROPS_FILE1_PROP)); ArrayList<String> processedArgs = main.getProcessedArgs(); Assert.assertTrue(processedArgs.isEmpty()); }