Beispiel #1
0
  @Test
  public void testRenameAndLookup() {
    final LdapName name1 =
        LdapUtils.createLdapName(
            RECORD.getNodeTypeName(), "TestEren3",
            IOC.getNodeTypeName(), "TestEcon2",
            COMPONENT.getNodeTypeName(), "TestEcom2",
            FACILITY.getNodeTypeName(), EFAN_NAME,
            UNIT.getNodeTypeName(), UNIT.getUnitTypeValue());

    final LdapName name2 =
        LdapUtils.createLdapName(
            RECORD.getNodeTypeName(), "NedFlanders",
            IOC.getNodeTypeName(), "TestEcon2",
            COMPONENT.getNodeTypeName(), "TestEcom2",
            FACILITY.getNodeTypeName(), EFAN_NAME,
            UNIT.getNodeTypeName(), UNIT.getUnitTypeValue());

    try {
      LDAP_SERVICE.rename(name1, name2);
      Assert.assertNotNull(LDAP_SERVICE.lookup(name2));
      LDAP_SERVICE.rename(name2, name1);
      Assert.assertNotNull(LDAP_SERVICE.lookup(name1));
    } catch (final NamingException e) {
      Assert.fail("Rename failed");
    }
  }
Beispiel #2
0
  @Test
  public void testAttributeAccess() {
    final LdapName name =
        LdapUtils.createLdapName(
            IOC.getNodeTypeName(),
            "TestEcon2",
            COMPONENT.getNodeTypeName(),
            "TestEcom2",
            FACILITY.getNodeTypeName(),
            EFAN_NAME,
            UNIT.getNodeTypeName(),
            UNIT.getUnitTypeValue());

    try {
      Attributes attrs = LDAP_SERVICE.getAttributes(name);
      Assert.assertNotNull(attrs);
      Attribute attr = attrs.get(ATTR_FIELD_RESPONSIBLE_PERSON);
      Assert.assertNotNull(attr);
      String value = (String) attr.get();
      Assert.assertEquals("*****@*****.**", value);

      ModificationItem[] items =
          new ModificationItem[] {new ModificationItem(DirContext.REMOVE_ATTRIBUTE, attr)};
      LDAP_SERVICE.modifyAttributes(name, items);

      attrs = LDAP_SERVICE.getAttributes(name);
      Assert.assertNotNull(attrs);
      final Attribute attrNull = attrs.get(ATTR_FIELD_RESPONSIBLE_PERSON);
      Assert.assertNull(attrNull);

      items = new ModificationItem[] {new ModificationItem(DirContext.ADD_ATTRIBUTE, attr)};
      LDAP_SERVICE.modifyAttributes(name, items);

      attrs = LDAP_SERVICE.getAttributes(name);
      Assert.assertNotNull(attrs);
      attr = attrs.get(ATTR_FIELD_RESPONSIBLE_PERSON);
      Assert.assertNotNull(attr);
      value = (String) attr.get();
      Assert.assertEquals("*****@*****.**", value);

    } catch (final NamingException e) {
      Assert.fail("Unexpected Exception on attribute modification.");
    }
  }