Example usage for java.util Properties size

List of usage examples for java.util Properties size

Introduction

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

Prototype

@Override
    public int size() 

Source Link

Usage

From source file:org.apache.servicemix.jbi.deployer.impl.ComponentInstaller.java

public void configure(Properties props) throws Exception {
    if (props != null && props.size() > 0) {
        ObjectName on = getInstallerConfigurationMBean();
        if (on == null) {
            LOGGER.warn(//w  w  w. ja va  2s.  c o  m
                    "Could not find installation configuration MBean. Installation properties will be ignored.");
        } else {
            MBeanServer mbs = deployer.getMbeanServer();
            for (Object o : props.keySet()) {
                String key = (String) o;
                String val = props.getProperty(key);
                try {
                    mbs.setAttribute(on, new Attribute(key, val));
                } catch (JMException e) {
                    throw new DeploymentException("Could not set installation property: (" + key + " = " + val,
                            e);
                }
            }
        }
    }
}

From source file:io.cloudslang.content.database.utils.SQLInputsUtilsTest.java

@Test
public void getOrDefaultDBPoolingPropertiesSimple() throws Exception {
    final Properties dbProperties1 = getOrDefaultDBPoolingProperties("Truth = Beauty", EMPTY);
    assertThat("Beauty", is(dbProperties1.getProperty("Truth")));
    assertThat(1, is(dbProperties1.size()));

    final Properties dbProperties2 = getOrDefaultDBPoolingProperties(" fruits       "
            + "       apple, banana, pear, \\\n" + "       cantaloupe, watermelon, \\\n" + "       kiwi, mango",
            EMPTY);//from   w  w w.  ja  v a2s .  co  m
    assertThat("apple, banana, pear, cantaloupe, watermelon, kiwi, mango",
            is(dbProperties2.getProperty("fruits")));
    assertThat(1, is(dbProperties2.size()));
}

From source file:org.springframework.integration.handler.MethodInvokingMessageProcessorAnnotationTests.java

@Test
public void fromMessageWithPropertiesMethodAndPropertiesPayload() throws Exception {
    Method method = TestService.class.getMethod("propertiesPayload", Properties.class);
    MethodInvokingMessageProcessor processor = new MethodInvokingMessageProcessor(testService, method);
    Properties payload = new Properties();
    payload.setProperty("prop1", "foo");
    payload.setProperty("prop2", "bar");
    Message<Properties> message = MessageBuilder.withPayload(payload).setHeader("prop1", "not")
            .setHeader("prop2", "these").build();
    Properties result = (Properties) processor.processMessage(message);
    assertEquals(2, result.size());
    assertEquals("foo", result.getProperty("prop1"));
    assertEquals("bar", result.getProperty("prop2"));
}

From source file:com.smartitengineering.loadtest.engine.impl.LoadTestEngineImpl.java

private void createTestCaseResult(UnitTestInstance instance) {
    TestCaseResult caseResult = new TestCaseResult();
    caseResult.setName(instance.getName());
    caseResult.setInstanceFactoryClassName(instance.getInstanceFactoryClassName());
    final Properties testProperties = instance.getProperties();
    Set<TestProperty> testPropertySet = new HashSet<TestProperty>(testProperties.size());
    final Iterator<Object> keySetIterator = testProperties.keySet().iterator();
    while (keySetIterator.hasNext()) {
        TestProperty property = new TestProperty();
        final String key = keySetIterator.next().toString();
        property.setKey(key);/*from   ww w  .j a  v a  2 s.co m*/
        property.setValue(testProperties.getProperty(key));
        testPropertySet.add(property);
    }
    caseResult.setTestProperties(testPropertySet);
    caseResult.setTestCaseInstanceResults(new HashSet<TestCaseInstanceResult>());
    UnitTestInstanceRecord record = new UnitTestInstanceRecord(caseResult);
    instanceRecords.put(instance, record);
}

From source file:org.gvnix.service.roo.addon.addon.ws.importt.WSImportOperationsImpl.java

/**
 * Compares the values of two Property instances
 * //from w  w  w  .  j  a v  a  2s  . c o m
 * @param one
 * @param other
 * @return
 */
private boolean propertiesEquals(Properties one, Properties other) {
    if (one.size() != other.size()) {
        return false;
    }
    Set<Entry<Object, Object>> entrySet = one.entrySet();
    Object otherValue;
    for (Entry<Object, Object> entry : entrySet) {
        otherValue = other.get(entry.getKey());
        if (otherValue == null) {
            if (entry.getValue() != null) {
                return false;
            }
        } else if (!otherValue.equals(entry.getValue())) {
            return false;
        }
    }
    return true;
}

From source file:org.springframework.beans.factory.xml.PluggableSchemaResolver.java

