Example usage for java.lang System setProperty

List of usage examples for java.lang System setProperty

Introduction

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

Prototype

public static String setProperty(String key, String value) 

Source Link

Document

Sets the system property indicated by the specified key.

Usage

From source file:cascading.HiveTestCase.java

@BeforeClass
public static void beforeClass() throws IOException {
    // do this once per class, otherwise we run into bizarre derby errors
    if (DERBY_HOME.exists())
        FileUtils.deleteDirectory(DERBY_HOME);
    DERBY_HOME.mkdirs();//from  w w  w  .ja v  a 2  s.  co  m
    System.setProperty("derby.system.home", DERBY_HOME.getAbsolutePath());
    System.setProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname, HIVE_WAREHOUSE_DIR);
}

From source file:com.impetus.kundera.ycsb.OracleNosqlYCSBTest.java

/**
 * @throws java.lang.Exception/* w w w. j ava 2  s  . c o  m*/
 */
@Before
public void setUp() throws Exception {
    System.setProperty("fileName", "src/main/resources/db-oracle-nosql.properties");
    // in case property file name is not set as system property.
    super.setUp();
}

From source file:org.greencheek.utils.environment.propertyplaceholder.spring.TestEnvironmentalPropertySourcesPlaceholderConfigurerWithSpringValueResolution.java

@Test
public void testPropertyResolved() {
    System.setProperty("ENVIRONMENT", "dev");
    System.clearProperty("ENV");
    ctx = new ClassPathXmlApplicationContext(new String[] { "classpath:SpringValueResolution-config.xml" });

    String value = (String) ctx.getBean("string");

    assertEquals("defaultproperties", value);
    ctx.close();/*from  ww  w  . j ava2s  .c  om*/
}

From source file:org.cloudfoundry.identity.uaa.scim.job.AbstractJobIntegrationTests.java

@BeforeClass
public static void setUpDatabaseUrl() {
    // Switch the database URL for these tests so that any stale connections from other places don't muck things up
    if (System.getProperty("spring.profiles.active", "hsqldb").contains("hsqldb")) {
        System.setProperty("batch.jdbc.url", "jdbc:hsqldb:mem:batchtest;sql.enforce_strict_size=true");
    }//from  w w w  .j  a v  a2 s.c o  m
}

From source file:com.streamsets.datacollector.util.ClusterUtil.java

public static void setupCluster(String testName, String pipelineJson, YarnConfiguration yarnConfiguration)
        throws Exception {
    System.setProperty("sdc.testing-mode", "true");
    System.setProperty(MiniSDCTestingUtility.PRESERVE_TEST_DIR, "true");
    yarnConfiguration.set("yarn.nodemanager.delete.debug-delay-sec", "600");
    miniSDCTestingUtility = new MiniSDCTestingUtility();
    File dataTestDir = miniSDCTestingUtility.getDataTestDir();

    //copy spark files under the test data directory into a dir called "spark"
    File sparkHome = ClusterUtil.createSparkHome(dataTestDir);

    //start mini yarn cluster
    miniYarnCluster = miniSDCTestingUtility.startMiniYarnCluster(testName, 1, 1, 1, yarnConfiguration);
    Configuration config = miniYarnCluster.getConfig();

    long deadline = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(10);
    while (config.get(YarnConfiguration.RM_ADDRESS).split(":")[1] == "0") {
        if (System.currentTimeMillis() > deadline) {
            throw new IllegalStateException("Timed out waiting for RM to come up.");
        }//w  w  w.  ja v  a  2 s . c o  m
        LOG.debug("RM address still not set in configuration, waiting...");
        TimeUnit.MILLISECONDS.sleep(100);
    }
    LOG.debug("RM at " + config.get(YarnConfiguration.RM_ADDRESS));

    Properties sparkHadoopProps = new Properties();
    for (Map.Entry<String, String> entry : config) {
        sparkHadoopProps.setProperty("spark.hadoop." + entry.getKey(), entry.getValue());
    }

    LOG.debug("Creating spark properties file at " + dataTestDir);
    File propertiesFile = new File(dataTestDir, "spark.properties");
    propertiesFile.createNewFile();
    FileOutputStream sdcOutStream = new FileOutputStream(propertiesFile);
    sparkHadoopProps.store(sdcOutStream, null);
    sdcOutStream.flush();
    sdcOutStream.close();
    // Need to pass this property file to spark-submit for it pick up yarn confs
    System.setProperty(SPARK_PROPERTY_FILE, propertiesFile.getAbsolutePath());

    File sparkBin = new File(sparkHome, "bin");
    for (File file : sparkBin.listFiles()) {
        MiniSDCTestingUtility.setExecutePermission(file.toPath());
    }

    miniSDC = miniSDCTestingUtility.createMiniSDC(MiniSDC.ExecutionMode.CLUSTER);
    miniSDC.startSDC();
    serverURI = miniSDC.getServerURI();
    miniSDC.createPipeline(pipelineJson);
    miniSDC.startPipeline();

    int attempt = 0;
    //Hard wait for 2 minutes
    while (miniSDC.getListOfSlaveSDCURI().size() == 0 && attempt < 24) {
        Thread.sleep(5000);
        attempt++;
        LOG.debug("Attempt no: " + attempt + " to retrieve list of slaves");
    }
    if (miniSDC.getListOfSlaveSDCURI().size() == 0) {
        throw new IllegalStateException("Timed out waiting for slaves to come up.");
    }
}

