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.ldp4j.server.utils.spring.MonitorizedPropertyPlaceholderConfigurerTest.java

@Test
public void testMergeProperties$show() throws Exception {
    MonitorizedPropertyPlaceholderConfigurer sut = new MonitorizedPropertyPlaceholderConfigurer();
    sut.setModuleName("module");
    sut.setIgnoreResourceNotFound(true);
    sut.setLocations(this.locations);
    System.setProperty(MonitorizedPropertyPlaceholderConfigurer.LDP4J_CONFIG_DUMP, Boolean.TRUE.toString());
    System.setProperty(MonitorizedPropertyPlaceholderConfigurer.LDP4J_CONFIG_MODULES, "modules, module");
    Properties mergeProperties = sut.mergeProperties();
    assertThat(mergeProperties.size(), is(4));
}

From source file:org.codehaus.cargo.container.jonas.Jonas4xInstalledLocalContainerTest.java

/**
 * Test system properties.//from   ww  w  .j  a v a 2  s .c  o  m
 */
public void testSetupSysProps() {
    JvmLauncherStub java = new JvmLauncherStub();
    container.setupSysProps(java);

    Properties props = java.getSystemProperties();
    assertEquals(16, props.size());
    assertTrue(props.getProperty("install.root").endsWith("ram:/jonasroot"));
    assertTrue(props.getProperty("jonas.base").endsWith("ram:/jonasbase"));
    assertTrue(props.getProperty("java.endorsed.dirs")
            .endsWith(fileHandler.append("ram:/jonasroot", "lib/endorsed")));
    assertTrue(props.getProperty("java.security.policy")
            .endsWith(fileHandler.append("ram:/jonasbase", "conf/java.policy")));
    assertTrue(props.getProperty("java.security.auth.login.config")
            .endsWith(fileHandler.append("ram:/jonasbase", "conf/jaas.config")));
}

From source file:org.codehaus.cargo.container.jonas.Jonas5xInstalledLocalContainerTest.java

/**
 * Test system properties./* ww  w . j  a va 2  s . c o m*/
 */
public void testSetupSysProps() {
    JvmLauncherStub java = new JvmLauncherStub();
    container.setupSysProps(java);

    Properties props = java.getSystemProperties();
    assertEquals(12, props.size());
    assertTrue(props.getProperty("install.root").endsWith("ram:/jonasroot"));
    assertTrue(props.getProperty("jonas.base").endsWith("ram:/jonasbase"));
    assertTrue(props.getProperty("java.endorsed.dirs")
            .endsWith(fileHandler.append("ram:/jonasroot", "lib/endorsed")));
    assertTrue(props.getProperty("java.security.policy")
            .endsWith(fileHandler.append("ram:/jonasbase", "conf/java.policy")));
    assertTrue(props.getProperty("java.security.auth.login.config")
            .endsWith(fileHandler.append("ram:/jonasbase", "conf/jaas.config")));
}

From source file:pt.webdetails.browserid.spring.authorities.DomainWhitelistAuthoritiesService.java

/**
 * /*from   w w  w.j av  a 2 s . c  om*/
 * @param properties entries in the form <domain>=<roleName>[,&ltroleName>]* 
 */
public void setDomainMap(Properties properties) {
    Map<String, GrantedAuthority[]> domainMap = new HashMap<String, GrantedAuthority[]>(properties.size());
    for (Entry<Object, Object> entry : properties.entrySet()) {

        String domain = (String) entry.getKey();
        String authoritiesAsText = (String) entry.getValue();

        //parse authorities, may return empty
        String[] roles = StringUtils.commaDelimitedListToStringArray(authoritiesAsText);
        GrantedAuthority[] authorities = new GrantedAuthority[roles.length];
        int i = 0;
        for (String role : roles) {
            authorities[i++] = new GrantedAuthorityImpl(role);
        }

        domainMap.put(domain, authorities);

    }
    this.domainMap = domainMap;
}

From source file:edu.monash.merc.system.config.SystemPropertyConfigurator.java

@Override
protected void processProperties(ConfigurableListableBeanFactory confListBeanFactory, Properties props)
        throws BeansException {
    Map<String, String> tmpProps = new HashMap<String, String>(props.size());
    super.processProperties(confListBeanFactory, props);
    for (Map.Entry<Object, Object> entry : props.entrySet()) {
        tmpProps.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue()));
    }//from   w w w.  ja  v  a 2s . co m
    this.resolvedProps = Collections.unmodifiableMap(tmpProps);
}