/**
 * Load the specified schema mappings lazily.
 *//* w w w .  ja  va 2s. co m*/
private Map<String, String> getSchemaMappings() {
    Map<String, String> schemaMappings = this.schemaMappings;
    if (schemaMappings == null) {
        synchronized (this) {
            schemaMappings = this.schemaMappings;
            if (schemaMappings == null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Loading schema mappings from [" + this.schemaMappingsLocation + "]");
                }
                try {
                    Properties mappings = PropertiesLoaderUtils.loadAllProperties(this.schemaMappingsLocation,
                            this.classLoader);
                    if (logger.isDebugEnabled()) {
                        logger.debug("Loaded schema mappings: " + mappings);
                    }
                    Map<String, String> mappingsToUse = new ConcurrentHashMap<>(mappings.size());
                    CollectionUtils.mergePropertiesIntoMap(mappings, mappingsToUse);
                    schemaMappings = mappingsToUse;
                    this.schemaMappings = schemaMappings;
                } catch (IOException ex) {
                    throw new IllegalStateException("Unable to load schema mappings from location ["
                            + this.schemaMappingsLocation + "]", ex);
                }
            }
        }
    }
    return schemaMappings;
}

From source file:com.netflix.lipstick.Main.java

private static void configureLog4J(Properties properties, PigContext pigContext) {
    // TODO Add a file appender for the logs
    // TODO Need to create a property in the properties file for it.
    // sgroschupf, 25Feb2008: this method will be obsolete with PIG-115.

    String log4jconf = properties.getProperty(LOG4J_CONF);
    String trueString = "true";
    boolean brief = trueString.equalsIgnoreCase(properties.getProperty(BRIEF));
    Level logLevel = Level.INFO;

    String logLevelString = properties.getProperty(DEBUG);
    if (logLevelString != null) {
        logLevel = Level.toLevel(logLevelString, Level.INFO);
    }/*  w w w . j a v  a 2  s . co  m*/

    Properties props = new Properties();
    FileReader propertyReader = null;
    if (log4jconf != null) {
        try {
            propertyReader = new FileReader(log4jconf);
            props.load(propertyReader);
        } catch (IOException e) {
            System.err.println("Warn: Cannot open log4j properties file, use default");
        } finally {
            if (propertyReader != null)
                try {
                    propertyReader.close();
                } catch (Exception e) {
                }
        }
    }
    if (props.size() == 0) {
        props.setProperty("log4j.logger.org.apache.pig", logLevel.toString());
        if ((logLevelString = System.getProperty("pig.logfile.level")) == null) {
            props.setProperty("log4j.rootLogger", "INFO, PIGCONSOLE");
        } else {
            logLevel = Level.toLevel(logLevelString, Level.INFO);
            props.setProperty("log4j.logger.org.apache.pig", logLevel.toString());
            props.setProperty("log4j.rootLogger", "INFO, PIGCONSOLE, F");
            props.setProperty("log4j.appender.F", "org.apache.log4j.RollingFileAppender");
            props.setProperty("log4j.appender.F.File", properties.getProperty("pig.logfile"));
            props.setProperty("log4j.appender.F.layout", "org.apache.log4j.PatternLayout");
            props.setProperty("log4j.appender.F.layout.ConversionPattern",
                    brief ? "%m%n" : "%d [%t] %-5p %c - %m%n");
        }

        props.setProperty("log4j.appender.PIGCONSOLE", "org.apache.log4j.ConsoleAppender");
        props.setProperty("log4j.appender.PIGCONSOLE.target", "System.err");
        props.setProperty("log4j.appender.PIGCONSOLE.layout", "org.apache.log4j.PatternLayout");
        props.setProperty("log4j.appender.PIGCONSOLE.layout.ConversionPattern",
                brief ? "%m%n" : "%d [%t] %-5p %c - %m%n");
    }

    PropertyConfigurator.configure(props);
    logLevel = Logger.getLogger("org.apache.pig").getLevel();
    if (logLevel == null) {
        logLevel = Logger.getLogger("org.apache.pig").getEffectiveLevel();
    }
    Properties backendProps = pigContext.getLog4jProperties();
    backendProps.setProperty("log4j.logger.org.apache.pig", logLevel.toString());
    pigContext.setLog4jProperties(backendProps);
    pigContext.setDefaultLogLevel(logLevel);
}

From source file:org.pentaho.versionchecker.VersionCheckerTest.java

