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:com.erudika.para.rest.RestUtilsTest.java

@BeforeClass
public static void setUpClass() {
    System.setProperty("para.env", "embedded");
    System.setProperty("para.app_name", "para-test");
    System.setProperty("para.print_logo", "false");
    Para.initialize(new Module() {
        public void configure(Binder binder) {
            binder.bind(DAO.class).toInstance(new MockDAO());
            binder.bind(Cache.class).toInstance(new MockCache());
            binder.bind(Search.class).toInstance(Mockito.mock(Search.class));
        }//from  w w w.  j  a  v a 2s  .  c om
    });
}

From source file:com.ms.commons.nisa.impl.ConfigServiceImplTest.java

public void testInit3() {
    System.setProperty(ConfigServiceImpl.KEY_START_MINA_CLIENT, "false");
    String path = ConfigServiceImplTest.class.getResource("msun.test.properties").getFile();
    System.setProperty(ConfigServiceImpl.KEY_NISA_PROPERTIES, path);
    ConfigServiceImpl cs = new ConfigServiceImpl();
    try {/*from   ww w. j av a 2 s.c  o  m*/
        cs.init();
        int intkv = cs.getKV("I_junit.int", 400);
        assertEquals(100, intkv);
        float floatkv = cs.getKV("F_junit.float", 99.99f);
        assertEquals(30.5f, floatkv);
        boolean b = cs.getKV("B_junit.boolean", false);
        assertEquals(true, b);
        String s = cs.getKV("S_junit.string", "nono");
        assertEquals("oye", s);

        int[] kvIntArray = cs.getKVIntArray("IA_junit.intarray");
        assertEquals(2, kvIntArray.length);
        assertEquals(100, kvIntArray[0]);
        assertEquals(200, kvIntArray[1]);

        float[] kvFloatArray = cs.getKVFloatArray("FA_junit.floatarray");
        assertEquals(2, kvFloatArray.length);
        assertEquals(10.99f, kvFloatArray[0]);
        assertEquals(20.88f, kvFloatArray[1]);

        boolean[] kvBooleanArray = cs.getKVBooleanArray("BA_junit.booleanarray");
        assertEquals(3, kvBooleanArray.length);
        assertEquals(false, kvBooleanArray[0]);
        assertEquals(true, kvBooleanArray[1]);
        assertEquals(false, kvBooleanArray[2]);

        String[] kvStringArray = cs.getKVStringArray("SA_junit.stringarray");
        assertEquals(2, kvStringArray.length);
        assertEquals("abc", kvStringArray[0]);
        assertEquals("bcd", kvStringArray[1]);

    } catch (NisaException ee) {
        ee.printStackTrace();
        fail(ExceptionUtils.getFullStackTrace(ee));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}

From source file:com.github.rvesse.airline.parser.aliases.TestAliases.java

@BeforeClass
public static void setup() {
    homeDir = System.getProperty("user.home");

    // Change home directory for purposes of these tests
    System.setProperty("user.home", new File("target/").getAbsolutePath());
}

From source file:fedora.utilities.install.Installer.java

/**
 * Command-line entry point.//from   www  .j a  va 2 s .  c om
 */
public static void main(String[] args) {
    try {
        Distribution dist = new ClassLoaderDistribution();
        InstallOptions opts = null;

        if (args.length == 0) {
            opts = new InstallOptions(dist);
        } else if (args.length == 1) {
            Map<String, String> props = FileUtils.loadMap(new File(args[0]));
            opts = new InstallOptions(dist, props);
        } else {
            System.err.println("ERROR: Too many arguments.");
            System.err.println("Usage: java -jar fedora-install.jar [options-file]");
            System.exit(1);
        }

        // set fedora.home
        System.setProperty("fedora.home", opts.getValue(InstallOptions.FEDORA_HOME));
        new Installer(dist, opts).install();

    } catch (Exception e) {
        printException(e);
        System.exit(1);
    }
}

From source file:fr.jetoile.hadoopunit.HadoopUtils.java

public static void setHadoopHome() {

    // Set hadoop.home.dir to point to the windows lib dir
    if (System.getProperty("os.name").startsWith("Windows")) {

        if (StringUtils.isEmpty(System.getenv("HADOOP_HOME"))) {

            try {
                configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE);
            } catch (ConfigurationException e) {
                LOG.error("unable to load {}", HadoopUnitConfig.DEFAULT_PROPS_FILE, e);
            }//from   w  w  w  .  j  av  a2s .co m

            String hadoop_home = configuration.getString("HADOOP_HOME");

            LOG.info("Setting hadoop.home.dir: {}", hadoop_home);
            if (hadoop_home == null) {
                LOG.error("HADOOP_HOME should be set or informed into hadoop-unit-default.properties");
                System.exit(-1);
            } else {
                System.setProperty("HADOOP_HOME", hadoop_home);
            }

        } else {
            System.setProperty("HADOOP_HOME", System.getenv("HADOOP_HOME"));
        }

        String windowsLibDir = System.getenv("HADOOP_HOME");

        LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir);
        System.setProperty("hadoop.home.dir", windowsLibDir);
        System.load(new File(windowsLibDir + Path.SEPARATOR + "bin" + Path.SEPARATOR + "hadoop.dll")
                .getAbsolutePath());
        System.load(new File(windowsLibDir + Path.SEPARATOR + "bin" + Path.SEPARATOR + "hdfs.dll")
                .getAbsolutePath());
    }
}

