diff --git a/spring-ldap-odm/build.xml b/spring-ldap-odm/build.xml
index 3fcce091..41210221 100644
--- a/spring-ldap-odm/build.xml
+++ b/spring-ldap-odm/build.xml
@@ -1,95 +1,95 @@
-
-
-
+ *
* LdapTypeConverter is responsible for the conversion of LDAP attributes returned in String form - * to native java types and vice versa. It it leverages Spring's property editors, with + * to native java types and vice versa. It it leverages Spring's property editors, with * some custom editors to: *java.util.Date.org.springframework.ldap.core.DistinguishedName.
* + *
* Additional custom editors may be created at runtime to if an Object Directory Map * contains references to other mapped objects (eg. A role of type Role.class containing * references to members of type Person.class) - * + * * - * */ public class LdapTypeConverter extends SimpleTypeConverter { - private static final DateFormat GENERALIZED_TIME = new SimpleDateFormat("yyyyMMddHHmmss.S"); + + private static final DateFormat GENERALIZED_TIME + = new SimpleDateFormat("yyyyMMddHHmmss.SSSZ"); public LdapTypeConverter() { diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/package.html b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/package.html index 47855aae..ee513d29 100644 --- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/package.html +++ b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/package.html @@ -1,7 +1,8 @@ -Provides a realization of the Data Access Object (DAO) pattern using object directory mapping. +Provides a realization of the Data Access Object (DAO) pattern using LDAP +object directory mapping. diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMap.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMap.java index ef858c62..4607a118 100644 --- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMap.java +++ b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMap.java @@ -30,7 +30,9 @@ public interface ObjectDirectoryMap /** The set of bean property names in the Object Directory Map. */ SetClass that the Object Directory Map corresponds to. */
+ /** The Class that the Object Directory Map represents. That is,
+ * LDAP entries will be serialized to and from this class.
+ */
Class getClazz();
/** The name of the attribute corresponding to the first element in a distinguished
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/util/package.html b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/util/package.html
index 2d452367..f2fc2b22 100644
--- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/util/package.html
+++ b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/util/package.html
@@ -1,7 +1,7 @@
-Contains utility classes.
+Utility classes.
\ No newline at end of file
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/LdapTypeConverterTest.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/LdapTypeConverterTest.java
index 0979e4a0..3600116b 100644
--- a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/LdapTypeConverterTest.java
+++ b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/LdapTypeConverterTest.java
@@ -19,8 +19,8 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
+import java.util.Calendar;
-//TODO: There's probably a lot of redundant tests in here
public class LdapTypeConverterTest extends TestCase
{
private static final Log LOGGER = LogFactory.getLog(LdapTypeConverterTest.class);
@@ -120,17 +120,15 @@ public class LdapTypeConverterTest extends TestCase
}
}
- public void testConvertToGeneralizedTime() throws ParseException
+ public void testConvertToDate() throws ParseException
{
- String object1 = "20061005093637.44";
- DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss.S");
- Date expected = df.parse("20061005093637.44");
+ String object1 = "19700101100000.000+1000";
try
{
Object translated = typeConverter.convertIfNecessary(object1,
Date.class);
- Assert.assertEquals(translated, expected,
+ Assert.assertEquals(translated, new Date(0L),
"Unexpected translated value");
}
catch (TypeMismatchException e)
@@ -141,41 +139,44 @@ public class LdapTypeConverterTest extends TestCase
public void testConvertFromDate()
{
- Date source = new Date(1184283822285L); //Friday July 13, 2007 9:43:42 AM
- Assert.assertEquals(typeConverter.getAsText(source), "20070713094342.285");
+ Date source = new Date(1184283822285L); //Friday July 13, 2007 9:43:42 AM GMT+1000
+ LOGGER.debug(typeConverter.getAsText(source));
+
+ Assert.assertTrue(typeConverter.getAsText(source)
+ .matches("20070713\\d\\d\\d\\d42.285\\+\\d\\d\\d\\d"));
}
- public void testConvertToGeneralizedTimeArray() throws ParseException
+ public void testConvertToDateArray() throws ParseException
{
- String object1 = "20071105093655.44";
- String object2 = "20061005093637.44";
+ String object1 = "20071105093655.0+1000";
+ String object2 = "19700101100000.0+1000";
Object objectToTranslate = new String[]{object1, object2};
- DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss.S");
- Date expected = df.parse("20061005093637.44");
-
try
{
Object[] translated = (Object[]) typeConverter.convertIfNecessary(
objectToTranslate, Date[].class);
- Assert.assertEquals(translated[1], expected,
+ Assert.assertEquals(translated[1], new Date(0L),
"Unexpected translated value");
}
catch (TypeMismatchException e)
{
+ e.printStackTrace();
Assert.fail("Unexpected exception during translation");
+
}
}
+
public void testConvertFromDateArray()
{
- Date date1 = new Date(1184283822285L); //Friday July 13, 2007 9:43:42 AM
- Date date2 = new Date(0); //epoch
+ Date date1 = new Date(1184283822285L); //Friday July 13, 2007 9:43:42 AM + GMT+1000
+ Date date2 = new Date(0); //epoch + GMT + 1000
Date[] dates = new Date[]{date1, date2};
String[] converted = typeConverter.getAllAsText(dates);
- Assert.assertEquals(converted[0], "20070713094342.285");
- Assert.assertEquals(converted[1], "19700101100000.0");
+ Assert.assertTrue(converted[0].matches("20070713\\d\\d\\d\\d42.285\\+\\d\\d\\d\\d"));
+ Assert.assertTrue(converted[1].matches("19700101\\d\\d\\d\\d00.000\\+\\d\\d\\d\\d"));
}
public void testConvertToLdapName()
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperImplTest.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperImplTest.java
index 9a29cafd..9cf54399 100644
--- a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperImplTest.java
+++ b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperImplTest.java
@@ -150,7 +150,8 @@ public class ObjectDirectoryMapperImplTest extends TestCase
Assert.assertEquals("bean@bean.com", ctxAdapter.getStringAttribute("mail"));
Assert.assertEquals("fred", new String((byte[]) ctxAdapter.getObjectAttribute("userpassword")));
Assert.assertEquals("false", ctxAdapter.getStringAttribute("acceptemails"));
- Assert.assertEquals("19700101100000.1", ctxAdapter.getStringAttribute("loginresettime"));
+ Assert.assertTrue(ctxAdapter.getStringAttribute("loginresettime")
+ .matches("19700101\\d\\d\\d\\d00.001\\+\\d\\d\\d\\d"));
Assert.assertEquals("3", ctxAdapter.getStringAttribute("failedlogins"));
Assert.assertEquals("uid=amAdmin, ou=people, dc=myretsu, dc=com",
ctxAdapter.getStringAttribute("creatorname"));