From e17523daf39cdb0ca2d57d062da010537808e72d Mon Sep 17 00:00:00 2001 From: Ulrik Sandberg Date: Sun, 2 Aug 2009 19:31:38 +0000 Subject: [PATCH] Updated according to Keiths second delivery, plus some minor cleanup. --- .../ldap/{ldif => core}/LdapAttribute.java | 6 +-- .../ldap/{ldif => core}/LdapAttributes.java | 5 +- .../ldif/InvalidAttributeFormatException.java | 4 -- .../ldif/InvalidRecordFormatException.java | 4 -- .../{LDIFParser.java => LdifParser.java} | 49 +++++++++---------- .../ldap/ldif/parser/Parser.java | 17 +++---- .../support/AttributeValidationPolicy.java | 4 +- .../DefaultAttributeValidationPolicy.java | 23 ++++----- .../ldap/ldif/support/SeparatorPolicy.java | 13 ++--- .../schema/DefaultSchemaSpecification.java | 3 +- .../ldap/schema/Specification.java | 2 +- .../DefaultAttributeValidationPolicyTest.java | 3 +- ...DIFParserTest.java => LdifParserTest.java} | 33 +++++++------ 13 files changed, 69 insertions(+), 97 deletions(-) rename core-tiger/src/main/java/org/springframework/ldap/{ldif => core}/LdapAttribute.java (95%) rename core-tiger/src/main/java/org/springframework/ldap/{ldif => core}/LdapAttributes.java (95%) rename core-tiger/src/main/java/org/springframework/ldap/ldif/parser/{LDIFParser.java => LdifParser.java} (87%) rename core-tiger/src/test/java/org/springframework/ldap/ldif/{LDIFParserTest.java => LdifParserTest.java} (69%) diff --git a/core-tiger/src/main/java/org/springframework/ldap/ldif/LdapAttribute.java b/core-tiger/src/main/java/org/springframework/ldap/core/LdapAttribute.java similarity index 95% rename from core-tiger/src/main/java/org/springframework/ldap/ldif/LdapAttribute.java rename to core-tiger/src/main/java/org/springframework/ldap/core/LdapAttribute.java index 7b46a5c7..0066e298 100644 --- a/core-tiger/src/main/java/org/springframework/ldap/ldif/LdapAttribute.java +++ b/core-tiger/src/main/java/org/springframework/ldap/core/LdapAttribute.java @@ -1,7 +1,4 @@ -/** - * Extends BasicAttribute adding support for options. - */ -package org.springframework.ldap.ldif; +package org.springframework.ldap.core; import java.util.Collection; import java.util.HashSet; @@ -18,7 +15,6 @@ import javax.naming.directory.BasicAttribute; * {@link java.lang.String}. * * @author Keith Barlow - * */ public class LdapAttribute extends BasicAttribute { diff --git a/core-tiger/src/main/java/org/springframework/ldap/ldif/LdapAttributes.java b/core-tiger/src/main/java/org/springframework/ldap/core/LdapAttributes.java similarity index 95% rename from core-tiger/src/main/java/org/springframework/ldap/ldif/LdapAttributes.java rename to core-tiger/src/main/java/org/springframework/ldap/core/LdapAttributes.java index f61417f5..037cbd5b 100644 --- a/core-tiger/src/main/java/org/springframework/ldap/ldif/LdapAttributes.java +++ b/core-tiger/src/main/java/org/springframework/ldap/core/LdapAttributes.java @@ -1,7 +1,4 @@ -/** - * Extends BasicAttributes adding support for DNs. - */ -package org.springframework.ldap.ldif; +package org.springframework.ldap.core; import java.net.URI; diff --git a/core-tiger/src/main/java/org/springframework/ldap/ldif/InvalidAttributeFormatException.java b/core-tiger/src/main/java/org/springframework/ldap/ldif/InvalidAttributeFormatException.java index fca3f970..8a7398bb 100644 --- a/core-tiger/src/main/java/org/springframework/ldap/ldif/InvalidAttributeFormatException.java +++ b/core-tiger/src/main/java/org/springframework/ldap/ldif/InvalidAttributeFormatException.java @@ -1,6 +1,3 @@ -/** - * - */ package org.springframework.ldap.ldif; import org.springframework.ldap.NamingException; @@ -9,7 +6,6 @@ import org.springframework.ldap.NamingException; * Thrown whenever a parsed attribute does not conform to LDAP specifications. * * @author Keith Barlow - * */ public class InvalidAttributeFormatException extends NamingException { diff --git a/core-tiger/src/main/java/org/springframework/ldap/ldif/InvalidRecordFormatException.java b/core-tiger/src/main/java/org/springframework/ldap/ldif/InvalidRecordFormatException.java index d89b6664..07b6a7b4 100644 --- a/core-tiger/src/main/java/org/springframework/ldap/ldif/InvalidRecordFormatException.java +++ b/core-tiger/src/main/java/org/springframework/ldap/ldif/InvalidRecordFormatException.java @@ -1,6 +1,3 @@ -/** - * - */ package org.springframework.ldap.ldif; import org.springframework.ldap.NamingException; @@ -9,7 +6,6 @@ import org.springframework.ldap.NamingException; * Thrown whenever a parsed record does not conform to LDAP specifications. * * @author Keith Barlow - * */ public class InvalidRecordFormatException extends NamingException { diff --git a/core-tiger/src/main/java/org/springframework/ldap/ldif/parser/LDIFParser.java b/core-tiger/src/main/java/org/springframework/ldap/ldif/parser/LdifParser.java similarity index 87% rename from core-tiger/src/main/java/org/springframework/ldap/ldif/parser/LDIFParser.java rename to core-tiger/src/main/java/org/springframework/ldap/ldif/parser/LdifParser.java index 14c6bfc7..77e4fcff 100644 --- a/core-tiger/src/main/java/org/springframework/ldap/ldif/parser/LDIFParser.java +++ b/core-tiger/src/main/java/org/springframework/ldap/ldif/parser/LdifParser.java @@ -12,12 +12,13 @@ import javax.naming.directory.Attribute; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; import org.springframework.ldap.core.DistinguishedName; +import org.springframework.ldap.core.LdapAttributes; import org.springframework.ldap.ldif.InvalidAttributeFormatException; import org.springframework.ldap.ldif.InvalidRecordFormatException; -import org.springframework.ldap.ldif.LdapAttributes; import org.springframework.ldap.ldif.support.AttributeValidationPolicy; import org.springframework.ldap.ldif.support.DefaultAttributeValidationPolicy; import org.springframework.ldap.ldif.support.LineIdentifier; @@ -27,13 +28,13 @@ import org.springframework.ldap.schema.Specification; import org.springframework.util.Assert; /** - * The {@link LDIFParser LDIFParser} is the main class of the {@link org.springframework.ldap.ldif} package. + * The {@link LdifParser LdifParser} is the main class of the {@link org.springframework.ldap.ldif} package. * This class reads lines from a resource and assembles them into an {@link LdapAttributes LdapAttributes} object. - * The {@link LDIFParser LDIFParser} does ignores changetype LDIF entries as their usefulness in the + * The {@link LdifParser LdifParser} does ignores changetype LDIF entries as their usefulness in the * context of an application has yet to be determined. *

* Design
- * {@link LDIFPaser LDIFParser} provides the main interface for operation but requires three supporting classes to + * {@link LdifParser LdifParser} provides the main interface for operation but requires three supporting classes to * enable operation: *

* * @author Keith Barlow - * */ public class DefaultSchemaSpecification implements Specification { diff --git a/core-tiger/src/main/java/org/springframework/ldap/schema/Specification.java b/core-tiger/src/main/java/org/springframework/ldap/schema/Specification.java index 504b6765..2d1139a2 100644 --- a/core-tiger/src/main/java/org/springframework/ldap/schema/Specification.java +++ b/core-tiger/src/main/java/org/springframework/ldap/schema/Specification.java @@ -4,7 +4,7 @@ import javax.naming.NamingException; /** * The specification interface is implemented to declare rules that - * a record must conform to. The motiviation behind this class was + * a record must conform to. The motivation behind this class was * to provide a mechanism to enable schema validations. * * @author Keith Barlow diff --git a/core-tiger/src/test/java/org/springframework/ldap/ldif/DefaultAttributeValidationPolicyTest.java b/core-tiger/src/test/java/org/springframework/ldap/ldif/DefaultAttributeValidationPolicyTest.java index b4677d05..edc3065d 100644 --- a/core-tiger/src/test/java/org/springframework/ldap/ldif/DefaultAttributeValidationPolicyTest.java +++ b/core-tiger/src/test/java/org/springframework/ldap/ldif/DefaultAttributeValidationPolicyTest.java @@ -12,7 +12,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized.Parameters; import org.junit.runners.Parameterized; -import org.springframework.ldap.ldif.LdapAttribute; +import org.springframework.ldap.core.LdapAttribute; import org.springframework.ldap.ldif.support.DefaultAttributeValidationPolicy; import sun.misc.BASE64Decoder; @@ -23,7 +23,6 @@ import sun.misc.BASE64Decoder; * the requirements for attribute values prescribed in RFC2849. * * @author Keith Barlow - * */ @RunWith(Parameterized.class) public class DefaultAttributeValidationPolicyTest { diff --git a/core-tiger/src/test/java/org/springframework/ldap/ldif/LDIFParserTest.java b/core-tiger/src/test/java/org/springframework/ldap/ldif/LdifParserTest.java similarity index 69% rename from core-tiger/src/test/java/org/springframework/ldap/ldif/LDIFParserTest.java rename to core-tiger/src/test/java/org/springframework/ldap/ldif/LdifParserTest.java index df84506f..84bcd2c6 100644 --- a/core-tiger/src/test/java/org/springframework/ldap/ldif/LDIFParserTest.java +++ b/core-tiger/src/test/java/org/springframework/ldap/ldif/LdifParserTest.java @@ -10,39 +10,40 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.springframework.core.io.ClassPathResource; -import org.springframework.ldap.ldif.LdapAttributes; -import org.springframework.ldap.ldif.parser.LDIFParser; +import org.springframework.ldap.core.LdapAttributes; +import org.springframework.ldap.ldif.parser.LdifParser; /** - * Unit test for LDIFParser. + * Unit test for LdifParser. * - * Test results in complete end to end test of all LDIFParser functionality: - * 1.) Open a file - * 2.) Read lines and compose an attribute. - * 3.) Parse the attribute and create a LdapAttribute object. - * 4.) Repeat until end of record (Identify end of record). - * 5.) Return a valid LdapAttributes object. - * 6.) Close file upon completion. + * Test results in complete end to end test of all LdifParser functionality: + *
    + *
  1. Open a file + *
  2. Read lines and compose an attribute. + *
  3. Parse the attribute and create a LdapAttribute object. + *
  4. Repeat until end of record (Identify end of record). + *
  5. Return a valid LdapAttributes object. + *
  6. Close file upon completion. + *
* * Provided test file is comprised of sample LDIFs from RFC2849 and exhausts the full range of * the functionality prescribed by RFC2849 for the LDAP Data Interchange Format (LDIF). * * @author Keith Barlow - * */ -public class LDIFParserTest { +public class LdifParserTest { - private static Log log = LogFactory.getLog(LDIFParserTest.class); + private static Log log = LogFactory.getLog(LdifParserTest.class); - private LDIFParser parser; + private LdifParser parser; /** * Default constructor: loads a preselected resource with sample LDIF entries. * Each entry is parsed and checked for a DN and objectclass. Output is printed for visual verification * of LDIF correctness. */ - public LDIFParserTest() { - parser = new LDIFParser(new ClassPathResource("test.ldif")); + public LdifParserTest() { + parser = new LdifParser(new ClassPathResource("test.ldif")); } /**