From source file:com.clustercontrol.util.CommandCreator.java

public static void main(String[] args) {

    String command = "hogehoge \"a b\" c , d";
    String[] commandArr = null;//from  w w  w  . j  a v  a2 s  .  c o  m

    System.out.println("SpecifyUser = YES");

    // Windows
    System.setProperty("user.name", "Administrator");
    try {
        commandArr = createCommand("Administrator", command, PlatformType.WINDOWS, true);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }
    try {
        commandArr = createCommand("hinemos", command, PlatformType.WINDOWS, true);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }

    // UNIX/Linux
    System.setProperty("user.name", "root");
    try {
        commandArr = createCommand("root", command, PlatformType.UNIX, true);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }
    try {
        commandArr = createCommand("hinemos", command, PlatformType.UNIX, true);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }

    // ??
    System.setProperty("user.name", "root");
    try {
        commandArr = createCommand("hinemos", command, PlatformType.REGACY, true);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }
    System.setProperty("user.name", "Administrator");
    try {
        commandArr = createCommand("hinemos", command, PlatformType.REGACY, true);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }
    try {
        commandArr = createCommand("Administrator", command, PlatformType.REGACY, true);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }
    // 
    System.setProperty("user.name", "Administrator");
    System.setProperty("os.name", "Windows Server 2008");
    try {
        commandArr = createCommand("Administrator", command, PlatformType.AUTO, true);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }

    System.setProperty("user.name", "root");
    System.setProperty("os.name", "Linux");
    try {
        commandArr = createCommand("root", command, PlatformType.AUTO, true);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }

    System.out.println("SpecifyUser = NO");

    // Windows
    System.setProperty("user.name", "Administrator");
    try {
        commandArr = createCommand("Administrator", command, PlatformType.WINDOWS, false);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }
    try {
        commandArr = createCommand("hinemos", command, PlatformType.WINDOWS, false);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }

    // UNIX/Linux
    System.setProperty("user.name", "root");
    try {
        commandArr = createCommand("root", command, PlatformType.UNIX, false);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }
    try {
        commandArr = createCommand("hinemos", command, PlatformType.UNIX, false);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }

    // ??
    System.setProperty("user.name", "root");
    try {
        commandArr = createCommand("hinemos", command, PlatformType.REGACY, false);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }
    System.setProperty("user.name", "Administrator");
    try {
        commandArr = createCommand("hinemos", command, PlatformType.REGACY, false);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }
    try {
        commandArr = createCommand("Administrator", command, PlatformType.REGACY, false);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }
    // 
    System.setProperty("user.name", "Administrator");
    System.setProperty("os.name", "Windows Server 2008");
    try {
        commandArr = createCommand("Administrator", command, PlatformType.AUTO, false);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }

    System.setProperty("user.name", "root");
    System.setProperty("os.name", "Linux");
    try {
        commandArr = createCommand("root", command, PlatformType.AUTO, false);
        if (commandArr != null)
            for (String arg : commandArr) {
                System.out.println("arg : " + arg);
            }
        System.out.println();
    } catch (Exception e) {
        System.out.println("ERROR MSG * " + e.getMessage() + "\n");
    }
}

