Added integration tests for binding and looking up raw Java objects.
This commit is contained in:
@@ -18,7 +18,6 @@ package org.springframework.ldap;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.spi.DirObjectFactory;
|
||||
|
||||
import org.springframework.ldap.core.AttributesMapper;
|
||||
import org.springframework.ldap.core.ContextMapper;
|
||||
@@ -199,15 +198,13 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
*/
|
||||
public void testBindJavaObject() throws Exception {
|
||||
AbstractContextSource contextSource = (AbstractContextSource) tested.getContextSource();
|
||||
Class<? extends DirObjectFactory> originalObjectFactory = contextSource.getDirObjectFactory();
|
||||
Class originalObjectFactory = contextSource.getDirObjectFactory();
|
||||
try {
|
||||
contextSource.setDirObjectFactory(null);
|
||||
contextSource.afterPropertiesSet();
|
||||
Integer i = new Integer(54321);
|
||||
tested.bind("cn=myRandomInt", i, null);
|
||||
i = new Integer(12345);
|
||||
i = (Integer) tested.lookup("cn=myRandomInt");
|
||||
assertEquals(54321, i.intValue());
|
||||
tested.bind("cn=myRandomInt", new Integer(54321), null);
|
||||
Integer result = (Integer) tested.lookup("cn=myRandomInt");
|
||||
assertEquals(54321, result.intValue());
|
||||
}
|
||||
finally {
|
||||
// reset the DirObjectFactory so as not to disturb other tests
|
||||
|
||||
@@ -45,18 +45,17 @@ public class LdapTemplateObjectBindIntegrationTest extends AbstractLdapTemplateI
|
||||
assertEquals(54321, result.intValue());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testBindLinkedList() {
|
||||
LinkedList<Integer> list = new LinkedList<Integer>();
|
||||
list.add(54321);
|
||||
list.add(67890);
|
||||
LinkedList list = new LinkedList();
|
||||
list.add(new Integer(54321));
|
||||
list.add(new Integer(67890));
|
||||
|
||||
tested.bind("cn=myRandomList", list, null);
|
||||
|
||||
LinkedList<Integer> result = (LinkedList<Integer>) tested.lookup("cn=myRandomList");
|
||||
LinkedList result = (LinkedList) tested.lookup("cn=myRandomList");
|
||||
assertEquals(2, result.size());
|
||||
assertEquals(54321, result.get(0).intValue());
|
||||
assertEquals(67890, result.get(1).intValue());
|
||||
assertEquals(54321, ((Integer) result.get(0)).intValue());
|
||||
assertEquals(67890, ((Integer) result.get(1)).intValue());
|
||||
}
|
||||
|
||||
public void testBindNonSerializableJavaObjectShouldFail() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user