You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2008/03/18 06:07:29 UTC
svn commit: r638218 [3/4] - in /directory/sandbox/akarasulu/bigbang/shared:
./ asn1-codec/ asn1-codec/src/main/resources/META-INF/ asn1-codec/src/site/
asn1/ asn1/src/main/resources/META-INF/ asn1/src/site/ convert/
convert/src/main/java/org/apache/dir...
Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java?rev=638218&r1=638217&r2=638218&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java (original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/Rdn.java Mon Mar 17 22:07:20 2008
@@ -107,7 +107,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class Rdn implements Cloneable, Comparable, Serializable
+public class Rdn implements Cloneable, Comparable, Serializable, Iterable<AttributeTypeAndValue>
{
/** The LoggerFactory used by this class */
protected static final Logger LOG = LoggerFactory.getLogger( Rdn.class );
@@ -235,13 +235,13 @@
* @throws InvalidNameException
* If the RDN is invalid
*/
- public Rdn( String upType, String type, String upValue, String value ) throws InvalidNameException
+ public Rdn( String upType, String normType, String upValue, String normValue ) throws InvalidNameException
{
super();
- addAttributeTypeAndValue( upType, type, upValue, value );
+ addAttributeTypeAndValue( upType, normType, upValue, normValue );
- upName = type + '=' + value;
+ upName = upType + '=' + upValue;
start = 0;
length = upName.length();
// create the internal normalized form
@@ -250,6 +250,28 @@
/**
+ * A constructor that constructs a RDN from a type and a value. Constructs
+ * an Rdn from the given attribute type and value. The string attribute
+ * values are not interpretted as RFC 2253 formatted RDN strings. That is,
+ * the values are used literally (not parsed) and assumed to be unescaped.
+ *
+ * @param type
+ * The type of the RDN
+ * @param value
+ * The value of the RDN
+ * @throws InvalidNameException
+ * If the RDN is invalid
+ */
+ /* No protection */ Rdn( int start, int length, String upName, String normName )
+ {
+ this.start = 0;
+ this.length = length;
+ this.upName = upName;
+ this.normName = normName;
+ }
+
+
+ /**
* Constructs an Rdn from the given rdn. The contents of the rdn are simply
* copied into the newly created
*
@@ -312,13 +334,13 @@
case 1:
// We have a single AttributeTypeAndValue
// We will trim and lowercase type and value.
- if ( atav.getValue() instanceof String )
+ if ( atav.getNormValue() instanceof String )
{
normName = atav.getNormalizedValue();
}
else
{
- normName = atav.getNormType() + "=#" + StringTools.dumpHexPairs( (byte[])atav.getValue() );
+ normName = atav.getNormType() + "=#" + StringTools.dumpHexPairs( (byte[])atav.getNormValue() );
}
break;
@@ -408,6 +430,61 @@
/**
+ * Add a AttributeTypeAndValue to the current RDN
+ *
+ * @param type
+ * The type of the added RDN.
+ * @param value
+ * The value of the added RDN
+ * @throws InvalidNameException
+ * If the RDN is invalid
+ */
+ // WARNING : The protection level is left unspecified intentionnaly.
+ // We need this method to be visible from the DnParser class, but not
+ // from outside this package.
+ @SuppressWarnings({"unchecked"})
+ /* Unspecified protection */void addAttributeTypeAndValue( AttributeTypeAndValue atav )
+ {
+ String normalizedType = atav.getNormType();
+
+ switch ( nbAtavs )
+ {
+ case 0:
+ // This is the first AttributeTypeAndValue. Just stores it.
+ this.atav = atav;
+ nbAtavs = 1;
+ atavType = normalizedType;
+ return;
+
+ case 1:
+ // We already have an atav. We have to put it in the HashMap
+ // before adding a new one.
+ // First, create the HashMap,
+ atavs = new TreeSet<AttributeTypeAndValue>();
+
+ // and store the existing AttributeTypeAndValue into it.
+ atavs.add( this.atav );
+ atavTypes = new MultiHashMap();
+ atavTypes.put( atavType, this.atav );
+
+ this.atav = null;
+
+ // Now, fall down to the commmon case
+ // NO BREAK !!!
+
+ default:
+ // add a new AttributeTypeAndValue
+ atavs.add( atav );
+ atavTypes.put( normalizedType, atav );
+
+ nbAtavs++;
+ break;
+
+ }
+ }
+
+
+ /**
* Clear the RDN, removing all the AttributeTypeAndValues.
*/
public void clear()
@@ -445,7 +522,7 @@
case 1:
if ( StringTools.equals( atav.getNormType(), normalizedType ) )
{
- return atav.getValue();
+ return atav.getNormValue();
}
else
{
@@ -459,7 +536,7 @@
if ( obj instanceof AttributeTypeAndValue )
{
- return ( ( AttributeTypeAndValue ) obj ).getValue();
+ return ( ( AttributeTypeAndValue ) obj ).getNormValue();
}
else if ( obj instanceof List )
{
@@ -479,7 +556,7 @@
sb.append( ',' );
}
- sb.append( elem.getValue() );
+ sb.append( elem.getNormValue() );
}
return sb.toString();
@@ -496,8 +573,29 @@
}
}
+
+ /**
+ * Get the start position
+ *
+ * @return The start position in the DN
+ */
+ public int getStart()
+ {
+ return start;
+ }
+
/**
+ * Get the Rdn length
+ *
+ * @return The Rdn length
+ */
+ public int getLength()
+ {
+ return length;
+ }
+
+ /**
* Get the AttributeTypeAndValue which type is given as an argument. If we
* have more than one value associated with the type, we will return only
* the first one.
@@ -761,6 +859,15 @@
/**
+ * Returns The normalized name
+ */
+ public String getNormName()
+ {
+ return normName == null ? "" : normName;
+ }
+
+
+ /**
* Set the User Provided Name
*/
public void setUpName( String upName )
@@ -853,10 +960,10 @@
return null;
case 1:
- return atav.getValue();
+ return atav.getNormValue();
default:
- return ( ( AttributeTypeAndValue )((TreeSet)atavs).first() ).getValue();
+ return ( ( AttributeTypeAndValue )((TreeSet)atavs).first() ).getNormValue();
}
}
@@ -935,7 +1042,7 @@
case 1 :
attribute = new AttributeImpl( atavType, true );
- attribute.add( atav.getValue() );
+ attribute.add( atav.getNormValue() );
attributes.put( attribute );
break;
@@ -955,7 +1062,7 @@
{
AttributeTypeAndValue value = iterValues.next();
- attribute.add( value.getValue() );
+ attribute.add( value.getNormValue() );
}
attributes.put( attribute );
Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java?rev=638218&r1=638217&r2=638218&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java (original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java Mon Mar 17 22:07:20 2008
@@ -595,7 +595,7 @@
if( bytes.length <= pos.start )
{
// no attribute value
- return false;
+ return true;
}
byte c = bytes[pos.start];
@@ -907,6 +907,11 @@
*/
public static int parse( byte[] dn, Position pos, Rdn rdn ) throws InvalidNameException
{
+ if ( rdn == null )
+ {
+ throw new InvalidNameException( "Cannot feed a null RDN structure" );
+ }
+
String type = null;
Object value = null;
int start = pos.start;
@@ -921,10 +926,7 @@
return DNUtils.PARSING_ERROR;
}
- if ( rdn != null )
- {
- pos.start = pos.end;
- }
+ pos.start = pos.end;
StringTools.trimLeft( dn, pos );
@@ -946,14 +948,11 @@
return DNUtils.PARSING_ERROR;
}
- if ( rdn != null )
- {
- rdn.addAttributeTypeAndValue( type, type, value, value );
- rdn.normalize();
+ rdn.addAttributeTypeAndValue( type, type, value, value );
+ rdn.normalize();
- pos.start = pos.end;
- pos.length = 0;
- }
+ pos.start = pos.end;
+ pos.length = 0;
if ( parseNameComponents( dn, pos, rdn ) == DNUtils.PARSING_ERROR )
{
Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ComparableComparator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ComparableComparator.java?rev=638218&r1=638217&r2=638218&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ComparableComparator.java (original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ComparableComparator.java Mon Mar 17 22:07:20 2008
@@ -48,14 +48,37 @@
*/
public int compare( Object o1, Object o2 )
{
+ if ( ( o1 == null ) && ( o2 == null ) )
+ {
+ return 0;
+ }
+
if ( o1 instanceof Comparable )
{
- return ( ( Comparable ) o1 ).compareTo( o2 );
+ if ( o2 == null )
+ {
+ return -1;
+ }
+ else
+ {
+ return ( ( Comparable ) o1 ).compareTo( o2 );
+ }
}
- if ( o2 instanceof Comparable )
+ if ( o2 == null )
+ {
+ return 1;
+ }
+ else if ( o2 instanceof Comparable )
{
- return -( ( Comparable ) o2 ).compareTo( o1 );
+ if ( o1 == null )
+ {
+ return -1;
+ }
+ else
+ {
+ return -( ( Comparable ) o2 ).compareTo( o1 );
+ }
}
// before https://issues.apache.org/jira/browse/DIRSERVER-928 it was
Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/RegexNormalizer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/RegexNormalizer.java?rev=638218&r1=638217&r2=638218&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/RegexNormalizer.java (original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/RegexNormalizer.java Mon Mar 17 22:07:20 2008
@@ -47,20 +47,24 @@
* @param regexes
* the set of regular expressions used to transform values
*/
- public RegexNormalizer(Pattern[] regexes)
+ public RegexNormalizer( Pattern[] regexes )
{
if ( regexes != null )
{
this.regexes = new Pattern[ regexes.length ];
System.arraycopy( regexes, 0, this.regexes, 0, regexes.length );
- } else {
- this.regexes = null;
- }
- matchers = new Matcher[regexes.length];
- for ( int i = 0; i < regexes.length; i++ )
+ matchers = new Matcher[regexes.length];
+
+ for ( int i = 0; i < regexes.length; i++ )
+ {
+ matchers[i] = regexes[i].matcher( "" );
+ }
+ }
+ else
{
- matchers[i] = regexes[i].matcher( "" );
+ this.regexes = null;
+ matchers = new Matcher[0];
}
}
Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java?rev=638218&r1=638217&r2=638218&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java (original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java Mon Mar 17 22:07:20 2008
@@ -274,52 +274,6 @@
* @param type the attributeType spec of the Attribute to extract
* @return the modification item on the attributeType specified
*/
- public static final ModificationItem getModificationItem( ModificationItem[] mods, AttributeType type )
- {
- // optimization bypass to avoid cost of the loop below
- if ( type.getNames().length == 1 )
- {
- for ( int jj = 0; jj < mods.length; jj++ )
- {
- if ( mods[jj].getAttribute().getID().equalsIgnoreCase( type.getNames()[0] ) )
- {
- return mods[jj];
- }
- }
- }
-
- // check if the attribute's OID is used
- for ( int jj = 0; jj < mods.length; jj++ )
- {
- if ( mods[jj].getAttribute().getID().equals( type.getOid() ) )
- {
- return mods[jj];
- }
- }
-
- // iterate through aliases
- for ( int ii = 0; ii < type.getNames().length; ii++ )
- {
- for ( int jj = 0; jj < mods.length; jj++ )
- {
- if ( mods[jj].getAttribute().getID().equalsIgnoreCase( type.getNames()[ii] ) )
- {
- return mods[jj];
- }
- }
- }
-
- return null;
- }
-
-
- /**
- * Utility method to extract a modification item from an array of modifications.
- *
- * @param mods the array of ModificationItems to extract the Attribute from.
- * @param type the attributeType spec of the Attribute to extract
- * @return the modification item on the attributeType specified
- */
public static final ModificationItem getModificationItem( List<ModificationItemImpl> mods, AttributeType type )
{
// optimization bypass to avoid cost of the loop below
@@ -359,46 +313,6 @@
}
- /**
- * Utility method to extract an attribute from an array of modifications.
- *
- * @param mods the array of ModificationItems to extract the Attribute from.
- * @param type the attributeType spec of the Attribute to extract
- * @return the extract Attribute or null if no such attribute exists
- */
- public static final Attribute getAttribute( ModificationItem[] mods, AttributeType type )
- {
- ModificationItem mod = getModificationItem( mods, type );
-
- if ( mod != null )
- {
- return mod.getAttribute();
- }
-
- return null;
- }
-
-
- /**
- * Utility method to extract an attribute from a list of modifications.
- *
- * @param mods the list of ModificationItems to extract the Attribute from.
- * @param type the attributeType spec of the Attribute to extract
- * @return the extract Attribute or null if no such attribute exists
- */
- public static Attribute getAttribute( List<ModificationItemImpl> mods, AttributeType type )
- {
- ModificationItem mod = getModificationItem( mods, type );
-
- if ( mod != null )
- {
- return mod.getAttribute();
- }
-
- return null;
- }
-
-
/**
* Check if an attribute contains a specific value, using the associated matchingRule for that
*
Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java?rev=638218&r1=638217&r2=638218&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java (original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java Mon Mar 17 22:07:20 2008
@@ -35,7 +35,7 @@
import javax.naming.NamingException;
import org.apache.directory.shared.ldap.NotImplementedException;
-import org.apache.directory.shared.ldap.ldif.Entry;
+import org.apache.directory.shared.ldap.ldif.LdifEntry;
import org.apache.directory.shared.ldap.ldif.LdifReader;
import org.apache.directory.shared.ldap.message.AttributesImpl;
@@ -585,7 +585,7 @@
LdifReader ldifReader = new LdifReader( new StringReader( ldif ) );
- Entry entry = ldifReader.next();
+ LdifEntry entry = ldifReader.next();
if ( entry != null )
{
Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?rev=638218&r1=638217&r2=638218&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java (original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java Mon Mar 17 22:07:20 2008
@@ -2004,7 +2004,7 @@
}
else
{
- byte c = bytes[index++];
+ byte c = bytes[index];
if ( ( ( c | 0x7F ) != 0x7F ) || ( ALPHA[c] == false ) )
{
@@ -2035,7 +2035,7 @@
}
else
{
- char c = chars[index++];
+ char c = chars[index];
if ( ( c > 127 ) || ( ALPHA[c] == false ) )
{
@@ -2073,7 +2073,7 @@
}
else
{
- char c = string.charAt( index++ );
+ char c = string.charAt( index );
if ( ( c > 127 ) || ( ALPHA[c] == false ) )
{
@@ -2111,7 +2111,7 @@
}
else
{
- char c = string.charAt( index++ );
+ char c = string.charAt( index );
if ( ( c > 127 ) || ( ALPHA_LOWER_CASE[c] == false ) )
{
@@ -2149,7 +2149,7 @@
}
else
{
- char c = string.charAt( index++ );
+ char c = string.charAt( index );
if ( ( c > 127 ) || ( ALPHA_UPPER_CASE[c] == false ) )
{
@@ -2278,7 +2278,7 @@
}
else
{
- char c = string.charAt( index++ );
+ char c = string.charAt( index );
if ( ( c > 127 ) || ( ALPHA_DIGIT[c] == false ) )
{
@@ -2308,7 +2308,7 @@
}
else
{
- byte c = bytes[index++];
+ byte c = bytes[index];
if ( ( ( c | 0x7F ) != 0x7F ) || ( CHAR[c] == false ) )
{
@@ -2338,7 +2338,7 @@
}
else
{
- char c = chars[index++];
+ char c = chars[index];
if ( ( c > 127 ) || ( CHAR[c] == false ) )
{
@@ -2375,7 +2375,7 @@
}
else
{
- char c = string.charAt( index++ );
+ char c = string.charAt( index );
if ( ( c > 127 ) || ( CHAR[c] == false ) )
{
@@ -3246,9 +3246,7 @@
StringBuffer sb = new StringBuffer();
boolean isFirst = true;
- Iterator<?> iter = map.keySet().iterator();
-
- while ( iter.hasNext() )
+ for ( Map.Entry<?, ?> entry:map.entrySet() )
{
if ( isFirst )
{
@@ -3259,9 +3257,8 @@
sb.append( ", " );
}
- Object key = iter.next();
- sb.append( key );
- sb.append( " = '" ).append( map.get( key ) ).append( "'" );
+ sb.append( entry.getKey() );
+ sb.append( " = '" ).append( entry.getValue() ).append( "'" );
}
return sb.toString();
@@ -3285,16 +3282,12 @@
StringBuffer sb = new StringBuffer();
- Iterator<?> iter = map.keySet().iterator();
-
- while ( iter.hasNext() )
+ for ( Map.Entry<?, ?> entry:map.entrySet() )
{
- Object key = iter.next();
sb.append( tabs );
- sb.append( key );
- Object value = map.get( key );
+ sb.append( entry.getKey() );
- sb.append( " = '" ).append( value.toString() ).append( "'\n" );
+ sb.append( " = '" ).append( entry.getValue().toString() ).append( "'\n" );
}
return sb.toString();
Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java?rev=638218&r1=638217&r2=638218&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java Mon Mar 17 22:07:20 2008
@@ -23,8 +23,6 @@
import java.text.ParseException;
-import org.apache.directory.shared.ldap.aci.ACIItemParser;
-
import junit.framework.TestCase;
@@ -64,6 +62,13 @@
}
+ private void checkItemToString( String spec, ACIItem item ) throws Exception
+ {
+ // try to parse the result of item.toString() again
+ parser.parse( item.toString() );
+ }
+
+
/**
* Tests the parser with a rangeOfValues with a nested filter.
*/
@@ -73,7 +78,8 @@
+ "itemOrUserFirst itemFirst :{ protectedItems "
+ "{ rangeOfValues (&(&(|(|(cn=ccc)(!(cn=ddd))(&(cn=aaa)(cn=bbb)))))) " + "} , itemPermissions { } } }";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
spec = " { identificationTag \"id8\", precedence 0, authenticationLevel simple "
@@ -82,7 +88,8 @@
+ "{ protectedItems { rangeOfValues (|(!(cn=aaa))(sn=bbb)) }, grantsAndDenials { grantAdd } } "
+ " } } }";
- parser.parse( spec );
+ item = parser.parse( spec );
+ checkItemToString( spec, item );
}
@@ -100,7 +107,8 @@
+ "{ precedence 10, userClasses {allUsers , userGroup { \"1.2=y,z=t\" , \"a=b,c=d\" } "
+ " , subtree { { base \"ou=people\" } } } , grantsAndDenials { denyCompare , grantModify } } } }}";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
}
@@ -116,7 +124,8 @@
+ "userPermissions { { protectedItems{ entry , attributeType { cn , ou } , attributeValue {x=y,m=n,k=l} , "
+ "rangeOfValues (cn=ErsinEr) } , grantsAndDenials { grantBrowse } } } } } ";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
}
@@ -126,7 +135,8 @@
+ "itemOrUserFirst userFirst: { " + "userClasses { allUsers }, "
+ "userPermissions { { protectedItems {entry}, " + "grantsAndDenials { grantAdd } } } } }";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
}
@@ -136,7 +146,8 @@
+ "itemOrUserFirst userFirst: { " + "userClasses { allUsers, name { \"ou=blah\" } }, "
+ "userPermissions { { protectedItems {entry}, " + "grantsAndDenials { grantAdd } } } } }";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
}
@@ -151,7 +162,8 @@
+ "{ precedence 10, userClasses {allUsers , userGroup { \"1.2=y,z=t\" , \"a=b,c=d\" } "
+ " , subtree { { base \"ou=people\" } } } , grantsAndDenials { denyCompare , grantModify } } } }}";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
}
@@ -164,7 +176,8 @@
+ "userPermissions { { protectedItems{ entry , attributeType { cn , ou } , attributeValue {x=y,m=n,k=l} , "
+ "rangeOfValues (cn=ErsinEr) } , grantsAndDenials { grantBrowse } } } } } ";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
}
@@ -223,7 +236,8 @@
+ "{ precedence 10, userClasses {allUsers , userGroup { \"1.2=y,z=t\" , \"a=b,c=d\" } "
+ " , subtree { { base \"ou=people\" } } } , grantsAndDenials { denyCompare , grantModify } } } }}";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
}
@@ -260,7 +274,8 @@
+ "userPermissions { { grantsAndDenials { grantBrowse }, protectedItems{ entry , attributeType { cn , ou } , attributeValue {x=y,m=n,k=l} , "
+ "rangeOfValues (cn=ErsinEr) } } } } } ";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
}
@@ -294,7 +309,8 @@
+ "rangeOfValues (cn=ErsinEr) } , grantsAndDenials { grantBrowse } } } }, "
+ " identificationTag \"id2\" , authenticationLevel none, precedence 14 } ";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
}
@@ -348,7 +364,8 @@
+ "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
+ "minimum 1, maximum 2 } } } } } ";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
}
@@ -362,7 +379,8 @@
+ " attributeValue { ou=people , cn=Ersin } , rangeOfValues (cn=ErsinEr) , "
+ "classes and : { item: xyz , or:{item:X,item:Y} }} " + " }}";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
}
@@ -384,7 +402,7 @@
}
- public void testRestrictedValueComponentsOrderDoesNotMatter() throws Exception
+ public void testMaxValueCountComponentsOrderDoesNotMatter() throws Exception
{
String spec = "{ identificationTag \"id2\" , precedence 14, authenticationLevel none , "
+ "itemOrUserFirst userFirst: { userClasses { allUsers , name { \"ou=people,cn=ersin\" }, "
@@ -393,11 +411,12 @@
+ "maxValueCount { { type 10.11.12, maxCount 10 }, { maxCount 20, type 11.12.13 } } "
+ " } , grantsAndDenials { grantBrowse } } } } } ";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
}
- public void testMaxValueCountComponentsOrderDoesNotMatter() throws Exception
+ public void testRestrictedValueComponentsOrderDoesNotMatter() throws Exception
{
String spec = "{ identificationTag \"id2\" , precedence 14, authenticationLevel none , "
+ "itemOrUserFirst userFirst: { userClasses { allUsers , name { \"ou=people,cn=ersin\" }, "
@@ -406,10 +425,24 @@
+ "restrictedBy { { type 10.11.12, valuesIn ou }, { valuesIn cn, type 11.12.13 } } "
+ " } , grantsAndDenials { grantBrowse } } } } } ";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
}
+ public void testMaxImmSubComponentsOrderDoesNotMatter() throws Exception
+ {
+ String spec = "{ identificationTag \"id2\" , precedence 14, authenticationLevel none , "
+ + "itemOrUserFirst userFirst: { userClasses { allUsers , name { \"ou=people,cn=ersin\" }, "
+ + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\"," + "minimum 1, maximum 2 } } } , "
+ + "userPermissions { { protectedItems{ entry , maxImmSub 5 "
+ + " } , grantsAndDenials { grantBrowse } } } } } ";
+
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
+ }
+
+
public void testSubtreeSpecificationComponentsOrderDoesNotMatter() throws Exception
{
String spec = "{ identificationTag \"id2\" , precedence 14, authenticationLevel none , "
@@ -418,7 +451,8 @@
+ "subtree {{ minimum 7, maximum 9, base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
+ " maximum 2, minimum 1 } } } } } ";
- parser.parse( spec );
+ ACIItem item = parser.parse( spec );
+ checkItemToString( spec, item );
}
@@ -454,7 +488,7 @@
try
{
parser.parse( spec );
- fail("Expected ParseException, invalid protected item 'attributeValue { must_be_a_name_value_pair }'");
+ fail("Expected ParseException, invalid protected item 'attributeValue { x=y,m=n,k=l,x }'");
}
catch ( ParseException e )
{
Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReaderTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReaderTest.java?rev=638218&r1=638217&r2=638218&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReaderTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifAttributesReaderTest.java Mon Mar 17 22:07:20 2008
@@ -50,7 +50,7 @@
{
private byte[] data;
- private static File HJENSEN_JPEG_FILE = null;
+ private File HJENSEN_JPEG_FILE = null;
private File createFile( String name, byte[] data ) throws IOException
{
Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java?rev=638218&r1=638217&r2=638218&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java Mon Mar 17 22:07:20 2008
@@ -46,8 +46,8 @@
{
private byte[] data;
- private static File HJENSEN_JPEG_FILE = null;
- private static File FIONA_JPEG_FILE = null;
+ private File HJENSEN_JPEG_FILE = null;
+ private File FIONA_JPEG_FILE = null;
private File createFile( String name, byte[] data ) throws IOException
{
@@ -90,7 +90,7 @@
String ldif = null;
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertEquals( 0, entries.size() );
}
@@ -100,7 +100,7 @@
String ldif = "";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertEquals( 0, entries.size() );
}
@@ -110,7 +110,7 @@
String ldif = "\n\n\r\r\n";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertEquals( 0, entries.size() );
}
@@ -125,7 +125,7 @@
"\n";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertEquals( 0, entries.size() );
}
@@ -143,7 +143,7 @@
"# end";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertEquals( 0, entries.size() );
assertEquals( 1, reader.getVersion() );
@@ -165,12 +165,12 @@
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertEquals( 1, reader.getVersion() );
assertNotNull( entries );
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertTrue( entry.isChangeAdd() );
@@ -195,7 +195,7 @@
"# end";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertEquals( 0, entries.size() );
assertEquals( 1, reader.getVersion() );
@@ -220,10 +220,10 @@
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertNotNull( entries );
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertTrue( entry.isChangeAdd() );
@@ -264,10 +264,10 @@
{
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertNotNull( entries );
- Entry entry = ( Entry ) entries.get( 0 );
+ LdifEntry entry = ( LdifEntry ) entries.get( 0 );
assertTrue( entry.isChangeModify() );
@@ -443,11 +443,11 @@
"envVars:";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertNotNull( entries );
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertTrue( entry.isChangeAdd() );
assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
@@ -486,11 +486,11 @@
"envVars:";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertNotNull( entries );
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertTrue( entry.isChangeAdd() );
assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
@@ -529,11 +529,11 @@
"envVars:";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertNotNull( entries );
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertTrue( entry.isChangeAdd() );
assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
@@ -571,11 +571,11 @@
"envVars:";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertNotNull( entries );
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertTrue( entry.isChangeAdd() );
assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
@@ -614,11 +614,11 @@
"envVars:";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertNotNull( entries );
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertTrue( entry.isChangeAdd() );
assertEquals( "cn=app1,ou=applications,ou=conf,dc=apache,dc=org", entry.getDn() );
@@ -665,12 +665,12 @@
"telephonenumber: +1 408 555 1212";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertEquals( 2, entries.size() );
// Entry 1
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertTrue( entry.isChangeAdd() );
assertEquals( "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", entry.getDn() );
@@ -698,7 +698,7 @@
assertTrue( attr.contains( "A big sailing fan." ) );
// Entry 2
- entry = (Entry) entries.get( 1 );
+ entry = (LdifEntry) entries.get( 1 );
assertTrue( entry.isChangeAdd() );
attr = entry.get( "dn" );
@@ -738,12 +738,12 @@
"title:Product Manager, Rod and Reel Division";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertEquals( 1, entries.size() );
// Entry 1
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertTrue( entry.isChangeAdd() );
assertEquals( "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", entry.getDn() );
@@ -795,12 +795,12 @@
" b3V0IG1vcmUu";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertEquals( 1, entries.size() );
// Entry 1
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertTrue( entry.isChangeAdd() );
assertEquals( "cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com", entry.getDn() );
@@ -848,12 +848,12 @@
" b3V0IG1vcmUu ";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
assertEquals( 1, entries.size() );
// Entry 1
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertTrue( entry.isChangeAdd() );
assertEquals( "cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com", entry.getDn() );
@@ -940,7 +940,7 @@
"title;lang-en: Sales, Director\n";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
String[][][] values =
{
@@ -988,7 +988,7 @@
// Entry 1
for ( int i = 0; i < entries.size(); i++ )
{
- Entry entry = (Entry) entries.get( i );
+ LdifEntry entry = (LdifEntry) entries.get( i );
assertTrue( entry.isChangeAdd() );
for ( int j = 0; j < values[i].length; j++ )
@@ -1030,7 +1030,7 @@
"jpegphoto:< file:" + HJENSEN_JPEG_FILE.getAbsolutePath() + "\n";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
String[][] values =
{
@@ -1049,7 +1049,7 @@
assertEquals( 1, entries.size() );
// Entry 1
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertTrue( entry.isChangeAdd() );
for ( int i = 0; i < values.length; i++ )
@@ -1180,7 +1180,7 @@
"-\n";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
String[][][] values =
{
@@ -1233,7 +1233,7 @@
}
};
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertTrue( entry.isChangeAdd() );
for ( int i = 0; i < values.length; i++ )
@@ -1263,19 +1263,19 @@
}
// Second entry
- entry = (Entry) entries.get( 1 );
+ entry = (LdifEntry) entries.get( 1 );
assertTrue( entry.isChangeDelete() );
assertEquals( values[1][0][1], entry.getDn() );
// Third entry
- entry = (Entry) entries.get( 2 );
+ entry = (LdifEntry) entries.get( 2 );
assertTrue( entry.isChangeModRdn() );
assertEquals( values[2][0][1], entry.getDn() );
assertEquals( values[2][1][0], entry.getNewRdn() );
assertTrue( entry.isDeleteOldRdn() );
// Forth entry
- entry = (Entry) entries.get( 3 );
+ entry = (LdifEntry) entries.get( 3 );
assertTrue( entry.isChangeModDn() );
assertEquals( values[3][0][1], entry.getDn() );
assertEquals( values[3][1][0], entry.getNewRdn() );
@@ -1283,7 +1283,7 @@
assertEquals( values[3][2][0], entry.getNewSuperior() );
// Fifth entry
- entry = (Entry) entries.get( 4 );
+ entry = (LdifEntry) entries.get( 4 );
List<ModificationItemImpl> modifs = entry.getModificationItems();
assertTrue( entry.isChangeModify() );
@@ -1318,7 +1318,7 @@
assertEquals( values[4][4][1], item.getAttribute().get( 0 ) );
// Sixth entry
- entry = (Entry) entries.get( 5 );
+ entry = (LdifEntry) entries.get( 5 );
modifs = entry.getModificationItems();
assertTrue( entry.isChangeModify() );
@@ -1348,9 +1348,9 @@
"changetype: delete\n";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn() );
assertTrue( entry.isChangeDelete() );
@@ -1375,9 +1375,9 @@
"changetype: delete\n";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn() );
assertTrue( entry.isChangeDelete() );
@@ -1402,9 +1402,9 @@
"changetype: delete\n";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn() );
assertTrue( entry.isChangeDelete() );
@@ -1504,8 +1504,8 @@
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
- Entry entry = (Entry) entries.get( 0 );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertEquals( "ou=Users, dc=example, dc=com", entry.getDn() );
@@ -1561,9 +1561,9 @@
"prescriptiveACI: { identificationTag \"browseRoot\", precedence 100, authenticationLevel none, itemOrUserFirst userFirst: { userClasses { allUsers }, userPermissions { { protectedItems {entry}, grantsAndDenials { grantReturnDN, grantBrowse } } } } }\n";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( ldif );
+ List<LdifEntry> entries = reader.parseLdif( ldif );
- Entry entry = (Entry) entries.get( 0 );
+ LdifEntry entry = (LdifEntry) entries.get( 0 );
assertEquals( "cn=browseRootAci,dc=example,dc=com", entry.getDn() );
Attribute attr = entry.get( "objectClass" );
Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java?rev=638218&r1=638217&r2=638218&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java Mon Mar 17 22:07:20 2008
@@ -348,7 +348,7 @@
"objectClass: pe\n rson\n" +
"objectClass: in\n etorgPerson\n\n";
- Entry entry = new Entry();
+ LdifEntry entry = new LdifEntry();
entry.setDn( "cn=Saarbr\u00FCcken, dc=example, dc=com" );
entry.setChangeType( ChangeType.Add );
@@ -408,7 +408,7 @@
public void testReverseAdd() throws NamingException
{
LdapDN dn = new LdapDN( "dc=apache, dc=com" );
- Entry reversed = LdifUtils.reverseAdd( dn );
+ LdifEntry reversed = LdifUtils.reverseAdd( dn );
assertNotNull( reversed );
assertEquals( dn.getUpName(), reversed.getDn() );
@@ -426,7 +426,7 @@
public void testReverseAddBase64DN() throws NamingException
{
LdapDN dn = new LdapDN( "dc=Emmanuel L\u00c9charny" );
- Entry reversed = LdifUtils.reverseAdd( dn );
+ LdifEntry reversed = LdifUtils.reverseAdd( dn );
assertNotNull( reversed );
assertEquals( dn.getUpName(), reversed.getDn() );
assertEquals( ChangeType.Delete, reversed.getChangeType() );
@@ -456,7 +456,7 @@
deletedEntry.put( "sn", "apache" );
deletedEntry.put( "dc", "apache" );
- Entry reversed = LdifUtils.reverseDel( dn, deletedEntry );
+ LdifEntry reversed = LdifUtils.reverseDel( dn, deletedEntry );
assertNotNull( reversed );
assertEquals( dn.getUpName(), reversed.getDn() );
@@ -484,7 +484,7 @@
attrs.put( "sn", "doe" );
attrs.put( "uid", "jdoe" );
- Entry reversed = LdifUtils.reverseModifyRdn( attrs, null, dn, new Rdn( "cn=jack doe" ) );
+ LdifEntry reversed = LdifUtils.reverseModifyRdn( attrs, null, dn, new Rdn( "cn=jack doe" ) );
assertNotNull( reversed );
assertEquals( "cn=jack doe, dc=example, dc=com", reversed.getDn() );
@@ -515,7 +515,7 @@
attrs.put( "sn", "doe" );
attrs.put( "uid", "jdoe" );
- Entry reversed = LdifUtils.reverseModifyRdn( attrs, null, dn, new Rdn( "cn=jack doe" ) );
+ LdifEntry reversed = LdifUtils.reverseModifyRdn( attrs, null, dn, new Rdn( "cn=jack doe" ) );
assertNotNull( reversed );
assertEquals( "cn=jack doe, dc=example, dc=com", reversed.getDn() );
@@ -547,7 +547,7 @@
attrs.put( "sn", "doe" );
attrs.put( "uid", "jdoe" );
- Entry reversed = LdifUtils.reverseModifyRdn( attrs, newSuperior, dn, new Rdn( "cn=jack doe" ) );
+ LdifEntry reversed = LdifUtils.reverseModifyRdn( attrs, newSuperior, dn, new Rdn( "cn=jack doe" ) );
assertNotNull( reversed );
assertEquals( "cn=jack doe,ou=system", reversed.getDn() );
@@ -577,7 +577,7 @@
attrs.put( "sn", "doe" );
attrs.put( "uid", "jdoe" );
- Entry reversed = LdifUtils.reverseModifyRdn( attrs, newSuperior, dn, null );
+ LdifEntry reversed = LdifUtils.reverseModifyRdn( attrs, newSuperior, dn, null );
assertNotNull( reversed );
assertEquals( "cn=john doe,ou=system", reversed.getDn() );
@@ -606,7 +606,7 @@
attrs.put( "sn", "doe" );
attrs.put( "uid", "jdoe" );
- Entry reversed = LdifUtils.reverseModifyRdn( attrs, newSuperior, dn, new Rdn( "cn=jack doe" ) );
+ LdifEntry reversed = LdifUtils.reverseModifyRdn( attrs, newSuperior, dn, new Rdn( "cn=jack doe" ) );
assertNotNull( reversed );
assertEquals( "cn=jack doe,ou=system", reversed.getDn() );
@@ -637,7 +637,7 @@
DirContext.ADD_ATTRIBUTE,
new AttributeImpl( "ou", "BigCompany inc." ) );
- Entry reversed = LdifUtils.reverseModify( dn,
+ LdifEntry reversed = LdifUtils.reverseModify( dn,
Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
assertNotNull( reversed );
@@ -674,7 +674,7 @@
DirContext.ADD_ATTRIBUTE,
new AttributeImpl( "ou", "BigCompany inc." ) );
- Entry reversed = LdifUtils.reverseModify( dn,
+ LdifEntry reversed = LdifUtils.reverseModify( dn,
Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
assertNotNull( reversed );
@@ -712,7 +712,7 @@
DirContext.ADD_ATTRIBUTE,
new AttributeImpl( "cn", "test" ) );
- Entry reversed = LdifUtils.reverseModify( dn,
+ LdifEntry reversed = LdifUtils.reverseModify( dn,
Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
assertNull( reversed );
@@ -738,7 +738,7 @@
DirContext.REMOVE_ATTRIBUTE,
new AttributeImpl( "ou", "acme corp" ) );
- Entry reversed = LdifUtils.reverseModify( dn,
+ LdifEntry reversed = LdifUtils.reverseModify( dn,
Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
assertNotNull( reversed );
@@ -783,7 +783,7 @@
DirContext.REMOVE_ATTRIBUTE,
new AttributeImpl( "ou" ) );
- Entry reversed = LdifUtils.reverseModify( dn,
+ LdifEntry reversed = LdifUtils.reverseModify( dn,
Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
@@ -828,7 +828,7 @@
ModificationItemImpl mod = new ModificationItemImpl(
DirContext.REMOVE_ATTRIBUTE, ou );
- Entry reversed = LdifUtils.reverseModify( dn,
+ LdifEntry reversed = LdifUtils.reverseModify( dn,
Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
@@ -877,7 +877,7 @@
ModificationItemImpl mod = new ModificationItemImpl(
DirContext.REPLACE_ATTRIBUTE, ouModified );
- Entry reversed = LdifUtils.reverseModify( dn,
+ LdifEntry reversed = LdifUtils.reverseModify( dn,
Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
@@ -921,7 +921,7 @@
ModificationItemImpl mod = new ModificationItemImpl(
DirContext.REPLACE_ATTRIBUTE, newOu );
- Entry reversed = LdifUtils.reverseModify( dn,
+ LdifEntry reversed = LdifUtils.reverseModify( dn,
Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
assertNotNull( reversed );
@@ -965,7 +965,7 @@
ModificationItemImpl mod = new ModificationItemImpl(
DirContext.REPLACE_ATTRIBUTE, new AttributeImpl( "ou" ) );
- Entry reversed = LdifUtils.reverseModify( dn,
+ LdifEntry reversed = LdifUtils.reverseModify( dn,
Collections.<ModificationItemImpl>singletonList( mod ), modifiedEntry );
assertNotNull( reversed );
@@ -1075,9 +1075,9 @@
"ou: acme corp\n";
LdifReader reader = new LdifReader();
- List<Entry> entries = reader.parseLdif( initialEntryLdif );
+ List<LdifEntry> entries = reader.parseLdif( initialEntryLdif );
- Entry initialEntry = entries.get( 0 );
+ LdifEntry initialEntry = entries.get( 0 );
// We will :
// - add an 'ou' value 'BigCompany inc.'
@@ -1115,7 +1115,7 @@
DirContext.REPLACE_ATTRIBUTE, new AttributeImpl( "ou", "apache" ) );
modifications.add( mod );
- Entry reversedEntry = LdifUtils.reverseModify( dn, modifications, initialEntry.getAttributes() );
+ LdifEntry reversedEntry = LdifUtils.reverseModify( dn, modifications, initialEntry.getAttributes() );
String expectedEntryLdif =
"dn: cn=test, ou=system\n" +
@@ -1140,7 +1140,7 @@
reader = new LdifReader();
entries = reader.parseLdif( expectedEntryLdif );
- Entry expectedEntry = entries.get( 0 );
+ LdifEntry expectedEntry = entries.get( 0 );
assertEquals( expectedEntry, reversedEntry );
}
Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValueTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValueTest.java?rev=638218&r1=638217&r2=638218&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValueTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/AttributeTypeAndValueTest.java Mon Mar 17 22:07:20 2008
@@ -32,9 +32,9 @@
import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
import org.apache.directory.shared.ldap.util.StringTools;
import org.junit.Test;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
/**
@@ -42,13 +42,14 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class AttributeTypeAndValueTest extends TestCase
+public class AttributeTypeAndValueTest
{
// ~ Methods
// ------------------------------------------------------------------------------------
/**
* Test a null AttributeTypeAndValue
*/
+ @Test
public void testAttributeTypeAndValueNull()
{
AttributeTypeAndValue atav = new AttributeTypeAndValue();
@@ -62,6 +63,7 @@
/**
* Test a null type for an AttributeTypeAndValue
*/
+ @Test
public void testAttributeTypeAndValueNullType() throws InvalidNameException
{
try
@@ -79,6 +81,7 @@
/**
* Test an invalid type for an AttributeTypeAndValue
*/
+ @Test
public void testAttributeTypeAndValueInvalidType() throws InvalidNameException
{
try
@@ -96,6 +99,7 @@
/**
* Test a valid type for an AttributeTypeAndValue
*/
+ @Test
public void testAttributeTypeAndValueValidType() throws InvalidNameException
{
AttributeTypeAndValue atav = new AttributeTypeAndValue( "A", "a", null, null );
@@ -119,12 +123,13 @@
/**
* test an empty AttributeTypeAndValue
*/
+ @Test
public void testLdapRDNEmpty()
{
try
{
new AttributeTypeAndValue( "", "", "", "" );
- Assert.fail( "Should not occurs ... " );
+ fail( "Should not occurs ... " );
}
catch ( InvalidNameException ine )
{
@@ -136,6 +141,7 @@
/**
* test a simple AttributeTypeAndValue : a = b
*/
+ @Test
public void testLdapRDNSimple() throws InvalidNameException
{
AttributeTypeAndValue atav = new AttributeTypeAndValue( "a", "a", "b", "b" );
@@ -149,6 +155,7 @@
/**
* Compares two equals atavs
*/
+ @Test
public void testCompareToEquals() throws InvalidNameException
{
AttributeTypeAndValue atav1 = new AttributeTypeAndValue( "a", "a", "b", "b" );
@@ -161,6 +168,7 @@
/**
* Compares two equals atavs but with a type in different case
*/
+ @Test
public void testCompareToEqualsCase() throws InvalidNameException
{
AttributeTypeAndValue atav1 = new AttributeTypeAndValue( "a", "a", "b", "b" );
@@ -174,6 +182,7 @@
* Compare two atavs : the first one is superior because its type is
* superior
*/
+ @Test
public void testCompareAtav1TypeSuperior() throws InvalidNameException
{
AttributeTypeAndValue atav1 = new AttributeTypeAndValue( "b", "b", "b", "b" );
@@ -187,6 +196,7 @@
* Compare two atavs : the second one is superior because its type is
* superior
*/
+ @Test
public void testCompareAtav2TypeSuperior() throws InvalidNameException
{
AttributeTypeAndValue atav1 = new AttributeTypeAndValue( "a", "a", "b", "b" );
@@ -200,6 +210,7 @@
* Compare two atavs : the first one is superior because its type is
* superior
*/
+ @Test
public void testCompareAtav1ValueSuperior() throws InvalidNameException
{
AttributeTypeAndValue atav1 = new AttributeTypeAndValue( "a", "a", "b", "b" );
@@ -213,6 +224,7 @@
* Compare two atavs : the second one is superior because its type is
* superior
*/
+ @Test
public void testCompareAtav2ValueSuperior() throws InvalidNameException
{
AttributeTypeAndValue atav1 = new AttributeTypeAndValue( "a", "a", "a", "a" );
@@ -222,6 +234,7 @@
}
+ @Test
public void testNormalize() throws InvalidNameException
{
AttributeTypeAndValue atav = new AttributeTypeAndValue( " A ", " A ", "a", "a" );
@@ -391,6 +404,165 @@
AttributeTypeAndValue atav2 = new AttributeTypeAndValue();
atav2.readExternal( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ /**
+ * Test serialization of a simple ATAV
+ */
+ @Test
+ public void testStringAtavStaticSerialization() throws NamingException, IOException, ClassNotFoundException
+ {
+ AttributeTypeAndValue atav = new AttributeTypeAndValue( "cn", "CN", "test", "Test" );
+
+ atav.normalize();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ AtavSerializer.serialize( atav, out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ AttributeTypeAndValue atav2 = AtavSerializer.deserialize( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ @Test
+ public void testBinaryAtavStaticSerialization() throws NamingException, IOException, ClassNotFoundException
+ {
+ byte[] upValue = StringTools.getBytesUtf8( " Test " );
+ byte[] normValue = StringTools.getBytesUtf8( "Test" );
+
+ AttributeTypeAndValue atav = new AttributeTypeAndValue( "cn", "CN", upValue, normValue );
+
+ atav.normalize();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ AtavSerializer.serialize( atav, out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ AttributeTypeAndValue atav2 = AtavSerializer.deserialize( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ /**
+ * Test static serialization of a simple ATAV
+ */
+ @Test
+ public void testNullAtavStaticSerialization() throws NamingException, IOException, ClassNotFoundException
+ {
+ AttributeTypeAndValue atav = new AttributeTypeAndValue();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ try
+ {
+ AtavSerializer.serialize( atav, out );
+ fail();
+ }
+ catch ( IOException ioe )
+ {
+ assertTrue( true );
+ }
+ }
+
+
+ @Test
+ public void testNullNormValueStaticSerialization() throws NamingException, IOException, ClassNotFoundException
+ {
+ AttributeTypeAndValue atav = new AttributeTypeAndValue( "CN", "cn", "test", (String)null );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ try
+ {
+ AtavSerializer.serialize( atav, out );
+ fail();
+ }
+ catch ( IOException ioe )
+ {
+ String message = ioe.getMessage();
+ assertEquals( "Cannot serialize an wrong ATAV, the value should not be null", message );
+ }
+ }
+
+
+ @Test
+ public void testNullUpValueStaticSerialization() throws NamingException, IOException, ClassNotFoundException
+ {
+ AttributeTypeAndValue atav = new AttributeTypeAndValue( "CN", "cn", null, "test" );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ try
+ {
+ AtavSerializer.serialize( atav, out );
+ fail();
+ }
+ catch ( IOException ioe )
+ {
+ String message = ioe.getMessage();
+ assertEquals( "Cannot serialize an wrong ATAV, the upValue should not be null", message );
+ }
+ }
+
+
+ @Test
+ public void testEmptyNormValueStaticSerialization() throws NamingException, IOException, ClassNotFoundException
+ {
+ AttributeTypeAndValue atav = new AttributeTypeAndValue( "CN", "cn", "test", "" );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ AtavSerializer.serialize( atav, out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ AttributeTypeAndValue atav2 = AtavSerializer.deserialize( in );
+
+ assertEquals( atav, atav2 );
+ }
+
+
+ @Test
+ public void testEmptyUpValueStaticSerialization() throws NamingException, IOException, ClassNotFoundException
+ {
+ AttributeTypeAndValue atav = new AttributeTypeAndValue( "CN", "cn", "", "test" );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ AtavSerializer.serialize( atav, out );
+
+ ObjectInputStream in = null;
+
+ byte[] data = baos.toByteArray();
+ in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ AttributeTypeAndValue atav2 = AtavSerializer.deserialize( in );
assertEquals( atav, atav2 );
}
Modified: directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java?rev=638218&r1=638217&r2=638218&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/shared/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java Mon Mar 17 22:07:20 2008
@@ -21,9 +21,8 @@
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -2319,91 +2318,7 @@
"2.5.4.11= Some People + domainComponent= And Some anImAls,DomainComponent = eXample,0.9.2342.19200300.100.1.25= cOm" ) );
}
-
- /**
- * Test the serialization of a DN
- *
- * @throws Exception
- */
- @Test public void testNameSerialization() throws Exception
- {
- LdapDN name = new LdapDN( "ou= Some People + dc= And Some anImAls,dc = eXample,dc= cOm" );
- name.normalize( oids );
-
- FileOutputStream fOut = null;
- ObjectOutputStream oOut = null;
- File file = new File( "LdapDN.ser" );
-
- try
- {
- fOut = new FileOutputStream( file );
- oOut = new ObjectOutputStream( fOut );
- oOut.writeObject( name );
- }
- catch ( IOException ioe )
- {
- throw ioe;
- }
- finally
- {
- try
- {
- if ( oOut != null )
- {
- oOut.flush();
- oOut.close();
- }
-
- if ( fOut != null )
- {
- fOut.close();
- }
- }
- catch ( IOException ioe )
- {
- throw ioe;
- }
- }
-
- FileInputStream fIn = null;
- ObjectInputStream oIn = null;
-
- try
- {
- fIn = new FileInputStream( file );
- oIn = new ObjectInputStream( fIn );
-
- LdapDN nameSer = ( LdapDN ) oIn.readObject();
-
- assertEquals( 0, nameSer.compareTo( name ) );
- }
- catch ( IOException ioe )
- {
- throw ioe;
- }
- finally
- {
- try
- {
- if ( oIn != null )
- {
- oIn.close();
- }
-
- if ( fIn != null )
- {
- fIn.close();
- }
-
- file.delete();
- }
- catch ( IOException ioe )
- {
- throw ioe;
- }
- }
- }
-
+
/**
* Class to test for hashCode().
*/
@@ -2827,11 +2742,188 @@
assertFalse( LdapDN.isValid( "a" ) );
assertFalse( LdapDN.isValid( "a " ) );
- assertFalse( LdapDN.isValid( "a=" ) );
- assertFalse( LdapDN.isValid( "a= " ) );
+ assertTrue( LdapDN.isValid( "a=" ) );
+ assertTrue( LdapDN.isValid( "a= " ) );
assertFalse( LdapDN.isValid( "=" ) );
assertFalse( LdapDN.isValid( " = " ) );
assertFalse( LdapDN.isValid( " = a" ) );
+ }
+
+ private ByteArrayOutputStream serializeDN( LdapDN dn ) throws IOException
+ {
+ ObjectOutputStream oOut = null;
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ try
+ {
+ oOut = new ObjectOutputStream( out );
+ oOut.writeObject( dn );
+ }
+ catch ( IOException ioe )
+ {
+ throw ioe;
+ }
+ finally
+ {
+ try
+ {
+ if ( oOut != null )
+ {
+ oOut.flush();
+ oOut.close();
+ }
+ }
+ catch ( IOException ioe )
+ {
+ throw ioe;
+ }
+ }
+
+ return out;
+ }
+
+
+ private LdapDN deserializeDN( ByteArrayOutputStream out ) throws IOException, ClassNotFoundException
+ {
+ ObjectInputStream oIn = null;
+ ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
+
+ try
+ {
+ oIn = new ObjectInputStream( in );
+
+ LdapDN dn = ( LdapDN ) oIn.readObject();
+
+ return dn;
+ }
+ catch ( IOException ioe )
+ {
+ throw ioe;
+ }
+ finally
+ {
+ try
+ {
+ if ( oIn != null )
+ {
+ oIn.close();
+ }
+ }
+ catch ( IOException ioe )
+ {
+ throw ioe;
+ }
+ }
+ }
+
+
+ /**
+ * Test the serialization of a DN
+ *
+ * @throws Exception
+ */
+ @Test public void testNameSerialization() throws Exception
+ {
+ LdapDN dn = new LdapDN( "ou= Some People + dc= And Some anImAls,dc = eXample,dc= cOm" );
+ dn.normalize( oids );
+
+ assertEquals( dn, deserializeDN( serializeDN( dn ) ) );
+ }
+
+
+ @Test public void testSerializeEmptyDN() throws Exception
+ {
+ LdapDN dn = LdapDN.EMPTY_LDAPDN;
+
+ assertEquals( dn, deserializeDN( serializeDN( dn ) ) );
+ }
+
+
+ /**
+ * Test the serialization of a DN
+ *
+ * @throws Exception
+ */
+ @Test public void testNameStaticSerialization() throws Exception
+ {
+ LdapDN dn = new LdapDN( "ou= Some People + dc= And Some anImAls,dc = eXample,dc= cOm" );
+ dn.normalize( oids );
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ LdapDNSerializer.serialize( dn, out );
+
+ byte[] data = baos.toByteArray();
+ ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ assertEquals( dn, LdapDNSerializer.deserialize( in ) );
+ }
+
+
+ /*
+ @Test public void testSerializationPerfs() throws Exception
+ {
+ LdapDN dn = new LdapDN( "ou= Some People + dc= And Some anImAls,dc = eXample,dc= cOm" );
+ dn.normalize( oids );
+
+ long t0 = System.currentTimeMillis();
+
+ for ( int i = 0; i < 1000; i++ )
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ DnSerializer.serialize( dn, out );
+
+ byte[] data = baos.toByteArray();
+ ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ LdapDN dn1 = DnSerializer.deserialize( in );
+ }
+
+ long t1 = System.currentTimeMillis();
+
+ System.out.println( "delta :" + ( t1 - t0) );
+
+ long t2 = System.currentTimeMillis();
+
+ for ( int i = 0; i < 1000000; i++ )
+ {
+ //ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ //ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ //DnSerializer.serializeString( dn, out );
+
+ //byte[] data = baos.toByteArray();
+ //ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ //LdapDN dn1 = DnSerializer.deserializeString( in, oids );
+ dn.normalize( oids );
+ }
+
+ long t3 = System.currentTimeMillis();
+
+ System.out.println( "delta :" + ( t3 - t2) );
+
+ //assertEquals( dn, DnSerializer.deserialize( in ) );
+ }
+ */
+
+ @Test public void testStaticSerializeEmptyDN() throws Exception
+ {
+ LdapDN dn = LdapDN.EMPTY_LDAPDN;
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( baos );
+
+ LdapDNSerializer.serialize( dn, out );
+
+ byte[] data = baos.toByteArray();
+ ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+ assertEquals( dn, LdapDNSerializer.deserialize( in ) );
+ assertEquals( dn, deserializeDN( serializeDN( dn ) ) );
}
}