示例#1
0
  @Test
  public void testAllParseUserFieldTypes() throws IOException, JDOMException {
    final StringBuffer configXml = new StringBuffer();
    configXml.append("<config>");
    configXml.append("  <user-fields>");
    for (final UserFieldType type : UserFieldType.values()) {
      configXml.append("    <" + type.getName() + "/>");
    }
    configXml.append("  </user-fields>");
    configXml.append("</config>");
    final Element configEl = JDOMUtil.parseDocument(configXml.toString()).getRootElement();

    final UserStoreConfig config = UserStoreConfigParser.parse(configEl);

    assertNotNull(config);
    assertNotNull(config.getUserFieldConfigs());
    assertEquals(UserFieldType.values().length, config.getUserFieldConfigs().size());

    /* Verify unique types */
    final Set<UserFieldType> userFields = new HashSet<UserFieldType>();
    for (final UserStoreUserFieldConfig userFieldConfig : config.getUserFieldConfigs()) {
      userFields.add(userFieldConfig.getType());
    }
    assertEquals(UserFieldType.values().length, userFields.size());
  }
示例#2
0
  @Test
  public void testParseRequiredFlag() throws IOException, JDOMException {
    final StringBuffer configXml = new StringBuffer();
    configXml.append("<config>");
    configXml.append("  <user-fields>");
    configXml.append("    <first-name required='true' />");
    configXml.append("    <initials required='false' />");
    configXml.append("    <birthday/>");
    configXml.append("  </user-fields>");
    configXml.append("</config>");
    final Element configEl = JDOMUtil.parseDocument(configXml.toString()).getRootElement();

    final UserStoreConfig config = UserStoreConfigParser.parse(configEl);

    final Collection<UserStoreUserFieldConfig> allUserFieldConfigs = config.getUserFieldConfigs();

    for (final UserStoreUserFieldConfig userFieldConfig : allUserFieldConfigs) {
      if (userFieldConfig.getType().getName().equals("first-name")) {
        assertEquals(true, userFieldConfig.isRequired());
      } else if (userFieldConfig.getType().getName().equals("initials")) {
        assertEquals(false, userFieldConfig.isRequired());
      } else if (userFieldConfig.getType().getName().equals("birthday")) {
        assertEquals(false, userFieldConfig.isRequired());
      }
    }
  }
示例#3
0
  @Test
  public void testParseIsoFlag() throws IOException, JDOMException {
    final StringBuffer configXml = new StringBuffer();
    configXml.append("<config>");
    configXml.append("  <user-fields>");
    configXml.append("    <address iso='true' />");
    configXml.append("  </user-fields>");
    configXml.append("</config>");
    final Element configEl = JDOMUtil.parseDocument(configXml.toString()).getRootElement();

    final UserStoreConfig config = UserStoreConfigParser.parse(configEl);

    final Collection<UserStoreUserFieldConfig> allUserFieldConfigs = config.getUserFieldConfigs();

    for (final UserStoreUserFieldConfig userFieldConfig : allUserFieldConfigs) {
      if (userFieldConfig.getType().getName().equals("address")) {
        assertEquals(true, userFieldConfig.useIso());
      }
    }
  }