List of usage examples for java.lang System getenv
public static String getenv(String name)
From source file:org.usergrid.persistence.cassandra.PersistenceTestHelperImpl.java
@Override public void setup() throws Exception { // assertNotNull(client); String maven_opts = System.getenv("MAVEN_OPTS"); logger.info("Maven options: " + maven_opts); logger.info("Starting Cassandra"); embedded = new EmbeddedServerHelper(); embedded.setup();/*from w w w. j av a 2s. c om*/ // copy("/testApplicationContext.xml", TMP); String[] locations = { "testApplicationContext.xml" }; ac = new ClassPathXmlApplicationContext(locations); AutowireCapableBeanFactory acbf = ac.getAutowireCapableBeanFactory(); acbf.autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false); acbf.initializeBean(this, "testClient"); assertNotNull(emf); assertTrue("EntityManagerFactory is instance of EntityManagerFactoryImpl", emf instanceof EntityManagerFactoryImpl); Setup setup = ((EntityManagerFactoryImpl) emf).getSetup(); logger.info("Setting up Usergrid schema"); setup.setup(); logger.info("Usergrid schema setup"); setup.checkKeyspaces(); }
From source file:com.urbancode.ud.client.UDRestClient.java
/** * Create an HTTP client configured with credentials and any proxy settings * from the environment.//w w w.j a va 2 s . c o m * * @param user The username to associate with the http client connection. * @param password The password of the username used to associate with the http client connection. * @param trustAllCerts Boolean to trust or deny all insecure certifications with the http client. * * @return DefaultHttpClient */ static public DefaultHttpClient createHttpClient(String user, String password, boolean trustAllCerts) { HttpClientBuilder builder = new HttpClientBuilder(); builder.setPreemptiveAuthentication(true); builder.setUsername(user); builder.setPassword(password); builder.setTrustAllCerts(trustAllCerts); if (!StringUtils.isEmpty(System.getenv("PROXY_HOST")) && StringUtils.isNumeric(System.getenv("PROXY_PORT"))) { log.debug("Configuring proxy settings."); builder.setProxyHost(System.getenv("PROXY_HOST")); builder.setProxyPort(Integer.valueOf(System.getenv("PROXY_PORT"))); } if (!StringUtils.isEmpty(System.getenv("PROXY_USERNAME")) && !StringUtils.isEmpty(System.getenv("PROXY_PASSWORD"))) { log.debug("Configuring proxy settings."); builder.setProxyUsername(System.getenv("PROXY_USERNAME")); builder.setProxyPassword(System.getenv("PROXY_PASSWORD")); } return builder.buildClient(); }
From source file:eu.itool.glassfishmavenplugin.AbstractGlassfishMojo.java
private void checkConfig() throws MojoExecutionException, MojoFailureException { if (glassfishHome == null || glassfishHome.equals("ENV")) { if (SystemUtils.JAVA_VERSION_FLOAT < 1.5) { throw new MojoExecutionException( "Neither GLASSFISH_HOME nor the glassfishHome configuration parameter is set! Also, to save you the trouble, JBOSS_HOME cannot be read running a VM < 1.5, so set the GlassFish Home configuration parameter or use -D."); }/*from w w w . jav a 2s.c om*/ glassfishHome = System.getenv("GLASSFISH_HOME"); } if (glassfishHome == null) { throw new MojoExecutionException( "Neither GLASSFISH_HOME nor the glassfishHome configuration parameter is set!"); } glassfishHomeDir = new File(glassfishHome); if (!glassfishHomeDir.exists()) { throw new MojoFailureException("The glassfishHome specifed does not exist."); } }
From source file:com.collective.celos.ci.config.CiCommandLineParser.java
public CiCommandLine parse(final String[] commandLineArguments) throws Exception { final CommandLineParser cmdLineGnuParser = new GnuParser(); final Options gnuOptions = constructOptionsForParsing(); CommandLine commandLine = cmdLineGnuParser.parse(gnuOptions, commandLineArguments); if (!commandLine.hasOption(CLI_TARGET) || !commandLine.hasOption(CLI_MODE) || !commandLine.hasOption(CLI_WORKFLOW_NAME)) { printHelp(80, 5, 3, true, System.out); throw new RuntimeException("Wrong CelosCi configuration provided"); }//www . j ava 2 s . co m String deployDir = commandLine.getOptionValue(CLI_DEPLOY_DIR); String mode = commandLine.getOptionValue(CLI_MODE); String workflowName = commandLine.getOptionValue(CLI_WORKFLOW_NAME); String targetUri = commandLine.getOptionValue(CLI_TARGET); String testCasesDir = commandLine.getOptionValue(CLI_TEST_CASES_DIR, DEFAULT_TEST_CASES_DIR); String hdfsRoot = commandLine.getOptionValue(CLI_HDFS_ROOT, Constants.DEFAULT_HDFS_ROOT); String celosServerUri = commandLine.getOptionValue(CLI_CELOS_SERVER); boolean keepTempData = Boolean.parseBoolean(System.getenv(KEEP_TEMP_DATA)); String userName = System.getenv(USERNAME_ENV_VAR); if (userName == null) { userName = System.getProperty("user.name"); } return new CiCommandLine(targetUri, mode, deployDir, workflowName, testCasesDir, userName, keepTempData, celosServerUri, hdfsRoot); }
From source file:com.github.lynxdb.server.common.CassandraConfig.java
@Override protected LoadBalancingPolicy getLoadBalancingPolicy() { DCAwareRoundRobinPolicy.Builder builder = DCAwareRoundRobinPolicy.builder(); if (System.getenv("cassandra_dc") != null) { builder.withLocalDc(System.getenv("cassandra_dc")); }// w ww.j a va2 s .c o m return builder.build(); }
From source file:com.fer.hr.service.datasource.ClassPathResourceDatasourceManager.java
public void init() { if (repoURL == null) { File f = new File(System.getProperty("java.io.tmpdir") + "/files/"); f.mkdir();//from w w w . j a v a2 s . co m setPath(System.getProperty("java.io.tmpdir") + "/files/"); InputStream inputStream = ClassPathResourceDatasourceManager.class .getResourceAsStream("/connection.properties"); Properties testProps = new Properties(); try { testProps.load(inputStream); } catch (IOException e) { e.printStackTrace(); } String connStr = System.getenv("DATABASE_URL"); if (connStr != null && !connStr.isEmpty()) { URI dbUri = null; try { dbUri = new URI(connStr); } catch (URISyntaxException e) { e.printStackTrace(); } String username = dbUri.getUserInfo().split(":")[0]; String password = dbUri.getUserInfo().split(":")[1]; String mondrianJdbcKey = "jdbc:mondrian:Jdbc="; String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ':' + dbUri.getPort() + dbUri.getPath(); String catalog = ";Catalog=res:schemas/MondrianSalesSchema.xml;"; String dbConnStr = mondrianJdbcKey + dbUrl + catalog; testProps.replace("location", dbConnStr); testProps.replace("username", username); testProps.replace("password", password); System.out.println("ClassPathResourceDatasourceManager -> init() -> props=" + testProps.toString()); } setDatasource(new SaikuDatasource("test", SaikuDatasource.Type.OLAP, testProps)); } }
From source file:demo.MongoTestSupport.java
private Statement failOrSkip(final Exception e) { String serversRequired = System.getenv(EXTERNAL_SERVERS_REQUIRED); if ("true".equalsIgnoreCase(serversRequired)) { this.logger.error(this.resourceDescription + " IS REQUIRED BUT NOT AVAILABLE", e); fail(this.resourceDescription + " IS NOT AVAILABLE"); // Never reached, here to satisfy method signature return null; } else {// www .java 2 s . com this.logger.error(this.resourceDescription + " IS NOT AVAILABLE, SKIPPING TESTS", e); return new Statement() { @Override public void evaluate() throws Throwable { Assume.assumeTrue("Skipping test due to " + MongoTestSupport.this.resourceDescription + " not being available " + e, false); } }; } }
From source file:com.github.cmisbox.core.Config.java
private Config() { String osName = System.getProperty("os.name").toLowerCase(); if (osName.equals("linux")) { this.os = OS.LINUX; } else if (osName.startsWith("windows")) { this.os = OS.WINDOWS; } else if (osName.startsWith("mac os x")) { this.os = OS.MACOSX; } else {/*from ww w .j a v a 2 s .c om*/ throw new RuntimeException(Messages.unsupportedOs + ": " + osName); } String homePath = System.getProperty("user.home"); if (this.os == OS.LINUX) { homePath += "/.cmisbox"; } else if (this.os == OS.MACOSX) { homePath += "/Library/Application Support/CMISBox"; } else if (this.os == OS.WINDOWS) { homePath = System.getenv("APPDATA") + "/CMISBox"; } this.configHome = new File(homePath); if (!this.configHome.exists()) { this.configHome.mkdirs(); } File logdir = new File(this.configHome, "logs"); if (!logdir.exists()) { logdir.mkdirs(); } System.getProperties().setProperty("cmisbox.home", this.configHome.getAbsolutePath()); PropertyConfigurator.configure(this.getClass().getResource("log4j.properties")); this.log = LogFactory.getLog(this.getClass()); this.properties = this.createDefaultProperties(); try { File propertiesFile = new File(this.configHome, Config.PROPERTIES_FILE); if (!propertiesFile.exists()) { FileOutputStream out = new FileOutputStream(propertiesFile); this.properties.store(out, null); out.close(); } this.properties.load(new FileInputStream(propertiesFile)); } catch (IOException e) { } this.log.info(Messages.cmisBoxConfigHome + ": " + this.configHome); String watchParent = this.properties.getProperty(Config.WATCHPARENT); UI ui = UI.getInstance(); while (watchParent == null) { if (ui.isAvailable()) { File f = ui.getWatchFolder(); watchParent = f != null ? f.getAbsolutePath() : null; if (watchParent != null) { this.saveProperties(); File box = new File(f, "Box"); box.mkdirs(); this.setWatchParent(box.getAbsolutePath()); } } else { System.err.print(Messages.unableToLocateParent + ", " + Messages.pleaseInsertInProps); this.log.error(Messages.unableToLocateParent); Main.exit(1); } } }
From source file:com.att.aro.core.util.Util.java
/** * Determines whether OS is Windows 64 bit. *//*from w w w. j a va 2s. c o m*/ public static boolean isWindows64OS() { String arch = System.getenv("PROCESSOR_ARCHITECTURE"); String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432"); return (arch != null && arch.endsWith("64")) || (wow64Arch != null && wow64Arch.endsWith("64")); }
From source file:com.twosigma.beaker.sql.JDBCClient.java
public void loadDrivers(List<String> pathList) { synchronized (this) { dsMap = new HashMap<>(); drivers = new HashSet<>(); Set<URL> urlSet = new HashSet<>(); String dbDriverString = System.getenv("BEAKER_JDBC_DRIVER_LIST"); if (dbDriverString != null && !dbDriverString.isEmpty()) { String[] dbDriverList = dbDriverString.split(File.pathSeparator); for (String s : dbDriverList) { try { urlSet.add(toURL(s)); } catch (MalformedURLException e) { logger.error(e.getMessage()); }/*from w ww .ja va 2 s . c o m*/ } } if (pathList != null) { for (String path : pathList) { path = path.trim(); if (path.startsWith("--") || path.startsWith("#")) { continue; } try { urlSet.add(toURL(path)); } catch (MalformedURLException e) { logger.error(e.getMessage()); } } } URLClassLoader loader = new URLClassLoader(urlSet.toArray(new URL[urlSet.size()])); ServiceLoader<Driver> loadedDrivers = ServiceLoader.load(Driver.class, loader); Iterator<Driver> driversIterator = loadedDrivers.iterator(); try { while (driversIterator.hasNext()) { Driver d = driversIterator.next(); drivers.add(d); } } catch (Throwable t) { logger.error(t.getMessage()); } } }