@Test public void testGetConnection() { String url = "jdbc:mysql://10.112.1.110:3306/test_mysql"; String driver = "com.mysql.jdbc.Driver"; String user = "******"; String passwd = "111111"; try { Class.forName(driver); } catch (Exception e) { System.out.println("Get Connection failed!!!"); } try { Connection con = DriverManager.getConnection(url, user, passwd); System.out.println("Get Connection Success!!!"); Properties properties = con.getClientInfo(); Iterator<Map.Entry<Object, Object>> it = properties.entrySet().iterator(); while (it.hasNext()) { Map.Entry<Object, Object> entry = it.next(); System.out.println(entry.getKey() + "---------------" + entry.getValue()); } } catch (Exception e) { e.printStackTrace(); } }
@BeforeClass public static void setUpClass() throws Exception { Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); props.put(Context.PROVIDER_URL, "localhost:1099"); ic = new InitialContext(props); }
@Test public void testEmptyState() throws IOException { final File fcontent = File.createTempFile("foo2", "bar"); final Properties loadProperties = new Properties(); final InputStream in = new FileInputStream(fcontent); loadProperties.load(in); assertEquals(0, loadProperties.size()); }
@Before public void setup() throws DBException { orientDBClient = new OrientDBClient(); Properties p = new Properties(); // TODO: Extract the property names into final variables in OrientDBClient p.setProperty("orientdb.url", TEST_DB_URL); orientDBClient.setProperties(p); orientDBClient.init(); orientDBConnection = new ODatabaseDocumentTx(TEST_DB_URL).open("admin", "admin"); orientDBDictionary = orientDBConnection.getMetadata().getIndexManager().getDictionary(); }
public void writeProperties(Map<?, ?> properties) { Properties props = new Properties(); props.putAll(properties); try { FileOutputStream stream = new FileOutputStream(this); try { props.store(stream, "comment"); } finally { stream.close(); } } catch (IOException e) { throw new RuntimeException(e); } }
public Map<String, String> getProperties() { assertIsFile(); Properties properties = new Properties(); try { FileInputStream inStream = new FileInputStream(this); try { properties.load(inStream); } finally { inStream.close(); } } catch (IOException e) { throw new RuntimeException(e); } Map<String, String> map = new HashMap<String, String>(); for (Object key : properties.keySet()) { map.put(key.toString(), properties.getProperty(key.toString())); } return map; }
private Properties createConf(boolean local) { Properties conf = new Properties(); if (local) { conf.put(CLIENT_IN_PROCESS.key, "true"); conf.put("spark.master", "local"); conf.put("spark.app.name", "SparkClientSuite Local App"); } else { String classpath = System.getProperty("java.class.path"); conf.put("spark.master", "local"); conf.put("spark.app.name", "SparkClientSuite Remote App"); conf.put("spark.driver.extraClassPath", classpath); conf.put("spark.executor.extraClassPath", classpath); conf.put(LIVY_JARS.key, ""); } return conf; }
/* github issue 304 */ @Test public void testIssue304EvictionDespitePut() throws InterruptedException { Config c = new Config(); c.getGroupConfig().setName("testIssue304EvictionDespitePut"); final HashMap<String, MapConfig> mapConfigs = new HashMap<String, MapConfig>(); final MapConfig value = new MapConfig(); value.setMaxIdleSeconds(3); mapConfigs.put("default", value); c.setMapConfigs(mapConfigs); final Properties properties = new Properties(); properties.setProperty("hazelcast.map.cleanup.delay.seconds", "1"); // we need faster cleanups c.setProperties(properties); int n = 1; TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(n); final HazelcastInstance hazelcastInstance = factory.newHazelcastInstance(c); IMap<String, Long> map = hazelcastInstance.getMap("testIssue304EvictionDespitePutMap"); final AtomicInteger evictCount = new AtomicInteger(0); map.addEntryListener( new EntryListener<String, Long>() { public void entryAdded(EntryEvent<String, Long> event) {} public void entryRemoved(EntryEvent<String, Long> event) {} public void entryUpdated(EntryEvent<String, Long> event) {} public void entryEvicted(EntryEvent<String, Long> event) { evictCount.incrementAndGet(); } }, true); String key = "key"; for (int i = 0; i < 5; i++) { map.put(key, System.currentTimeMillis()); Thread.sleep(1000); } assertEquals(evictCount.get(), 0); assertNotNull(map.get(key)); hazelcastInstance.getLifecycleService().shutdown(); }
@Test public void testProperties() { final Properties properties = config.getProperties(); assertNotNull(properties); assertEquals("5", properties.get(GroupProperties.PROP_MERGE_FIRST_RUN_DELAY_SECONDS)); assertEquals("5", properties.get(GroupProperties.PROP_MERGE_NEXT_RUN_DELAY_SECONDS)); final Config config2 = instance.getConfig(); final Properties properties2 = config2.getProperties(); assertNotNull(properties2); assertEquals("5", properties2.get(GroupProperties.PROP_MERGE_FIRST_RUN_DELAY_SECONDS)); assertEquals("5", properties2.get(GroupProperties.PROP_MERGE_NEXT_RUN_DELAY_SECONDS)); }
@Before public void before() throws Exception { catalogPropertiesFile = getResourceUri("catalog.properties").getPath(); Properties properties = new Properties(); properties.load( CatalogManagerTest.class.getClassLoader().getResourceAsStream("catalog.properties")); CatalogManagerTest.clearCatalog(properties); catalogManager = new CatalogManager(properties); fileMetadataReader = FileMetadataReader.get(catalogManager); catalogFileUtils = new CatalogFileUtils(catalogManager); User user = catalogManager.createUser(userId, "User", "*****@*****.**", "user", "ACME", null).first(); sessionId = catalogManager.login(userId, "user", "localhost").first().getString("sessionId"); projectId = catalogManager .createProject(userId, "p1", "p1", "Project 1", "ACME", null, sessionId) .first() .getId(); studyId = catalogManager .createStudy( projectId, "s1", "s1", Study.Type.CASE_CONTROL, null, null, "Study 1", null, null, null, null, Collections.singletonMap(File.Bioformat.VARIANT, new DataStore("mongodb", DB_NAME)), null, null, null, sessionId) .first() .getId(); outputId = catalogManager .createFolder(studyId, Paths.get("data", "index"), false, null, sessionId) .first() .getId(); files.add( create( "1-500.filtered.10k.chr22.phase3_shapeit2_mvncall_integrated_v5.20130502.genotypes.vcf.gz")); files.add( create( "501-1000.filtered.10k.chr22.phase3_shapeit2_mvncall_integrated_v5.20130502.genotypes.vcf.gz")); files.add( create( "1001-1500.filtered.10k.chr22.phase3_shapeit2_mvncall_integrated_v5.20130502.genotypes.vcf.gz")); files.add( create( "1501-2000.filtered.10k.chr22.phase3_shapeit2_mvncall_integrated_v5.20130502.genotypes.vcf.gz")); files.add( create( "2001-2504.filtered.10k.chr22.phase3_shapeit2_mvncall_integrated_v5.20130502.genotypes.vcf.gz")); }
private BuildResult doRun( final OutputListenerImpl outputListener, OutputListenerImpl errorListener, BuildListenerImpl listener) { // Capture the current state of things that we will change during execution InputStream originalStdIn = System.in; Properties originalSysProperties = new Properties(); originalSysProperties.putAll(System.getProperties()); File originalUserDir = new File(originalSysProperties.getProperty("user.dir")); Map<String, String> originalEnv = new HashMap<String, String>(System.getenv()); // Augment the environment for the execution System.setIn(getStdin()); processEnvironment.maybeSetProcessDir(getWorkingDir()); for (Map.Entry<String, String> entry : getEnvironmentVars().entrySet()) { processEnvironment.maybeSetEnvironmentVariable(entry.getKey(), entry.getValue()); } Map<String, String> implicitJvmSystemProperties = getImplicitJvmSystemProperties(); System.getProperties().putAll(implicitJvmSystemProperties); DefaultStartParameter parameter = new DefaultStartParameter(); parameter.setCurrentDir(getWorkingDir()); parameter.setShowStacktrace(ShowStacktrace.ALWAYS); CommandLineParser parser = new CommandLineParser(); DefaultCommandLineConverter converter = new DefaultCommandLineConverter(); converter.configure(parser); ParsedCommandLine parsedCommandLine = parser.parse(getAllArgs()); BuildLayoutParameters layout = converter.getLayoutConverter().convert(parsedCommandLine); Map<String, String> properties = new HashMap<String, String>(); new LayoutToPropertiesConverter().convert(layout, properties); converter.getSystemPropertiesConverter().convert(parsedCommandLine, properties); new PropertiesToStartParameterConverter().convert(properties, parameter); converter.convert(parsedCommandLine, parameter); DefaultGradleLauncherFactory factory = DeprecationLogger.whileDisabled( new Factory<DefaultGradleLauncherFactory>() { public DefaultGradleLauncherFactory create() { return (DefaultGradleLauncherFactory) GradleLauncher.getFactory(); } }); factory.addListener(listener); GradleLauncher gradleLauncher = factory.newInstance(parameter); gradleLauncher.addStandardOutputListener(outputListener); gradleLauncher.addStandardErrorListener(errorListener); try { return gradleLauncher.run(); } finally { // Restore the environment System.setProperties(originalSysProperties); processEnvironment.maybeSetProcessDir(originalUserDir); for (String envVar : getEnvironmentVars().keySet()) { String oldValue = originalEnv.get(envVar); if (oldValue != null) { processEnvironment.maybeSetEnvironmentVariable(envVar, oldValue); } else { processEnvironment.maybeRemoveEnvironmentVariable(envVar); } } factory.removeListener(listener); System.setIn(originalStdIn); } }
@Test public void testState() throws IOException { final File fcontent = File.createTempFile("foo", "bar"); final Properties properties = new Properties(); final Date dt = new Date(); properties.put("int", 10453); properties.put("long", 1000000L); properties.put("date", dt); final OutputStream out = new FileOutputStream(fcontent); properties.store(out); final Properties loadProperties = new Properties(); final InputStream in = new FileInputStream(fcontent); loadProperties.load(in); assertNotNull(properties.get("int")); assertNotNull(properties.get("long")); assertNotNull(properties.get("date")); assertEquals(10453, properties.get("int")); assertEquals(1000000L, properties.get("long")); assertEquals(dt, properties.get("date")); }