Example usage for java.lang System setProperties

List of usage examples for java.lang System setProperties

Introduction

In this page you can find the example usage for java.lang System setProperties.

Prototype

public static void setProperties(Properties props) 

Source Link

Document

Sets the system properties to the Properties argument.

Usage

From source file:org.apache.sentry.api.service.thrift.TestSentryWebServerWithSSL.java

@Test
public void testTraceIsDisabled() throws Exception {
    final URL url = new URL("https://" + SERVER_HOST + ":" + webServerPort);
    Properties systemProps = System.getProperties();
    systemProps.put("javax.net.ssl.trustStore", Resources.getResource("cacerts.jks").getPath());
    System.setProperties(systemProps);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("TRACE");
    Assert.assertEquals(HttpURLConnection.HTTP_FORBIDDEN, conn.getResponseCode());
}

From source file:org.apache.activemq.store.jdbc.JmsTransactionCommitFailureTest.java

@Before
public void setUp() throws Exception {
    originalSystemProps = System.getProperties();
    Properties systemProps = (Properties) originalSystemProps.clone();
    systemProps.setProperty("derby.stream.error.file", OUTPUT_DIR + "/derby.log");
    System.setProperties(systemProps);

    dataSource = createDataSource();/*from  w  w  w .j  av a2  s . c  om*/
    persistenceAdapter = new CommitFailurePersistenceAdapter(dataSource);
    broker = createBroker(persistenceAdapter);
    broker.start();
    connectionFactory = createConnectionFactory(broker.getBrokerName());
}

From source file:io.inkstand.it.StaticContentITCase.java

@After
public void tearDown() throws Exception {
    System.setProperties(originalProperties);
    CdiContainerLoader.getCdiContainer().shutdown();
}

From source file:com.amalto.core.server.Initialization.java

@Override
public void destroy() throws Exception {
    LOGGER.info("Shutdown in progress..."); //$NON-NLS-1$
    try {//from   w ww. j  a va  2s .  co  m
        System.setProperties(previousSystemProperties);
        ServerContext.INSTANCE.get().close();
        LOGGER.info("Shutdown done."); //$NON-NLS-1$
    } catch (Exception e) {
        LOGGER.info("Shutdown done (with error).", e); //$NON-NLS-1$
    }
}

From source file:org.commonjava.propulsor.boot.BootOptions.java

protected final void setSystemProperties() {
    final Properties properties = System.getProperties();

    setProperty(properties, getHomeSystemProperty(), getHomeDir());
    setProperty(properties, getConfigSystemProperty(), getConfig());
    setApplicationSystemProperties(properties);

    System.setProperties(properties);
}

From source file:nz.co.fortytwo.signalk.server.SignalKServer.java

protected SignalKServer(String configDir) throws Exception {
    // init config
    Properties props = System.getProperties();
    props.setProperty("java.net.preferIPv4Stack", "true");
    System.setProperties(props);

    Util.getConfig();//from  w ww . j a va2 s .co  m
    // make sure we have all the correct dirs and files now
    ensureInstall();

    logger.info("SignalKServer starting....");

    // do we have a USB drive connected?
    //logger.info("USB drive " + Util.getUSBFile());

    // create a new Camel Main so we can easily start Camel
    Main main = new Main();
    //main.setApplicationContextUri("classpath:META-INF/spring/camel-context.xml");
    // enable hangup support which mean we detect when the JVM terminates,
    // and stop Camel graceful
    main.enableHangupSupport();

    // Start activemq broker
    BrokerService broker = ActiveMqBrokerFactory.newInstance();

    broker.start();
    //DNS-SD, zeroconf mDNS
    startMdns();
    configureRouteManager(main);
    // and run, which keeps blocking until we terminate the JVM (or stop
    // CamelContext)
    main.start();

    WatchService service = FileSystems.getDefault().newWatchService();
    Path dir = Paths.get("./conf");
    dir.register(service, StandardWatchEventKinds.ENTRY_MODIFY);
    WatchKey key = null;
    while (true) {
        key = service.take();
        // Dequeueing events
        Kind<?> kind = null;
        for (WatchEvent<?> watchEvent : key.pollEvents()) {
            // Get the type of the event
            kind = watchEvent.kind();
            logger.debug(
                    "SignalKServer conf/ event:" + watchEvent.kind() + " : " + watchEvent.context().toString());
            if (StandardWatchEventKinds.OVERFLOW == kind) {
                continue; //loop
            } else if (StandardWatchEventKinds.ENTRY_MODIFY == kind) {
                // A new Path was created 
                @SuppressWarnings("unchecked")
                Path newPath = ((WatchEvent<Path>) watchEvent).context();
                // Output
                if (newPath.endsWith("signalk-restart")) {
                    logger.info("SignalKServer conf/signalk-restart changed, stopping..");
                    main.stop();
                    main.getCamelContexts().clear();
                    main.getRouteBuilders().clear();
                    main.getRouteDefinitions().clear();

                    // so now shutdown serial reader and server
                    RouteManager routeManager = RouteManagerFactory.getInstance();
                    routeManager.stopNettyServers();
                    routeManager.stopSerial();
                    if (server != null) {
                        server.stop();
                        server = null;
                    }
                    RouteManagerFactory.clear();
                    configureRouteManager(main);
                    main.start();
                }

            }
        }

        if (!key.reset()) {
            break; //loop
        }
    }

    stopMdns();
    broker.stop();
    // write out the signalk model
    SignalKModelFactory.save(SignalKModelFactory.getInstance());
    System.exit(0);
}

