public LdapTestsSetup() {
    String confFile = System.getenv("LDAP_TESTER_PROPERTIES_FILE");
    if (confFile == null) {
      confFile = "ldap.integ/ldap-test.properties";
    }

    try {
      testProperties = new PropertiesConfiguration(confFile);

      Configuration usersSubset = testProperties.subset("users");
      HierarchicalConfiguration usersConfig = ConfigurationUtils.convertToHierarchical(usersSubset);
      List<ConfigurationNode> childrens = usersConfig.getRootNode().getChildren();
      for (ConfigurationNode node : childrens) {
        String name = node.getName();
        users.put(name, new Person(usersSubset.subset(name)));
      }

      Configuration groupsSubset = testProperties.subset("groups");
      HierarchicalConfiguration groupsConfig =
          ConfigurationUtils.convertToHierarchical(groupsSubset);
      childrens = groupsConfig.getRootNode().getChildren();
      for (ConfigurationNode node : childrens) {
        String name = node.getName();
        groups.put(name, new Group(groupsSubset.subset(name)));
      }

      Configuration ldapConfigurationSubset = testProperties.subset("configuration");
      HierarchicalConfiguration ldapConfig =
          ConfigurationUtils.convertToHierarchical(ldapConfigurationSubset);
      childrens = ldapConfig.getRootNode().getChildren();
      for (ConfigurationNode node : childrens) {
        String key = node.getName();
        String value = (String) node.getValue();
        ldapConfiguration.put(key, value);
      }
    } catch (ConfigurationException ex) {
      String message = "Problem loading configuration: " + ex.getMessage();
      log.error(message);
      throw new IllegalStateException(message);
    }
  }
Example #2
0
  @Test
  public void testPropertiesConfiguration() {
    DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
    try {
      System.out.println(builder.getConfigurationBasePath());
      System.out.println(
          FileSystem.getDefaultFileSystem().getFileName("pss-settings.properties").toString());
      URL locate =
          ConfigurationUtils.locate(
              "E:/study/jelyworkspace/jelypss/pss-core/target/test-classes/conf",
              "pss-settings.properties");
      builder.load(locate);
      Configuration config = builder.getConfiguration();
      config.setProperty("1123", "asdf");

    } catch (ConfigurationException e) {
      e.printStackTrace();
    }
  }