コード例 #1
0
  @Test
  public void testGetPrimaryEntitiesNegativeStart() {
    LDAPConfiguration ldapCfg = Configuration.getInstance().getLDAPConfiguration();
    ldapCfg.setMapping(LDAPConfiguration.LDAP_MAPPING_ID, "uid");

    LDAPDataProvider dp = new LDAPDataProvider();
    users = dp.getPrimaryEntities(null, null, -1, 5, null);
    assertEquals(5, users.size());
    first = users.get(0);
    last = users.get(users.size() - 1);
    assertEquals("bjensen", first.getId());
    assertEquals("ahall", last.getId());
  }
コード例 #2
0
  @Test
  public void testGetPrimaryEntitiesBiggerPage() {
    LDAPConfiguration ldapCfg = Configuration.getInstance().getLDAPConfiguration();
    ldapCfg.setMapping(LDAPConfiguration.LDAP_MAPPING_ID, "uid");

    LDAPDataProvider dp = new LDAPDataProvider();
    users = dp.getPrimaryEntities(null, null, 0, 20, null);
    assertEquals(12, users.size());
    first = users.get(0);
    last = users.get(users.size() - 1);
    assertEquals("bjensen", first.getId());
    assertEquals("ashelton", last.getId());
  }
コード例 #3
0
  @Test
  public void testFromSearchResultEntry() throws Exception {
    LDAPDataProvider dp = new LDAPDataProvider();
    Configuration cfg = Configuration.getInstance();

    LDAPConnection conn = ldapServer.getConnection();
    SearchResultEntry item =
        conn.searchForEntry(
            cfg.getLDAPConfiguration().getUserBaseDN(), SearchScope.SUB, "uid=bjensen");

    List<Treaty> t =
        new ArrayList<Treaty>() {
          {
            add(Treaty.CMS);
            add(Treaty.AEWA);
          }
        };

    LDAPConfiguration ldap = cfg.getLDAPConfiguration();
    ldap.setMapping(LDAPConfiguration.LDAP_MAPPING_PREFIX, "personalTitle");
    ldap.setMapping(LDAPConfiguration.LDAP_MAPPING_COUNTRY, "c");
    ldap.setMapping(LDAPConfiguration.LDAP_MAPPING_FIRST_NAME, "givenName");
    ldap.setMapping(LDAPConfiguration.LDAP_MAPPING_LAST_NAME, "sn");
    ldap.setMapping(
        LDAPConfiguration.LDAP_MAPPING_ADDRESS, "Address: ${registeredAddress} ${postalCode}");
    ldap.setMapping(LDAPConfiguration.LDAP_MAPPING_DEPARTMENT, "ou");
    ldap.setMapping(LDAPConfiguration.LDAP_MAPPING_EMAIL, "mail");
    ldap.setMapping(LDAPConfiguration.LDAP_MAPPING_FAX, "facsimileTelephoneNumber");
    ldap.setMapping(LDAPConfiguration.LDAP_MAPPING_INSTITUTION, "o");
    ldap.setMapping(LDAPConfiguration.LDAP_MAPPING_PHONE, "telephoneNumber");
    ldap.setMapping(LDAPConfiguration.LDAP_MAPPING_POSITION, "title");
    ldap.setMapping(LDAPConfiguration.LDAP_MAPPING_UPDATED, "roomNumber");
    ldap.setMapping(LDAPConfiguration.LDAP_MAPPING_TREATIES, "carLicense");
    cfg.save();

    IContact c = dp.fromSearchResultEntry(item);

    assertEquals("Address: 5th Avenue, NY 12345", c.getAddress());
    assertEquals("bjensen", c.getId());
    assertEquals("RO", c.getCountry());
    assertEquals("Software Development", c.getDepartment());
    assertEquals("*****@*****.**", c.getEmail());
    assertEquals("+1 408 555 1992", c.getFax());
    assertEquals("Barbara", c.getFirstName());
    assertEquals("Eau de Web", c.getInstitution());
    assertEquals("Jensen", c.getLastName());
    assertEquals("+1 408 555 1862", c.getPhoneNumber());
    assertEquals("Web Developer", c.getPosition());
    assertEquals("H.E.", c.getPrefix());
    assertEquals(new Short((short) 1), c.getProtocolVersion());
    assertEquals(t, c.getTreaties());

    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+2"));
    cal.set(2006, 11, 25, 16, 45, 22);
    cal.set(Calendar.MILLISECOND, 0);
    Date d = cal.getTime();
    Date updated = c.getUpdated();
    assertEquals(updated, d);
  }
コード例 #4
0
  @Test
  public void testGetPrimaryEntitiesMaxPageSize() {
    Configuration cfg = Configuration.getInstance();
    LDAPConfiguration ldapCfg = Configuration.getInstance().getLDAPConfiguration();
    ldapCfg.setMapping(LDAPConfiguration.LDAP_MAPPING_ID, "uid");
    ldapCfg.setMaxPageSize(8);

    LDAPDataProvider dp = new LDAPDataProvider();
    users = dp.getPrimaryEntities(null, null, 0, 10000, null);
    assertEquals(8, users.size());
    first = users.get(0);
    last = users.get(users.size() - 1);
    assertEquals("bjensen", first.getId());
    assertEquals("ajensen", last.getId());
    // Reset to default
    cfg.getLDAPConfiguration().setMaxPageSize(0);
  }
コード例 #5
0
  @Test
  public void testGetPrimaryEntitiesNegativePageSize() {
    Configuration cfg = Configuration.getInstance();
    LDAPConfiguration ldapCfg = cfg.getLDAPConfiguration();
    ldapCfg.setMaxPageSize(5);
    ldapCfg.setMapping(LDAPConfiguration.LDAP_MAPPING_ID, "uid");

    LDAPDataProvider dp = new LDAPDataProvider();
    users = dp.getPrimaryEntities(null, null, 10, -1, null);
    assertEquals(2, users.size());
    first = users.get(0);
    last = users.get(users.size() - 1);
    assertEquals("alutz", first.getId());
    assertEquals("ashelton", last.getId());
    // Reset to default
    cfg.getLDAPConfiguration().setMaxPageSize(0);
  }
コード例 #6
0
  @Test
  public void testGetPrimaryEntity() {
    Configuration cfg = Configuration.getInstance();
    LDAPConfiguration ldap = cfg.getLDAPConfiguration();
    ldap.setMapping(LDAPConfiguration.LDAP_MAPPING_ID, "uid");

    LDAPDataProvider dp = new LDAPDataProvider();
    IContact row = (IContact) dp.getPrimaryEntity(null, "bjensen");
    assertNotNull(row);
    assertEquals("bjensen", row.getId());
  }