Example usage for java.util Properties get

List of usage examples for java.util Properties get

Introduction

In this page you can find the example usage for java.util Properties get.

Prototype

@Override
    public Object get(Object key) 

Source Link

Usage

From source file:es.gva.cit.catalog.DiscoveryServiceClient.java

/**
 * It tries if the server is ready/*  www  . ja  v a2  s  .  c  o  m*/
 * 
 * @return boolean true --> server is ready false --> server is not ready
 */
public boolean serverIsReady() throws ServerIsNotReadyException {
    Properties systemSettings = System.getProperties();

    Object isProxyEnabled = systemSettings.get("http.proxySet");
    if ((isProxyEnabled == null) || (isProxyEnabled.equals("false"))) {
        Socket sock;
        try {
            sock = new Socket(getUri().getHost(), getUri().getPort());
        } catch (UnknownHostException e) {
            throw new ServerIsNotReadyException(e);
        } catch (IOException e) {
            throw new ServerIsNotReadyException(e);
        }
        return (sock != null);
    } else {
        Object host = systemSettings.get("http.proxyHost");
        Object port = systemSettings.get("http.proxyPort");
        Object user = systemSettings.get("http.proxyUserName");
        Object password = systemSettings.get("http.proxyPassword");
        if ((host != null) && (port != null)) {
            int iPort = 80;
            try {
                iPort = Integer.parseInt((String) port);
            } catch (Exception e) {
                // Use 80
            }
            HttpConnection connection = new HttpConnection(getUri().getHost(), getUri().getPort());
            connection.setProxyHost((String) host);
            connection.setProxyPort(iPort);
            Authenticator.setDefault(new SimpleAuthenticator(user, password));

            try {
                connection.open();
                connection.close();
            } catch (IOException e) {
                throw new ServerIsNotReadyException(e);
            }
        }
    }
    return true;
}

From source file:com.sun.socialsite.business.impl.JPASocialSiteModule.java

/**
 * Configures bindings which are appropriate for a JPA-based SocialSite backend.
 *///w w  w.ja v a 2s .c o m
public void configure(Binder binder) {

    // We don't need many explicit bindings here, since they'd just mirror
    // the @ImplementedBy defaults which are set on each interface.

    // Read Shindig properties from standard SocialSite configuration file
    // Backend needs them too
    Properties shindigProperties = Config.getPropertiesStartingWith("shindig.");
    Properties properties = PropertyExpander.expandProperties(shindigProperties, Config.toMap(), null);

    if (log.isDebugEnabled()) {
        for (Object key : properties.keySet()) {
            log.debug(String.format("%s[%s]=%s", "socialsite.properties", key, properties.get(key)));
        }
    }
    Names.bindProperties(binder, properties);

    binder.bind(UserManager.class).to(DelegatingUserManagerImpl.class);

    binder.bind(OAuthStore.class).to(JPAOAuthStore.class);

}

From source file:com.opensoc.enrichment.adapters.whois.WhoisHBaseAdapterTest.java

protected void setUp() throws Exception {
    super.setUp();
    Properties prop = super.getTestProperties();
    assertNotNull(prop);/*from w w w .  j a va2  s. com*/

    if (skipTests(this.getMode())) {
        return;//skip tests
    }

    String[] zk = prop.get("kafka.zk.list").toString().split(",");

    for (String z : zk) {
        InetAddress address = InetAddress.getByName(z);
        boolean reachable = address.isReachable(100);

        if (!reachable) {
            this.setMode("local");
            break;
            //throw new Exception("Unable to reach zookeeper, skipping WHois adapter test");
        }

        System.out.println("kafka.zk.list =" + (String) prop.get("kafka.zk.list"));
        System.out.println("kafka.zk.list =" + (String) prop.get("kafka.zk.port"));
        System.out.println("kafka.zk.list =" + (String) prop.get("bolt.enrichment.cif.tablename"));

    }

    if (skipTests(this.getMode())) {
        System.out.println("Local Mode Skipping tests !! ");
    } else {
        whoisHbaseAdapter = new WhoisHBaseAdapter((String) prop.get("bolt.enrichment.whois.hbase.table.name"),
                (String) prop.get("kafka.zk.list"), (String) prop.get("kafka.zk.port"));
        connected = whoisHbaseAdapter.initializeAdapter();
        assertTrue(connected);
    }

}

From source file:ac.simons.spring.boot.wro4j.Wro4jAutoConfigurationTest.java

