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:hudson.plugins.sonar.utils.PathResolverOperatorTest.java

@Test
public void testResolvePaths() throws IOException, InterruptedException {
    Properties input = new Properties();
    input.put("untouchedKey", "untouchedValue");
    input.put("anotherKey", "anotherValue");
    input.put(SONAR_JAVA_BINARIES_INCLUDE, "lib1,lib2");
    input.put(SONAR_JAVA_BINARIES_EXCLUDE, "lib2");

    Map<String, PathResolver> resolverMap = Maps.newHashMap();
    resolverMap.put(SONAR_JAVA_BINARIES_INCLUDE, new MockAbstractPathResolver("lib1", "lib2"));
    resolverMap.put(SONAR_JAVA_BINARIES_EXCLUDE, new MockAbstractPathResolver("lib2"));
    this.resolverOperator.setResolverMap(resolverMap);

    Properties result = this.resolverOperator.resolvePaths(input);

    assertEquals(4, result.size());
    assertEquals("untouchedValue", result.getProperty("untouchedKey"));
    assertEquals("anotherValue", result.getProperty("anotherKey"));
    assertEquals("lib1", result.getProperty(SONAR_JAVA_BINARIES));
    assertEquals("", result.getProperty(SONAR_JAVA_LIBRARIES));
}

From source file:net.sourceforge.jaulp.lang.ClassUtilsTest.java

/**
 * Test method for.// w ww  . j a v a 2 s .c  om
 *
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 *             {@link net.sourceforge.jaulp.lang.ClassUtils#getResourceAsStream(java.lang.String)}
 *             .
 */
@Test(enabled = true)
public void testGetResourceAsStreamString() throws IOException {
    final String propertiesFilename = "net/sourceforge/jaulp/lang/resources.properties";

    final InputStream is = ClassUtils.getResourceAsStream(propertiesFilename);
    this.result = is != null;
    AssertJUnit.assertTrue("", this.result);
    final Properties prop = new Properties();
    prop.load(is);
    this.result = prop.size() == 3;
}

From source file:com.igormaznitsa.mindmap.model.ModelUtilsTest.java

@Test
public void testExtractQueryParameters() throws Exception {
    final Properties properties = ModelUtils
            .extractQueryPropertiesFromURI(new URI("file://hello?some=test&other=&misc=%26ffsdsd&h=1"));
    assertEquals(4, properties.size());
    assertEquals("test", properties.get("some"));
    assertEquals("", properties.get("other"));
    assertEquals("&ffsdsd", properties.get("misc"));
    assertEquals("1", properties.get("h"));
}

From source file:net.sourceforge.jaulp.lang.ClassUtilsTest.java

/**
 * Test method for {@link net.sourceforge.jaulp.lang.ClassUtils#getResourceAsStream(java.lang.Class, java.lang.String)}.
 *
 * @throws IOException/*  w ww  . j av a2  s  .  c o m*/
 *             Signals that an I/O exception has occurred.
 */
@Test(enabled = false)
public void testGetRessourceAsStream() throws IOException {
    final String propertiesFilename = "resources.properties";
    final String pathFromObject = PackageUtils.getPackagePathWithSlash(this);
    final String path = pathFromObject + propertiesFilename;

    final ClassUtilsTest obj = new ClassUtilsTest();
    final InputStream is = ClassUtils.getResourceAsStream(obj.getClass(), path);
    this.result = is != null;
    AssertJUnit.assertTrue("InputStream should not be null", this.result);
    final Properties prop = new Properties();
    prop.load(is);
    this.result = prop.size() == 3;
    AssertJUnit.assertTrue("Size of prop should be 3.", this.result);
}

From source file:com.tacitknowledge.flip.spring.config.FeatureServiceHandlerParserTest.java