From source file:org.imsglobal.basiclti.consumersecret.impl.PropertiesConsumerSecretServiceImpl.java

public List<OauthConsumerSecret> searchOauthConsumerSecrets() {
    Properties properties = getPropertiesInternal();
    List<OauthConsumerSecret> rv = new ArrayList<OauthConsumerSecret>(properties.size());
    for (Entry<Object, Object> entry : properties.entrySet()) {
        String consumerSecret = ObjectUtils.toString(entry.getValue());
        String consumerKey = ObjectUtils.toString(entry.getKey());
        if (StringUtils.isNotEmpty(consumerKey) && StringUtils.isNotEmpty(consumerSecret)) {
            rv.add(new OauthConsumerSecret(consumerKey, consumerSecret));
        }/*from w w w.  j  a v  a2 s  .  c  o m*/
    }
    return rv;
}

From source file:org.codice.ddf.admin.insecure.defaults.service.UsersPropertiesFileValidator.java

@Override
public List<Alert> validate() {
    resetAlerts();/*from w ww .  ja  v  a2s .c o m*/
    Properties properties = readFile(false);

    if (properties != null && properties.size() > 0) {
        validateAdminUser(properties);
        validateCertificateUser(properties);
    }

    for (Alert alert : alerts) {
        LOGGER.debug("Alert: {}, {}", alert.getLevel(), alert.getMessage());
    }

    return alerts;
}

From source file:org.nuxeo.runtime.deployment.preprocessor.install.commands.AppendCommandTest.java

@Test
public void testProperties() throws Exception {
    File dest = tmp.newFile("dst.properties");
    File src = tmp.newFile("src1.properties");

    FileUtils.writeStringToFile(dest, "key1=value1");
    FileUtils.writeStringToFile(src, "key2=value2");
    append(src, dest);//from  w  ww  .  jav a2s  .c om

    Properties props = new Properties();
    props.load(new FileReader(dest));
    assertEquals(2, props.size());
}

From source file:net.padlocksoftware.padlock.tools.LicenseValidator.java

public String validate() {
    Date currentDate = new Date();

    Validator v = new Validator(license, new String(Hex.encodeHex(pair.getPublic().getEncoded())));
    v.setIgnoreFloatTime(true);//w  w  w  . j a v  a 2 s . c  o m

    LicenseState state;
    try {
        state = v.validate();
    } catch (ValidatorException e) {
        state = e.getLicenseState();
    }

    StringBuilder builder = new StringBuilder();

    // Show test status
    builder.append("\nValidation Test Results:\n");
    builder.append("========================\n\n");
    for (TestResult result : state.getTests()) {
        builder.append(
                "\t" + result.getTest().getName() + "\t\t\t" + (result.passed() ? "Passed" : "Failed") + "\n");
    }

    builder.append("\nLicense state: " + (state.isValid() ? "Valid" : "Invalid" + "\n"));

    //
    // Cycle through any dates
    //
    Date d = license.getCreationDate();
    builder.append("\nCreation date: \t\t" + d + "\n");

    d = license.getStartDate();
    builder.append("Start date: \t\t" + d + "\n");

    d = license.getExpirationDate();
    builder.append("Expiration date: \t" + d + "\n");

    Long floatPeroid = license.getFloatingExpirationPeriod();
    if (floatPeroid != null) {
        long seconds = floatPeroid / 1000L;
        builder.append("\nExpire after first run: " + seconds + " seconds\n");

    }

    if (floatPeroid != null || license.getExpirationDate() != null) {
        long remaining = v.getTimeRemaining(currentDate) / 1000L;
        builder.append("\nTime remaining: " + remaining + " seconds\n");
    }

    //
    // License properties
    //
    builder.append("\nLicense Properties\n");
    Properties p = license.getProperties();
    if (p.size() == 0) {
        builder.append("None\n");
    }

    for (final Enumeration propNames = p.propertyNames(); propNames.hasMoreElements();) {
        final String key = (String) propNames.nextElement();
        builder.append("Property: " + key + " = " + p.getProperty(key) + "\n");
    }

    //
    // Hardware locking
    //
    for (String address : license.getHardwareAddresses()) {
        builder.append("\nHardware lock: " + address + "\n");
    }
    builder.append("\n");

    return builder.toString();
}

From source file:cn.vlabs.duckling.vwb.service.config.impl.ContainerConfig.java

@Override
public void setProperty(Properties props) {
    if (props != null && props.size() != 0) {
        m_globalProps.setProperty(GLOBAL_SITE_ID, props);
        writeToFile(props);//w  w w .j av a  2s  . c om
    }

}