You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/05/27 10:08:45 UTC
svn commit: r948711 [2/7] - in /directory:
apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/
apacheds/trunk/core-avl/src/main/java/org/apache/directory/server/core/avltree/
apacheds/trunk/core-integ/src/test/java/org/apache/...
Modified: directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/SchemaAwareEntryTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/SchemaAwareEntryTest.java?rev=948711&r1=948710&r2=948711&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/SchemaAwareEntryTest.java (original)
+++ directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/SchemaAwareEntryTest.java Thu May 27 08:08:44 2010
@@ -44,9 +44,9 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.entry.BinaryValue;
import org.apache.directory.shared.ldap.entry.DefaultEntry;
import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
-import org.apache.directory.shared.ldap.entry.StringValue;
import org.apache.directory.shared.ldap.entry.Entry;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.StringValue;
import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
@@ -63,6 +63,7 @@ import org.apache.directory.shared.ldap.
import org.junit.BeforeClass;
import org.junit.Test;
+
/**
* Test the DefaultEntry class.
*
@@ -71,33 +72,37 @@ import org.junit.Test;
*/
public class SchemaAwareEntryTest
{
- private static final byte[] BYTES1 = new byte[]{ 'a', 'b' };
- private static final byte[] BYTES2 = new byte[]{ 'b' };
- private static final byte[] BYTES3 = new byte[]{ 'c' };
+ private static final byte[] BYTES1 = new byte[]
+ { 'a', 'b' };
+ private static final byte[] BYTES2 = new byte[]
+ { 'b' };
+ private static final byte[] BYTES3 = new byte[]
+ { 'c' };
private static LdifSchemaLoader loader;
private static SchemaManager schemaManager;
-
+
private static AttributeType atObjectClass;
private static AttributeType atCN;
private static AttributeType atDC;
private static AttributeType atSN;
- private static AttributeType atC;
- private static AttributeType atL;
- private static AttributeType atOC;
-
+ private static AttributeType atC;
+ private static AttributeType atL;
+ private static AttributeType atOC;
+
// A Binary attribute
private static AttributeType atPwd;
private static DN EXAMPLE_DN;
-
+
+
/**
* Initialize the registries once for the whole test suite
*/
@BeforeClass
public static void setup() throws Exception
{
- String workingDirectory = System.getProperty( "workingDirectory" );
+ String workingDirectory = System.getProperty( "workingDirectory" );
if ( workingDirectory == null )
{
@@ -113,9 +118,9 @@ public class SchemaAwareEntryTest
schemaManager = new DefaultSchemaManager( loader );
schemaManager.loadAllEnabled();
-
+
List<Throwable> errors = schemaManager.getErrors();
-
+
if ( errors.size() != 0 )
{
fail( "Schema load failed : " + LdapExceptionUtils.printErrors( errors ) );
@@ -129,7 +134,7 @@ public class SchemaAwareEntryTest
atOC = schemaManager.lookupAttributeTypeRegistry( "objectClass" );
atSN = schemaManager.lookupAttributeTypeRegistry( "sn" );
atPwd = schemaManager.lookupAttributeTypeRegistry( "userpassword" );
-
+
EXAMPLE_DN = new DN( "dc=example,dc=com" );
}
@@ -148,8 +153,8 @@ public class SchemaAwareEntryTest
assertEquals( DN.EMPTY_DN, entry.getDn() );
assertEquals( 0, entry.size() );
}
-
-
+
+
/**
* Test for method DefaultEntry( registries )
*/
@@ -161,8 +166,8 @@ public class SchemaAwareEntryTest
assertEquals( DN.EMPTY_DN, entry.getDn() );
assertEquals( 0, entry.size() );
}
-
-
+
+
/**
* Test for method DefaultEntry( registries, DN )
*/
@@ -174,8 +179,8 @@ public class SchemaAwareEntryTest
assertEquals( EXAMPLE_DN, entry.getDn() );
assertEquals( 0, entry.size() );
}
-
-
+
+
/**
* Test for method DefaultEntry( registries, DN, AttributeType... )
*/
@@ -190,8 +195,8 @@ public class SchemaAwareEntryTest
assertTrue( entry.containsAttribute( atPwd ) );
assertTrue( entry.containsAttribute( atCN ) );
}
-
-
+
+
/**
* Test for method DefaultEntry( registries, DN, AttributeType, upId )
*/
@@ -206,8 +211,8 @@ public class SchemaAwareEntryTest
assertEquals( "objectclass", entry.get( atOC ).getId() );
assertEquals( " OBJECTCLASS ", entry.get( atOC ).getUpId() );
}
-
-
+
+
/**
* Test for method DefaultEntry( registries, DN, AttributeType, upId )
*/
@@ -225,8 +230,8 @@ public class SchemaAwareEntryTest
assertEquals( "cn", entry.get( atCN ).getId() );
assertEquals( " Cn ", entry.get( atCN ).getUpId() );
}
-
-
+
+
//-------------------------------------------------------------------------
// Test the Add methods
//-------------------------------------------------------------------------
@@ -237,38 +242,38 @@ public class SchemaAwareEntryTest
public void testAddEntryAttribute() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
EntryAttribute oc = new DefaultEntryAttribute( atObjectClass, "top", "person" );
EntryAttribute cn = new DefaultEntryAttribute( atCN, "test1", "test2" );
EntryAttribute sn = new DefaultEntryAttribute( atSN, "Test1", "Test2" );
EntryAttribute up = new DefaultEntryAttribute( atPwd, BYTES1, BYTES2 );
EntryAttribute c = new DefaultEntryAttribute( atC, "FR", "US" );
-
+
entry.add( oc, cn, sn, c );
-
+
assertEquals( 4, entry.size() );
assertTrue( entry.containsAttribute( "ObjectClass" ) );
assertTrue( entry.containsAttribute( "CN" ) );
assertTrue( entry.containsAttribute( " sn " ) );
assertTrue( entry.containsAttribute( " countryName " ) );
-
+
EntryAttribute attr = entry.get( "objectclass" );
assertEquals( 2, attr.size() );
-
+
EntryAttribute c2 = new DefaultEntryAttribute( atC, "UK", "DE" );
entry.add( c2, up );
assertEquals( 5, entry.size() );
-
+
assertTrue( entry.containsAttribute( "userPassword" ) );
assertTrue( entry.containsAttribute( " countryName " ) );
EntryAttribute attrC = entry.get( "countryName" );
assertEquals( 4, attrC.size() );
-
+
entry.clear();
}
-
+
/**
* Test for method add( String, byte[]...)
*/
@@ -276,16 +281,16 @@ public class SchemaAwareEntryTest
public void testAddStringByteArrayArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
- entry.add( "userPassword", (byte[])null );
+
+ entry.add( "userPassword", ( byte[] ) null );
assertEquals( 1, entry.size() );
EntryAttribute attributePWD = entry.get( "userPassword" );
assertEquals( 1, attributePWD.size() );
assertNotNull( attributePWD.get() );
assertNull( attributePWD.get().get() );
-
+
entry.clear();
-
+
entry.add( "userPassword", BYTES1, BYTES1, BYTES2 );
assertEquals( 1, entry.size() );
EntryAttribute attributeJPG = entry.get( "userPassword" );
@@ -293,25 +298,25 @@ public class SchemaAwareEntryTest
assertNotNull( attributeJPG.get() );
assertTrue( attributeJPG.contains( BYTES1 ) );
assertTrue( attributeJPG.contains( BYTES2 ) );
-
+
entry.clear();
-
+
try
{
// Cannot add an attribute which does not exist
entry.add( "wrongAT", BYTES1, BYTES2 );
fail();
- }
- catch ( LdapNoSuchAttributeException nsae )
- {
- assertTrue( true );
- }
-
- // Cannot add String values into a binary attribute
- entry.add( "userPassword", "test", "test2" );
- assertEquals( 2, entry.get( "userPassword" ).size() );
+ }
+ catch ( LdapNoSuchAttributeException nsae )
+ {
+ assertTrue( true );
+ }
+
+ // Cannot add String values into a binary attribute
+ entry.add( "userPassword", "test", "test2" );
+ assertEquals( 2, entry.get( "userPassword" ).size() );
}
-
+
/**
* Test for method add( String, String...)
@@ -320,24 +325,24 @@ public class SchemaAwareEntryTest
public void testAddStringStringArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
- entry.add( "cn", (String)null );
+
+ entry.add( "cn", ( String ) null );
assertEquals( 1, entry.size() );
EntryAttribute attributeCN = entry.get( "cn" );
-
+
assertEquals( 0, attributeCN.size() );
assertNull( attributeCN.get() );
-
+
entry.add( "sn", "test", "test", "TEST" );
assertEquals( 2, entry.size() );
EntryAttribute attributeSN = entry.get( "sn" );
-
+
// 'TEST' and 'test' are the same value for 'sn' (this is a case insensitive attributeType)
assertEquals( 1, attributeSN.size() );
assertNotNull( attributeSN.get() );
assertTrue( attributeSN.contains( "test" ) );
assertTrue( attributeSN.contains( "TEST" ) );
-
+
entry.clear();
try
@@ -352,10 +357,10 @@ public class SchemaAwareEntryTest
}
// Cannot add binary values into a String attribute
- entry.add( "sn",BYTES1, BYTES2 );
+ entry.add( "sn", BYTES1, BYTES2 );
assertEquals( 0, entry.get( "sn" ).size() );
}
-
+
/**
* Test for method add( String, Value<?>...)
@@ -364,15 +369,15 @@ public class SchemaAwareEntryTest
public void testAddStringValueArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
- Value<String> value = new StringValue( atCN, (String)null );
-
+ Value<String> value = new StringValue( atCN, ( String ) null );
+
entry.add( "cn", value );
assertEquals( 1, entry.size() );
EntryAttribute attributeCN = entry.get( "cn" );
assertEquals( 1, attributeCN.size() );
assertNotNull( attributeCN.get() );
assertNull( attributeCN.get().get() );
-
+
Value<String> value1 = new StringValue( atCN, "test1" );
Value<String> value2 = new StringValue( atCN, "test2" );
Value<String> value3 = new StringValue( atCN, "test1" );
@@ -384,12 +389,12 @@ public class SchemaAwareEntryTest
assertNotNull( attributeSN.get() );
assertTrue( attributeSN.contains( value1 ) );
assertTrue( attributeSN.contains( value2 ) );
-
+
Value<byte[]> value4 = new BinaryValue( atPwd, BYTES1 );
entry.add( "l", value1, value4 );
assertEquals( 3, entry.size() );
EntryAttribute attributeL = entry.get( "l" );
-
+
// Cannot store a binary value in a String attribute
assertEquals( 1, attributeL.size() );
assertNotNull( attributeL.get() );
@@ -417,22 +422,22 @@ public class SchemaAwareEntryTest
public void testAddAttributeTypeByteArrayArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
entry.add( atPwd, BYTES1, BYTES2 );
assertEquals( 1, entry.size() );
assertTrue( entry.contains( atPwd, BYTES1, BYTES2 ) );
-
- entry.add( atPwd, (byte[])null, BYTES1 );
+
+ entry.add( atPwd, ( byte[] ) null, BYTES1 );
assertEquals( 1, entry.size() );
-
+
EntryAttribute attribute = entry.get( atPwd );
assertEquals( 3, attribute.size() );
assertTrue( attribute.contains( BYTES1 ) );
assertTrue( attribute.contains( BYTES2 ) );
- assertTrue( attribute.contains( (byte[])null ) );
+ assertTrue( attribute.contains( ( byte[] ) null ) );
}
-
-
+
+
/**
* Test method for add( AttributeType, String... )
*/
@@ -440,27 +445,27 @@ public class SchemaAwareEntryTest
public void testAddAttributeTypeStringArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
entry.add( atC, "us", "fr" );
assertEquals( 1, entry.size() );
assertTrue( entry.contains( atC, "fr", "us" ) );
-
- entry.add( atC, (String)null, "de", "fr" );
+
+ entry.add( atC, ( String ) null, "de", "fr" );
assertEquals( 1, entry.size() );
-
+
EntryAttribute attribute = entry.get( atC );
assertEquals( 3, attribute.size() );
assertTrue( attribute.contains( "de" ) );
assertTrue( attribute.contains( "fr" ) );
- assertFalse( attribute.contains( (String)null ) );
+ assertFalse( attribute.contains( ( String ) null ) );
assertTrue( attribute.contains( "us" ) );
-
+
entry.clear();
-
+
assertEquals( 0, entry.size() );
}
-
-
+
+
/**
* Test method for add( AttributeType, Value<?>... )
*/
@@ -468,43 +473,41 @@ public class SchemaAwareEntryTest
public void testAddAttributeTypeValueArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
Value<String> strValue1 = new StringValue( atCN, "test1" );
Value<String> strValue2 = new StringValue( atCN, "test2" );
Value<String> strValue3 = new StringValue( atCN, "test3" );
- Value<String> strNullValue = new StringValue( atCN, null);
+ Value<String> strNullValue = new StringValue( atCN, null );
Value<byte[]> binValue1 = new BinaryValue( atPwd, BYTES1 );
Value<byte[]> binValue2 = new BinaryValue( atPwd, BYTES2 );
Value<byte[]> binValue3 = new BinaryValue( atPwd, BYTES3 );
-
+
try
{
- entry.add( (AttributeType)null, strValue1 );
+ entry.add( ( AttributeType ) null, strValue1 );
fail();
}
- catch( IllegalArgumentException iae )
+ catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
-
+
entry.add( atCN, strValue1, strValue2, strValue1 );
entry.add( atPwd, binValue1, binValue2, binValue1 );
-
+
assertEquals( 2, entry.size() );
assertTrue( entry.contains( atCN, "test1", "test2" ) );
assertTrue( entry.contains( atPwd, BYTES1, BYTES2 ) );
-
+
entry.add( atCN, strValue3, strNullValue );
-
+
assertEquals( 4, entry.get( atCN ).size() );
assertTrue( entry.contains( atCN, strNullValue ) );
-
+
entry.add( atCN, binValue3 );
assertFalse( entry.contains( atCN, binValue3 ) );
}
-
-
/**
@@ -514,21 +517,21 @@ public class SchemaAwareEntryTest
public void testAddStringAttributeTypeByteArrayArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
entry.add( "UserPassword", atPwd, BYTES1, BYTES2 );
assertEquals( 1, entry.size() );
assertTrue( entry.contains( atPwd, BYTES1, BYTES2 ) );
assertEquals( "UserPassword", entry.get( atPwd ).getUpId() );
assertEquals( "userpassword", entry.get( atPwd ).getId() );
-
- entry.add( " UserPassword ", atPwd, (byte[])null, BYTES1 );
+
+ entry.add( " UserPassword ", atPwd, ( byte[] ) null, BYTES1 );
assertEquals( 1, entry.size() );
-
+
EntryAttribute attribute = entry.get( atPwd );
assertEquals( 3, attribute.size() );
assertTrue( attribute.contains( BYTES1 ) );
assertTrue( attribute.contains( BYTES2 ) );
- assertTrue( attribute.contains( (byte[])null ) );
+ assertTrue( attribute.contains( ( byte[] ) null ) );
assertEquals( " UserPassword ", attribute.getUpId() );
assertEquals( "userpassword", attribute.getId() );
@@ -537,13 +540,13 @@ public class SchemaAwareEntryTest
entry.add( " ObjectClass ", atOC, BYTES1 );
fail();
}
- catch( UnsupportedOperationException uoe )
+ catch ( UnsupportedOperationException uoe )
{
assertTrue( true );
}
}
-
-
+
+
/**
* Test method for add( String, AttributeType, String... )
*/
@@ -551,34 +554,34 @@ public class SchemaAwareEntryTest
public void testAddStringAttributeTypeStringArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
entry.add( "DomainComponent", atDC, "test1", "test2" );
assertEquals( 1, entry.size() );
assertTrue( entry.contains( atDC, "test1", "test2" ) );
assertEquals( "DomainComponent", entry.get( atDC ).getUpId() );
assertEquals( "domaincomponent", entry.get( atDC ).getId() );
-
- entry.add( " DC ", atDC, (String)null, "test1" );
+
+ entry.add( " DC ", atDC, ( String ) null, "test1" );
assertEquals( 1, entry.size() );
-
+
EntryAttribute attribute = entry.get( atDC );
assertEquals( 3, attribute.size() );
assertTrue( attribute.contains( "test1" ) );
- assertTrue( attribute.contains( (String)null ) );
+ assertTrue( attribute.contains( ( String ) null ) );
assertTrue( attribute.contains( "test2" ) );
assertEquals( " DC ", attribute.getUpId() );
assertEquals( "dc", attribute.getId() );
entry.clear();
-
+
// Binary values are not allowed
entry.add( " DC ", atDC, BYTES1 );
assertEquals( 1, entry.size() );
assertNotNull( entry.get( atDC ) );
assertEquals( 0, entry.get( atDC ).size() );
}
-
-
+
+
/**
* Test method for add( String, AttributeType, Value<?>... )
*/
@@ -586,29 +589,29 @@ public class SchemaAwareEntryTest
public void testAddStringAttributeTypeValueArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
Value<String> strValue1 = new StringValue( atCN, "test1" );
Value<String> strValue2 = new StringValue( atCN, "test2" );
Value<String> strValue3 = new StringValue( atCN, "test3" );
- Value<String> strNullValue = new StringValue( atCN, null);
+ Value<String> strNullValue = new StringValue( atCN, null );
Value<byte[]> binValue1 = new BinaryValue( atPwd, BYTES1 );
Value<byte[]> binValue2 = new BinaryValue( atPwd, BYTES2 );
Value<byte[]> binValue3 = new BinaryValue( atPwd, BYTES3 );
-
+
try
{
- entry.add( "cn", (AttributeType)null, strValue1 );
+ entry.add( "cn", ( AttributeType ) null, strValue1 );
fail();
}
- catch( IllegalArgumentException iae )
+ catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
-
+
entry.add( "CN", atCN, strValue1, strValue2, strValue1 );
entry.add( "UserPassword", atPwd, binValue1, binValue2, binValue1 );
-
+
assertEquals( 2, entry.size() );
assertTrue( entry.contains( atCN, "test1", "test2" ) );
assertTrue( entry.contains( atPwd, BYTES1, BYTES2 ) );
@@ -616,15 +619,15 @@ public class SchemaAwareEntryTest
assertEquals( "cn", entry.get( atCN ).getId() );
assertEquals( "UserPassword", entry.get( atPwd ).getUpId() );
assertEquals( "userpassword", entry.get( atPwd ).getId() );
-
+
entry.add( "CN", atCN, strValue3, strNullValue );
-
+
assertEquals( 4, entry.get( atCN ).size() );
assertTrue( entry.contains( atCN, strNullValue ) );
-
+
entry.add( atCN, binValue3 );
assertFalse( entry.contains( atCN, binValue3 ) );
-
+
try
{
entry.add( "SN", atCN, "test" );
@@ -635,33 +638,34 @@ public class SchemaAwareEntryTest
assertTrue( true );
}
}
-
-
+
+
/**
* Test the add( AT, String... ) method
*/
- @Test public void testAddAtStringElipsis() throws Exception
+ @Test
+ public void testAddAtStringElipsis() throws Exception
{
DN dn = new DN( "cn=test" );
DefaultEntry entry = new DefaultEntry( schemaManager, dn );
-
+
// Test that we can't inject a null AT
try
{
- entry.add( (AttributeType)null, "test" );
+ entry.add( ( AttributeType ) null, "test" );
fail();
}
catch ( IllegalArgumentException iae )
{
// Expected
}
-
+
// Test a simple addition
entry.add( atDC, "test1" );
assertNotNull( entry.get( atDC ) );
assertEquals( 1, entry.get( atDC ).size() );
assertEquals( "test1", entry.get( atDC ).get().getString() );
-
+
// Test some more addition
entry.add( atDC, "test2", "test3" );
assertNotNull( entry.get( atDC ) );
@@ -669,7 +673,7 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
-
+
// Test some addition of existing values
entry.add( atDC, "test2" );
assertNotNull( entry.get( atDC ) );
@@ -677,21 +681,21 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
-
+
// Test the addition of a null value
- entry.add( atDC, (String)null );
+ entry.add( atDC, ( String ) null );
assertNotNull( entry.get( atDC ) );
assertEquals( 4, entry.get( atDC ).size() );
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
- assertTrue( entry.contains( atDC, (String )null ) );
-
+ assertTrue( entry.contains( atDC, ( String ) null ) );
+
entry.clear();
-
+
// Test the addition of a binary value
byte[] test4 = StringTools.getBytesUtf8( "test4" );
-
+
entry.add( atCN, test4 );
assertFalse( entry.get( atCN ).contains( test4 ) );
}
@@ -700,46 +704,47 @@ public class SchemaAwareEntryTest
/**
* Test the add( AT, byte[]... ) method
*/
- @Test public void testAddAtBytesElipsis() throws Exception
+ @Test
+ public void testAddAtBytesElipsis() throws Exception
{
DN dn = new DN( "cn=test" );
DefaultEntry entry = new DefaultEntry( schemaManager, dn );
-
+
AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
AttributeType atJpegPhoto = schemaManager.lookupAttributeTypeRegistry( "jpegPhoto" );
-
+
byte[] test1 = StringTools.getBytesUtf8( "test1" );
byte[] test2 = StringTools.getBytesUtf8( "test2" );
byte[] test3 = StringTools.getBytesUtf8( "test3" );
-
+
// Test that we can't inject a null AT
try
{
- entry.add( (AttributeType)null, test1 );
+ entry.add( ( AttributeType ) null, test1 );
fail();
}
catch ( IllegalArgumentException iae )
{
// Expected
}
-
+
// Test that we cannot inject a null value in an AT that does not allow it
try
{
- entry.add( atJpegPhoto, (byte[])null );
+ entry.add( atJpegPhoto, ( byte[] ) null );
fail();
}
catch ( IllegalArgumentException iae )
{
// Expected
}
-
+
// Test a simple addition
entry.add( atPassword, test1 );
assertNotNull( entry.get( atPassword ) );
assertEquals( 1, entry.get( atPassword ).size() );
assertTrue( Arrays.equals( test1, entry.get( atPassword ).get().getBytes() ) );
-
+
// Test some more addition
entry.add( atPassword, test2, test3 );
assertNotNull( entry.get( atPassword ) );
@@ -747,7 +752,7 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atPassword, test1 ) );
assertTrue( entry.contains( atPassword, test2 ) );
assertTrue( entry.contains( atPassword, test3 ) );
-
+
// Test some addition of existing values
entry.add( atPassword, test2 );
assertNotNull( entry.get( atPassword ) );
@@ -755,18 +760,18 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atPassword, test1 ) );
assertTrue( entry.contains( atPassword, test2 ) );
assertTrue( entry.contains( atPassword, test3 ) );
-
+
// Test the addition of a null value
- entry.add( atPassword, (byte[])null );
+ entry.add( atPassword, ( byte[] ) null );
assertNotNull( entry.get( atPassword ) );
assertEquals( 4, entry.get( atPassword ).size() );
assertTrue( entry.contains( atPassword, test1 ) );
assertTrue( entry.contains( atPassword, test2 ) );
assertTrue( entry.contains( atPassword, test3 ) );
- assertTrue( entry.contains( atPassword, (byte[] )null ) );
-
+ assertTrue( entry.contains( atPassword, ( byte[] ) null ) );
+
entry.clear();
-
+
// Test the addition of a String value. It should be converted to a byte array
byte[] test4 = StringTools.getBytesUtf8( "test4" );
@@ -780,13 +785,14 @@ public class SchemaAwareEntryTest
/**
* Test the add( AT, SV... ) method
*/
- @Test public void testAddAtServerValueElipsis() throws Exception
+ @Test
+ public void testAddAtServerValueElipsis() throws Exception
{
DN dn = new DN( "cn=test" );
DefaultEntry entry = new DefaultEntry( schemaManager, dn );
-
+
AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
-
+
byte[] b1 = StringTools.getBytesUtf8( "test1" );
byte[] b2 = StringTools.getBytesUtf8( "test2" );
byte[] b3 = StringTools.getBytesUtf8( "test3" );
@@ -794,28 +800,28 @@ public class SchemaAwareEntryTest
Value<String> test1 = new StringValue( atDC, "test1" );
Value<String> test2 = new StringValue( atDC, "test2" );
Value<String> test3 = new StringValue( atDC, "test3" );
-
+
Value<byte[]> testB1 = new BinaryValue( atPassword, b1 );
Value<byte[]> testB2 = new BinaryValue( atPassword, b2 );
Value<byte[]> testB3 = new BinaryValue( atPassword, b3 );
-
+
// Test that we can't inject a null AT
try
{
- entry.add( (AttributeType)null, test1 );
+ entry.add( ( AttributeType ) null, test1 );
fail();
}
catch ( IllegalArgumentException iae )
{
// Expected
}
-
+
// Test a simple addition in atDC
entry.add( atDC, test1 );
assertNotNull( entry.get( atDC ) );
assertEquals( 1, entry.get( atDC ).size() );
assertEquals( "test1", entry.get( atDC ).get().getString() );
-
+
// Test some more addition
entry.add( atDC, test2, test3 );
assertNotNull( entry.get( atDC ) );
@@ -823,7 +829,7 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
-
+
// Test some addition of existing values
entry.add( atDC, test2 );
assertNotNull( entry.get( atDC ) );
@@ -831,18 +837,18 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
-
+
// Test the addition of a null value
- entry.add( atDC, (String)null );
+ entry.add( atDC, ( String ) null );
assertNotNull( entry.get( atDC ) );
assertEquals( 4, entry.get( atDC ).size() );
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
- assertTrue( entry.contains( atDC, (String )null ) );
-
+ assertTrue( entry.contains( atDC, ( String ) null ) );
+
entry.clear();
-
+
// Test the addition of a String value. It should be converted to a byte array
byte[] test4 = StringTools.getBytesUtf8( "test4" );
@@ -855,7 +861,7 @@ public class SchemaAwareEntryTest
assertNotNull( entry.get( atPassword ) );
assertEquals( 1, entry.get( atPassword ).size() );
assertTrue( Arrays.equals( b1, entry.get( atPassword ).get().getBytes() ) );
-
+
// Test some more addition
entry.add( atPassword, testB2, testB3 );
assertNotNull( entry.get( atPassword ) );
@@ -863,7 +869,7 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atPassword, b1 ) );
assertTrue( entry.contains( atPassword, b2 ) );
assertTrue( entry.contains( atPassword, b3 ) );
-
+
// Test some addition of existing values
entry.add( atPassword, testB2 );
assertNotNull( entry.get( atPassword ) );
@@ -871,18 +877,18 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atPassword, b1 ) );
assertTrue( entry.contains( atPassword, b2 ) );
assertTrue( entry.contains( atPassword, b3 ) );
-
+
// Test the addition of a null value
- entry.add( atPassword, (byte[])null );
+ entry.add( atPassword, ( byte[] ) null );
assertNotNull( entry.get( atPassword ) );
assertEquals( 4, entry.get( atPassword ).size() );
assertTrue( entry.contains( atPassword, b1 ) );
assertTrue( entry.contains( atPassword, b2 ) );
assertTrue( entry.contains( atPassword, b3 ) );
- assertTrue( entry.contains( atPassword, (byte[] )null ) );
-
+ assertTrue( entry.contains( atPassword, ( byte[] ) null ) );
+
entry.clear();
-
+
// Test the addition of a String value. It should be converted to a byte array
byte[] b4 = StringTools.getBytesUtf8( "test4" );
@@ -896,11 +902,12 @@ public class SchemaAwareEntryTest
/**
* Test the add( upId, String... ) method
*/
- @Test public void testAddUpIdStringElipsis() throws Exception
+ @Test
+ public void testAddUpIdStringElipsis() throws Exception
{
DN dn = new DN( "cn=test" );
DefaultEntry entry = new DefaultEntry( schemaManager, dn );
-
+
// Test a simple addition
entry.add( "DC", "test1" );
assertNotNull( entry.get( atDC ) );
@@ -909,7 +916,7 @@ public class SchemaAwareEntryTest
assertEquals( "DC", entry.get( atDC ).getUpId() );
assertEquals( 1, entry.get( atDC ).size() );
assertEquals( "test1", entry.get( atDC ).get().getString() );
-
+
// Test some more addition
entry.add( "DC", "test2", "test3" );
assertNotNull( entry.get( atDC ) );
@@ -917,7 +924,7 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
-
+
// Test some addition of existing values
entry.add( "DC", "test2" );
assertNotNull( entry.get( atDC ) );
@@ -925,21 +932,21 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
-
+
// Test the addition of a null value
- entry.add( "DC", (String)null );
+ entry.add( "DC", ( String ) null );
assertNotNull( entry.get( atDC ) );
assertEquals( 4, entry.get( atDC ).size() );
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
- assertTrue( entry.contains( atDC, (String )null ) );
-
+ assertTrue( entry.contains( atDC, ( String ) null ) );
+
entry.clear();
-
+
// Test the addition of a binary value
byte[] test4 = StringTools.getBytesUtf8( "test4" );
-
+
entry.add( "DC", test4 );
assertFalse( entry.contains( "DC", test4 ) );
}
@@ -948,23 +955,24 @@ public class SchemaAwareEntryTest
/**
* Test the add( upId, byte[]... ) method
*/
- @Test public void testAddUpIdBytesElipsis() throws Exception
+ @Test
+ public void testAddUpIdBytesElipsis() throws Exception
{
DN dn = new DN( "cn=test" );
DefaultEntry entry = new DefaultEntry( schemaManager, dn );
-
+
AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
-
+
byte[] test1 = StringTools.getBytesUtf8( "test1" );
byte[] test2 = StringTools.getBytesUtf8( "test2" );
byte[] test3 = StringTools.getBytesUtf8( "test3" );
-
+
// Test a simple addition
entry.add( "userPassword", test1 );
assertNotNull( entry.get( atPassword ) );
assertEquals( 1, entry.get( atPassword ).size() );
assertTrue( Arrays.equals( test1, entry.get( atPassword ).get().getBytes() ) );
-
+
// Test some more addition
entry.add( "userPassword", test2, test3 );
assertNotNull( entry.get( atPassword ) );
@@ -972,7 +980,7 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atPassword, test1 ) );
assertTrue( entry.contains( atPassword, test2 ) );
assertTrue( entry.contains( atPassword, test3 ) );
-
+
// Test some addition of existing values
entry.add( "userPassword", test2 );
assertNotNull( entry.get( atPassword ) );
@@ -980,18 +988,18 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atPassword, test1 ) );
assertTrue( entry.contains( atPassword, test2 ) );
assertTrue( entry.contains( atPassword, test3 ) );
-
+
// Test the addition of a null value
- entry.add( "userPassword", (byte[])null );
+ entry.add( "userPassword", ( byte[] ) null );
assertNotNull( entry.get( atPassword ) );
assertEquals( 4, entry.get( atPassword ).size() );
assertTrue( entry.contains( atPassword, test1 ) );
assertTrue( entry.contains( atPassword, test2 ) );
assertTrue( entry.contains( atPassword, test3 ) );
- assertTrue( entry.contains( atPassword, (byte[] )null ) );
-
+ assertTrue( entry.contains( atPassword, ( byte[] ) null ) );
+
entry.clear();
-
+
// Test the addition of a String value. It should be converted to a byte array
byte[] test4 = StringTools.getBytesUtf8( "test4" );
@@ -1005,13 +1013,14 @@ public class SchemaAwareEntryTest
/**
* Test the add( upId, SV... ) method
*/
- @Test public void testAddUpIdServerValueElipsis() throws Exception
+ @Test
+ public void testAddUpIdServerValueElipsis() throws Exception
{
DN dn = new DN( "cn=test" );
Entry entry = new DefaultEntry( schemaManager, dn );
-
+
AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
-
+
byte[] b1 = StringTools.getBytesUtf8( "test1" );
byte[] b2 = StringTools.getBytesUtf8( "test2" );
byte[] b3 = StringTools.getBytesUtf8( "test3" );
@@ -1019,11 +1028,11 @@ public class SchemaAwareEntryTest
Value<String> test1 = new StringValue( atDC, "test1" );
Value<String> test2 = new StringValue( atDC, "test2" );
Value<String> test3 = new StringValue( atDC, "test3" );
-
+
Value<byte[]> testB1 = new BinaryValue( atPassword, b1 );
Value<byte[]> testB2 = new BinaryValue( atPassword, b2 );
Value<byte[]> testB3 = new BinaryValue( atPassword, b3 );
-
+
// Test a simple addition in atDC
entry.add( "dC", test1 );
assertNotNull( entry.get( atDC ) );
@@ -1031,7 +1040,7 @@ public class SchemaAwareEntryTest
assertEquals( "test1", entry.get( atDC ).get().getString() );
assertTrue( entry.containsAttribute( atDC ) );
assertEquals( "dC", entry.get( atDC ).getUpId() );
-
+
// Test some more addition
entry.add( "dC", test2, test3 );
assertNotNull( entry.get( atDC ) );
@@ -1041,7 +1050,7 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atDC, "test3" ) );
assertTrue( entry.containsAttribute( atDC ) );
assertEquals( "dC", entry.get( atDC ).getUpId() );
-
+
// Test some addition of existing values
entry.add( "dC", test2 );
assertNotNull( entry.get( atDC ) );
@@ -1049,18 +1058,18 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
-
+
// Test the addition of a null value
- entry.add( "dC", (String)null );
+ entry.add( "dC", ( String ) null );
assertNotNull( entry.get( atDC ) );
assertEquals( 4, entry.get( atDC ).size() );
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
- assertTrue( entry.contains( atDC, (String )null ) );
-
+ assertTrue( entry.contains( atDC, ( String ) null ) );
+
entry.clear();
-
+
// Test the addition of a String value. It should be converted to a byte array
byte[] test4 = StringTools.getBytesUtf8( "test4" );
@@ -1075,7 +1084,7 @@ public class SchemaAwareEntryTest
assertTrue( Arrays.equals( b1, entry.get( atPassword ).get().getBytes() ) );
assertTrue( entry.containsAttribute( atPassword ) );
assertEquals( "userPASSWORD", entry.get( atPassword ).getUpId() );
-
+
// Test some more addition
entry.add( "userPASSWORD", testB2, testB3 );
assertNotNull( entry.get( atPassword ) );
@@ -1083,7 +1092,7 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atPassword, b1 ) );
assertTrue( entry.contains( atPassword, b2 ) );
assertTrue( entry.contains( atPassword, b3 ) );
-
+
// Test some addition of existing values
entry.add( "userPASSWORD", testB2 );
assertNotNull( entry.get( atPassword ) );
@@ -1091,18 +1100,18 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atPassword, b1 ) );
assertTrue( entry.contains( atPassword, b2 ) );
assertTrue( entry.contains( atPassword, b3 ) );
-
+
// Test the addition of a null value
- entry.add( "userPASSWORD", (byte[])null );
+ entry.add( "userPASSWORD", ( byte[] ) null );
assertNotNull( entry.get( atPassword ) );
assertEquals( 4, entry.get( atPassword ).size() );
assertTrue( entry.contains( atPassword, b1 ) );
assertTrue( entry.contains( atPassword, b2 ) );
assertTrue( entry.contains( atPassword, b3 ) );
- assertTrue( entry.contains( atPassword, (byte[] )null ) );
-
+ assertTrue( entry.contains( atPassword, ( byte[] ) null ) );
+
entry.clear();
-
+
// Test the addition of a String value. It should be converted to a byte array
byte[] b4 = StringTools.getBytesUtf8( "test4" );
@@ -1116,17 +1125,18 @@ public class SchemaAwareEntryTest
/**
* Test the add( UpId, AT, String... ) method
*/
- @Test public void testAddUpIdAtStringElipsis() throws Exception
+ @Test
+ public void testAddUpIdAtStringElipsis() throws Exception
{
DN dn = new DN( "cn=test" );
DefaultEntry entry = new DefaultEntry( schemaManager, dn );
-
+
// Test a simple addition
entry.add( "dc", atDC, "test1" );
assertNotNull( entry.get( atDC ) );
assertEquals( 1, entry.get( atDC ).size() );
assertEquals( "test1", entry.get( atDC ).get().getString() );
-
+
// Test some more addition
entry.add( "DC", atDC, "test2", "test3" );
assertNotNull( entry.get( atDC ) );
@@ -1134,7 +1144,7 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
-
+
// Test some addition of existing values
entry.add( "domainComponent", atDC, "test2" );
assertNotNull( entry.get( atDC ) );
@@ -1142,21 +1152,21 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
-
+
// Test the addition of a null value
- entry.add( "DOMAINComponent", atDC, (String)null );
+ entry.add( "DOMAINComponent", atDC, ( String ) null );
assertNotNull( entry.get( atDC ) );
assertEquals( 4, entry.get( atDC ).size() );
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
- assertTrue( entry.contains( atDC, (String )null ) );
-
+ assertTrue( entry.contains( atDC, ( String ) null ) );
+
entry.clear();
-
+
// Test the addition of a binary value
byte[] test4 = StringTools.getBytesUtf8( "test4" );
-
+
entry.add( "dc", atDC, test4 );
assertFalse( entry.contains( "dc", test4 ) );
}
@@ -1165,23 +1175,24 @@ public class SchemaAwareEntryTest
/**
* Test the add( upId, AT, byte[]... ) method
*/
- @Test public void testAddUpIdAtBytesElipsis() throws Exception
+ @Test
+ public void testAddUpIdAtBytesElipsis() throws Exception
{
DN dn = new DN( "cn=test" );
DefaultEntry entry = new DefaultEntry( schemaManager, dn );
-
+
AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
-
+
byte[] test1 = StringTools.getBytesUtf8( "test1" );
byte[] test2 = StringTools.getBytesUtf8( "test2" );
byte[] test3 = StringTools.getBytesUtf8( "test3" );
-
+
// Test a simple addition
entry.add( "userPassword", atPassword, test1 );
assertNotNull( entry.get( atPassword ) );
assertEquals( 1, entry.get( atPassword ).size() );
assertTrue( Arrays.equals( test1, entry.get( atPassword ).get().getBytes() ) );
-
+
// Test some more addition
entry.add( "userPassword", atPassword, test2, test3 );
assertNotNull( entry.get( atPassword ) );
@@ -1189,7 +1200,7 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atPassword, test1 ) );
assertTrue( entry.contains( atPassword, test2 ) );
assertTrue( entry.contains( atPassword, test3 ) );
-
+
// Test some addition of existing values
entry.add( "userPassword", atPassword, test2 );
assertNotNull( entry.get( atPassword ) );
@@ -1197,18 +1208,18 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atPassword, test1 ) );
assertTrue( entry.contains( atPassword, test2 ) );
assertTrue( entry.contains( atPassword, test3 ) );
-
+
// Test the addition of a null value
- entry.add( "userPassword", atPassword, (byte[])null );
+ entry.add( "userPassword", atPassword, ( byte[] ) null );
assertNotNull( entry.get( atPassword ) );
assertEquals( 4, entry.get( atPassword ).size() );
assertTrue( entry.contains( atPassword, test1 ) );
assertTrue( entry.contains( atPassword, test2 ) );
assertTrue( entry.contains( atPassword, test3 ) );
- assertTrue( entry.contains( atPassword, (byte[] )null ) );
-
+ assertTrue( entry.contains( atPassword, ( byte[] ) null ) );
+
entry.clear();
-
+
// Test the addition of a String value. It should be converted to a byte array
byte[] test4 = StringTools.getBytesUtf8( "test4" );
@@ -1222,13 +1233,14 @@ public class SchemaAwareEntryTest
/**
* Test the add( upId, AT, SV... ) method
*/
- @Test public void testAddUpIdAtServerValueElipsis() throws Exception
+ @Test
+ public void testAddUpIdAtServerValueElipsis() throws Exception
{
DN dn = new DN( "cn=test" );
Entry entry = new DefaultEntry( schemaManager, dn );
-
+
AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
-
+
byte[] b1 = StringTools.getBytesUtf8( "test1" );
byte[] b2 = StringTools.getBytesUtf8( "test2" );
byte[] b3 = StringTools.getBytesUtf8( "test3" );
@@ -1236,11 +1248,11 @@ public class SchemaAwareEntryTest
Value<String> test1 = new StringValue( atDC, "test1" );
Value<String> test2 = new StringValue( atDC, "test2" );
Value<String> test3 = new StringValue( atDC, "test3" );
-
+
Value<byte[]> testB1 = new BinaryValue( atPassword, b1 );
Value<byte[]> testB2 = new BinaryValue( atPassword, b2 );
Value<byte[]> testB3 = new BinaryValue( atPassword, b3 );
-
+
// Test a simple addition in atCN
entry.add( "dC", atDC, test1 );
assertNotNull( entry.get( atDC ) );
@@ -1248,7 +1260,7 @@ public class SchemaAwareEntryTest
assertEquals( "test1", entry.get( atDC ).get().getString() );
assertTrue( entry.containsAttribute( atDC ) );
assertEquals( "dC", entry.get( atDC ).getUpId() );
-
+
// Test some more addition
entry.add( "dC", atDC, test2, test3 );
assertNotNull( entry.get( atDC ) );
@@ -1258,7 +1270,7 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atDC, "test3" ) );
assertTrue( entry.containsAttribute( atDC ) );
assertEquals( "dC", entry.get( atDC ).getUpId() );
-
+
// Test some addition of existing values
entry.add( "dC", atDC, test2 );
assertNotNull( entry.get( atDC ) );
@@ -1266,18 +1278,18 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
-
+
// Test the addition of a null value
- entry.add( "dC", atDC, (String)null );
+ entry.add( "dC", atDC, ( String ) null );
assertNotNull( entry.get( atDC ) );
assertEquals( 4, entry.get( atDC ).size() );
assertTrue( entry.contains( atDC, "test1" ) );
assertTrue( entry.contains( atDC, "test2" ) );
assertTrue( entry.contains( atDC, "test3" ) );
- assertTrue( entry.contains( atDC, (String )null ) );
-
+ assertTrue( entry.contains( atDC, ( String ) null ) );
+
entry.clear();
-
+
// Test the addition of a String value. It should be converted to a byte array
byte[] test4 = StringTools.getBytesUtf8( "test4" );
@@ -1292,7 +1304,7 @@ public class SchemaAwareEntryTest
assertTrue( Arrays.equals( b1, entry.get( atPassword ).get().getBytes() ) );
assertTrue( entry.containsAttribute( atPassword ) );
assertEquals( "userPASSWORD", entry.get( atPassword ).getUpId() );
-
+
// Test some more addition
entry.add( "userPASSWORD", atPassword, testB2, testB3 );
assertNotNull( entry.get( atPassword ) );
@@ -1300,7 +1312,7 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atPassword, b1 ) );
assertTrue( entry.contains( atPassword, b2 ) );
assertTrue( entry.contains( atPassword, b3 ) );
-
+
// Test some addition of existing values
entry.add( "userPASSWORD", atPassword, testB2 );
assertNotNull( entry.get( atPassword ) );
@@ -1308,18 +1320,18 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( atPassword, b1 ) );
assertTrue( entry.contains( atPassword, b2 ) );
assertTrue( entry.contains( atPassword, b3 ) );
-
+
// Test the addition of a null value
- entry.add( "userPASSWORD", atPassword, (byte[])null );
+ entry.add( "userPASSWORD", atPassword, ( byte[] ) null );
assertNotNull( entry.get( atPassword ) );
assertEquals( 4, entry.get( atPassword ).size() );
assertTrue( entry.contains( atPassword, b1 ) );
assertTrue( entry.contains( atPassword, b2 ) );
assertTrue( entry.contains( atPassword, b3 ) );
- assertTrue( entry.contains( atPassword, (byte[] )null ) );
-
+ assertTrue( entry.contains( atPassword, ( byte[] ) null ) );
+
entry.clear();
-
+
// Test the addition of a String value. It should be converted to a byte array
byte[] b4 = StringTools.getBytesUtf8( "test4" );
@@ -1337,17 +1349,17 @@ public class SchemaAwareEntryTest
public void testClear() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
assertEquals( 0, entry.size() );
assertNull( entry.get( "ObjectClass" ) );
entry.clear();
assertEquals( 0, entry.size() );
assertNull( entry.get( "ObjectClass" ) );
-
+
entry.add( "ObjectClass", "top", "person" );
assertEquals( 1, entry.size() );
assertNotNull( entry.get( "ObjectClass" ) );
-
+
entry.clear();
assertEquals( 0, entry.size() );
assertNull( entry.get( "ObjectClass" ) );
@@ -1361,33 +1373,33 @@ public class SchemaAwareEntryTest
public void testClone() throws Exception
{
Entry entry1 = new DefaultEntry( schemaManager );
-
+
Entry entry2 = entry1.clone();
-
+
assertEquals( entry1, entry2 );
entry2.setDn( EXAMPLE_DN );
-
- assertEquals( DN.EMPTY_DN,entry1.getDn() );
-
+
+ assertEquals( DN.EMPTY_DN, entry1.getDn() );
+
entry1.setDn( EXAMPLE_DN );
entry2 = entry1.clone();
assertEquals( entry1, entry2 );
-
+
entry1.add( "objectClass", "top", "person" );
entry1.add( "cn", "test1", "test2" );
-
+
entry2 = entry1.clone();
assertEquals( entry1, entry2 );
-
+
entry1.add( "cn", "test3" );
assertEquals( 2, entry2.get( "cn" ).size() );
assertFalse( entry2.contains( "cn", "test3" ) );
-
- entry1.add( "sn", (String)null );
+
+ entry1.add( "sn", ( String ) null );
assertFalse( entry2.containsAttribute( "sn" ) );
}
-
-
+
+
//-------------------------------------------------------------------------
// Test the Contains methods
//-------------------------------------------------------------------------
@@ -1398,22 +1410,22 @@ public class SchemaAwareEntryTest
public void testContainsAttributeTypeByteArrayArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
- assertFalse( entry.contains( (AttributeType )null, BYTES1 ) );
+
+ assertFalse( entry.contains( ( AttributeType ) null, BYTES1 ) );
assertFalse( entry.contains( atPwd, BYTES1 ) );
-
+
EntryAttribute attrPWD = new DefaultEntryAttribute( atPwd, BYTES1, BYTES2 );
assertFalse( entry.contains( attrPWD ) );
-
+
entry.add( attrPWD );
-
+
assertTrue( entry.contains( atPwd, BYTES1, BYTES2 ) );
assertFalse( entry.contains( atPwd, BYTES1, BYTES2, BYTES3 ) );
assertFalse( entry.contains( atPwd, "ab" ) );
}
-
-
+
+
/**
* Test for method contains( AttributeType, String... )
*/
@@ -1421,22 +1433,22 @@ public class SchemaAwareEntryTest
public void testContainsAttributeTypeStringArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
- assertFalse( entry.contains( (AttributeType )null, "test" ) );
+
+ assertFalse( entry.contains( ( AttributeType ) null, "test" ) );
assertFalse( entry.contains( atCN, "test" ) );
-
+
EntryAttribute attrCN = new DefaultEntryAttribute( atCN, "test1", "test2" );
assertFalse( entry.contains( attrCN ) );
-
+
entry.add( attrCN );
-
+
assertTrue( entry.contains( atCN, "test1", "test2" ) );
assertFalse( entry.contains( atCN, "test1", "test2", "test3" ) );
assertFalse( entry.contains( atCN, BYTES1 ) );
}
-
-
+
+
/**
* Test for method contains( AttributeType, Value<?>... )
*/
@@ -1444,34 +1456,34 @@ public class SchemaAwareEntryTest
public void testContainsAttributeTypeValuesArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
Value<String> strValue1 = new StringValue( atCN, "test1" );
Value<String> strValue2 = new StringValue( atCN, "test2" );
Value<String> strValue3 = new StringValue( atCN, "test3" );
- Value<String> strNullValue = new StringValue( atCN, null);
+ Value<String> strNullValue = new StringValue( atCN, null );
Value<byte[]> binValue1 = new BinaryValue( atPwd, BYTES1 );
Value<byte[]> binValue2 = new BinaryValue( atPwd, BYTES2 );
Value<byte[]> binValue3 = new BinaryValue( atPwd, BYTES3 );
Value<byte[]> binNullValue = new BinaryValue( atPwd, null );
- assertFalse( entry.contains( (String)null, strValue1 ) );
+ assertFalse( entry.contains( ( String ) null, strValue1 ) );
assertFalse( entry.contains( atCN, binValue1 ) );
-
+
EntryAttribute attrCN = new DefaultEntryAttribute( atCN, strValue1, strValue2 );
EntryAttribute attrPWD = new DefaultEntryAttribute( atPwd, binValue1, binValue2, binNullValue );
entry.add( attrCN, attrPWD );
-
+
assertTrue( entry.contains( atCN, strValue1, strValue2 ) );
assertTrue( entry.contains( atPwd, binValue1, binValue2, binNullValue ) );
-
+
assertFalse( entry.contains( atCN, strValue3 ) );
assertFalse( entry.contains( atCN, strNullValue ) );
assertFalse( entry.contains( atPwd, binValue3 ) );
}
-
-
+
+
/**
* Test for method contains( EntryAttribute... )
*/
@@ -1479,29 +1491,29 @@ public class SchemaAwareEntryTest
public void testContainsEntryAttributeArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
EntryAttribute attrOC = new DefaultEntryAttribute( atOC, "top", "person" );
EntryAttribute attrCN = new DefaultEntryAttribute( atCN, "test1", "test2" );
EntryAttribute attrSN = new DefaultEntryAttribute( atSN, "Test1", "Test2" );
EntryAttribute attrPWD = new DefaultEntryAttribute( atPwd, BYTES1, BYTES2 );
assertFalse( entry.contains( attrOC, attrCN ) );
-
+
entry.add( attrOC, attrCN );
assertTrue( entry.contains( attrOC, attrCN ) );
assertFalse( entry.contains( attrOC, attrCN, attrSN ) );
-
+
entry.add( attrSN, attrPWD );
assertTrue( entry.contains( attrSN, attrPWD ) );
-
- assertFalse( entry.contains( (EntryAttribute)null ) );
+
+ assertFalse( entry.contains( ( EntryAttribute ) null ) );
entry.clear();
- assertTrue( entry.contains( (EntryAttribute)null ) );
+ assertTrue( entry.contains( ( EntryAttribute ) null ) );
}
-
-
+
+
/**
* Test for method contains( String, byte[]... )
*/
@@ -1509,23 +1521,23 @@ public class SchemaAwareEntryTest
public void testContainsStringByteArrayArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
- assertFalse( entry.contains( (String)null, BYTES3 ) );
+
+ assertFalse( entry.contains( ( String ) null, BYTES3 ) );
assertFalse( entry.containsAttribute( "objectClass" ) );
-
- EntryAttribute attrPWD = new DefaultEntryAttribute( atPwd, BYTES1, (byte[])null, BYTES2 );
+
+ EntryAttribute attrPWD = new DefaultEntryAttribute( atPwd, BYTES1, ( byte[] ) null, BYTES2 );
entry.add( attrPWD );
-
+
assertTrue( entry.contains( " userPASSWORD ", BYTES1, BYTES2 ) );
- assertTrue( entry.contains( " userPASSWORD ", (byte[])null ) );
-
+ assertTrue( entry.contains( " userPASSWORD ", ( byte[] ) null ) );
+
assertFalse( entry.contains( " userPASSWORD ", "ab", "b" ) );
assertFalse( entry.contains( " userPASSWORD ", BYTES3 ) );
assertFalse( entry.contains( " userASSWORD ", BYTES3 ) );
}
-
-
+
+
/**
* Test for method contains( String, String... )
*/
@@ -1533,23 +1545,23 @@ public class SchemaAwareEntryTest
public void testContainsStringStringArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
- assertFalse( entry.contains( (String)null, "test" ) );
+
+ assertFalse( entry.contains( ( String ) null, "test" ) );
assertFalse( entry.containsAttribute( "objectClass" ) );
-
- EntryAttribute attrDC = new DefaultEntryAttribute( atDC, "test1", (String)null, "test2" );
+
+ EntryAttribute attrDC = new DefaultEntryAttribute( atDC, "test1", ( String ) null, "test2" );
entry.add( attrDC );
-
+
assertTrue( entry.contains( " DC ", "test1", "test2" ) );
-
- assertTrue( entry.contains( " DC ", (String)null ) );
+
+ assertTrue( entry.contains( " DC ", ( String ) null ) );
assertFalse( entry.contains( " DC ", BYTES1, BYTES2 ) );
assertFalse( entry.contains( " DC ", "test3" ) );
assertFalse( entry.contains( " DCC ", "test3" ) );
}
-
-
+
+
/**
* Test for method contains( String, Value<?>... )
*/
@@ -1557,19 +1569,19 @@ public class SchemaAwareEntryTest
public void testContainsStringValueArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
- assertFalse( entry.contains( (String)null, "test" ) );
+
+ assertFalse( entry.contains( ( String ) null, "test" ) );
assertFalse( entry.containsAttribute( "objectClass" ) );
-
- EntryAttribute attrDC = new DefaultEntryAttribute( atDC, "test1", "test2", (String)null );
- EntryAttribute attrPWD = new DefaultEntryAttribute( atPwd, BYTES1, BYTES2, (byte[])null );
+
+ EntryAttribute attrDC = new DefaultEntryAttribute( atDC, "test1", "test2", ( String ) null );
+ EntryAttribute attrPWD = new DefaultEntryAttribute( atPwd, BYTES1, BYTES2, ( byte[] ) null );
entry.add( attrDC, attrPWD );
-
+
Value<String> strValue1 = new StringValue( atDC, "test1" );
Value<String> strValue2 = new StringValue( atDC, "test2" );
Value<String> strValue3 = new StringValue( atDC, "test3" );
- Value<String> strNullValue = new StringValue( atDC, null);
+ Value<String> strNullValue = new StringValue( atDC, null );
Value<byte[]> binValue1 = new BinaryValue( atPwd, BYTES1 );
Value<byte[]> binValue2 = new BinaryValue( atPwd, BYTES2 );
@@ -1578,13 +1590,13 @@ public class SchemaAwareEntryTest
assertTrue( entry.contains( "DC", strValue1, strValue2 ) );
assertTrue( entry.contains( "userpassword", binValue1, binValue2, binNullValue ) );
-
+
assertFalse( entry.contains( "dc", strValue3 ) );
assertTrue( entry.contains( "dc", strNullValue ) );
assertFalse( entry.contains( "UserPassword", binValue3 ) );
}
-
-
+
+
/**
* Test method for containsAttribute( AttributeType )
*/
@@ -1592,21 +1604,21 @@ public class SchemaAwareEntryTest
public void testContainsAttributeAttributeType() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
assertFalse( entry.containsAttribute( atOC ) );
-
+
EntryAttribute attrOC = new DefaultEntryAttribute( atOC, "top", "person" );
EntryAttribute attrCN = new DefaultEntryAttribute( atCN, "test1", "test2" );
EntryAttribute attrSN = new DefaultEntryAttribute( atSN, "Test1", "Test2" );
EntryAttribute attrPWD = new DefaultEntryAttribute( atPwd, BYTES1, BYTES2 );
entry.add( attrOC, attrCN, attrSN, attrPWD );
-
+
assertTrue( entry.containsAttribute( atOC ) );
assertTrue( entry.containsAttribute( atCN ) );
assertTrue( entry.containsAttribute( atSN ) );
assertTrue( entry.containsAttribute( atPwd ) );
-
+
entry.clear();
assertFalse( entry.containsAttribute( atOC ) );
@@ -1623,18 +1635,18 @@ public class SchemaAwareEntryTest
public void testContainsAttributeString() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
assertFalse( entry.containsAttribute( "objectClass" ) );
-
+
EntryAttribute attrOC = new DefaultEntryAttribute( atOC, "top", "person" );
EntryAttribute attrCN = new DefaultEntryAttribute( atCN, "test1", "test2" );
EntryAttribute attrSN = new DefaultEntryAttribute( atSN, "Test1", "Test2" );
EntryAttribute attrPWD = new DefaultEntryAttribute( atPwd, BYTES1, BYTES2 );
entry.add( attrOC, attrCN, attrSN, attrPWD );
-
+
assertTrue( entry.containsAttribute( "OBJECTCLASS", " cn ", "Sn", " userPASSWORD " ) );
-
+
entry.clear();
assertFalse( entry.containsAttribute( "OBJECTCLASS" ) );
@@ -1644,7 +1656,7 @@ public class SchemaAwareEntryTest
assertFalse( entry.containsAttribute( " userASSWORD " ) );
}
-
+
/**
* Test method for equals()
*/
@@ -1653,12 +1665,12 @@ public class SchemaAwareEntryTest
{
Entry entry1 = new DefaultEntry( schemaManager );
Entry entry2 = new DefaultEntry( schemaManager );
-
+
assertEquals( entry1, entry2 );
-
+
entry1.setDn( EXAMPLE_DN );
assertNotSame( entry1, entry2 );
-
+
entry2.setDn( EXAMPLE_DN );
assertEquals( entry1, entry2 );
@@ -1666,21 +1678,21 @@ public class SchemaAwareEntryTest
EntryAttribute attrCN = new DefaultEntryAttribute( "cn", atCN, "test1", "test2" );
EntryAttribute attrSN = new DefaultEntryAttribute( "sn", atSN, "Test1", "Test2" );
EntryAttribute attrPWD = new DefaultEntryAttribute( "userPassword", atPwd, BYTES1, BYTES2 );
-
+
entry1.put( attrOC, attrCN, attrSN, attrPWD );
entry2.put( attrOC, attrCN, attrSN );
assertNotSame( entry1, entry2 );
-
+
entry2.put( attrPWD );
assertEquals( entry1, entry2 );
-
+
EntryAttribute attrL1 = new DefaultEntryAttribute( "l", atL, "Paris", "New-York" );
EntryAttribute attrL2 = new DefaultEntryAttribute( "l", atL, "Paris", "Tokyo" );
-
+
entry1.put( attrL1 );
entry2.put( attrL1 );
assertEquals( entry1, entry2 );
-
+
entry1.add( "l", "London" );
assertNotSame( entry1, entry2 );
@@ -1700,7 +1712,7 @@ public class SchemaAwareEntryTest
public void testGetAttributeTypes() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
assertEquals( 0, entry.getAttributeTypes().size() );
EntryAttribute attrOC = new DefaultEntryAttribute( atOC, "top", "person" );
@@ -1709,9 +1721,9 @@ public class SchemaAwareEntryTest
EntryAttribute attrPWD = new DefaultEntryAttribute( atPwd, BYTES1, BYTES2 );
entry.add( attrOC, attrCN, attrSN, attrPWD );
-
+
Set<AttributeType> attributeTypes = entry.getAttributeTypes();
-
+
assertEquals( 4, attributeTypes.size() );
assertTrue( attributeTypes.contains( atOC ) );
assertTrue( attributeTypes.contains( atCN ) );
@@ -1725,71 +1737,71 @@ public class SchemaAwareEntryTest
* Test method for get( AttributeType )
*/
@Test
- public void testGetAttributeType() throws Exception
+ public void testGetAttributeType() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
assertNull( entry.get( atCN ) );
- assertNull( entry.get( (AttributeType)null ) );
-
+ assertNull( entry.get( ( AttributeType ) null ) );
+
EntryAttribute attrOC = new DefaultEntryAttribute( atOC, "top", "person" );
EntryAttribute attrCN = new DefaultEntryAttribute( atCN, "test1", "test2" );
EntryAttribute attrSN = new DefaultEntryAttribute( atSN, "Test1", "Test2" );
EntryAttribute attrPWD = new DefaultEntryAttribute( atPwd, BYTES1, BYTES2 );
-
+
entry.add( attrOC, attrCN, attrSN, attrPWD );
-
+
assertNotNull( entry.get( atCN ) );
-
+
assertEquals( attrCN, entry.get( atCN ) );
assertEquals( attrOC, entry.get( atOC ) );
assertEquals( attrSN, entry.get( atSN ) );
assertEquals( attrPWD, entry.get( atPwd ) );
}
-
+
/**
* Test method for get( String )
*/
@Test
- public void testGetString() throws Exception
+ public void testGetString() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
assertNull( entry.get( "cn" ) );
assertNull( entry.get( "badId" ) );
-
+
EntryAttribute attrOC = new DefaultEntryAttribute( atOC, "top", "person" );
EntryAttribute attrCN = new DefaultEntryAttribute( atCN, "test1", "test2" );
EntryAttribute attrSN = new DefaultEntryAttribute( atSN, "Test1", "Test2" );
EntryAttribute attrPWD = new DefaultEntryAttribute( atPwd, BYTES1, BYTES2 );
-
+
entry.add( attrOC, attrCN, attrSN, attrPWD );
-
+
assertNotNull( entry.get( "CN" ) );
assertNotNull( entry.get( " commonName " ) );
assertNotNull( entry.get( "2.5.4.3" ) );
-
+
assertEquals( attrCN, entry.get( "2.5.4.3" ) );
assertEquals( attrOC, entry.get( " OBJECTCLASS" ) );
assertEquals( attrSN, entry.get( "sn" ) );
assertEquals( attrPWD, entry.get( " userPassword " ) );
}
-
+
/**
* Test method for getDN()
*/
@Test
- public void testGetDn() throws LdapInvalidDnException
+ public void testGetDn() throws LdapInvalidDnException
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
assertEquals( EXAMPLE_DN, entry.getDn() );
-
+
DN testDn = new DN( "cn=test" );
entry.setDn( testDn );
-
+
assertEquals( testDn, entry.getDn() );
}
@@ -1802,16 +1814,15 @@ public class SchemaAwareEntryTest
{
Entry entry1 = new DefaultEntry( schemaManager, EXAMPLE_DN );
Entry entry2 = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
assertEquals( entry1.hashCode(), entry2.hashCode() );
-
+
entry2.setDn( new DN( "ou=system,dc=com" ) );
assertNotSame( entry1.hashCode(), entry2.hashCode() );
-
+
entry2.setDn( EXAMPLE_DN );
assertEquals( entry1.hashCode(), entry2.hashCode() );
-
-
+
EntryAttribute attrOC = new DefaultEntryAttribute( "objectClass", atOC, "top", "person" );
EntryAttribute attrCN = new DefaultEntryAttribute( "cn", atCN, "test1", "test2" );
EntryAttribute attrSN = new DefaultEntryAttribute( "sn", atSN, "Test1", "Test2" );
@@ -1821,14 +1832,14 @@ public class SchemaAwareEntryTest
entry2.add( attrOC, attrCN, attrSN, attrPWD );
assertEquals( entry1.hashCode(), entry2.hashCode() );
-
+
Entry entry3 = new DefaultEntry( schemaManager, EXAMPLE_DN );
entry3.add( attrOC, attrSN, attrCN, attrPWD );
assertEquals( entry1.hashCode(), entry3.hashCode() );
}
-
+
/**
* Test method for hasObjectClass( EntryAttribute )
*/
@@ -1836,14 +1847,14 @@ public class SchemaAwareEntryTest
public void testHasObjectClassEntryAttribute() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
EntryAttribute attrOC = new DefaultEntryAttribute( atOC, "top", "person" );
-
+
assertFalse( entry.contains( attrOC ) );
assertFalse( entry.hasObjectClass( attrOC ) );
-
+
entry.add( attrOC );
-
+
assertTrue( entry.hasObjectClass( attrOC ) );
EntryAttribute attrOC2 = new DefaultEntryAttribute( atOC, "person" );
@@ -1851,13 +1862,13 @@ public class SchemaAwareEntryTest
EntryAttribute attrOC3 = new DefaultEntryAttribute( atOC, "inetOrgPerson" );
assertFalse( entry.hasObjectClass( attrOC3 ) );
- assertFalse( entry.hasObjectClass( (EntryAttribute)null ) );
+ assertFalse( entry.hasObjectClass( ( EntryAttribute ) null ) );
EntryAttribute attrCN = new DefaultEntryAttribute( atCN, "top" );
assertFalse( entry.hasObjectClass( attrCN ) );
}
-
+
/**
* Test method for hasObjectClass( String )
*/
@@ -1865,20 +1876,20 @@ public class SchemaAwareEntryTest
public void testHasObjectClassString() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
assertFalse( entry.containsAttribute( "objectClass" ) );
assertFalse( entry.hasObjectClass( "top" ) );
-
+
entry.add( new DefaultEntryAttribute( atOC, "top", "person" ) );
-
+
assertTrue( entry.hasObjectClass( "top" ) );
assertTrue( entry.hasObjectClass( "person" ) );
assertFalse( entry.hasObjectClass( "inetorgperson" ) );
- assertFalse( entry.hasObjectClass( (String)null ) );
+ assertFalse( entry.hasObjectClass( ( String ) null ) );
assertFalse( entry.hasObjectClass( "" ) );
}
-
+
/**
* Test method for isValid()
*/
@@ -1899,8 +1910,8 @@ public class SchemaAwareEntryTest
// @TODO Implement me !
assertTrue( true );
}
-
-
+
+
/**
* Test method for isValid( String )
*/
@@ -1910,8 +1921,8 @@ public class SchemaAwareEntryTest
// @TODO Implement me !
assertTrue( true );
}
-
-
+
+
/**
* Test method for Iterator()
*/
@@ -1919,37 +1930,37 @@ public class SchemaAwareEntryTest
public void testIterator() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
EntryAttribute attrOC = new DefaultEntryAttribute( atOC, "top", "person" );
EntryAttribute attrCN = new DefaultEntryAttribute( atCN, "test1", "test2" );
EntryAttribute attrSN = new DefaultEntryAttribute( atSN, "Test1", "Test2" );
EntryAttribute attrPWD = new DefaultEntryAttribute( atPwd, BYTES1, BYTES2 );
-
+
entry.put( attrOC, attrCN, attrSN, attrPWD );
-
+
Iterator<EntryAttribute> iterator = entry.iterator();
-
+
assertTrue( iterator.hasNext() );
-
+
Set<AttributeType> expectedIds = new HashSet<AttributeType>();
expectedIds.add( atOC );
expectedIds.add( atCN );
expectedIds.add( atSN );
expectedIds.add( atPwd );
-
+
while ( iterator.hasNext() )
{
EntryAttribute attribute = iterator.next();
-
+
AttributeType attributeType = attribute.getAttributeType();
assertTrue( expectedIds.contains( attributeType ) );
expectedIds.remove( attributeType );
}
-
+
assertEquals( 0, expectedIds.size() );
}
-
+
//-------------------------------------------------------------------------
// Test the Put methods
//-------------------------------------------------------------------------
@@ -1960,41 +1971,41 @@ public class SchemaAwareEntryTest
public void testPutAttributeTypeByteArrayArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
try
{
- entry.put( (AttributeType)null, BYTES1 );
+ entry.put( ( AttributeType ) null, BYTES1 );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
-
- entry.put( atPwd, (byte[])null );
+
+ entry.put( atPwd, ( byte[] ) null );
assertEquals( 1, entry.size() );
assertTrue( entry.containsAttribute( atPwd ) );
- assertTrue( entry.contains( atPwd, (byte[])null ) );
-
+ assertTrue( entry.contains( atPwd, ( byte[] ) null ) );
+
EntryAttribute replaced = entry.put( atPwd, BYTES1, BYTES2, BYTES1 );
assertNotNull( replaced );
assertEquals( atPwd, replaced.getAttributeType() );
- assertTrue( replaced.contains( (byte[])null ) );
+ assertTrue( replaced.contains( ( byte[] ) null ) );
assertEquals( 1, entry.size() );
assertTrue( entry.contains( atPwd, BYTES1, BYTES2 ) );
assertFalse( entry.contains( atPwd, BYTES3 ) );
assertEquals( 2, entry.get( atPwd ).size() );
-
+
replaced = entry.put( atPwd, "test" );
assertNotNull( replaced );
assertTrue( replaced.contains( BYTES1, BYTES2 ) );
-
+
EntryAttribute attribute = entry.get( atPwd );
assertEquals( 1, attribute.size() );
assertTrue( attribute.contains( "test".getBytes() ) );
}
-
-
+
+
/**
* Test for method put( AttributeType, String... )
*/
@@ -2002,40 +2013,40 @@ public class SchemaAwareEntryTest
public void testPutAttributeTypeStringArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
try
{
- entry.put( (AttributeType)null, "test" );
+ entry.put( ( AttributeType ) null, "test" );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
-
- entry.put( atDC, (String)null );
+
+ entry.put( atDC, ( String ) null );
assertEquals( 1, entry.size() );
- assertTrue( entry.containsAttribute( atDC) );
- assertTrue( entry.contains( atDC, (String)null ) );
-
+ assertTrue( entry.containsAttribute( atDC ) );
+ assertTrue( entry.contains( atDC, ( String ) null ) );
+
EntryAttribute replaced = entry.put( atDC, "test1", "test2", "test1" );
assertNotNull( replaced );
assertEquals( atDC, replaced.getAttributeType() );
- assertTrue( replaced.contains( (String)null ) );
+ assertTrue( replaced.contains( ( String ) null ) );
assertEquals( 1, entry.size() );
assertTrue( entry.contains( atDC, "test1", "test2" ) );
assertFalse( entry.contains( atDC, "test3" ) );
assertEquals( 2, entry.get( atDC ).size() );
-
+
replaced = entry.put( atDC, BYTES1 );
assertNotNull( replaced );
assertTrue( replaced.contains( "test1", "test2" ) );
-
+
EntryAttribute attribute = entry.get( atDC );
assertEquals( 0, attribute.size() );
}
-
-
+
+
/**
* Test for method put( AttributeType, Value<?>... )
*/
@@ -2043,47 +2054,47 @@ public class SchemaAwareEntryTest
public void testPutAttributeTypeValueArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
Value<String> strValue1 = new StringValue( atCN, "test1" );
Value<String> strValue2 = new StringValue( atCN, "test2" );
Value<String> strValue3 = new StringValue( atCN, "test3" );
- Value<String> strNullValue = new StringValue( atCN, null);
+ Value<String> strNullValue = new StringValue( atCN, null );
Value<byte[]> binValue1 = new BinaryValue( atPwd, BYTES1 );
try
{
- entry.put( (AttributeType)null, strValue1 );
+ entry.put( ( AttributeType ) null, strValue1 );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
-
+
entry.put( atCN, strNullValue );
assertEquals( 1, entry.size() );
- assertTrue( entry.containsAttribute( atCN) );
- assertTrue( entry.contains( atCN, (String)null ) );
-
+ assertTrue( entry.containsAttribute( atCN ) );
+ assertTrue( entry.contains( atCN, ( String ) null ) );
+
EntryAttribute replaced = entry.put( atCN, strValue1, strValue2, strValue1 );
assertNotNull( replaced );
assertEquals( atCN, replaced.getAttributeType() );
- assertTrue( replaced.contains( (String)null ) );
+ assertTrue( replaced.contains( ( String ) null ) );
assertEquals( 1, entry.size() );
assertTrue( entry.contains( atCN, strValue1, strValue2 ) );
assertFalse( entry.contains( atCN, strValue3 ) );
assertEquals( 2, entry.get( atCN ).size() );
-
+
replaced = entry.put( atCN, binValue1 );
assertNotNull( replaced );
assertTrue( replaced.contains( strValue1, strValue2 ) );
-
+
EntryAttribute attribute = entry.get( atCN );
assertEquals( 0, attribute.size() );
}
-
-
+
+
/**
* Test for method put( EntryAttribute...)
*/
@@ -2091,34 +2102,34 @@ public class SchemaAwareEntryTest
public void testPutEntryAttribute() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
EntryAttribute oc = new DefaultEntryAttribute( atObjectClass, "top", "person" );
EntryAttribute cn = new DefaultEntryAttribute( atCN, "test1", "test2" );
EntryAttribute sn = new DefaultEntryAttribute( atSN, "Test1", "Test2" );
EntryAttribute up = new DefaultEntryAttribute( atPwd, BYTES1, BYTES2 );
EntryAttribute c = new DefaultEntryAttribute( atC, "FR", "US" );
-
+
List<EntryAttribute> removed = entry.put( oc, cn, sn, c );
-
+
assertEquals( 4, entry.size() );
assertEquals( 0, removed.size() );
assertTrue( entry.containsAttribute( "ObjectClass" ) );
assertTrue( entry.containsAttribute( "CN" ) );
assertTrue( entry.containsAttribute( " sn " ) );
assertTrue( entry.containsAttribute( " countryName " ) );
-
+
EntryAttribute attr = entry.get( "objectclass" );
assertEquals( 2, attr.size() );
-
+
EntryAttribute c2 = new DefaultEntryAttribute( atC, "UK", "DE" );
removed = entry.put( c2, up );
assertEquals( 1, removed.size() );
assertEquals( c, removed.get( 0 ) );
assertTrue( removed.get( 0 ).contains( "FR" ) );
assertTrue( removed.get( 0 ).contains( "US" ) );
-
+
assertEquals( 5, entry.size() );
-
+
assertTrue( entry.containsAttribute( "userPassword" ) );
assertTrue( entry.containsAttribute( " countryName " ) );
@@ -2133,7 +2144,7 @@ public class SchemaAwareEntryTest
assertEquals( 0, attrC.size() );
}
-
+
/**
* Test for method put( String, AttributeType, byte[]... )
*/
@@ -2141,37 +2152,37 @@ public class SchemaAwareEntryTest
public void testPutStringAttributeTypeByteArrayArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
try
{
- entry.put( (String)null, (AttributeType)null, BYTES1 );
+ entry.put( ( String ) null, ( AttributeType ) null, BYTES1 );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
-
+
try
{
- entry.put( " ", (AttributeType)null, BYTES1 );
+ entry.put( " ", ( AttributeType ) null, BYTES1 );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
-
+
try
{
- entry.put( "badAttr", (AttributeType)null, BYTES1 );
+ entry.put( "badAttr", ( AttributeType ) null, BYTES1 );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
-
+
try
{
entry.put( "badAttr", atPwd, BYTES1 );
@@ -2181,34 +2192,34 @@ public class SchemaAwareEntryTest
{
assertTrue( true );
}
-
- entry.put( "UserPassword", atPwd, (byte[])null );
+
+ entry.put( "UserPassword", atPwd, ( byte[] ) null );
assertEquals( 1, entry.size() );
assertTrue( entry.containsAttribute( atPwd ) );
- assertTrue( entry.contains( atPwd, (byte[])null ) );
-
+ assertTrue( entry.contains( atPwd, ( byte[] ) null ) );
+
assertEquals( "UserPassword", entry.get( atPwd ).getUpId() );
-
+
EntryAttribute replaced = entry.put( "USERpassword ", atPwd, BYTES1, BYTES2, BYTES1 );
assertNotNull( replaced );
assertEquals( atPwd, replaced.getAttributeType() );
- assertTrue( replaced.contains( (byte[])null ) );
+ assertTrue( replaced.contains( ( byte[] ) null ) );
assertEquals( 1, entry.size() );
assertTrue( entry.contains( atPwd, BYTES1, BYTES2 ) );
assertFalse( entry.contains( atPwd, BYTES3 ) );
assertEquals( 2, entry.get( atPwd ).size() );
assertEquals( "USERpassword ", entry.get( atPwd ).getUpId() );
-
+
replaced = entry.put( "userpassword", atPwd, "test" );
assertNotNull( replaced );
assertTrue( replaced.contains( BYTES1, BYTES2 ) );
assertEquals( "userpassword", entry.get( atPwd ).getUpId() );
-
+
EntryAttribute attribute = entry.get( atPwd );
assertEquals( 1, attribute.size() );
}
-
-
+
+
/**
* Test for method put( String, AttributeType, String... )
*/
@@ -2216,37 +2227,37 @@ public class SchemaAwareEntryTest
public void testPutStringAttributeTypeStringArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
try
{
- entry.put( (String)null, (AttributeType)null, "test" );
+ entry.put( ( String ) null, ( AttributeType ) null, "test" );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
-
+
try
{
- entry.put( " ", (AttributeType)null, "test" );
+ entry.put( " ", ( AttributeType ) null, "test" );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
-
+
try
{
- entry.put( "badAttr", (AttributeType)null, "test" );
+ entry.put( "badAttr", ( AttributeType ) null, "test" );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
-
+
try
{
entry.put( "badAttr", atCN, "test" );
@@ -2256,33 +2267,33 @@ public class SchemaAwareEntryTest
{
assertTrue( true );
}
-
- entry.put( "DC", atDC, (String)null );
+
+ entry.put( "DC", atDC, ( String ) null );
assertEquals( 1, entry.size() );
assertTrue( entry.containsAttribute( atDC ) );
- assertTrue( entry.contains( atDC, (String)null ) );
+ assertTrue( entry.contains( atDC, ( String ) null ) );
assertEquals( "DC", entry.get( atDC ).getUpId() );
-
+
EntryAttribute replaced = entry.put( "domainComponent", atDC, "test1", "test2", "test1" );
assertNotNull( replaced );
assertEquals( atDC, replaced.getAttributeType() );
assertEquals( "domainComponent", entry.get( atDC ).getUpId() );
- assertTrue( replaced.contains( (String)null ) );
+ assertTrue( replaced.contains( ( String ) null ) );
assertEquals( 1, entry.size() );
assertTrue( entry.contains( atDC, "test1", "test2" ) );
assertFalse( entry.contains( atDC, "test3" ) );
assertEquals( 2, entry.get( atDC ).size() );
-
+
replaced = entry.put( "0.9.2342.19200300.100.1.25", atDC, BYTES1 );
assertNotNull( replaced );
assertTrue( replaced.contains( "test1", "test2" ) );
assertEquals( "0.9.2342.19200300.100.1.25", entry.get( atDC ).getUpId() );
-
+
EntryAttribute attribute = entry.get( atDC );
assertEquals( 0, attribute.size() );
}
-
-
+
+
/**
* Test for method put( String, AttributeType, Value<?>... )
*/
@@ -2290,44 +2301,44 @@ public class SchemaAwareEntryTest
public void testPutStringAttributeTypeValueArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
+
Value<String> strValue1 = new StringValue( atCN, "test1" );
Value<String> strValue2 = new StringValue( atCN, "test2" );
Value<String> strValue3 = new StringValue( atCN, "test3" );
- Value<String> strNullValue = new StringValue( atCN, null);
+ Value<String> strNullValue = new StringValue( atCN, null );
Value<byte[]> binValue1 = new BinaryValue( atPwd, BYTES1 );
try
{
- entry.put( (String)null, (AttributeType)null, strValue1 );
+ entry.put( ( String ) null, ( AttributeType ) null, strValue1 );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
-
+
try
{
- entry.put( " ", (AttributeType)null, strValue1 );
+ entry.put( " ", ( AttributeType ) null, strValue1 );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
-
+
try
{
- entry.put( "badAttr", (AttributeType)null, strValue1 );
+ entry.put( "badAttr", ( AttributeType ) null, strValue1 );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
-
+
try
{
entry.put( "badAttr", atCN, strValue1 );
@@ -2337,33 +2348,33 @@ public class SchemaAwareEntryTest
{
assertTrue( true );
}
-
+
entry.put( "Cn", atCN, strNullValue );
assertEquals( 1, entry.size() );
- assertTrue( entry.containsAttribute( atCN) );
- assertTrue( entry.contains( atCN, (String)null ) );
+ assertTrue( entry.containsAttribute( atCN ) );
+ assertTrue( entry.contains( atCN, ( String ) null ) );
[... 1816 lines stripped ...]