public void testCheckForUpdates() {
    String xmlTest = "<vercheck protocol=\"1.0\"/>"; //$NON-NLS-1$
    IVersionCheckDataProvider dataProvider = new MockDataProvider();
    Properties props = new Properties();
    String output = VersionChecker.checkForUpdates(dataProvider, xmlTest, props, false);
    assertEquals(xmlTest, output);/*w  w  w  .  j av a  2s .co  m*/
    assertEquals(props.size(), 0);

    xmlTest = "<vercheck protocol=\"1.0\">\n" + //$NON-NLS-1$
            "<product id=\"\"><update title=\"\" version=\"\" type=\"\"/></product>\n" + //$NON-NLS-1$
            "</vercheck>"; //$NON-NLS-1$

    output = VersionChecker.checkForUpdates(dataProvider, xmlTest, props, false);
    assertEquals(xmlTest, output);
    assertEquals(props.getProperty("versionchk.prd.1.6.0-RC1.123.update"), "  "); //$NON-NLS-1$ //$NON-NLS-2$

    output = VersionChecker.checkForUpdates(dataProvider, xmlTest, props, true);
    assertEquals(output, "<vercheck protocol=\"1.0\"/>"); //$NON-NLS-1$
    assertEquals(props.getProperty("versionchk.prd.1.6.0-RC1.123.update"), "  "); //$NON-NLS-1$ //$NON-NLS-2$

    xmlTest = "<vercheck protocol=\"1.0\">\n" + //$NON-NLS-1$
            "<product id=\"POBS\">\n" + //$NON-NLS-1$
            "<update title=\"Pentaho BI Suite\" version=\"1.1\" type=\"GA\"/>\n" + //$NON-NLS-1$
            "<update title=\"Pentaho BI Suite\" version=\"1.2\" type=\"GA\"/>\n" + //$NON-NLS-1$
            "</product>\n" + //$NON-NLS-1$
            "</vercheck>"; //$NON-NLS-1$

    props = new Properties();

    output = VersionChecker.checkForUpdates(dataProvider, xmlTest, props, true);
    assertEquals(xmlTest, output);
    assertEquals(props.getProperty("versionchk.prd.1.6.0-RC1.123.update"), //$NON-NLS-1$
            "Pentaho BI Suite 1.1 GA,Pentaho BI Suite 1.2 GA"); //$NON-NLS-1$

    output = VersionChecker.checkForUpdates(dataProvider, xmlTest, props, false);
    assertEquals(xmlTest, output);
    assertEquals(props.getProperty("versionchk.prd.1.6.0-RC1.123.update"), //$NON-NLS-1$
            "Pentaho BI Suite 1.1 GA,Pentaho BI Suite 1.2 GA"); //$NON-NLS-1$

    output = VersionChecker.checkForUpdates(dataProvider, xmlTest, props, true);
    assertEquals(output, "<vercheck protocol=\"1.0\"/>"); //$NON-NLS-1$
    assertEquals(props.getProperty("versionchk.prd.1.6.0-RC1.123.update"), //$NON-NLS-1$
            "Pentaho BI Suite 1.1 GA,Pentaho BI Suite 1.2 GA"); //$NON-NLS-1$

}

From source file:org.springframework.batch.core.jsr.configuration.xml.JsrBeanDefinitionDocumentReaderTests.java

@Test
@SuppressWarnings("resource")
public void testGetJobParameters() {
    Properties jobParameters = new Properties();
    jobParameters.setProperty("jobParameter1", "jobParameter1Value");
    jobParameters.setProperty("jobParameter2", "jobParameter2Value");

    JsrXmlApplicationContext applicationContext = new JsrXmlApplicationContext(jobParameters);
    applicationContext.setValidating(false);
    applicationContext.load(new ClassPathResource("jsrBaseContext.xml"),
            new ClassPathResource("/META-INF/batch.xml"),
            new ClassPathResource("/META-INF/batch-jobs/jsrPropertyPreparseTestJob.xml"));
    applicationContext.refresh();/*from ww  w.ja v  a 2s .c o m*/

    BeanDefinition beanDefinition = applicationContext.getBeanDefinition(JOB_PARAMETERS_BEAN_DEFINITION_NAME);

    Properties processedJobParameters = (Properties) beanDefinition.getConstructorArgumentValues()
            .getGenericArgumentValue(Properties.class).getValue();
    assertNotNull(processedJobParameters);
    assertTrue("Wrong number of job parameters", processedJobParameters.size() == 2);
    assertEquals("jobParameter1Value", processedJobParameters.getProperty("jobParameter1"));
    assertEquals("jobParameter2Value", processedJobParameters.getProperty("jobParameter2"));
}

From source file:algorithm.ImageImageFrameExpanding.java

/**
 * There is another payload file attached, if there is valid restoration
 * metadata.//from  ww w .  ja  v  a  2  s.  c  o m
 * 
 * @param restorationMetadata
 * @return true if another payload file is attached
 */
private boolean payloadAttached(Properties restorationMetadata) {
    return restorationMetadata != null && restorationMetadata.size() > 0;
}