From source file:org.commonjava.maven.galley.cache.infinispan.FastLocalCacheProviderBaseTest.java

@Test(expected = java.lang.IllegalArgumentException.class)
public void testConstructorWitNoNFSSysPath() throws IOException {
    Properties props = System.getProperties();
    props.remove(FastLocalCacheProvider.NFS_BASE_DIR_KEY);
    System.setProperties(props);
    final String NON_EXISTS_PATH = "";
    new FastLocalCacheProvider(new PartyLineCacheProvider(temp.newFolder(), pathgen, events, decorator),
            new SimpleCacheInstance<>("test", nfsOwnerCache), pathgen, events, decorator, executor,
            NON_EXISTS_PATH, new SimpleCacheInstance<>("localFileCache", localFileCache));
}

From source file:org.ops4j.pax.runner.platform.InProcessJavaRunner.java

/**
 * {@inheritDoc}//w  ww .  j a  v  a 2  s . c om
 */
public synchronized void exec(final String[] vmOptions, final String[] classpath, final String mainClass,
        final String[] programOptions, final String javaHome, final File workingDirectory)
        throws PlatformException {
    if (m_frameworkActive) {
        throw new PlatformException("Platform already started");
    }
    m_frameworkActive = true;

    final URLClassLoader classLoader = createClassLoader(classpath);
    final Properties systemProps = extractSystemProperties(vmOptions);

    final ClassLoader tcclBackup = Thread.currentThread().getContextClassLoader();
    final Properties systemPropsBackup = System.getProperties();
    final URLStreamHandlerFactory handlerFactoryBackup = URLUtils.resetURLStreamHandlerFactory();
    try {
        Thread.currentThread().setContextClassLoader(classLoader);
        System.setProperties(systemProps);

        final Class<?> clazz = classLoader.loadClass(mainClass);
        final Method mainMethod = clazz.getMethod("main", String[].class);

        LOG.info("Runner has successfully finished his job!");
        Info.println(); // print an empty line

        mainMethod.invoke(null, new Object[] { programOptions });
    } catch (ClassNotFoundException e) {
        throw new PlatformException("Cannot find target framework main class", e);
    } catch (NoSuchMethodException e) {
        throw new PlatformException("Cannot find target framework main method", e);
    } catch (IllegalAccessException e) {
        throw new PlatformException("Cannot run the target framework", e);
    } catch (InvocationTargetException e) {
        throw new PlatformException("Cannot run the target framework", e);
    } finally {
        URLUtils.setURLStreamHandlerFactory(handlerFactoryBackup);
        System.setProperties(systemPropsBackup);
        Thread.currentThread().setContextClassLoader(tcclBackup);
    }
}

From source file:org.apache.oodt.cas.filemgr.cli.TestFileManagerCli.java

@Override
public void setUp() throws Exception {
    super.setUp();

    Properties properties = new Properties(System.getProperties());

    properties.setProperty("org.apache.oodt.cas.cli.debug", "true");

    URL actionsUrl = this.getClass().getResource("/cmd-line-actions.xml");
    properties.setProperty("org.apache.oodt.cas.cli.action.spring.config",
            "file:" + new File(actionsUrl.getFile()).getAbsolutePath());

    URL optionsUrl = this.getClass().getResource("/cmd-line-options.xml");
    properties.setProperty("org.apache.oodt.cas.cli.option.spring.config",
            "file:" + new File(optionsUrl.getFile()).getAbsolutePath());

    System.setProperties(properties);

    cmdLineUtility = new CmdLineUtility();
    UseMockClientCmdLineActionStore actionStore = new UseMockClientCmdLineActionStore();
    client = actionStore.getClient();/*  www.j  a v a 2 s. c  o  m*/
    cmdLineUtility.setActionStore(actionStore);
}

From source file:WebCrawler.java

public static void main(String argv[]) {
    Frame f = new Frame("WebFrame");
    WebCrawler applet = new WebCrawler();
    f.add("Center", applet);

    /*    Behind a firewall set your proxy and port here!
    *///  w  w  w  .ja  va 2  s  .  co  m
    Properties props = new Properties(System.getProperties());
    props.put("http.proxySet", "true");
    props.put("http.proxyHost", "webcache-cup");
    props.put("http.proxyPort", "8080");

    Properties newprops = new Properties(props);
    System.setProperties(newprops);
    /**/

    applet.init();
    applet.start();
    f.pack();
    f.show();
}