List of usage examples for java.lang System setProperties
public static void setProperties(Properties props)
From source file:org.geoserver.geofence.core.dao.util.PwEncoderTest.java
@Test public void cannotDecodePwWithCustomKey() throws Exception { Properties originalProperties = System.getProperties(); Properties properties = new Properties(); properties.putAll(originalProperties); System.setProperties(properties); properties.setProperty("GEOFENCE_PWENCODER_KEY", "mycustomkeyforencrypting"); String encoded = PwEncoder.encode("test"); System.out.println(encoded);//from w w w . j a v a2 s . c o m String defaultKey = "installation dependant key needed"; byte[] bytes = defaultKey.substring(0, 16).getBytes(); SecretKeySpec keySpec = new SecretKeySpec(bytes, "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, keySpec); try { cipher.doFinal(Base64.decodeBase64(encoded)); fail(); } catch (GeneralSecurityException e) { } System.setProperties(originalProperties); }
From source file:localdomain.localhost.MyServletTest.java
@Ignore @Test// www .j av a2 s . com public void testService() throws Exception { InputStream credentials = Thread.currentThread().getContextClassLoader() .getResourceAsStream("credentials.properties"); if (credentials == null) { System.out.println("No credentials found, use default ones"); } else { Properties props = new Properties(); props.load(credentials); System.setProperties(props); } MockHttpServletRequest req = new MockHttpServletRequest(); MockHttpServletResponse resp = new MockHttpServletResponse(); MyServlet myServlet = new MyServlet(); myServlet.service(req, resp); System.out.println(resp.getContentAsString()); }
From source file:org.ambraproject.configuration.OverrideTest.java
protected void tearDown() { // Make an attempt to remove the system property for other test classes Properties p = System.getProperties(); p.remove(ConfigurationStore.OVERRIDES_URL); p.remove("conf.test"); System.setProperties(p); }
From source file:com.partnet.automation.util.SystemPropsUtil.java
/** * Load properties from the given configuration file name. * <p>/*w ww. ja v a 2 s .co m*/ * Given error message is displayed if file not found. * <p> * * @param configFileName * - File name of properties file. * @throws RuntimeException * - If the file has a error while reading the properties file */ public static void loadProperties(String configFileName) { Properties cmdlineProps = System.getProperties(); Properties fileProps = new Properties(); // load property file InputStream inputStream = SystemPropsUtil.class.getResourceAsStream(configFileName); if (inputStream == null) { // force use of classloader to look for properties file inputStream = SystemPropsUtil.class.getClassLoader().getResourceAsStream(configFileName); if (inputStream == null) { log.warn(String.format("Failed to locate and load properties file: %s", configFileName)); return; } } else { log.info("Properties file ({}) exists", configFileName); } // load fileProps with config.properties try { fileProps.load(inputStream); } catch (IOException e) { throw new RuntimeException( String.format("Failure occurred while reading properties file: %s", configFileName), e); } // Override any fileProp with cmdlineProps fileProps.putAll(cmdlineProps); System.setProperties(fileProps); }
From source file:com.asakusafw.bulkloader.testutil.UnitTestUtil.java
public static void setUpEnv() throws Exception { Properties p = System.getProperties(); p.setProperty(Constants.ASAKUSA_HOME, new File(".").getCanonicalPath()); p.setProperty(Constants.THUNDER_GATE_HOME, new File(PATH_DIST_TEST).getCanonicalPath()); ConfigurationLoader.setSysProp(p);//from ww w. j av a 2 s . c o m System.setProperties(p); }
From source file:org.apache.sentry.api.service.thrift.TestSentryWebServerWithSSL.java
@Test public void testPing() throws Exception { final URL url = new URL("https://" + SERVER_HOST + ":" + webServerPort + "/ping"); Properties systemProps = System.getProperties(); systemProps.put("javax.net.ssl.trustStore", Resources.getResource("cacerts.jks").getPath()); System.setProperties(systemProps); HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); Assert.assertEquals(HttpsURLConnection.HTTP_OK, conn.getResponseCode()); String response = IOUtils.toString(conn.getInputStream()); Assert.assertEquals("pong\n", response); }
From source file:com.thoughtworks.go.agent.service.RemoteRegistrationRequesterTest.java
@After public void after() { System.setProperties(original); }
From source file:org.evosuite.SystemTest.java
@After public void resetStaticVariables() { TestGenerationContext.getInstance().resetContext(); ResetManager.getInstance().clearManager(); System.setProperties(currentProperties); Properties.getInstance().resetToDefaults(); }
From source file:org.apache.sentry.provider.db.service.thrift.TestSentryWebServerWithSSL.java
@Test public void testPing() throws Exception { final URL url = new URL("https://" + SentryServiceIntegrationBase.SERVER_HOST + ":" + SentryServiceIntegrationBase.webServerPort + "/ping"); Properties systemProps = System.getProperties(); systemProps.put("javax.net.ssl.trustStore", Resources.getResource("cacerts.jks").getPath()); System.setProperties(systemProps); HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); Assert.assertEquals(HttpsURLConnection.HTTP_OK, conn.getResponseCode()); String response = IOUtils.toString(conn.getInputStream()); Assert.assertEquals("pong\n", response); }
From source file:org.dd4t.core.util.XSLTransformer.java
private XSLTransformer() { // point the transformerfactory towards Xalan XSLTC // smartFactory. This factory will generate XSLTC // COMPILED templates, and INTERPRETED transformers String key = "javax.xml.transform.TransformerFactory"; String value = "org.apache.xalan.xsltc.trax.SmartTransformerFactoryImpl"; Properties props = System.getProperties(); props.put(key, value);/*from ww w. j av a 2s. c o m*/ System.setProperties(props); }