protected void setUp() throws Exception { super.setUp(); apacheDs = (ApacheDs) lookup(ApacheDs.ROLE); Partition partition = new Partition(); partition.setName("test"); partition.setSuffix("dc=test"); partition.getContextAttributes().put(new BasicAttribute("objectClass", "top")); apacheDs.addPartition(partition); apacheDs.startServer(); }
public void testBasic() throws Exception { LdapFactoryHelper helper = (LdapFactoryHelper) lookup(LdapFactoryHelper.ROLE); PersonLdapFactory.setHelper(helper); InitialDirContext context = apacheDs.getAdminContext(); context.addToEnvironment(Context.OBJECT_FACTORIES, PersonLdapFactory.class.getName()); context.addToEnvironment(Context.STATE_FACTORIES, PersonLdapFactory.class.getName()); LdapName name = new LdapName("uid=trygvis,dc=test"); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- try { context.unbind(name); } catch (NamingException e) { // ignore } Person person = new Person(); person.setName("Trygve"); context.bind(name, person); Object o = context.lookup(name); assertEquals(Person.class, o.getClass()); person = (Person) o; assertEquals("Trygve", person.getName()); assertEquals(null, person.getDescription()); context.close(); }
protected void tearDown() throws Exception { apacheDs.stopServer(); }