From 2c72b14706758dca4829205b2d5d7416a276d8e2 Mon Sep 17 00:00:00 2001
From: Ulrik Sandberg The NamingAttribute annotation identifies the name of the attribute that forms
+ * NamingAttribute annotation identifies the name of the attribute that forms
* the first part of a Distinguished Name. For example, in the Distinguished Name
- * 'uid=x232, ou=people' the naming attribute is 'uid'. The NamingAttribute together
- * with a NamingSuffix tell the Object Directory Mapper how to serialize a java object
- * to and from an LDAP repository.
- * Example: @NamingAttribute("uid")
+ * 'uid=x232, ou=people' the naming attribute is 'uid'.
The NamingAttribute together with a {@link NamingSuffix} tell the
+ * {@link org.springframework.ldap.odm.mapping.ObjectDirectoryMapper} how to assemble a
+ * Distinguished Name for an object.
Example:
@NamingAttribute("uid")
*
* @see NamingSuffix
*/
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/annotations/NamingSuffix.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/annotations/NamingSuffix.java
index c4547493..357989c8 100644
--- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/annotations/NamingSuffix.java
+++ b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/annotations/NamingSuffix.java
@@ -17,6 +17,10 @@ import java.lang.annotation.Target;
* @NamingSuffix({"ou=people", "dc=example", "dc=com"})
* will be persisted under the branch 'com/example/people' in the LDAP repository.
*
+ * The NamingSuffix together with a {@link NamingAttribute} tell the
+ * {@link org.springframework.ldap.odm.mapping.ObjectDirectoryMapper} how to assemble a
+ * Distinguished Name for an object.
java.util.Date.javax.naming.ldap.LdapName or
- * org.springframework.ldap.core.DistinguishedName.LdapName.class for String <--> LdapName and
- * DistinguishedName.class for String <--> DistinguishedName
- */
- public NameEditor(Class conversionClass)
- {
- this.conversionClass = conversionClass;
- if (!conversionClass.equals(DistinguishedName.class) && !conversionClass.equals(LdapName.class))
- {
- throw new IllegalArgumentException(
- "NameEditor can only be created for LdapName or DistinguishedName");
- }
- }
-
- /**
- * Invokes toString() on the LdapName or DistinguishedName
- */
- public String getAsText()
- {
- Object value = conversionClass.cast(getValue());
- return value != null ? value.toString() : "";
- }
-
- /**
- * Attempts to parse and String and return an LdapName or DistinguishedName
- */
- public void setAsText(String text) throws IllegalArgumentException
- {
- try
- {
- setValue(conversionClass.getConstructor(String.class).newInstance(text));
- }
- catch (Exception e)
- {
- throw new IllegalArgumentException(e.getMessage(), e);
- }
- }
-}
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/attributetypes/ReferencedEntryEditor.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/attributetypes/ReferencedEntryEditor.java
deleted file mode 100644
index b76b8f22..00000000
--- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/attributetypes/ReferencedEntryEditor.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2006 by Majitek. All Rights Reserved.
- *
- * This software is the proprietary information of Majitek. Use is subject to license terms.
- */
-package org.springframework.ldap.odm.attributetypes;
-
-import org.springframework.ldap.core.LdapTemplate;
-import org.springframework.ldap.core.DistinguishedName;
-import org.springframework.ldap.odm.mapping.MappingException;
-import org.springframework.ldap.odm.mapping.ObjectDirectoryMapper;
-
-import java.beans.PropertyEditorSupport;
-
-/** ReferencedEntryEditor is responsible for converting references in an object
- * directory map from distinguished name strings to the target type and vice versa.
- */
-public class ReferencedEntryEditor extends PropertyEditorSupport
-{
- private DistinguishedName base;
- private LdapTemplate ldapTemplate;
- private ObjectDirectoryMapper objectDirectoryMapper;
-
- public ReferencedEntryEditor(DistinguishedName baseDn,
- LdapTemplate ldapTemplate,
- ObjectDirectoryMapper objectDirectoryMapper)
- {
- this.base = baseDn;
- this.ldapTemplate = ldapTemplate;
- this.objectDirectoryMapper = objectDirectoryMapper;
- }
-
- /** Builds a distinguished name from the instance value */
- public String getAsText()
- {
- try
- {
- DistinguishedName value = (DistinguishedName) base.clone();
- value.append((DistinguishedName) objectDirectoryMapper.buildDn(getValue()));
- return value.toString();
- }
- catch (MappingException e)
- {
- throw new RuntimeException(e.getMessage(), e);
- }
- }
-
- /** Sets the value of the editor by performing a lookup and mapping the result
- * to the target type using an object directory mapper.
- * @param text The distinguished name of an ldap entry.
- * @throws IllegalArgumentException
- */
- public void setAsText(String text) throws IllegalArgumentException
- {
- DistinguishedName dn = new DistinguishedName(text);
- if (dn.startsWith(base))
- {
- for (int i = 0; i < base.size(); i++)
- {
- dn.removeFirst();
- }
- }
- setValue(ldapTemplate.lookup(dn, objectDirectoryMapper));
- }
-}
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/attributetypes/ReferencedEntryEditorFactory.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/attributetypes/ReferencedEntryEditorFactory.java
deleted file mode 100644
index 0705af31..00000000
--- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/attributetypes/ReferencedEntryEditorFactory.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2006 by Majitek. All Rights Reserved.
- *
- * This software is the proprietary information of Majitek. Use is subject to license terms.
- */
-package org.springframework.ldap.odm.attributetypes;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.ldap.core.DistinguishedName;
-import org.springframework.ldap.core.LdapTemplate;
-import org.springframework.ldap.odm.mapping.MappingException;
-import org.springframework.ldap.odm.mapping.ObjectDirectoryMapper;
-import org.springframework.ldap.odm.mapping.ObjectDirectoryMapperFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * ReferencedEntryEditorFactory is a factory for assembling ReferencedEntryEditors.
- *
- * @see ReferencedEntryEditor
- */
-public class ReferencedEntryEditorFactory
-{
- private static final Log LOGGER = LogFactory.getLog(ReferencedEntryEditorFactory.class);
- private String base;
- private ObjectDirectoryMapperFactory odmFactory;
- private LdapTemplate ldapTemplate;
- private MapMappingException is thrown.
- *
- * @param clazz the type to build a ReferencedEntryEditor for.
- * @return A ReferencedEntryEditor for the given type.
- *
- */
- public ReferencedEntryEditor referencedEntryEditorForClass(Class clazz)
- throws MappingException
- {
- if (referencedEntryEditors.containsKey(clazz))
- {
- LOGGER.debug("Returning cached referenced entry editor for class: " + clazz.getSimpleName());
- return referencedEntryEditors.get(clazz);
- }
- else
- {
- LOGGER.debug("Attempting to create a referenced entry editor for class: "
- + clazz.getSimpleName());
-
- ObjectDirectoryMapper odm = odmFactory.objectDirectoryMapperForClass(clazz);
- ReferencedEntryEditor referencedEntryEditor =
- new ReferencedEntryEditor(new DistinguishedName(base), ldapTemplate, odm);
- referencedEntryEditors.put(clazz, referencedEntryEditor);
- return referencedEntryEditor;
- }
- }
-
- /**
- * @param mapperFactory the ObjectDirectoryMapperFactory to use when attempting
- * to build a ReferencedEntryEditor.
- */
- public void setObjectDirectoryMapperFactory(ObjectDirectoryMapperFactory
- mapperFactory)
- {
- this.odmFactory = mapperFactory;
- }
-}
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/attributetypes/ValidConversionType.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/attributetypes/ValidConversionType.java
deleted file mode 100644
index 87478fe3..00000000
--- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/attributetypes/ValidConversionType.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2006 by Majitek. All Rights Reserved.
- *
- * This software is the proprietary information of Majitek. Use is subject to license terms.
- */
-package org.springframework.ldap.odm.attributetypes;
-
-import org.springframework.ldap.core.DistinguishedName;
-
-import javax.naming.ldap.LdapName;
-import java.util.Date;
-
-
-/** This list of types supported for mapping between ldap attributes and bean properties. */
-public enum ValidConversionType
-{
- BYTE_ARRAY(byte[].class),
- BOOLEAN(Boolean.class),
- STRING(String.class),
- STRING_ARRAY(String[].class),
- DATE(Date.class),
- DATE_ARRAY(Date[].class),
- LDAP_NAME(LdapName.class),
- LDAP_NAME_ARRAY(LdapName[].class),
- DISTINGUISHED_NAME(DistinguishedName.class),
- DISTINGUISHED_NAME_ARRAY(DistinguishedName[].class),
- INTEGER(Integer.class),
- INTEGER_ARRAY(Integer[].class),
- LONG(Long.class),
- LONG_ARRAY(Long[].class);
-
- private final Class clazz;
-
-
- ValidConversionType(Class validType)
- {
- this.clazz = validType;
-
- }
-
- /** Returns the enumeration of types as a human-friendly string. */
- public static String listTypes()
- {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < ValidConversionType.values().length; i++)
- {
- ValidConversionType validType = ValidConversionType.values()[i];
- sb.append("\n");
- sb.append(validType.clazz.getSimpleName());
- if (i != ValidConversionType.values().length - 1)
- {
- sb.append(",");
- }
- }
- return sb.toString();
- }
-
- /** Returns true if the argument is a member of this enumeration. */
- public static boolean isValidConversionType(Class returnType)
- {
- for (ValidConversionType type : ValidConversionType.values())
- {
- if (returnType.equals(type.clazz))
- {
- return true;
- }
- }
- return false;
- }
-
-
-
-}
-
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/attributetypes/package.html b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/attributetypes/package.html
deleted file mode 100644
index 38316f67..00000000
--- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/attributetypes/package.html
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-Contains support classes used to assemble an LdapDao implementation.
-
-
-
\ No newline at end of file
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/DaoException.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/DaoException.java
index a38705a6..3073b724 100644
--- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/DaoException.java
+++ b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/DaoException.java
@@ -6,7 +6,7 @@
package org.springframework.ldap.odm.dao;
/**
- * Thrown by LdapDao under exceptional circumstances.
+ * Thrown by {@link LdapDao} under exceptional circumstances.
*
* @see LdapDao
*/
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/LdapDao.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/LdapDao.java
index 44ba682c..aab596e8 100644
--- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/LdapDao.java
+++ b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/LdapDao.java
@@ -8,7 +8,11 @@ package org.springframework.ldap.odm.dao;
import javax.naming.Name;
import java.util.List;
-/** A realization of the Data Access Object (DAO) pattern using object directory mapping. */
+/** A realization of the Data Access Object (DAO) pattern using object directory mapping.
+ *
+ * @see org.springframework.ldap.odm.mapping.ObjectDirectoryMap
+ * @see org.springframework.ldap.odm.mapping.ObjectDirectoryMapper
+ */
public interface LdapDao
{
/** Persists the mapped object dirObject in the LDAP repository. */
@@ -39,5 +43,5 @@ public interface LdapDao
List findAll(Class ofType);
/** Search for entries in the repository and map results to class returnType. */
- List filterByBeanProperty(String value, String beanPropertyName, Class returnType);
+ List filterByBeanProperty(String beanPropertyName, String value, Class returnType);
}
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/LdapDaoImpl.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/LdapDaoImpl.java
index 53b3725c..3d08f4f8 100644
--- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/LdapDaoImpl.java
+++ b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/dao/LdapDaoImpl.java
@@ -13,6 +13,7 @@ import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.odm.mapping.MappingException;
import org.springframework.ldap.odm.mapping.ObjectDirectoryMapper;
import org.springframework.ldap.odm.mapping.ObjectDirectoryMapperFactory;
+import org.springframework.util.StringUtils;
import javax.naming.Name;
import java.util.List;
@@ -136,14 +137,16 @@ public class LdapDaoImpl implements LdapDao
}
- public List filterByBeanProperty(String value, String beanPropertyName, Class returnType)
+ public List filterByBeanProperty(String beanPropertyName, String value, Class returnType)
{
try
{
LOGGER.debug("Filtering on property: " + beanPropertyName + ", for value: " + value);
ObjectDirectoryMapper mapper = odmFactory.objectDirectoryMapperForClass(returnType);
- String filter = mapper.getObjectDirectoryMap().attributeNameFor(beanPropertyName) + "=" + value;
- List results = ldapTemplate.search(mapper.getObjectDirectoryMap().getNamingSuffix().toString(), filter, mapper);
+ String filter = mapper.getObjectDirectoryMap().attributeNameFor(beanPropertyName)
+ + "=" + value;
+ List results = ldapTemplate.search(mapper.getObjectDirectoryMap().getNamingSuffix().toString(),
+ filter, mapper);
LOGGER.debug(results.size() + " results found for filter: " + filter);
return results;
}
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/AbstractObjectDirectoryMap.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/AbstractObjectDirectoryMap.java
index 002900a3..b18064a0 100644
--- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/AbstractObjectDirectoryMap.java
+++ b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/AbstractObjectDirectoryMap.java
@@ -15,7 +15,7 @@ import java.util.Map;
import java.util.Set;
/**
- * An abstract base class implementing an ObjectDirectoryMap. Actual parsing of
+ * An abstract base class implementing an {@link ObjectDirectoryMap}. Actual parsing of
* mapping information needs to be implemented in a concrete sub class.
*/
public abstract class AbstractObjectDirectoryMap implements ObjectDirectoryMap
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/AnnotationObjectDirectoryMap.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/AnnotationObjectDirectoryMap.java
index 90d3bc20..2d22ed4b 100644
--- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/AnnotationObjectDirectoryMap.java
+++ b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/AnnotationObjectDirectoryMap.java
@@ -10,17 +10,17 @@ import org.springframework.ldap.odm.annotations.DirAttribute;
import org.springframework.ldap.odm.annotations.NamingAttribute;
import org.springframework.ldap.odm.annotations.NamingSuffix;
import org.springframework.ldap.odm.annotations.ObjectClasses;
-import org.springframework.util.StringUtils;
import java.lang.reflect.Field;
-/** An implementation of an ObjectDirectoryMap based on Annotations. A class that is
+/**
+ * An implementation of an {@link ObjectDirectoryMap} based on Annotations. A class that is
* to be serialized to and from and LDAP repository must include the following annotations:
* ObjectDirectoryMap encapsulates the information required to serialize a java bean
- * to and from an LDAP repository. An ObjectDirectoryMapper performs the
- * serialization using this information.
+ * Encapsulates the information required to serialize a java object to and from an LDAP repository.
+ * An {@link ObjectDirectoryMapper} performs the serialization using this information.
*
* @see ObjectDirectoryMapper
*/
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapper.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapper.java
index cc373f1e..ef6a67c7 100644
--- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapper.java
+++ b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapper.java
@@ -11,27 +11,46 @@ import org.springframework.ldap.core.ContextMapper;
import javax.naming.Name;
-/** An ObjectDirectoryMapper performs serialization between java beans and and
- * an LDAP repository using the information in an ObjectDirectoryMap.
+/**
+ * Performs serialization between java objects and and an LDAP repository using the information
+ * in an {@link ObjectDirectoryMap}.
*
- * @see ObjectDirectoryMap
+ * @see ObjectDirectoryMap
*/
public interface ObjectDirectoryMapper extends ContextMapper, ContextAssembler
{
- /** Map the supplied object to the specified context. */
+ /**
+ * Map the supplied object to the specified context, using the associated
+ * {@link ObjectDirectoryMap}.
+ */
Object mapFromContext(Object ctx);
- /** Map a single LDAP Context to an object. */
+ /**
+ * Map a single LDAP Context to an object using the associated {@link ObjectDirectoryMap}.
+ */
void mapToContext(Object beanInstance, Object ctx);
- /** Builds a DistinguishedName from an object instance. */
+ /**
+ * Builds a Distinguished Name from an object instance. Looks up the Naming Attribute and
+ * Naming Suffix from the {@link ObjectDirectoryMap}. Populates the Naming Attribute value
+ * with value on the beanInstance.
+ *
+ * @throws MappingException if the naming attribute value on the beanInstance is null.
+ */
Name buildDn(Object beanInstance) throws MappingException;
- /** Builds a DistinguishedName given the value of the naming attribute. */
+ /**
+ * Builds a Distinguished Name from the given namingAttributeValue.
+ * Looks up the Naming Attribute and Naming Suffix from the {@link ObjectDirectoryMap}.
+ * Populates the Naming Attribute value with the given value.
+ *
+ * @throws MappingException if the given value is null.
+ */
Name buildDn(String namingAttributeValue) throws MappingException;
- /** Returns the ObjectDirectoryMap that the ObjectDirectoryMapper
- * corresponds to.
+ /**
+ * Returns the {@link ObjectDirectoryMap} associated with the given instance of the
+ * ObjectDirectoryMapper.
*/
ObjectDirectoryMap getObjectDirectoryMap();
}
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperFactory.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperFactory.java
index 621e3a96..bd733e73 100644
--- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperFactory.java
+++ b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperFactory.java
@@ -7,20 +7,20 @@ package org.springframework.ldap.odm.mapping;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.springframework.ldap.odm.attributetypes.LdapTypeConverter;
-import org.springframework.ldap.odm.attributetypes.ReferencedEntryEditorFactory;
+import org.springframework.ldap.odm.typeconversion.LdapTypeConverter;
+import org.springframework.ldap.odm.typeconversion.ReferencedEntryEditorFactory;
import java.util.HashMap;
import java.util.Map;
/**
- * ObjectDirectoryMapperFactory is a factory for assembling
- * ObjectDirectoryMappers. It builds a registry of ObjectDirectoryMappers, such
- * that the first request for a mapper of a given type results in the attempt to build one.
- * Subsequent requests result in the return of a cached instance.
+ * A factory for assembling {@link ObjectDirectoryMapper ObjectDirectoryMappers}.
+ * It builds a registry such that the first request for an {@link ObjectDirectoryMapper}
+ * of a given type results in the attempt to build one. Subsequent requests return a
+ * cached instance.
*
* @see ObjectDirectoryMapper
- * @see org.springframework.ldap.odm.attributetypes.ReferencedEntryEditorFactory
+ * @see org.springframework.ldap.odm.typeconversion.ReferencedEntryEditorFactory
*/
public class ObjectDirectoryMapperFactory
{
@@ -38,11 +38,11 @@ public class ObjectDirectoryMapperFactory
this.referencedEntryEditorFactory.setObjectDirectoryMapperFactory(this);
}
- /** Attempts to return an ObjectDirectoryMapper for the given class. Upon the first encounter
- * of the given class, mapping is attempted. If mapping is successful the mapper is returned.
- * Subsequent requests for the given class return a cached mapper.
+ /** Attempts to return an {@link ObjectDirectoryMapper} for the given class. Upon the
+ * first encounter of the given class, mapping is attempted. If mapping is successful
+ * the mapper is returned. Subsequent requests for same class return a cached mapper.
* @param clazz
- * @return ObjectDirectoryMapper
+ * @return An {@link ObjectDirectoryMapper} for the Class clazz
* @throws MappingException when the mapping information for the given class contains errors.
*/
public ObjectDirectoryMapper objectDirectoryMapperForClass(Class clazz)
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperImpl.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperImpl.java
index bc94d88b..1ac218d7 100644
--- a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperImpl.java
+++ b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperImpl.java
@@ -11,10 +11,11 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.TypeMismatchException;
import org.springframework.ldap.core.DirContextAdapter;
import org.springframework.ldap.core.DistinguishedName;
-import org.springframework.ldap.odm.attributetypes.LdapTypeConverter;
-import org.springframework.ldap.odm.attributetypes.ReferencedEntryEditorFactory;
-import org.springframework.ldap.odm.attributetypes.ValidConversionType;
+import org.springframework.ldap.odm.typeconversion.LdapTypeConverter;
+import org.springframework.ldap.odm.typeconversion.ReferencedEntryEditorFactory;
+import org.springframework.ldap.odm.typeconversion.ValidConversionType;
import org.springframework.ldap.odm.util.AttributeWrapper;
+import org.springframework.util.StringUtils;
import javax.naming.Name;
import javax.naming.directory.Attribute;
@@ -23,7 +24,7 @@ import java.util.HashMap;
import java.util.Map;
/**
- * An implemtation of the ObjectDirectoryMapper interface.
+ * An implemtation of the {@link ObjectDirectoryMapper} interface.
*/
public class ObjectDirectoryMapperImpl implements ObjectDirectoryMapper
{
@@ -184,9 +185,10 @@ public class ObjectDirectoryMapperImpl implements ObjectDirectoryMapper
{
try
{
- Method getter = clazz.getMethod("get" + beanPropertyName);
+ String methodSuffix = StringUtils.capitalize(beanPropertyName);
+ Method getter = clazz.getMethod("get" + methodSuffix);
propertyGetters.put(beanPropertyName, getter);
- Method setter = clazz.getMethod("set" + beanPropertyName, getter.getReturnType());
+ Method setter = clazz.getMethod("set" + methodSuffix, getter.getReturnType());
propertySetters.put(beanPropertyName, setter);
}
catch (NoSuchMethodException e)
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/typeconversion/LdapTypeConverter.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/typeconversion/LdapTypeConverter.java
new file mode 100644
index 00000000..e69de29b
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/typeconversion/NameEditor.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/typeconversion/NameEditor.java
new file mode 100644
index 00000000..e69de29b
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/typeconversion/ReferencedEntryEditor.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/typeconversion/ReferencedEntryEditor.java
new file mode 100644
index 00000000..e69de29b
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/typeconversion/ReferencedEntryEditorFactory.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/typeconversion/ReferencedEntryEditorFactory.java
new file mode 100644
index 00000000..e69de29b
diff --git a/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/typeconversion/ValidConversionType.java b/spring-ldap-odm/src/main/java/org/springframework/ldap/odm/typeconversion/ValidConversionType.java
new file mode 100644
index 00000000..e69de29b
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
deleted file mode 100644
index 3600116b..00000000
--- a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/LdapTypeConverterTest.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * Copyright 2006 by Majitek. All Rights Reserved.
- *
- * This software is the proprietary information of Majitek. Use is subject to license terms.
- */
-package org.springframework.ldap.odm.attributetypes;
-
-import junit.framework.TestCase;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.TypeMismatchException;
-import org.springframework.ldap.core.DistinguishedName;
-import org.testng.Assert;
-
-import javax.naming.InvalidNameException;
-import javax.naming.ldap.LdapName;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Calendar;
-
-public class LdapTypeConverterTest extends TestCase
-{
- private static final Log LOGGER = LogFactory.getLog(LdapTypeConverterTest.class);
-
- private LdapTypeConverter typeConverter;
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- typeConverter = new LdapTypeConverter();
- }
-
- public void testConvertToByteArray()
- {
- byte[] objectToTranslate = "fred".getBytes();
-
- try
- {
- byte[] translated = (byte[]) typeConverter.convertIfNecessary(
- objectToTranslate, byte[].class);
- Assert.assertTrue(Arrays.equals(objectToTranslate, translated),
- "byte[] attributes should pass through unchanged.");
- }
- catch (TypeMismatchException e)
- {
- Assert.fail("Unexpected exception: byte[] attributes should pass through unchanged.",
- e);
- }
- }
-
- public void testConvertToBoolean()
- {
- String objectToTranslate = "true";
- try
- {
- Object translated = typeConverter.convertIfNecessary(
- objectToTranslate, Boolean.class);
- Assert
- .assertEquals(true, translated,
- "Unexpected translated value");
- }
- catch (TypeMismatchException e)
- {
- Assert.fail("Unexpected exception during translation", e);
- }
- }
-
- public void testConvertFromBoolean()
- {
- boolean objectToTranslate = false;
- try
- {
- Object translated = typeConverter.getAsText(objectToTranslate);
- Assert.assertEquals(translated, "false",
- "Unexpected translated value");
- }
- catch (TypeMismatchException e)
- {
- Assert.fail("Unexpected exception during translation", e);
- }
- }
-
- public void testConvertToString()
- {
- String objectToTranslate = "onetwothree";
- try
- {
- Object translated = typeConverter.convertIfNecessary(
- objectToTranslate, String.class);
- Assert.assertEquals("onetwothree", translated,
- "Unexpected translated value");
- }
- catch (TypeMismatchException e)
- {
- Assert.fail("Unexpected exception during translation", e);
- }
- }
-
- public void testConvertToStringArray()
- {
- String object1 = "onetwothree";
- String object2 = "fourfivesix";
- String object3 = "seveneightnine";
- Object objectToTranslate = new String[]{object1, object2, object3};
-
- try
- {
- Object[] translated = (Object[]) typeConverter.convertIfNecessary(
- objectToTranslate, String[].class);
- Assert.assertEquals("fourfivesix", translated[1],
- "Unexpected translated value");
- }
- catch (TypeMismatchException e)
- {
- Assert.fail("Unexpected exception during translation", e);
- }
- }
-
- public void testConvertToDate() throws ParseException
- {
- String object1 = "19700101100000.000+1000";
-
- try
- {
- Object translated = typeConverter.convertIfNecessary(object1,
- Date.class);
- Assert.assertEquals(translated, new Date(0L),
- "Unexpected translated value");
- }
- catch (TypeMismatchException e)
- {
- Assert.fail("Unexpected exception during translation", e);
- }
- }
-
- public void testConvertFromDate()
- {
- 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 testConvertToDateArray() throws ParseException
- {
- String object1 = "20071105093655.0+1000";
- String object2 = "19700101100000.0+1000";
- Object objectToTranslate = new String[]{object1, object2};
-
- try
- {
- Object[] translated = (Object[]) typeConverter.convertIfNecessary(
- objectToTranslate, Date[].class);
- 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 + GMT+1000
- Date date2 = new Date(0); //epoch + GMT + 1000
-
- Date[] dates = new Date[]{date1, date2};
- String[] converted = typeConverter.getAllAsText(dates);
- 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()
- {
- String object1 = "uid=amAdmin, ou = people, dc = myretsu,dc=com";
- try
- {
- Object translated = typeConverter.convertIfNecessary(object1,
- LdapName.class);
- Assert.assertEquals(translated, new LdapName(object1),
- "Unexpected translated value");
- }
- catch (TypeMismatchException e)
- {
- Assert.fail("Unexpected exception during translation", e);
- }
- catch (InvalidNameException e)
- {
- Assert.fail("Problem with test: Ldap name can't be parsed.", e);
- }
- }
-
- public void testConvertToLdapNameArray()
- {
- String object1 = "uid=amAdmin, ou = people, dc = myretsu,dc=com";
- String object2 = "uid=fred, ou = people, dc = myretsu,dc=com";
- Object objectToTranslate = new String[]{object1, object2};
-
- try
- {
- Object[] translated = (Object[]) typeConverter.convertIfNecessary(
- objectToTranslate, LdapName[].class);
- Assert.assertEquals(new LdapName(object2), translated[1],
- "Unexpected translated value");
- }
- catch (TypeMismatchException e)
- {
- Assert.fail("Unexpected exception during translation", e);
- }
- catch (InvalidNameException e)
- {
- Assert.fail("Problem with test: Ldap name can't be parsed.", e);
- }
- }
-
- public void testConvertToDistinguishedName()
- {
- String object1 = "uid=amAdmin, ou = people, dc = myretsu,dc=com";
- try
- {
- Object translated = typeConverter.convertIfNecessary(object1,
- DistinguishedName.class);
- Assert.assertEquals(new DistinguishedName(object1), translated,
- "Unexpected translated value");
- }
- catch (TypeMismatchException e)
- {
- Assert.fail("Unexpected exception during translation", e);
- }
- }
-
- public void testConvertToDistinguishedNameArray()
- {
- String object1 = "uid=amAdmin, ou = people, dc = myretsu,dc=com";
- String object2 = "uid=fred, ou = people, dc = myretsu,dc=com";
- Object objectToTranslate = new String[]{object1, object2};
-
- try
- {
- Object[] translated = (Object[]) typeConverter.convertIfNecessary(
- objectToTranslate, DistinguishedName[].class);
- Assert.assertEquals(new DistinguishedName(object2), translated[1],
- "Unexpected translated value");
- }
- catch (TypeMismatchException e)
- {
- Assert.fail("Unexpected exception during translation", e);
- }
- }
-
- public void testConvertToLong()
- {
- String object1 = "9887342";
- try
- {
- Object translated = typeConverter.convertIfNecessary(object1,
- Long.class);
- Assert.assertEquals(9887342L, translated,
- "Unexpected translated value");
- }
- catch (TypeMismatchException e)
- {
- Assert.fail("Unexpected exception during translation", e);
- }
- }
-
- public void testConvertToLongArray()
- {
- String object1 = "878787";
- String object2 = "23948787";
- Object objectToTranslate = new String[]{object1, object2};
-
- try
- {
- Object[] translated = (Object[]) typeConverter.convertIfNecessary(
- objectToTranslate, Long[].class);
- Assert.assertEquals(23948787L, translated[1],
- "Unexpected translated value");
- }
- catch (TypeMismatchException e)
- {
- Assert.fail("Unexpected exception during translation", e);
- }
- }
-
- public void testConvertToInteger()
- {
- String object1 = "9887342";
-
- try
- {
- Object translated = typeConverter.convertIfNecessary(object1,
- Integer.class);
- Assert.assertEquals(9887342, translated,
- "Unexpected translated value");
- }
- catch (TypeMismatchException e)
- {
- Assert.fail("Unexpected exception during translation", e);
- }
- }
-
- public void testConvertToIntegerArray()
- {
- String object1 = "878787";
- String object2 = "23948787";
- Object objectToTranslate = new String[]{object1, object2};
-
- try
- {
- Object[] translated = (Object[]) typeConverter.convertIfNecessary(
- objectToTranslate, Integer[].class);
- Assert.assertEquals(23948787, translated[1],
- "Unexpected translated value");
- }
- catch (TypeMismatchException e)
- {
- Assert.fail("Unexpected exception during translation", e);
- }
- }
-
- public void testThrowsTypeMismatchExceptionWhenTypeTranslationFails()
- {
- String object1 = "asdlkjkalkjl";
-
- Object[] translated;
- try
- {
- translated = (Object[]) typeConverter.convertIfNecessary(object1,
- LdapName.class);
- Assert.fail("Should've thrown exception");
- }
- catch (TypeMismatchException e)
- {
- // Pass
- }
- }
-
- public void testGetAsTextReturnsStringsUnchanged()
- {
- String string = "onetwothree123";
- Assert.assertEquals(typeConverter.getAsText(string), "onetwothree123");
- }
-
- public void testGetAsTextReturnsNullWhenNoPropertyEditorRegistered()
- {
- Assert.assertNull(typeConverter.getAsText(new Foo("fooString")));
- }
-
- //Something there'll definitely be no property editor registered for
- private class Foo
- {
- private String fooString;
-
- public Foo(String fooString)
- {
- this.fooString = fooString;
- }
- }
-
-}
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/NameEditorTest.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/NameEditorTest.java
deleted file mode 100644
index 899b8631..00000000
--- a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/NameEditorTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2005 by Majitek. All Rights Reserved.
- *
- * This software is the proprietary information of Majitek. Use is subject to license terms.
- */
-
-package org.springframework.ldap.odm.attributetypes;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.springframework.ldap.core.DistinguishedName;
-
-public class NameEditorTest extends TestCase
-{
-
- public void testThrowsExceptionWhenConstructorArgumentNotAName()
- {
- try
- {
- NameEditor nameEditor = new NameEditor(String.class);
- fail("Should've thrown exception.");
- }
- catch (IllegalArgumentException e)
- {
- Assert.assertEquals(e.getMessage(),
- "NameEditor can only be created for LdapName or DistinguishedName");
- }
- }
-
- public void testGetAsText()
- {
- NameEditor editor = new NameEditor(DistinguishedName.class);
- DistinguishedName name = new DistinguishedName("uid=zzz, ou=people");
- editor.setValue(name);
- Assert.assertEquals(editor.getAsText(), "uid=zzz, ou=people");
-
- editor.setValue(null);
- Assert.assertEquals(editor.getAsText(), "");
- }
-
- public void testSetAsText()
- {
- NameEditor editor = new NameEditor(DistinguishedName.class);
- editor.setAsText("uid=zzz, ou=people");
- DistinguishedName expected = new DistinguishedName("uid=zzz, ou=people");
- Assert.assertEquals(editor.getValue(), expected);
-
-
- }
-
-
-}
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/ReferencedEntryEditorFactoryTest.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/ReferencedEntryEditorFactoryTest.java
deleted file mode 100644
index e500e5a0..00000000
--- a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/ReferencedEntryEditorFactoryTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2005 by Majitek. All Rights Reserved.
- *
- * This software is the proprietary information of Majitek. Use is subject to license terms.
- */
-
-package org.springframework.ldap.odm.attributetypes;
-
-import junit.framework.TestCase;
-import org.easymock.classextension.EasyMock;
-import org.springframework.ldap.core.LdapTemplate;
-import org.springframework.ldap.odm.mapping.MappingException;
-import org.springframework.ldap.odm.mapping.ObjectDirectoryMapper;
-import org.springframework.ldap.odm.mapping.ObjectDirectoryMapperFactory;
-
-
-public class ReferencedEntryEditorFactoryTest extends TestCase
-{
- private LdapTemplate ldapTemplate;
- private ObjectDirectoryMapperFactory odmFactory;
- private ObjectDirectoryMapper odm;
- private ReferencedEntryEditorFactory editorFactory;
-
- protected void setUp() throws Exception
- {
- super.setUp();
- ldapTemplate = EasyMock.createStrictMock(LdapTemplate.class);
- odmFactory = EasyMock.createStrictMock(ObjectDirectoryMapperFactory.class);
- odm = EasyMock.createStrictMock(ObjectDirectoryMapper.class);
- editorFactory = new ReferencedEntryEditorFactory(null, ldapTemplate);
- editorFactory.setObjectDirectoryMapperFactory(odmFactory);
- }
-
- /**
- * Asserts that a referenced entry editor is created, after successful mapping of
- * the referenced entity.
- *
- * @throws MappingException
- *
- */
- public void testReferencedEditorForClass_successfulMapping()
- throws MappingException
- {
- EasyMock.expect(odmFactory.objectDirectoryMapperForClass(TestReferencedEntry.class)).andReturn(odm);
- replayMocks();
-
- try
- {
- editorFactory.referencedEntryEditorForClass(TestReferencedEntry.class);
- //second call to return cached editor, verified by the fact that objectDirectoryMapperForClass
- //is only called once.
- editorFactory.referencedEntryEditorForClass(TestReferencedEntry.class);
- }
- catch (MappingException e)
- {
- fail();
- }
- verifyMocks();
- }
-
-
- /**
- * Asserts that an exception is thrown when the referenced entity cannot be mapped
- *
- * @throws org.springframework.ldap.odm.mapping.MappingException
- *
- *
- */
- public void testReferencedEditorForClass_unsuccessfulMapping()
- throws MappingException
- {
- ReferencedEntryEditorFactory editorFactory =
- new ReferencedEntryEditorFactory(null, ldapTemplate);
- editorFactory.setObjectDirectoryMapperFactory(odmFactory);
-
- EasyMock.expect(odmFactory.objectDirectoryMapperForClass(TestReferencedEntry.class))
- .andThrow(new MappingException("unsuccessful mapping"));
-
- replayMocks();
-
- try
- {
- editorFactory.referencedEntryEditorForClass(TestReferencedEntry.class);
- fail("Should've thrown exception");
- }
- catch (MappingException e)
- {
- //expected behaviour
- }
-
- verifyMocks();
- }
-
- private void verifyMocks()
- {
- EasyMock.verify(ldapTemplate);
- EasyMock.verify(odmFactory);
- EasyMock.verify(odm);
- }
-
- private void replayMocks()
- {
- EasyMock.replay(ldapTemplate);
- EasyMock.replay(odmFactory);
- EasyMock.replay(odm);
- }
-
-
-}
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/ReferencedEntryEditorTest.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/ReferencedEntryEditorTest.java
deleted file mode 100644
index f8f6ae62..00000000
--- a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/ReferencedEntryEditorTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2005 by Majitek. All Rights Reserved.
- *
- * This software is the proprietary information of Majitek. Use is subject to license terms.
- */
-
-package org.springframework.ldap.odm.attributetypes;
-
-import junit.framework.TestCase;
-import org.easymock.classextension.EasyMock;
-import org.springframework.ldap.core.DistinguishedName;
-import org.springframework.ldap.core.LdapTemplate;
-import org.springframework.ldap.odm.mapping.MappingException;
-import org.springframework.ldap.odm.mapping.ObjectDirectoryMapper;
-
-import javax.naming.InvalidNameException;
-import javax.naming.ldap.LdapName;
-
-public class ReferencedEntryEditorTest extends TestCase
-{
- private LdapTemplate ldapTemplate;
- private ObjectDirectoryMapper objectDirectoryMapper;
- private ReferencedEntryEditor editor;
-
- protected void setUp() throws Exception
- {
- super.setUp();
- ldapTemplate = EasyMock.createStrictMock(LdapTemplate.class);
- objectDirectoryMapper = EasyMock.createStrictMock(ObjectDirectoryMapper.class);
- editor = new ReferencedEntryEditor(new DistinguishedName("dc=example, dc=com"),
- ldapTemplate, objectDirectoryMapper);
- }
-
- public void testGetAsText() throws MappingException
- {
- TestReferencedEntry referencedEntry = new TestReferencedEntry();
- editor.setValue(referencedEntry);
-
- EasyMock.expect(objectDirectoryMapper.buildDn(referencedEntry))
- .andReturn(new DistinguishedName("uid=referencedEntry, ou=foobars"));
-
- replayMocks();
- editor.getAsText();
- verifyMocks();
- }
-
- public void testGetAsTextThrowsRuntimeExceptionWhenMappingExceptionOccurs()
- throws MappingException
- {
- TestReferencedEntry referencedEntry = new TestReferencedEntry();
- editor.setValue(referencedEntry);
-
- EasyMock.expect(objectDirectoryMapper.buildDn(referencedEntry))
- .andThrow(new MappingException("no mapper"));
-
- replayMocks();
- try
- {
- editor.getAsText();
- fail("Should've propogated mapping exception.");
- }
- catch (RuntimeException e)
- {
- //expected
- }
-
- verifyMocks();
- }
-
- public void testSetAsText()
- {
- DistinguishedName referenceName =
- new DistinguishedName("uid = referencedEntry, ou=foobars");
- TestReferencedEntry referencedEntry = new TestReferencedEntry();
-
- EasyMock.expect(ldapTemplate.lookup(referenceName, objectDirectoryMapper))
- .andReturn(referencedEntry);
-
- replayMocks();
- editor.setAsText("uid = referencedEntry, ou=foobars");
-
- verifyMocks();
- }
-
- public void testSetAsTextRemovingBaseDn()
- {
- DistinguishedName referenceName =
- new DistinguishedName("uid = referencedEntry, ou=foobars");
- TestReferencedEntry referencedEntry = new TestReferencedEntry();
-
-
- EasyMock.expect(ldapTemplate.lookup(referenceName, objectDirectoryMapper))
- .andReturn(referencedEntry);
-
- replayMocks();
- editor.setAsText("uid = referencedEntry, ou=foobars, dc=example, dc=com");
- verifyMocks();
- }
-
- private void verifyMocks()
- {
- EasyMock.verify(ldapTemplate);
- EasyMock.verify(objectDirectoryMapper);
- }
-
- private void replayMocks()
- {
- EasyMock.replay(ldapTemplate);
- EasyMock.replay(objectDirectoryMapper);
- }
-
-
-}
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/TestReferencedEntry.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/TestReferencedEntry.java
deleted file mode 100644
index 7469c2be..00000000
--- a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/TestReferencedEntry.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2005 by Majitek. All Rights Reserved.
- *
- * This software is the proprietary information of Majitek. Use is subject to license terms.
- */
-
-package org.springframework.ldap.odm.attributetypes;
-
-import org.springframework.ldap.odm.annotations.DirAttribute;
-import org.springframework.ldap.odm.annotations.NamingAttribute;
-import org.springframework.ldap.odm.annotations.NamingSuffix;
-import org.springframework.ldap.odm.annotations.ObjectClasses;
-
-@NamingAttribute("cn")
-@NamingSuffix({"ou = people", "dc = example", "dc=com"})
-@ObjectClasses({"top", "person", "organizationalPerson", "inetorgperson"})
-public class TestReferencedEntry
-{
- @DirAttribute("cn")
- private String name;
-
- @DirAttribute("addr")
- private String address;
-
- @DirAttribute("mail")
- private String mail;
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public String getAddress()
- {
- return address;
- }
-
- public void setAddress(String address)
- {
- this.address = address;
- }
-
- public String getMail()
- {
- return mail;
- }
-
- public void setMail(String mail)
- {
- this.mail = mail;
- }
-}
\ No newline at end of file
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/ValidConversionTypeTest.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/ValidConversionTypeTest.java
deleted file mode 100644
index 744ee3cc..00000000
--- a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/attributetypes/ValidConversionTypeTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2005 by Majitek. All Rights Reserved.
- *
- * This software is the proprietary information of Majitek. Use is subject to license terms.
- */
-
-package org.springframework.ldap.odm.attributetypes;
-
-import junit.framework.TestCase;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.ldap.core.DistinguishedName;
-import org.testng.Assert;
-
-import javax.naming.ldap.LdapName;
-import java.util.Date;
-import java.util.List;
-
-public class ValidConversionTypeTest extends TestCase
-{
- private static final Log LOGGER = LogFactory.getLog(ValidConversionTypeTest.class);
-
- public void testListTypes()
- {
- LOGGER.debug(ValidConversionType.listTypes());
- }
-
- public void testIsValidConversionType()
- {
- Assert.assertFalse(ValidConversionType.isValidConversionType(List.class));
-
- Assert.assertTrue(ValidConversionType.isValidConversionType(byte[].class));
- Assert.assertTrue(ValidConversionType.isValidConversionType(Boolean.class));
- Assert.assertTrue(ValidConversionType.isValidConversionType(String.class));
- Assert.assertTrue(ValidConversionType.isValidConversionType(String[].class));
- Assert.assertTrue(ValidConversionType.isValidConversionType(Date.class));
- Assert.assertTrue(ValidConversionType.isValidConversionType(Date[].class));
- Assert.assertTrue(ValidConversionType.isValidConversionType(LdapName.class));
- Assert.assertTrue(ValidConversionType.isValidConversionType(LdapName[].class));
- Assert.assertTrue(ValidConversionType.isValidConversionType(DistinguishedName.class));
- Assert.assertTrue(ValidConversionType.isValidConversionType(DistinguishedName[].class));
- Assert.assertTrue(ValidConversionType.isValidConversionType(Integer.class));
- Assert.assertTrue(ValidConversionType.isValidConversionType(Integer[].class));
- Assert.assertTrue(ValidConversionType.isValidConversionType(Long.class));
- Assert.assertTrue(ValidConversionType.isValidConversionType(Long[].class));
- }
-
-
-}
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/mapping/AbstractObjectDirectoryMapTest.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/mapping/AbstractObjectDirectoryMapTest.java
index b1ba544f..b1041d4f 100644
--- a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/mapping/AbstractObjectDirectoryMapTest.java
+++ b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/mapping/AbstractObjectDirectoryMapTest.java
@@ -20,7 +20,7 @@ public abstract class AbstractObjectDirectoryMapTest extends TestCase
public void testAttributeNameFor()
{
- Assert.assertEquals(odm.attributeNameFor("Identifier"), "uid");
+ Assert.assertEquals(odm.attributeNameFor("identifier"), "uid");
}
public void testThrowsExceptionWhenClassArgumentIsNull() throws MappingException
@@ -45,7 +45,7 @@ public abstract class AbstractObjectDirectoryMapTest extends TestCase
public void testbeanPropertyNameFor()
{
- Assert.assertEquals(odm.beanPropertyNameFor("uid"), "Identifier");
+ Assert.assertEquals(odm.beanPropertyNameFor("uid"), "identifier");
}
public void testBeanPropertyNames()
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperFactoryTest.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperFactoryTest.java
index 6f3c8145..a675da9e 100644
--- a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperFactoryTest.java
+++ b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/mapping/ObjectDirectoryMapperFactoryTest.java
@@ -8,8 +8,8 @@ package org.springframework.ldap.odm.mapping;
import junit.framework.TestCase;
import org.easymock.classextension.EasyMock;
-import org.springframework.ldap.odm.attributetypes.LdapTypeConverter;
-import org.springframework.ldap.odm.attributetypes.ReferencedEntryEditorFactory;
+import org.springframework.ldap.odm.typeconversion.LdapTypeConverter;
+import org.springframework.ldap.odm.typeconversion.ReferencedEntryEditorFactory;
import org.springframework.ldap.odm.entity.UnitTestPerson;
public class ObjectDirectoryMapperFactoryTest extends TestCase
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 9cf54399..48a37983 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
@@ -13,8 +13,8 @@ import org.apache.commons.logging.LogFactory;
import org.easymock.classextension.EasyMock;
import org.springframework.ldap.core.DirContextAdapter;
import org.springframework.ldap.core.DistinguishedName;
-import org.springframework.ldap.odm.attributetypes.LdapTypeConverter;
-import org.springframework.ldap.odm.attributetypes.ReferencedEntryEditorFactory;
+import org.springframework.ldap.odm.typeconversion.LdapTypeConverter;
+import org.springframework.ldap.odm.typeconversion.ReferencedEntryEditorFactory;
import org.springframework.ldap.odm.entity.UnitTestPerson;
import javax.naming.Name;
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/typeconversion/LdapTypeConverterTest.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/typeconversion/LdapTypeConverterTest.java
new file mode 100644
index 00000000..e69de29b
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/typeconversion/NameEditorTest.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/typeconversion/NameEditorTest.java
new file mode 100644
index 00000000..e69de29b
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/typeconversion/ReferencedEntryEditorFactoryTest.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/typeconversion/ReferencedEntryEditorFactoryTest.java
new file mode 100644
index 00000000..e69de29b
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/typeconversion/ReferencedEntryEditorTest.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/typeconversion/ReferencedEntryEditorTest.java
new file mode 100644
index 00000000..e69de29b
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/typeconversion/TestReferencedEntry.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/typeconversion/TestReferencedEntry.java
new file mode 100644
index 00000000..e69de29b
diff --git a/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/typeconversion/ValidConversionTypeTest.java b/spring-ldap-odm/src/test/java/org/springframework/ldap/odm/typeconversion/ValidConversionTypeTest.java
new file mode 100644
index 00000000..e69de29b