@Test
public void wroFilterPropertiesShouldWork() {
    final Wro4jProperties wro4jProperties = new Wro4jProperties();

    Properties p;

    p = new Wro4jAutoConfiguration(this.applicationContext).wroFilterProperties(wro4jProperties);
    Assert.assertEquals("true", p.get(ConfigConstants.debug.name()));
    Assert.assertEquals("true", p.get(ConfigConstants.minimizeEnabled.name()));
    Assert.assertEquals("true", p.get(ConfigConstants.gzipResources.name()));
    Assert.assertEquals("0", p.get(ConfigConstants.resourceWatcherUpdatePeriod.name()));
    Assert.assertEquals("false", p.get(ConfigConstants.resourceWatcherAsync.name()));
    Assert.assertEquals("0", p.get(ConfigConstants.cacheUpdatePeriod.name()));
    Assert.assertEquals("0", p.get(ConfigConstants.modelUpdatePeriod.name()));
    Assert.assertNull(p.get(ConfigConstants.header.name()));
    Assert.assertEquals("false", p.get(ConfigConstants.parallelPreprocessing.name()));
    Assert.assertEquals("2000", p.get(ConfigConstants.connectionTimeout.name()));
    Assert.assertEquals("UTF-8", p.get(ConfigConstants.encoding.name()));
    Assert.assertEquals("true", p.get(ConfigConstants.ignoreMissingResources.name()));
    Assert.assertEquals("true", p.get(ConfigConstants.ignoreEmptyGroup.name()));
    Assert.assertEquals("false", p.get(ConfigConstants.ignoreFailingProcessor.name()));
    Assert.assertEquals("true", p.get(ConfigConstants.cacheGzippedContent.name()));
    Assert.assertEquals("false", p.get(ConfigConstants.jmxEnabled.name()));
    Assert.assertNull(p.get(ConfigConstants.mbeanName.name()));

    wro4jProperties.setResourceWatcherUpdatePeriod(null);
    wro4jProperties.setCacheUpdatePeriod(null);
    wro4jProperties.setModelUpdatePeriod(null);
    wro4jProperties.setHeader("   ");
    wro4jProperties.setConnectionTimeout(null);
    wro4jProperties.setEncoding("\t ");
    wro4jProperties.setMbeanName(" ");
    p = new Wro4jAutoConfiguration(this.applicationContext).wroFilterProperties(wro4jProperties);
    Assert.assertNull(p.get(ConfigConstants.resourceWatcherUpdatePeriod.name()));
    Assert.assertNull(p.get(ConfigConstants.cacheUpdatePeriod.name()));
    Assert.assertNull(p.get(ConfigConstants.modelUpdatePeriod.name()));
    Assert.assertNull(p.get(ConfigConstants.header.name()));
    Assert.assertNull(p.get(ConfigConstants.connectionTimeout.name()));
    Assert.assertNull(p.get(ConfigConstants.encoding.name()));
    Assert.assertNull(p.get(ConfigConstants.mbeanName.name()));

    wro4jProperties.setHeader("If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT");
    wro4jProperties.setEncoding("ISO-8859-1");
    wro4jProperties.setMbeanName("wro4j-bean");
    p = new Wro4jAutoConfiguration(this.applicationContext).wroFilterProperties(wro4jProperties);
    Assert.assertEquals(wro4jProperties.getHeader(), p.get(ConfigConstants.header.name()));
    Assert.assertEquals(wro4jProperties.getEncoding(), p.get(ConfigConstants.encoding.name()));
    Assert.assertEquals(wro4jProperties.getMbeanName(), p.get(ConfigConstants.mbeanName.name()));

    wro4jProperties.setEncoding(null);// ww  w.j  a v a2  s.  co m
    p = new Wro4jAutoConfiguration(this.applicationContext).wroFilterProperties(wro4jProperties);
    Assert.assertNull(p.get(ConfigConstants.encoding.name()));
}

From source file:cz.cuni.mff.d3s.been.mapstore.mongodb.MongoMapStore.java

@Override
public void init(HazelcastInstance hazelcastInstance, Properties properties, String mapName) {
    if (properties.get("collection") != null) {
        this.mapName = (String) properties.get("collection");
    } else {/*  w ww  . j  a  v a 2s .co  m*/
        this.mapName = mapName;
    }
    this.failedStoreMapName = String.format("%s_%s", this.mapName, FAILED_STORE_MIRROR_MAP_SUFFIX);
    this.failedStoreMap = hazelcastInstance.getMap(failedStoreMapName);
    this.hazelcastInstance = hazelcastInstance;
    this.coll = mongoTemplate.getCollection(this.mapName);
    this.converter = new SpringMongoDBConverter(mongoTemplate);

    scheduleFailoverMapFlusher();
}

From source file:com.goodformobile.build.mobile.GenerateRAPCMojoTest.java

@Test
public void testJadVersionShouldNotContainText() throws Exception {

    setPluginConfigFileName("com/goodformobile/build/mobile/generate-rapc-plugin-config.xml");
    AbstractRIMBuildMojo mojo = setupMojo();

    MavenProject project = getProject(mojo);

    File buildDirectory = new File(getBasedir(), "target/test/unit/generate-rapc-mojo-basic-test/target");
    setupBuildDirectory(buildDirectory);
    project.getBuild().setDirectory(buildDirectory.getAbsolutePath());
    project.setVersion("1.0-SNAPSHOT");

    mojo.execute();/*from   www  . jav  a2 s  .co  m*/

    File propertiesFile = new File(getBasedir(),
            "target/test/unit/generate-rapc-mojo-basic-test/target/rapc/maven_blackberry_plugin_test.rapc");
    assertTrue("Properties File not found.", propertiesFile.exists());
    Properties result = PropertyUtils.loadProperties(propertiesFile);
    assertNotNull(result);
    String midletVersion = (String) result.get("MIDlet-Version");

    assertFalse("Midlet version should not contain the word SNAPSHOT but is: " + midletVersion,
            midletVersion.contains("SNAPSHOT"));
}