From source file:org.wso2.carbon.metrics.data.service.MetricsDataServiceTest.java

public static Test suite() {
    return new TestSetup(new TestSuite(MetricsDataServiceTest.class)) {

        protected void setUp() throws Exception {
            DataSource dataSource = JdbcConnectionPool.create("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "sa", "");
            template = new JdbcTemplate(dataSource);
            ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
            populator.addScript(new ClassPathResource("dbscripts/h2.sql"));
            populator.populate(dataSource.getConnection());

            // Create initial context
            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory");
            System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming");
            InitialContext ic = new InitialContext();
            ic.createSubcontext("jdbc");
            ic.bind("jdbc/WSO2MetricsDB", dataSource);
        }//from   www . j a  v  a  2  s  .com

        protected void tearDown() throws Exception {
            InitialContext ic = new InitialContext();
            ic.unbind("jdbc/WSO2MetricsDB");
            ic.unbind("jdbc");
        }
    };
}

From source file:com.liferay.maven.arquillian.importer.LiferayPluginTestCase.java

protected static void setupPortalMinimal() {

    System.setProperty("liferay.version", LIFERAY_VERSION);

    System.setProperty("liferay.auto.deploy.dir", PORTAL_AUTO_DEPLOY_DIR);

    System.setProperty("liferay.app.server.deploy.dir", PORTAL_SERVER_DEPLOY_DIR);

    System.setProperty("liferay.app.server.lib.global.dir", PORTAL_SERVER_LIB_GLOBAL_DIR);

    System.setProperty("liferay.app.server.portal.dir", SERVER_PORTAL_DIR);

    try {/*from ww w.  j a  va  2  s.c  om*/

        ArchiverManager archiverManager = plexusContainer.lookup(ArchiverManager.class);

        assertNotNull(archiverManager);

        FileUtils.forceMkdir(new File(PORTAL_AUTO_DEPLOY_DIR));
        FileUtils.forceMkdir(new File(PORTAL_SERVER_DEPLOY_DIR));
        FileUtils.forceMkdir(new File(PORTAL_SERVER_LIB_GLOBAL_DIR));
        FileUtils.forceMkdir(new File(SERVER_PORTAL_DIR));

        final MavenResolverSystem mavenResolverSystem = Maven.configureResolver()
                .fromClassloaderResource("settings.xml");

        File[] dependencies = mavenResolverSystem.loadPomFromClassLoaderResource("liferay-setup.xml")
                .importRuntimeAndTestDependencies().resolve().withoutTransitivity().asFile();

        File warFile = null;

        for (File file : dependencies) {

            String fileName = file.getName();
            String fileExtension = FilenameUtils.getExtension(fileName);

            if ("jar".equalsIgnoreCase(fileExtension)) {
                FileUtils.copyFile(file, new File(PORTAL_SERVER_LIB_GLOBAL_DIR, file.getName()));
            } else if ("war".equalsIgnoreCase(fileExtension) && fileName.contains("portal-web")) {
                warFile = file;
            }

        }

        assertNotNull(warFile);

        // extract portal war
        UnArchiver unArchiver = archiverManager.getUnArchiver(warFile);
        unArchiver.setDestDirectory(new File(SERVER_PORTAL_DIR));
        unArchiver.setSourceFile(warFile);
        unArchiver.setOverwrite(false);
        unArchiver.extract();
        setup = true;

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:org.eclipse.gemini.blueprint.test.provisioning.internal.LocalFileSystemMavenRepositoryTest.java

public void testSystemProperty() throws Exception {
    String SYS_PROP = "fake/sys/location";
    System.setProperty("localRepository", SYS_PROP);
    repository = new LocalFileSystemMavenRepository();
    assertTrue("system property not used",
            repository.locateArtifact("foo", "bar", "1.0").toString().indexOf(SYS_PROP) >= -1);
}

From source file:edu.northwestern.bioinformatics.studycalendar.osgi.OsgiLayerIntegratedTestHelper.java

public static synchronized BundleContext getBundleContext() throws IOException {
    if (bundleContext == null) {
        System.setProperty("catalina.base",
                getModuleRelativeDirectory("osgi-layer:integrated-tests", "tmp").getAbsolutePath());

        EmbedderConfiguration configuration = new EmbedderFilesystemConfiguration(
                getModuleRelativeDirectory("osgi-layer", "target/test/embedder").getAbsoluteFile());
        Embedder embedder = new Embedder();
        embedder.setConfiguration(configuration);
        embedder.setFrameworkFactory(FrameworkFactoryFinder.getFrameworkFactory());

        bundleContext = embedder.start();
    }//from w  w w.  j a  v a 2 s .co m
    return bundleContext;
}