@Test
public void testFeatureServiceFactoryProperties() {
    BeanDefinition beanDefinition = context.getBeanDefinition("featureServiceFactory");

    // Test ContextProviders setup
    PropertyValue contextProvidersProperty = beanDefinition.getPropertyValues()
            .getPropertyValue("contextProviders");
    assertNotNull(contextProvidersProperty);
    assertTrue(contextProvidersProperty.getValue() instanceof List);
    List contextProvidersList = ((List) contextProvidersProperty.getValue());
    assertEquals(2, contextProvidersList.size());

    assertTrue(contextProvidersList.get(0) instanceof BeanDefinitionHolder);
    assertEquals(SystemPropertiesContextProvider.class.getName(),
            ((BeanDefinitionHolder) contextProvidersList.get(0)).getBeanDefinition().getBeanClassName());

    assertTrue(contextProvidersList.get(1) instanceof BeanReference);
    assertEquals("contextProviderBean", ((BeanReference) contextProvidersList.get(1)).getBeanName());

    // Test PropertyReaders setup
    PropertyValue propertyReadersProperty = beanDefinition.getPropertyValues()
            .getPropertyValue("propertyReaders");
    assertNotNull(propertyReadersProperty);
    assertTrue(propertyReadersProperty.getValue() instanceof List);
    List propertyReadersList = ((List) propertyReadersProperty.getValue());
    assertEquals(2, propertyReadersList.size());

    assertTrue(propertyReadersList.get(0) instanceof BeanDefinitionHolder);
    assertEquals(XmlPropertyReader.class.getName(),
            ((BeanDefinitionHolder) propertyReadersList.get(0)).getBeanDefinition().getBeanClassName());

    assertTrue(propertyReadersList.get(1) instanceof BeanReference);
    assertEquals("propertyReaderBean", ((BeanReference) propertyReadersList.get(1)).getBeanName());

    // Test properties setup
    PropertyValue propertiesProperty = beanDefinition.getPropertyValues().getPropertyValue("properties");
    assertNotNull(propertiesProperty);//from w  ww  . j  a v a2 s . com
    assertTrue(propertiesProperty.getValue() instanceof Properties);
    Properties properties = ((Properties) propertiesProperty.getValue());
    assertEquals(1, properties.size());

    for (Map.Entry entry : properties.entrySet()) {
        assertEquals("aa", ((TypedStringValue) entry.getKey()).getValue());
        assertEquals("bb", ((TypedStringValue) entry.getValue()).getValue());
    }
}

From source file:org.gridgain.client.impl.GridClientPropertiesConfigurationSelfTest.java

/**
 * Load properties from the url.//from   w ww  .  jav a  2 s . c  o  m
 *
 * @param expLoaded Expected number of loaded properties.
 * @param url URL to load properties from.
 * @return Loaded properties.
 * @throws IOException In case of IO exception.
 */
private Properties loadProperties(int expLoaded, URL url) throws IOException {
    InputStream in = url.openStream();

    Properties props = new Properties();

    assertEquals(0, props.size());

    props.load(in);

    assertEquals(expLoaded, props.size());

    GridUtils.closeQuiet(in);

    return props;
}

From source file:org.opentides.util.FileUtilTest.java

/**
 * Test method for {@link org.opentides.util.FileUtil#readProperty(java.lang.String)}.
 *//*ww w  . j a  v a 2s.  c o m*/
@Test
public void testReadProperty() {
    Properties props = FileUtil.readProperty(new File("src/test/resources/test.properties"));
    Assert.assertEquals(2, props.size());
    Assert.assertEquals("test", props.get("run.environment"));
    Assert.assertEquals("true", props.get("application.mode.debug"));
}

From source file:org.apache.ignite.internal.client.impl.ClientPropertiesConfigurationSelfTest.java

/**
 * Load properties from the url./*from  w w w .j  a va 2  s .  c o m*/
 *
 * @param expLoaded Expected number of loaded properties.
 * @param url URL to load properties from.
 * @return Loaded properties.
 * @throws IOException In case of IO exception.
 */
private Properties loadProperties(int expLoaded, URL url) throws IOException {
    InputStream in = url.openStream();

    Properties props = new Properties();

    assertEquals(0, props.size());

    props.load(in);

    assertEquals(expLoaded, props.size());

    IgniteUtils.closeQuiet(in);

    return props;
}

From source file:org.apache.roller.weblogger.business.plugins.entry.AcronymsPlugin.java

public String render(WeblogEntry entry, String str) {
    String text = str;/* www  .j  av a 2 s .c  o  m*/

    if (mLogger.isDebugEnabled()) {
        mLogger.debug("render(entry = " + entry.getId() + ")");
    }

    /*
     * Get acronyms Properties.
     */
    Properties acronyms = loadAcronyms(entry.getWebsite());
    mLogger.debug("acronyms.size()=" + acronyms.size());
    if (acronyms.size() == 0) {
        return text;
    }

    /*
     * Compile the user's acronyms into RegEx patterns.
     */
    Pattern[] acronymPatterns = new Pattern[acronyms.size()];
    String[] acronymTags = new String[acronyms.size()];
    int count = 0;
    for (Iterator iter = acronyms.keySet().iterator(); iter.hasNext();) {
        String acronym = (String) iter.next();
        acronymPatterns[count] = Pattern.compile("\\b" + acronym + "\\b");
        mLogger.debug("match '" + acronym + "'");
        acronymTags[count] = "<acronym title=\"" + acronyms.getProperty(acronym) + "\">" + acronym
                + "</acronym>";
        count++;
    }

    // if there are none, no work to do
    if (acronymPatterns == null || acronymPatterns.length == 0) {
        return text;
    }

    return matchAcronyms(text, acronymPatterns, acronymTags);
}