From source file:net.sf.ehcache.hibernate.SingletonEhCacheProvider.java

/**
 * Callback to perform any necessary initialization of the underlying cache implementation
 * during SessionFactory construction.//  w w w .  j  a va  2s  .  c  om
 * <p/>
 *
 * @param properties current configuration settings.
 */
public final void start(Properties properties) throws CacheException {
    String configurationResourceName = null;
    if (properties != null) {
        configurationResourceName = (String) properties.get(NET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAME);
    }
    if (configurationResourceName == null || configurationResourceName.length() == 0) {
        manager = CacheManager.create();
        referenceCount++;
    } else {
        if (!configurationResourceName.startsWith("/")) {
            configurationResourceName = "/" + configurationResourceName;
            if (LOG.isDebugEnabled()) {
                LOG.debug("prepending / to " + configurationResourceName + ". It should be placed in the root"
                        + "of the classpath rather than in a package.");
            }
        }
        URL url = loadResource(configurationResourceName);
        manager = CacheManager.create(url);
        referenceCount++;
    }
}

From source file:com.goodformobile.build.mobile.GenerateRAPCMojoTest.java

@Test
public void testExecuteForBasicApplication() throws Exception {

    setPluginConfigFileName("com/goodformobile/build/mobile/generate-rapc-plugin-config.xml");
    AbstractRIMBuildMojo mojo = setupMojo();

    MavenProject project = getProject(mojo);

    File buildDirectory = new File(getBasedir(), "target/test/unit/generate-rapc-mojo-basic-test/target");
    setupBuildDirectory(buildDirectory);
    project.getBuild().setDirectory(buildDirectory.getAbsolutePath());

    mojo.execute();/*  w  w  w  .ja v a2s . c om*/

    File propertiesFile = new File(getBasedir(),
            "target/test/unit/generate-rapc-mojo-basic-test/target/rapc/maven_blackberry_plugin_test.rapc");
    assertTrue("Properties File not found.", propertiesFile.exists());
    Properties result = PropertyUtils.loadProperties(propertiesFile);
    assertNotNull(result);
    assertEquals(project.getName(), result.get("MIDlet-Name"));
    assertEquals(project.getVersion().replace("-", "."), result.get("MIDlet-Version"));
    assertEquals("MIDP-2.0", result.get("MicroEdition-Profile"));
    assertEquals("CLDC-1.1", result.get("MicroEdition-Configuration"));
    assertEquals("Test Description", result.get("MIDlet-Description"));
    assertEquals("Good For Mobile", result.get("MIDlet-Vendor"));
    assertEquals(project.getName() + ",img/icon.png,", result.get("MIDlet-1"));
    assertEquals("0", result.get("RIM-MIDlet-Flags-1"));
    assertEquals(project.getArtifactId() + ".jar", result.get("MIDlet-Jar-URL"));
}

From source file:com.goodformobile.build.mobile.GenerateRAPCMojoTest.java

@Test
public void testExecuteForLibraryWithoutDependencies() throws Exception {

    setPluginConfigFileName("com/goodformobile/build/mobile/generate-rapc-for-library-plugin-config.xml");
    AbstractRIMBuildMojo mojo = setupMojo();

    MavenProject project = getProject(mojo);
    project.setArtifactId("library-project-1");
    project.setVersion("1.0.0");

    File buildDirectory = new File(getBasedir(),
            "target/test/unit/generate-rapc-for-library-mojo-basic-test/target");
    setupBuildDirectory(buildDirectory);

    project.getBuild().setDirectory(buildDirectory.getAbsolutePath());

    mojo.execute();/*from   w w  w . ja  v  a2 s  . c om*/

    File propertiesFile = new File(getBasedir(),
            "target/test/unit/generate-rapc-for-library-mojo-basic-test/target/rapc/library_project_1.rapc");
    assertTrue("Properties File not found.", propertiesFile.exists());
    Properties result = PropertyUtils.loadProperties(propertiesFile);
    assertNotNull(result);
    assertEquals(project.getName(), result.get("MIDlet-Name"));
    assertEquals("1.0.0", result.get("MIDlet-Version"));
    assertEquals("MIDP-2.0", result.get("MicroEdition-Profile"));
    assertEquals("CLDC-1.1", result.get("MicroEdition-Configuration"));
    assertEquals("BlackBerry Developer", result.get("MIDlet-Vendor"));
    assertEquals("2", result.get("RIM-Library-Flags"));
    assertEquals("library-project-1.jar", result.get("MIDlet-Jar-URL"));
}