List of usage examples for java.lang System setProperty
public static String setProperty(String key, String value)
From source file:com.comcast.cats.CatsAbstarctIT.java
@BeforeClass public static void setup() { System.setProperty(CatsProperties.SERVER_URL_PROPERTY, SERVER_BASE); catsFramework = new CatsFramework(new CatsVisionApplicationContext()); }
From source file:eu.delving.services.MockServices.java
public static void start() { try {// w w w. j a v a 2 s . c om String root = StarterUtil.getEuropeanaPath(); System.setProperty("launch.properties", MockServices.class.getResource("/mock-launch.properties").getFile()); dropMongoDatabase(); System.setProperty("solr.solr.home", root + "/core/src/test/solr/single-core"); String solrDataDir = root + "/core/target/solrdata/mock_services"; System.setProperty("solr.data.dir", solrDataDir); FileUtils.deleteDirectory(new File(solrDataDir)); server.addHandler(new WebAppContext(root + "/services/src/main/webapp", "/services")); server.addHandler(new WebAppContext(root + "/core/src/test/solr/solr-1.4.1.war", "/solr")); server.start(); } catch (Exception e) { throw new RuntimeException("Couldn't start server", e); } }
From source file:com.cslc.eils.gameControl.util.PropertiesUtil.java
/** * @param propertyName//from w w w. j a va 2 s. co m * @param value * @return */ public static String set(String propertyName, String value) { if (propertyName == null || propertyName.equals("") || value == null || value.equals("")) { log.warn("parameters propertyName or value is null"); return null; } return System.setProperty(propertyName, value); }
From source file:com.coinblesk.server.utilTest.TestBean.java
@PostConstruct public void init() { System.setProperty("db.injectCredentials", "false"); }
From source file:org.constretto.spring.configuration.ConstrettoNameSpaceTest.java
@BeforeClass public static void setupTags() { System.setProperty(DefaultConfigurationContextResolver.TAGS, "test"); System.clearProperty("key7"); }
From source file:sample.tomcat.SampleWebApplicationTest.java
@BeforeClass public static void beforeClass() { System.setProperty("jasypt.encryptor.password", "password"); }
From source file:at.pagu.soldockr.AbstractITestWithEmbeddedSolrServer.java
@BeforeClass public static void initSolrServer() throws IOException, ParserConfigurationException, SAXException { System.setProperty("solr.solr.home", StringUtils.remove(ResourceUtils.getURL("classpath:at/pagu/soldockr").toString(), "file:/")); CoreContainer.Initializer initializer = new CoreContainer.Initializer(); CoreContainer coreContainer = initializer.initialize(); solrServer = new EmbeddedSolrServer(coreContainer, ""); }
From source file:com.zotoh.maedr.test.flow.BaseJUT.java
@BeforeClass public static void iniz() throws Exception { System.setProperty(PIPLINE_MODULE, "com.zotoh.maedr.wflow.FlowModule"); _appDir = CoreUte.genTmpDir();//from w w w .j ava 2 s . c om new File(_appDir, LOGS).mkdirs(); new File(_appDir, CFG).mkdirs(); }
From source file:edu.stanford.muse.launcher.Main.java
public static void main(String args[]) throws Exception { // set javawebstart.version to a dummy value if not already set (might happen when running with java -jar from cmd line) // exit.jsp doesn't allow us to showdown unless this prop is set if (System.getProperty("javawebstart.version") == null) System.setProperty("javawebstart.version", "UNKNOWN"); final int TIMEOUT_SECS = 60; if (args.length > 0) { out.print(args.length + " argument(s): "); for (int i = 0; i < args.length; i++) out.print(args[i] + " "); out.println();/*from w w w .j a v a 2 s . co m*/ } Options options = getOpt(); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Muse batch mode", options); return; } boolean debug = false; if (cmd.hasOption("debug")) { URL url = ClassLoader.getSystemResource("log4j.properties.debug"); out.println("Loading logging configuration from url: " + url); PropertyConfigurator.configure(url); debug = true; } else if (cmd.hasOption("debug-address-book")) { URL url = ClassLoader.getSystemResource("log4j.properties.debug.ab"); out.println("Loading logging configuration from url: " + url); PropertyConfigurator.configure(url); debug = false; } else if (cmd.hasOption("debug-groups")) { URL url = ClassLoader.getSystemResource("log4j.properties.debug.groups"); out.println("Loading logging configuration from url: " + url); PropertyConfigurator.configure(url); debug = false; } if (cmd.hasOption("no-browser-open")) browserOpen = false; if (cmd.hasOption("port")) { String portStr = cmd.getOptionValue('p'); try { PORT = Integer.parseInt(portStr); String mesg = " Running on port: " + PORT; out.println(mesg); } catch (NumberFormatException nfe) { out.println("invalid port number " + portStr); } } if (cmd.hasOption("start-page")) startPage = cmd.getOptionValue("start-page"); if (cmd.hasOption("base-dir")) baseDir = cmd.getOptionValue("base-dir"); if (cmd.hasOption("search-mode")) searchMode = true; if (cmd.hasOption("amuse-mode")) amuseMode = true; System.setSecurityManager(null); // this is important WebAppContext webapp0 = null; // deployWarAt("root.war", "/"); // for redirecting String path = "/muse"; WebAppContext webapp1 = deployWarAt("muse.war", path); if (webapp1 == null) { System.err.println("Aborting... no webapp"); return; } // if in any debug mode, turn blurring off if (debug) webapp1.setAttribute("noblur", true); // we set this and its read by JSPHelper within the webapp System.setProperty("muse.container", "jetty"); // need to copy crossdomain.xml file for String tmp = System.getProperty("java.io.tmpdir"); final URL url = Main.class.getClassLoader().getResource("crossdomain.xml"); try { InputStream is = url.openStream(); String file = tmp + File.separatorChar + "crossdomain.xml"; copy_stream_to_file(is, file); } catch (Exception e) { System.err.println("Aborting..." + e); return; } server = new Server(PORT); ResourceHandler resource_handler = new ResourceHandler(); // resource_handler.setWelcomeFiles(new String[]{ "index.html" }); resource_handler.setResourceBase(tmp); // set the header buffer size in the connectors, default is a ridiculous 4K, which causes failures any time there is // is a large request, such as selecting a few hundred folders. (even for posts!) // usually there is only one SocketConnector, so we just put the setHeaderBufferSize in a loop. Connector conns[] = server.getConnectors(); for (Connector conn : conns) { int NEW_BUFSIZE = 1000000; // out.println ("Connector " + conn + " buffer size is " + conn.getHeaderBufferSize() + " setting to " + NEW_BUFSIZE); conn.setHeaderBufferSize(NEW_BUFSIZE); } BASE_URL = "http://localhost:" + PORT + path; String MUSE_CHECK_URL = BASE_URL + "/js/muse.js"; // for quick check of existing muse or successful start up. BASE_URL may take some time to run and may not always be available now that we set dirAllowed to false and public mode does not serve /muse. String debugFile = tmp + File.separatorChar + "debug.txt"; HandlerList hl = new HandlerList(); if (webapp0 != null) hl.setHandlers(new Handler[] { webapp1, webapp0, resource_handler }); else hl.setHandlers(new Handler[] { webapp1, resource_handler }); out.println("Starting up Muse on the local computer at " + BASE_URL + ", " + formatDateLong(new GregorianCalendar())); out.println("***For troubleshooting information, see this file: " + debugFile + "***\n"); out.println("Current directory = " + System.getProperty("user.dir") + ", home directory = " + System.getProperty("user.home")); out.println("Memory status at the beginning: " + getMemoryStats()); if (Runtime.getRuntime().maxMemory() / MB < 512) aggressiveWarn( "You are probably running Muse without enough memory. \nIf you launched Muse from the command line, you can increase memory with an option like java -Xmx1g", 2000); server.setHandler(hl); // handle frequent error of user trying to launch another server when its already on // server.start() usually takes a few seconds to return // after that it takes a few seconds for the webapp to deploy // ignore any exceptions along the way and assume not if we can't prove it is alive boolean urlAlive = false; try { urlAlive = isURLAlive(MUSE_CHECK_URL); } catch (Exception e) { out.println("Exception: e"); e.printStackTrace(out); } boolean disableStart = false; if (urlAlive) { out.println("Oh! Muse is already running at the URL: " + BASE_URL + ", will have to kill it!"); killRunningServer(BASE_URL); Thread.sleep(3000); try { urlAlive = isURLAlive(MUSE_CHECK_URL); } catch (Exception e) { out.println("Exception: e"); e.printStackTrace(out); } if (!urlAlive) out.println("Good. Kill succeeded, will restart"); else { String message = "Previously running Muse still alive despite attempt to kill it, disabling fresh restart!\n"; message += "If you just want to use the previous instance of Muse, please go to http://localhost:9099/muse\n"; message += "\nTo kill this instance, please go to your computer's task manager and kill running java or javaw processes.\nThen try launching Muse again.\n"; aggressiveWarn(message, 2000); return; } } // else // out.println ("Muse not already alive at URL: ..." + URL); if (!disableStart) { out.println("Starting Muse at URL: ..." + BASE_URL); try { server.start(); } catch (BindException be) { out.println("port busy, but webapp not alive: " + BASE_URL + "\n" + be); throw new RuntimeException("Error: Port in use (Please kill Muse if its already running!)\n" + be); } } // webapp1.start(); -- not needed PrintStream debugOut1 = System.err; try { File f = new File(debugFile); if (f.exists()) f.delete(); // particular problem on windows :-( debugOut1 = new PrintStream(new FileOutputStream(debugFile), false, "UTF-8"); } catch (IOException ioe) { System.err.println("Warning: failed to delete debug file " + debugFile + " : " + ioe); } final PrintStream debugOut = debugOut1; Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { public void run() { try { server.stop(); server.destroy(); debugOut.close(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } })); // InfoFrame frame = new InfoFrame(); // frame.doShow(); boolean success = waitTillPageAlive(MUSE_CHECK_URL, TIMEOUT_SECS); // frame.updateText ("Opening a browser window"); if (success) { // best effort to start shutdown thread // out.println ("Starting Muse shutdown listener at port " + JettyShutdownThread.SHUTDOWN_PORT); try { int shutdownPort = PORT + 1; // shut down port is arbitrarily set to port + 1. it is ASSUMED to be free. new JettyShutdownThread(server, shutdownPort).start(); out.println("Listening for Muse shutdown message on port " + shutdownPort); } catch (Exception e) { out.println( "Unable to start shutdown listener, you will have to stop the server manually using Cmd-Q on Mac OS or kill javaw processes on Windows"); } try { setupSystemTrayIcon(); } catch (Exception e) { out.println("Unable to setup system tray icon: " + e); e.printStackTrace(out); } // open browser window if (browserOpen) { preferredBrowser = null; // launch a browser here try { String link; if (System.getProperty("muse.mode.public") != null) link = "http://localhost:" + PORT + "/muse/archives/"; else link = "http://localhost:" + PORT + "/muse/index.jsp"; if (searchMode) { String u = "http://localhost:" + PORT + "/muse/search"; out.println("Launching URL in browser: " + u); link += "?mode=search"; } else if (amuseMode) { String u = "http://localhost:" + PORT + "/muse/amuse.jsp"; out.println("Launching URL in browser: " + u); link = u; } else if (startPage != null) { // startPage has to be absolute link = "http://localhost:" + PORT + "/muse/" + startPage; } if (baseDir != null) link = link + "?cacheDir=" + baseDir; // typically this is used when starting from command line. note: still using name, cacheDir out.println("Launching URL in browser: " + link); launchBrowser(link); } catch (Exception e) { out.println( "Warning: Unable to launch browser due to exception (use the -n option to prevent Muse from trying to launch a browser):"); e.printStackTrace(out); } } if (!cmd.hasOption("no-shutdown")) { // arrange to kill Muse after a period of time, we don't want the server to run forever // i clearly have too much time on my hands right now... long secs = KILL_AFTER_MILLIS / 1000; long hh = secs / 3600; long mm = (secs % 3600) / 60; long ss = secs % (60); out.print("Muse will shut down automatically after "); if (hh != 0) out.print(hh + " hours "); if (mm != 0 || (hh != 0 && ss != 0)) out.print(mm + " minutes"); if (ss != 0) out.print(ss + " seconds"); out.println(); Timer timer = new Timer(); TimerTask tt = new ShutdownTimerTask(); timer.schedule(tt, KILL_AFTER_MILLIS); } } else { out.println("\n\n\nSORRY!!! UNABLE TO DEPLOY WEBAPP, EXITING\n\n\n"); // frame.updateText("Sorry, looks like we are having trouble starting the jetty server\n"); } savedSystemOut = out; savedSystemErr = System.err; System.setOut(debugOut); System.setErr(debugOut); }
From source file:org.chimi.s4s.metainfo.mongo.MongoMetaInfoDaoTest.java
@BeforeClass public static void init() { System.setProperty("metainfo.db", "mongo"); }