From 0af6a342ded62e499b4028f9fbe34012132ec098 Mon Sep 17 00:00:00 2001 From: Ulrik Sandberg Date: Sat, 15 Mar 2008 21:13:18 +0000 Subject: [PATCH] Added integration tests for binding and looking up raw Java objects. --- .../ldap/LdapTemplateLookupITest.java | 11 ++++------- .../ldap/LdapTemplateObjectBindIntegrationTest.java | 13 ++++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/spring-ldap/src/itest/java/org/springframework/ldap/LdapTemplateLookupITest.java b/spring-ldap/src/itest/java/org/springframework/ldap/LdapTemplateLookupITest.java index 0956506e..e2d9330c 100644 --- a/spring-ldap/src/itest/java/org/springframework/ldap/LdapTemplateLookupITest.java +++ b/spring-ldap/src/itest/java/org/springframework/ldap/LdapTemplateLookupITest.java @@ -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 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 diff --git a/spring-ldap/src/itest/java/org/springframework/ldap/LdapTemplateObjectBindIntegrationTest.java b/spring-ldap/src/itest/java/org/springframework/ldap/LdapTemplateObjectBindIntegrationTest.java index e0f7d030..0674bc1d 100644 --- a/spring-ldap/src/itest/java/org/springframework/ldap/LdapTemplateObjectBindIntegrationTest.java +++ b/spring-ldap/src/itest/java/org/springframework/ldap/LdapTemplateObjectBindIntegrationTest.java @@ -45,18 +45,17 @@ public class LdapTemplateObjectBindIntegrationTest extends AbstractLdapTemplateI assertEquals(54321, result.intValue()); } - @SuppressWarnings("unchecked") public void testBindLinkedList() { - LinkedList list = new LinkedList(); - 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 result = (LinkedList) 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 {