From source file:com.sitewhere.test.MultithreadedRestTest.java

@Test
public void doRestTest() throws Exception {
    java.util.logging.Logger.getLogger("org.apache.http.wire").setLevel(java.util.logging.Level.FINEST);
    java.util.logging.Logger.getLogger("org.apache.http.headers").setLevel(java.util.logging.Level.FINEST);
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
    System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "ERROR");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", "ERROR");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.headers", "ERROR");

    ExecutorService executor = Executors.newFixedThreadPool(numThreads);
    CompletionService<SiteWhereClientTester.TestResults> completionService = new ExecutorCompletionService<SiteWhereClientTester.TestResults>(
            executor);/*from   ww  w .  jav a 2s  .  c o  m*/

    for (int i = 0; i < numThreads; i++) {
        completionService
                .submit(new SiteWhereClientTester("90389b40-7c25-401b-bf72-98673913d59e", 100, updateState));
    }
    for (int i = 0; i < numThreads; ++i) {
        completionService.take().get();
    }
}

From source file:com.redhat.lightblue.crud.ldap.ITCaseLdapCRUDController_WithProperties_Test.java

@BeforeClass
public static void beforeClass() throws Exception {
    ldapServer.add(BASEDB_CUSTOMERS, new Attribute[] { new Attribute("objectClass", "top"),
            new Attribute("objectClass", "organizationalUnit"), new Attribute("ou", "Customers") });

    System.setProperty("ldap.host", "localhost");
    System.setProperty("ldap.port", String.valueOf(LdapServerExternalResource.DEFAULT_PORT));
    System.setProperty("ldap.database", "test");
    System.setProperty("ldap.customer.basedn", BASEDB_CUSTOMERS);

    System.setProperty("mongo.host", "localhost");
    System.setProperty("mongo.port", String.valueOf(MongoServerExternalResource.DEFAULT_PORT));
    System.setProperty("mongo.database", "lightblue");

    initLightblueFactory("./datasources.json", "./metadata/customer-metadata.json");
}

From source file:com.apifest.doclet.integration.tests.DocletModeTest.java

@BeforeMethod
public void setup() {
    System.setProperty("sourcePath", "./src/test/java/com/apifest/doclet/tests/resources");
    System.setProperty("mapping.version", "v1");
    System.setProperty("mapping.filename", "all-mappings.xml");
    System.setProperty("mapping.docs.filename", "all-mappings-docs.json");
    System.setProperty("backend.host", "localhost");
    System.setProperty("backend.port", "1212");
    System.setProperty("application.path", "/");
    System.setProperty("defaultActionClass", "com.all.mappings.DefaultMapping");
    System.setProperty("defaultFilterClass", "com.all.mappings.DefaultFilter");

}

From source file:com.seeyon.apps.dee.DEEInitialitionListener.java

public void contextInitialized(ServletContextEvent arg0) {
    String dee_home = System.getenv(DEE_HOME);
    if (dee_home == null) {
        dee_home = SystemEnvironment.getBaseFolder() + File.separator + "dee";
        System.setProperty(DEE_HOME, dee_home);
    }/*from w w w .j  a  v a 2  s.c  o  m*/
    File deeLicensePath = new File(dee_home + File.separator + "licence");
    if (deeLicensePath.exists() && deeLicensePath.isDirectory()) {
        File[] keys = deeLicensePath.listFiles(new DeekeyFileFilter(Pattern.compile("(?:.+\\.seeyonkey)")));
        boolean checked = keys.length > 0;
        for (File file : keys) {
            checked = checked && checkLicense(file);
        }
        if (checked) {
            //            DataSourceManager.getInstance();
        } else {
            log.info("?DEE.");
        }
    } else {
        log.info("?DEE License.");
        return;
    }
}