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 2012/01/24 18:44:32 UTC
svn commit: r1235374 [16/27] - in /directory/shared/trunk:
ldap/model/src/main/java/org/apache/directory/shared/ldap/model/constants/
ldap/model/src/main/java/org/apache/directory/shared/ldap/model/csn/
ldap/model/src/main/java/org/apache/directory/sha...
Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/DefaultAttributeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/DefaultAttributeTest.java?rev=1235374&r1=1235373&r2=1235374&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/DefaultAttributeTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/DefaultAttributeTest.java Tue Jan 24 17:44:03 2012
@@ -18,6 +18,7 @@
*/
package org.apache.directory.shared.ldap.model.entry;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
@@ -46,6 +47,7 @@ import org.junit.runner.RunWith;
import com.mycila.junit.concurrent.Concurrency;
import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
/**
* Test the DefaultEntryAttribute class
*
@@ -55,13 +57,17 @@ import com.mycila.junit.concurrent.Concu
@Concurrency()
public class DefaultAttributeTest
{
- private static final Value<String> NULL_STRING_VALUE = new StringValue( (String)null );
- private static final Value<byte[]> NULL_BINARY_VALUE = new BinaryValue( (byte[])null );
- 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[] BYTES4 = new byte[]{ 'd' };
-
+ private static final Value<String> NULL_STRING_VALUE = new StringValue( ( String ) null );
+ private static final Value<byte[]> NULL_BINARY_VALUE = new BinaryValue( ( byte[] ) null );
+ 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[] BYTES4 = new byte[]
+ { 'd' };
+
private static final StringValue STR_VALUE1 = new StringValue( "a" );
private static final StringValue STR_VALUE2 = new StringValue( "b" );
private static final StringValue STR_VALUE3 = new StringValue( "c" );
@@ -72,8 +78,7 @@ public class DefaultAttributeTest
private static final BinaryValue BIN_VALUE3 = new BinaryValue( BYTES3 );
private static final BinaryValue BIN_VALUE4 = new BinaryValue( BYTES4 );
-
-
+
/**
* Serialize a DefaultEntryAttribute
*/
@@ -106,11 +111,11 @@ public class DefaultAttributeTest
throw ioe;
}
}
-
+
return out;
}
-
-
+
+
/**
* Deserialize a DefaultEntryAttribute
*/
@@ -148,7 +153,7 @@ public class DefaultAttributeTest
}
}
-
+
/**
* @throws java.lang.Exception
*/
@@ -165,7 +170,7 @@ public class DefaultAttributeTest
public void testDefaultClientAttribute()
{
Attribute attr = new DefaultAttribute();
-
+
assertFalse( attr.isHumanReadable() );
assertEquals( 0, attr.size() );
assertNull( attr.getId() );
@@ -180,7 +185,7 @@ public class DefaultAttributeTest
public void testDefaultClientAttributeString()
{
Attribute attr = new DefaultAttribute( "TEST" );
-
+
assertFalse( attr.isHumanReadable() );
assertEquals( 0, attr.size() );
assertEquals( "test", attr.getId() );
@@ -195,7 +200,7 @@ public class DefaultAttributeTest
public void testDefaultClientAttributeStringValueArray()
{
Attribute attr = new DefaultAttribute( "Test", STR_VALUE1, STR_VALUE2 );
-
+
assertTrue( attr.isHumanReadable() );
assertEquals( 2, attr.size() );
assertTrue( attr.contains( "a" ) );
@@ -212,7 +217,7 @@ public class DefaultAttributeTest
public void testDefaultClientAttributeStringStringArray()
{
Attribute attr = new DefaultAttribute( "Test", "a", "b" );
-
+
assertTrue( attr.isHumanReadable() );
assertEquals( 2, attr.size() );
assertTrue( attr.contains( "a" ) );
@@ -229,7 +234,7 @@ public class DefaultAttributeTest
public void testDefaultClientAttributeStringBytesArray()
{
Attribute attr = new DefaultAttribute( "Test", BYTES1, BYTES2 );
-
+
assertFalse( attr.isHumanReadable() );
assertEquals( 2, attr.size() );
assertTrue( attr.contains( BYTES1 ) );
@@ -246,19 +251,19 @@ public class DefaultAttributeTest
public void testGetBytes() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
- attr1.add( (byte[])null );
+
+ attr1.add( ( byte[] ) null );
assertNull( attr1.getBytes() );
Attribute attr2 = new DefaultAttribute( "test" );
-
+
attr2.add( BYTES1, BYTES2 );
assertTrue( Arrays.equals( BYTES1, attr2.getBytes() ) );
-
+
Attribute attr3 = new DefaultAttribute( "test" );
-
+
attr3.add( "a", "b" );
-
+
try
{
attr3.getBytes();
@@ -278,19 +283,19 @@ public class DefaultAttributeTest
public void testGetString() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
- attr1.add( (String)null );
+
+ attr1.add( ( String ) null );
assertEquals( "", attr1.getString() );
Attribute attr2 = new DefaultAttribute( "test" );
-
+
attr2.add( "a", "b" );
assertEquals( "a", attr2.getString() );
-
+
Attribute attr3 = new DefaultAttribute( "test" );
-
+
attr3.add( BYTES1, BYTES2 );
-
+
try
{
attr3.getString();
@@ -312,11 +317,11 @@ public class DefaultAttributeTest
Attribute attr = new DefaultAttribute();
assertNull( attr.getId() );
-
+
attr.setUpId( "test" );
assertEquals( "test", attr.getId() );
-
- attr.setUpId( " TEST " );
+
+ attr.setUpId( " TEST " );
assertEquals( "test", attr.getId() );
}
@@ -338,7 +343,7 @@ public class DefaultAttributeTest
{
assertTrue( true );
}
-
+
try
{
attr.setUpId( "" );
@@ -348,7 +353,7 @@ public class DefaultAttributeTest
{
assertTrue( true );
}
-
+
try
{
attr.setUpId( " " );
@@ -358,10 +363,10 @@ public class DefaultAttributeTest
{
assertTrue( true );
}
-
+
attr.setUpId( "Test" );
assertEquals( "test", attr.getId() );
-
+
attr.setUpId( " Test " );
assertEquals( "test", attr.getId() );
}
@@ -376,11 +381,11 @@ public class DefaultAttributeTest
Attribute attr = new DefaultAttribute();
assertNull( attr.getUpId() );
-
+
attr.setUpId( "test" );
assertEquals( "test", attr.getUpId() );
-
- attr.setUpId( " TEST " );
+
+ attr.setUpId( " TEST " );
assertEquals( " TEST ", attr.getUpId() );
}
@@ -402,7 +407,7 @@ public class DefaultAttributeTest
{
assertTrue( true );
}
-
+
try
{
attr.setUpId( "" );
@@ -412,7 +417,7 @@ public class DefaultAttributeTest
{
assertTrue( true );
}
-
+
try
{
attr.setUpId( " " );
@@ -422,11 +427,11 @@ public class DefaultAttributeTest
{
assertTrue( true );
}
-
+
attr.setUpId( "Test" );
assertEquals( "Test", attr.getUpId() );
assertEquals( "test", attr.getId() );
-
+
attr.setUpId( " Test " );
assertEquals( " Test ", attr.getUpId() );
assertEquals( "test", attr.getId() );
@@ -440,16 +445,17 @@ public class DefaultAttributeTest
public void testIterator() throws LdapException
{
Attribute attr = new DefaultAttribute();
- attr.add( "a", "b", "c" );
-
+ attr.add( "a", "b", "c" );
+
Iterator<Value<?>> iter = attr.iterator();
-
+
assertTrue( iter.hasNext() );
-
- String[] values = new String[]{ "a", "b", "c" };
+
+ String[] values = new String[]
+ { "a", "b", "c" };
int pos = 0;
-
- for ( Value<?> val:attr )
+
+ for ( Value<?> val : attr )
{
assertTrue( val instanceof StringValue );
assertEquals( values[pos++], val.getString() );
@@ -464,37 +470,37 @@ public class DefaultAttributeTest
public void testAddValueArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
- int nbAdded = attr1.add( new StringValue( (String)null ) );
+
+ int nbAdded = attr1.add( new StringValue( ( String ) null ) );
assertEquals( 1, nbAdded );
assertTrue( attr1.isHumanReadable() );
assertEquals( NULL_STRING_VALUE, attr1.get() );
-
+
Attribute attr2 = new DefaultAttribute( "test" );
-
- nbAdded = attr2.add( new BinaryValue( (byte[])null ) );
+
+ nbAdded = attr2.add( new BinaryValue( ( byte[] ) null ) );
assertEquals( 1, nbAdded );
assertFalse( attr2.isHumanReadable() );
assertEquals( NULL_BINARY_VALUE, attr2.get() );
-
+
Attribute attr3 = new DefaultAttribute( "test" );
-
+
nbAdded = attr3.add( new StringValue( "a" ), new StringValue( "b" ) );
assertEquals( 2, nbAdded );
assertTrue( attr3.isHumanReadable() );
assertTrue( attr3.contains( "a" ) );
assertTrue( attr3.contains( "b" ) );
-
+
Attribute attr4 = new DefaultAttribute( "test" );
-
+
nbAdded = attr4.add( new BinaryValue( BYTES1 ), new BinaryValue( BYTES2 ) );
assertEquals( 2, nbAdded );
assertFalse( attr4.isHumanReadable() );
assertTrue( attr4.contains( BYTES1 ) );
assertTrue( attr4.contains( BYTES2 ) );
-
+
Attribute attr5 = new DefaultAttribute( "test" );
-
+
nbAdded = attr5.add( new StringValue( "c" ), new BinaryValue( BYTES1 ) );
assertEquals( 2, nbAdded );
assertTrue( attr5.isHumanReadable() );
@@ -502,7 +508,7 @@ public class DefaultAttributeTest
assertTrue( attr5.contains( "c" ) );
Attribute attr6 = new DefaultAttribute( "test" );
-
+
nbAdded = attr6.add( new BinaryValue( BYTES1 ), new StringValue( "c" ) );
assertEquals( 2, nbAdded );
assertFalse( attr6.isHumanReadable() );
@@ -510,16 +516,16 @@ public class DefaultAttributeTest
assertTrue( attr6.contains( BYTES3 ) );
Attribute attr7 = new DefaultAttribute( "test" );
-
- nbAdded = attr7.add( new BinaryValue( (byte[])null ), new StringValue( "c" ) );
+
+ nbAdded = attr7.add( new BinaryValue( ( byte[] ) null ), new StringValue( "c" ) );
assertEquals( 2, nbAdded );
assertFalse( attr7.isHumanReadable() );
assertTrue( attr7.contains( NULL_BINARY_VALUE ) );
assertTrue( attr7.contains( BYTES3 ) );
Attribute attr8 = new DefaultAttribute( "test" );
-
- nbAdded = attr8.add( new StringValue( (String)null ), new BinaryValue( BYTES1 ) );
+
+ nbAdded = attr8.add( new StringValue( ( String ) null ), new BinaryValue( BYTES1 ) );
assertEquals( 2, nbAdded );
assertTrue( attr8.isHumanReadable() );
assertTrue( attr8.contains( NULL_STRING_VALUE ) );
@@ -534,28 +540,28 @@ public class DefaultAttributeTest
public void testAddStringArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
- int nbAdded = attr1.add( (String)null );
+
+ int nbAdded = attr1.add( ( String ) null );
assertEquals( 1, nbAdded );
assertTrue( attr1.isHumanReadable() );
assertEquals( NULL_STRING_VALUE, attr1.get() );
-
+
Attribute attr2 = new DefaultAttribute( "test" );
-
+
nbAdded = attr2.add( "" );
assertEquals( 1, nbAdded );
assertTrue( attr2.isHumanReadable() );
assertEquals( "", attr2.getString() );
-
+
Attribute attr3 = new DefaultAttribute( "test" );
-
+
nbAdded = attr3.add( "t" );
assertEquals( 1, nbAdded );
assertTrue( attr3.isHumanReadable() );
assertEquals( "t", attr3.getString() );
-
+
Attribute attr4 = new DefaultAttribute( "test" );
-
+
nbAdded = attr4.add( "a", "b", "c", "d" );
assertEquals( 4, nbAdded );
assertTrue( attr4.isHumanReadable() );
@@ -564,7 +570,7 @@ public class DefaultAttributeTest
assertTrue( attr4.contains( "b" ) );
assertTrue( attr4.contains( "c" ) );
assertTrue( attr4.contains( "d" ) );
-
+
nbAdded = attr4.add( "e" );
assertEquals( 1, nbAdded );
assertTrue( attr4.isHumanReadable() );
@@ -574,7 +580,7 @@ public class DefaultAttributeTest
assertTrue( attr4.contains( "c" ) );
assertTrue( attr4.contains( "d" ) );
assertTrue( attr4.contains( "e" ) );
-
+
nbAdded = attr4.add( BYTES1 );
assertEquals( 0, nbAdded );
assertTrue( attr4.isHumanReadable() );
@@ -585,30 +591,30 @@ public class DefaultAttributeTest
assertTrue( attr4.contains( "d" ) );
assertTrue( attr4.contains( "e" ) );
assertFalse( attr4.contains( "ab" ) );
-
+
Attribute attr5 = new DefaultAttribute( "test" );
-
- nbAdded = attr5.add( "a", "b", (String)null, "d" );
+
+ nbAdded = attr5.add( "a", "b", ( String ) null, "d" );
assertEquals( 4, nbAdded );
assertTrue( attr5.isHumanReadable() );
assertTrue( attr5.contains( "a" ) );
assertTrue( attr5.contains( "b" ) );
- assertTrue( attr5.contains( (String)null ) );
+ assertTrue( attr5.contains( ( String ) null ) );
assertTrue( attr5.contains( "d" ) );
Attribute attr6 = new DefaultAttribute( "test" );
-
- nbAdded = attr6.add( "a", (String)null );
+
+ nbAdded = attr6.add( "a", ( String ) null );
assertEquals( 2, nbAdded );
assertTrue( attr6.isHumanReadable() );
assertTrue( attr6.contains( "a" ) );
- assertTrue( attr6.contains( (String)null ) );
-
+ assertTrue( attr6.contains( ( String ) null ) );
+
Attribute attr7 = new DefaultAttribute( "test" );
-
+
attr7.add( "a", "b" );
assertEquals( 2, attr7.size() );
-
+
assertEquals( 1, attr7.add( "b", "c" ) );
assertEquals( 3, attr7.size() );
assertTrue( attr7.contains( "a", "b", "c" ) );
@@ -622,28 +628,28 @@ public class DefaultAttributeTest
public void testAddByteArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
- int nbAdded = attr1.add( (byte[])null );
+
+ int nbAdded = attr1.add( ( byte[] ) null );
assertEquals( 1, nbAdded );
assertFalse( attr1.isHumanReadable() );
assertTrue( Arrays.equals( NULL_BINARY_VALUE.getBytes(), attr1.getBytes() ) );
-
+
Attribute attr2 = new DefaultAttribute( "test" );
-
+
nbAdded = attr2.add( StringConstants.EMPTY_BYTES );
assertEquals( 1, nbAdded );
assertFalse( attr2.isHumanReadable() );
assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, attr2.getBytes() ) );
-
+
Attribute attr3 = new DefaultAttribute( "test" );
-
+
nbAdded = attr3.add( BYTES1 );
assertEquals( 1, nbAdded );
assertFalse( attr3.isHumanReadable() );
assertTrue( Arrays.equals( BYTES1, attr3.getBytes() ) );
-
+
Attribute attr4 = new DefaultAttribute( "test" );
-
+
nbAdded = attr4.add( BYTES1, BYTES2, BYTES3, BYTES4 );
assertEquals( 4, nbAdded );
assertFalse( attr4.isHumanReadable() );
@@ -651,24 +657,24 @@ public class DefaultAttributeTest
assertTrue( attr4.contains( BYTES2 ) );
assertTrue( attr4.contains( BYTES3 ) );
assertTrue( attr4.contains( BYTES4 ) );
-
+
Attribute attr5 = new DefaultAttribute( "test" );
-
- nbAdded = attr5.add( BYTES1, BYTES2, (byte[])null, BYTES3 );
+
+ nbAdded = attr5.add( BYTES1, BYTES2, ( byte[] ) null, BYTES3 );
assertEquals( 4, nbAdded );
assertFalse( attr5.isHumanReadable() );
assertTrue( attr5.contains( BYTES1 ) );
assertTrue( attr5.contains( BYTES2 ) );
- assertTrue( attr5.contains( (byte[])null ) );
+ assertTrue( attr5.contains( ( byte[] ) null ) );
assertTrue( attr5.contains( BYTES3 ) );
Attribute attr6 = new DefaultAttribute( "test" );
-
- nbAdded = attr6.add( BYTES1, (byte[])null );
+
+ nbAdded = attr6.add( BYTES1, ( byte[] ) null );
assertEquals( 2, nbAdded );
assertFalse( attr6.isHumanReadable() );
assertTrue( attr6.contains( "ab" ) );
- assertTrue( attr6.contains( (byte[])null ) );
+ assertTrue( attr6.contains( ( byte[] ) null ) );
}
@@ -679,10 +685,10 @@ public class DefaultAttributeTest
public void testClear() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
+
assertEquals( 0, attr1.size() );
-
- attr1.add( (String)null );
+
+ attr1.add( ( String ) null );
assertEquals( 1, attr1.size() );
assertTrue( attr1.isHumanReadable() );
attr1.clear();
@@ -706,20 +712,20 @@ public class DefaultAttributeTest
public void testContainsValueArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
+
assertEquals( 0, attr1.size() );
assertFalse( attr1.contains( STR_VALUE1 ) );
assertFalse( attr1.contains( NULL_STRING_VALUE ) );
-
- attr1.add( (String)null );
+
+ attr1.add( ( String ) null );
assertEquals( 1, attr1.size() );
assertTrue( attr1.contains( NULL_STRING_VALUE ) );
-
- attr1.remove( (String)null );
+
+ attr1.remove( ( String ) null );
assertFalse( attr1.contains( NULL_STRING_VALUE ) );
assertEquals( 0, attr1.size() );
-
- attr1.add( "a", "b", "c" );
+
+ attr1.add( "a", "b", "c" );
assertEquals( 3, attr1.size() );
assertTrue( attr1.contains( STR_VALUE1 ) );
assertTrue( attr1.contains( STR_VALUE2 ) );
@@ -733,15 +739,15 @@ public class DefaultAttributeTest
assertEquals( 0, attr2.size() );
assertFalse( attr2.contains( BYTES1 ) );
assertFalse( attr2.contains( NULL_BINARY_VALUE ) );
-
- attr2.add( (byte[])null );
+
+ attr2.add( ( byte[] ) null );
assertEquals( 1, attr2.size() );
assertTrue( attr2.contains( NULL_BINARY_VALUE ) );
-
- attr2.remove( (byte[])null );
+
+ attr2.remove( ( byte[] ) null );
assertFalse( attr2.contains( NULL_BINARY_VALUE ) );
assertEquals( 0, attr2.size() );
-
+
attr2.add( BYTES1, BYTES2, BYTES3 );
assertEquals( 3, attr2.size() );
assertTrue( attr2.contains( BIN_VALUE1 ) );
@@ -759,46 +765,46 @@ public class DefaultAttributeTest
public void testContainsStringArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
+
assertEquals( 0, attr1.size() );
assertFalse( attr1.contains( "a" ) );
- assertFalse( attr1.contains( (String)null ) );
-
- attr1.add( (String)null );
+ assertFalse( attr1.contains( ( String ) null ) );
+
+ attr1.add( ( String ) null );
assertEquals( 1, attr1.size() );
- assertTrue( attr1.contains( (String)null ) );
-
- attr1.remove( (String)null );
- assertFalse( attr1.contains( (String)null ) );
+ assertTrue( attr1.contains( ( String ) null ) );
+
+ attr1.remove( ( String ) null );
+ assertFalse( attr1.contains( ( String ) null ) );
assertEquals( 0, attr1.size() );
-
- attr1.add( "a", "b", "c" );
+
+ attr1.add( "a", "b", "c" );
assertEquals( 3, attr1.size() );
assertTrue( attr1.contains( "a" ) );
assertTrue( attr1.contains( "b" ) );
assertTrue( attr1.contains( "c" ) );
assertFalse( attr1.contains( "e" ) );
- assertFalse( attr1.contains( (String)null ) );
+ assertFalse( attr1.contains( ( String ) null ) );
Attribute attr2 = new DefaultAttribute( "test" );
assertEquals( 0, attr2.size() );
assertFalse( attr2.contains( BYTES1 ) );
- assertFalse( attr2.contains( (byte[])null ) );
-
- attr2.add( (byte[])null );
+ assertFalse( attr2.contains( ( byte[] ) null ) );
+
+ attr2.add( ( byte[] ) null );
assertEquals( 1, attr2.size() );
- assertTrue( attr2.contains( (byte[])null ) );
-
- attr2.remove( (byte[])null );
- assertFalse( attr2.contains( (byte[])null ) );
+ assertTrue( attr2.contains( ( byte[] ) null ) );
+
+ attr2.remove( ( byte[] ) null );
+ assertFalse( attr2.contains( ( byte[] ) null ) );
assertEquals( 0, attr2.size() );
-
+
attr2.add( BYTES1, BYTES2, BYTES3 );
assertEquals( 3, attr2.size() );
assertTrue( attr2.contains( "ab" ) );
assertTrue( attr2.contains( "b" ) );
assertTrue( attr2.contains( "c" ) );
- assertFalse( attr2.contains( (String)null ) );
+ assertFalse( attr2.contains( ( String ) null ) );
}
@@ -809,46 +815,46 @@ public class DefaultAttributeTest
public void testContainsByteArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
+
assertEquals( 0, attr1.size() );
assertFalse( attr1.contains( BYTES1 ) );
- assertFalse( attr1.contains( (byte[])null ) );
-
- attr1.add( (byte[])null );
+ assertFalse( attr1.contains( ( byte[] ) null ) );
+
+ attr1.add( ( byte[] ) null );
assertEquals( 1, attr1.size() );
- assertTrue( attr1.contains( (byte[])null ) );
-
- attr1.remove( (byte[])null );
- assertFalse( attr1.contains( (byte[])null ) );
+ assertTrue( attr1.contains( ( byte[] ) null ) );
+
+ attr1.remove( ( byte[] ) null );
+ assertFalse( attr1.contains( ( byte[] ) null ) );
assertEquals( 0, attr1.size() );
-
- attr1.add( BYTES1, BYTES2, BYTES3 );
+
+ attr1.add( BYTES1, BYTES2, BYTES3 );
assertEquals( 3, attr1.size() );
assertTrue( attr1.contains( BYTES1 ) );
assertTrue( attr1.contains( BYTES2 ) );
assertTrue( attr1.contains( BYTES3 ) );
assertFalse( attr1.contains( BYTES4 ) );
- assertFalse( attr1.contains( (byte[])null ) );
+ assertFalse( attr1.contains( ( byte[] ) null ) );
Attribute attr2 = new DefaultAttribute( "test" );
assertEquals( 0, attr2.size() );
assertFalse( attr2.contains( "a" ) );
- assertFalse( attr2.contains( (String)null ) );
-
- attr2.add( (String)null );
+ assertFalse( attr2.contains( ( String ) null ) );
+
+ attr2.add( ( String ) null );
assertEquals( 1, attr2.size() );
- assertTrue( attr2.contains( (String)null ) );
-
- attr2.remove( (String)null );
- assertFalse( attr2.contains( (String)null ) );
+ assertTrue( attr2.contains( ( String ) null ) );
+
+ attr2.remove( ( String ) null );
+ assertFalse( attr2.contains( ( String ) null ) );
assertEquals( 0, attr2.size() );
-
+
attr2.add( "ab", "b", "c" );
assertEquals( 3, attr2.size() );
assertTrue( attr2.contains( BYTES1 ) );
assertTrue( attr2.contains( BYTES2 ) );
assertTrue( attr2.contains( BYTES3 ) );
- assertFalse( attr2.contains( (byte[])null ) );
+ assertFalse( attr2.contains( ( byte[] ) null ) );
}
@@ -859,15 +865,15 @@ public class DefaultAttributeTest
public void testGet() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
- attr1.add( (String)null );
- assertEquals( NULL_STRING_VALUE,attr1.get() );
+
+ attr1.add( ( String ) null );
+ assertEquals( NULL_STRING_VALUE, attr1.get() );
Attribute attr2 = new DefaultAttribute( "test" );
-
+
attr2.add( "a", "b", "c" );
assertEquals( "a", attr2.get().getString() );
-
+
attr2.remove( "a" );
assertEquals( "b", attr2.get().getString() );
@@ -878,10 +884,10 @@ public class DefaultAttributeTest
assertNull( attr2.get() );
Attribute attr3 = new DefaultAttribute( "test" );
-
+
attr3.add( BYTES1, BYTES2, BYTES3 );
assertTrue( Arrays.equals( BYTES1, attr3.get().getBytes() ) );
-
+
attr3.remove( BYTES1 );
assertTrue( Arrays.equals( BYTES2, attr3.get().getBytes() ) );
@@ -900,23 +906,23 @@ public class DefaultAttributeTest
public void testIterator2() throws LdapException
{
Attribute attr = new DefaultAttribute( "test" );
-
- Iterator<Value<?>> iterator = attr.iterator();
+
+ Iterator<Value<?>> iterator = attr.iterator();
assertFalse( iterator.hasNext() );
-
+
attr.add( NULL_STRING_VALUE );
- iterator = attr.iterator();
+ iterator = attr.iterator();
assertTrue( iterator.hasNext() );
-
+
Value<?> value = iterator.next();
assertEquals( NULL_STRING_VALUE, value );
-
+
attr.clear();
- iterator = attr.iterator();
+ iterator = attr.iterator();
assertFalse( iterator.hasNext() );
-
- attr.add( "a", "b", "c" );
- iterator = attr.iterator();
+
+ attr.add( "a", "b", "c" );
+ iterator = attr.iterator();
assertTrue( iterator.hasNext() );
assertEquals( "a", iterator.next().getString() );
assertEquals( "b", iterator.next().getString() );
@@ -934,15 +940,15 @@ public class DefaultAttributeTest
Attribute attr1 = new DefaultAttribute( "test" );
assertEquals( 0, attr1.size() );
-
- attr1.add( (String)null );
+
+ attr1.add( ( String ) null );
assertEquals( 1, attr1.size() );
Attribute attr2 = new DefaultAttribute( "test" );
-
+
attr2.add( "a", "b" );
assertEquals( 2, attr2.size() );
-
+
attr2.clear();
assertEquals( 0, attr2.size() );
}
@@ -958,58 +964,58 @@ public class DefaultAttributeTest
assertFalse( attr1.remove( STR_VALUE1 ) );
assertFalse( attr1.remove( STR_VALUE1 ) );
-
+
attr1.add( "a", "b", "c" );
assertTrue( attr1.remove( STR_VALUE1 ) );
assertEquals( 2, attr1.size() );
-
+
assertTrue( attr1.remove( STR_VALUE2, STR_VALUE3 ) );
assertEquals( 0, attr1.size() );
-
+
assertFalse( attr1.remove( STR_VALUE4 ) );
-
+
attr1.clear();
attr1.add( "a", "b", "c" );
assertFalse( attr1.remove( STR_VALUE2, STR_VALUE4 ) );
assertEquals( 2, attr1.size() );
-
+
attr1.clear();
- attr1.add( "a", (String)null, "b" );
+ attr1.add( "a", ( String ) null, "b" );
assertTrue( attr1.remove( NULL_STRING_VALUE, STR_VALUE1 ) );
assertEquals( 1, attr1.size() );
-
+
attr1.clear();
- attr1.add( "a", (String)null, "b" );
+ attr1.add( "a", ( String ) null, "b" );
attr1.add( BYTES3 );
assertTrue( attr1.remove( NULL_STRING_VALUE, STR_VALUE1 ) );
assertEquals( 1, attr1.size() );
-
+
Attribute attr2 = new DefaultAttribute( "test" );
assertFalse( attr2.remove( BIN_VALUE1 ) );
-
+
attr2.clear();
attr2.add( BYTES1, BYTES2, BYTES3 );
assertTrue( attr2.remove( BIN_VALUE1 ) );
assertEquals( 2, attr2.size() );
-
+
assertTrue( attr2.remove( BIN_VALUE2, BIN_VALUE3 ) );
assertEquals( 0, attr2.size() );
-
+
assertFalse( attr2.remove( BIN_VALUE4 ) );
-
+
attr2.clear();
attr2.add( BYTES1, BYTES2, BYTES3 );
assertFalse( attr2.remove( BIN_VALUE2, STR_VALUE4 ) );
assertEquals( 2, attr2.size() );
-
+
attr2.clear();
- attr2.add( BYTES1, (byte[])null, BYTES3 );
+ attr2.add( BYTES1, ( byte[] ) null, BYTES3 );
assertFalse( attr2.remove( NULL_STRING_VALUE, BIN_VALUE1 ) );
assertEquals( 2, attr2.size() );
-
+
attr2.clear();
- attr2.add( BYTES1, (byte[])null, BYTES2 );
+ attr2.add( BYTES1, ( byte[] ) null, BYTES2 );
attr2.add( "c" );
assertEquals( 4, attr2.size() );
assertFalse( attr2.remove( NULL_STRING_VALUE, BIN_VALUE1, STR_VALUE3 ) );
@@ -1026,31 +1032,31 @@ public class DefaultAttributeTest
Attribute attr1 = new DefaultAttribute( "test" );
assertFalse( attr1.remove( BYTES1 ) );
-
+
attr1.add( BYTES1, BYTES2, BYTES3 );
assertTrue( attr1.remove( BYTES1 ) );
assertEquals( 2, attr1.size() );
-
+
assertTrue( attr1.remove( BYTES2, BYTES3 ) );
assertEquals( 0, attr1.size() );
-
+
assertFalse( attr1.remove( BYTES4 ) );
-
+
attr1.clear();
attr1.add( BYTES1, BYTES2, BYTES3 );
assertFalse( attr1.remove( BYTES3, BYTES4 ) );
assertEquals( 2, attr1.size() );
-
+
attr1.clear();
- attr1.add( BYTES1, (byte[])null, BYTES2 ) ;
- assertTrue( attr1.remove( (byte[])null, BYTES1 ) );
+ attr1.add( BYTES1, ( byte[] ) null, BYTES2 );
+ assertTrue( attr1.remove( ( byte[] ) null, BYTES1 ) );
assertEquals( 1, attr1.size() );
-
+
Attribute attr2 = new DefaultAttribute( "test" );
-
+
attr2.add( "ab", "b", "c" );
-
- assertFalse( attr2.remove( (byte[])null ) );
+
+ assertFalse( attr2.remove( ( byte[] ) null ) );
assertTrue( attr2.remove( BYTES1, BYTES2 ) );
assertFalse( attr2.remove( BYTES4 ) );
}
@@ -1065,31 +1071,31 @@ public class DefaultAttributeTest
Attribute attr1 = new DefaultAttribute( "test" );
assertFalse( attr1.remove( "a" ) );
-
+
attr1.add( "a", "b", "c" );
assertTrue( attr1.remove( "a" ) );
assertEquals( 2, attr1.size() );
-
+
assertTrue( attr1.remove( "b", "c" ) );
assertEquals( 0, attr1.size() );
-
+
assertFalse( attr1.remove( "d" ) );
-
+
attr1.clear();
attr1.add( "a", "b", "c" );
assertFalse( attr1.remove( "b", "e" ) );
assertEquals( 2, attr1.size() );
-
+
attr1.clear();
- attr1.add( "a", (String)null, "b" );
- assertTrue( attr1.remove( (String )null, "a" ) );
+ attr1.add( "a", ( String ) null, "b" );
+ assertTrue( attr1.remove( ( String ) null, "a" ) );
assertEquals( 1, attr1.size() );
-
+
Attribute attr2 = new DefaultAttribute( "test" );
-
+
attr2.add( BYTES1, BYTES2, BYTES3 );
-
- assertFalse( attr2.remove( (String)null ) );
+
+ assertFalse( attr2.remove( ( String ) null ) );
assertTrue( attr2.remove( "ab", "c" ) );
assertFalse( attr2.remove( "d" ) );
}
@@ -1102,28 +1108,28 @@ public class DefaultAttributeTest
public void testPutStringArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
- int nbAdded = attr1.add( (String)null );
+
+ int nbAdded = attr1.add( ( String ) null );
assertEquals( 1, nbAdded );
assertTrue( attr1.isHumanReadable() );
assertEquals( NULL_STRING_VALUE, attr1.get() );
-
+
Attribute attr2 = new DefaultAttribute( "test" );
-
+
nbAdded = attr2.add( "" );
assertEquals( 1, nbAdded );
assertTrue( attr2.isHumanReadable() );
assertEquals( "", attr2.getString() );
-
+
Attribute attr3 = new DefaultAttribute( "test" );
-
+
nbAdded = attr3.add( "t" );
assertEquals( 1, nbAdded );
assertTrue( attr3.isHumanReadable() );
assertEquals( "t", attr3.getString() );
-
+
Attribute attr4 = new DefaultAttribute( "test" );
-
+
nbAdded = attr4.add( "a", "b", "c", "d" );
assertEquals( 4, nbAdded );
assertTrue( attr4.isHumanReadable() );
@@ -1131,24 +1137,24 @@ public class DefaultAttributeTest
assertTrue( attr4.contains( "b" ) );
assertTrue( attr4.contains( "c" ) );
assertTrue( attr4.contains( "d" ) );
-
+
Attribute attr5 = new DefaultAttribute( "test" );
-
- nbAdded = attr5.add( "a", "b", (String)null, "d" );
+
+ nbAdded = attr5.add( "a", "b", ( String ) null, "d" );
assertEquals( 4, nbAdded );
assertTrue( attr5.isHumanReadable() );
assertTrue( attr5.contains( "a" ) );
assertTrue( attr5.contains( "b" ) );
- assertTrue( attr5.contains( (String)null ) );
+ assertTrue( attr5.contains( ( String ) null ) );
assertTrue( attr5.contains( "d" ) );
Attribute attr6 = new DefaultAttribute( "test" );
-
- nbAdded = attr6.add( "a", (String)null );
+
+ nbAdded = attr6.add( "a", ( String ) null );
assertEquals( 2, nbAdded );
assertTrue( attr6.isHumanReadable() );
assertTrue( attr6.contains( "a" ) );
- assertTrue( attr6.contains( (String)null ) );
+ assertTrue( attr6.contains( ( String ) null ) );
}
@@ -1159,57 +1165,57 @@ public class DefaultAttributeTest
public void testPutByteArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
- int nbAdded = attr1.add( (byte[])null );
+
+ int nbAdded = attr1.add( ( byte[] ) null );
assertEquals( 1, nbAdded );
assertFalse( attr1.isHumanReadable() );
assertTrue( Arrays.equals( NULL_BINARY_VALUE.getBytes(), attr1.getBytes() ) );
-
+
Attribute attr2 = new DefaultAttribute( "test" );
-
+
nbAdded = attr2.add( StringConstants.EMPTY_BYTES );
assertEquals( 1, nbAdded );
assertFalse( attr2.isHumanReadable() );
assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, attr2.getBytes() ) );
-
+
Attribute attr3 = new DefaultAttribute( "test" );
-
+
nbAdded = attr3.add( BYTES1 );
assertEquals( 1, nbAdded );
assertFalse( attr3.isHumanReadable() );
assertTrue( Arrays.equals( BYTES1, attr3.getBytes() ) );
-
+
Attribute attr4 = new DefaultAttribute( "test" );
-
+
nbAdded = attr4.add( BYTES1, BYTES2 );
assertEquals( 2, nbAdded );
assertFalse( attr4.isHumanReadable() );
assertTrue( attr4.contains( BYTES1 ) );
assertTrue( attr4.contains( BYTES2 ) );
-
+
nbAdded = attr4.add( BYTES3, BYTES4 );
assertEquals( 2, nbAdded );
assertFalse( attr4.isHumanReadable() );
assertTrue( attr4.contains( BYTES3 ) );
assertTrue( attr4.contains( BYTES4 ) );
-
+
Attribute attr5 = new DefaultAttribute( "test" );
-
- nbAdded = attr5.add( BYTES1, BYTES2, (byte[])null, BYTES3 );
+
+ nbAdded = attr5.add( BYTES1, BYTES2, ( byte[] ) null, BYTES3 );
assertEquals( 4, nbAdded );
assertFalse( attr5.isHumanReadable() );
assertTrue( attr5.contains( BYTES1 ) );
assertTrue( attr5.contains( BYTES2 ) );
- assertTrue( attr5.contains( (byte[])null ) );
+ assertTrue( attr5.contains( ( byte[] ) null ) );
assertTrue( attr5.contains( BYTES3 ) );
Attribute attr6 = new DefaultAttribute( "test" );
-
- nbAdded = attr6.add( BYTES1, (byte[])null );
+
+ nbAdded = attr6.add( BYTES1, ( byte[] ) null );
assertEquals( 2, nbAdded );
assertFalse( attr6.isHumanReadable() );
assertTrue( attr6.contains( "ab" ) );
- assertTrue( attr6.contains( (byte[])null ) );
+ assertTrue( attr6.contains( ( byte[] ) null ) );
}
@@ -1220,13 +1226,13 @@ public class DefaultAttributeTest
public void testPutValueArray() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
+
assertEquals( 0, attr1.size() );
-
+
attr1.add( NULL_STRING_VALUE );
assertEquals( 1, attr1.size() );
assertTrue( attr1.contains( NULL_STRING_VALUE ) );
-
+
attr1.clear();
attr1.add( STR_VALUE1, STR_VALUE2, STR_VALUE3 );
assertEquals( 3, attr1.size() );
@@ -1240,29 +1246,28 @@ public class DefaultAttributeTest
assertTrue( attr1.contains( STR_VALUE1 ) );
assertTrue( attr1.contains( NULL_STRING_VALUE ) );
assertTrue( attr1.contains( STR_VALUE3 ) );
-
+
attr1.clear();
attr1.add( STR_VALUE1, NULL_STRING_VALUE, BIN_VALUE3 );
assertEquals( 3, attr1.size() );
assertTrue( attr1.contains( STR_VALUE1 ) );
assertTrue( attr1.contains( NULL_STRING_VALUE ) );
assertTrue( attr1.contains( STR_VALUE3 ) );
-
Attribute attr2 = new DefaultAttribute( "test" );
assertEquals( 0, attr2.size() );
-
+
attr2.add( NULL_BINARY_VALUE );
assertEquals( 1, attr2.size() );
assertTrue( attr2.contains( NULL_BINARY_VALUE ) );
-
+
attr2.clear();
attr2.add( BIN_VALUE1, BIN_VALUE2, BIN_VALUE3 );
assertEquals( 3, attr2.size() );
assertTrue( attr2.contains( BIN_VALUE1 ) );
assertTrue( attr2.contains( BIN_VALUE2 ) );
assertTrue( attr2.contains( BIN_VALUE3 ) );
-
+
attr2.clear();
attr2.add( BIN_VALUE1, NULL_BINARY_VALUE, STR_VALUE3 );
assertEquals( 3, attr2.size() );
@@ -1279,12 +1284,12 @@ public class DefaultAttributeTest
public void testToString() throws InvalidAttributeValueException, LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
+
assertEquals( " test: (null)\n", attr1.toString() );
-
+
attr1.add( "a" );
assertEquals( " test: a\n", attr1.toString() );
-
+
attr1.add( "b" );
assertEquals( " test: a\n test: b\n", attr1.toString() );
@@ -1309,19 +1314,19 @@ public class DefaultAttributeTest
Attribute attr1 = new DefaultAttribute( "test" );
Attribute attr2 = new DefaultAttribute( "test" );
-
+
assertEquals( attr1.hashCode(), attr2.hashCode() );
-
+
attr1.add( "a", "b", "c" );
attr2.add( "a", "b", "c" );
assertEquals( attr1.hashCode(), attr2.hashCode() );
-
+
attr1.add( "d" );
attr2.add( "d" );
assertEquals( attr1.hashCode(), attr2.hashCode() );
attr1.add( NULL_STRING_VALUE );
- attr2.add( NULL_STRING_VALUE );
+ attr2.add( NULL_STRING_VALUE );
assertEquals( attr1.hashCode(), attr2.hashCode() );
// Order mess up the hashCode
@@ -1330,20 +1335,20 @@ public class DefaultAttributeTest
attr1.add( "a", "b", "c" );
attr2.add( "c", "b", "a" );
assertNotSame( attr1.hashCode(), attr2.hashCode() );
-
+
Attribute attr3 = new DefaultAttribute( "test" );
Attribute attr4 = new DefaultAttribute( "test" );
-
+
attr3.add( BYTES1, BYTES2 );
attr4.add( BYTES1, BYTES2 );
assertEquals( attr3.hashCode(), attr4.hashCode() );
-
+
attr3.add( BYTES3 );
attr4.add( BYTES3 );
assertEquals( attr3.hashCode(), attr4.hashCode() );
-
+
attr3.add( NULL_BINARY_VALUE );
- attr4.add( NULL_BINARY_VALUE );
+ attr4.add( NULL_BINARY_VALUE );
assertEquals( attr3.hashCode(), attr4.hashCode() );
// Order mess up the hashCode
@@ -1362,52 +1367,52 @@ public class DefaultAttributeTest
public void testEquals() throws LdapException
{
Attribute attr1 = new DefaultAttribute( "test" );
-
+
assertFalse( attr1.equals( null ) );
-
+
Attribute attr2 = new DefaultAttribute( "test" );
-
+
assertTrue( attr1.equals( attr2 ) );
-
+
attr2.setUpId( "TEST" );
assertTrue( attr1.equals( attr2 ) );
attr1.setUpId( "tset" );
assertFalse( attr1.equals( attr2 ) );
-
+
attr1.setUpId( "TEST" );
assertTrue( attr1.equals( attr2 ) );
-
+
attr1.add( "a", "b", "c" );
attr2.add( "c", "b", "a" );
assertTrue( attr1.equals( attr2 ) );
-
+
assertTrue( attr1.equals( attr2 ) );
-
+
Attribute attr3 = new DefaultAttribute( "test" );
Attribute attr4 = new DefaultAttribute( "test" );
-
+
attr3.add( NULL_BINARY_VALUE );
attr4.add( NULL_BINARY_VALUE );
assertTrue( attr3.equals( attr4 ) );
-
+
Attribute attr5 = new DefaultAttribute( "test" );
Attribute attr6 = new DefaultAttribute( "test" );
-
+
attr5.add( NULL_BINARY_VALUE );
attr6.add( NULL_STRING_VALUE );
assertFalse( attr5.equals( attr6 ) );
Attribute attr7 = new DefaultAttribute( "test" );
Attribute attr8 = new DefaultAttribute( "test" );
-
+
attr7.add( "a" );
attr8.add( BYTES2 );
assertFalse( attr7.equals( attr8 ) );
Attribute attr9 = new DefaultAttribute( "test" );
Attribute attr10 = new DefaultAttribute( "test" );
-
+
attr7.add( "a" );
attr7.add( BYTES2 );
attr8.add( "a", "b" );
@@ -1422,25 +1427,25 @@ public class DefaultAttributeTest
public void testClone() throws LdapException
{
Attribute attr = new DefaultAttribute( "test" );
-
+
Attribute clone = attr.clone();
-
+
assertEquals( attr, clone );
attr.setUpId( "new" );
assertEquals( "test", clone.getId() );
-
- attr.add( "a", (String)null, "b" );
+
+ attr.add( "a", ( String ) null, "b" );
clone = attr.clone();
assertEquals( attr, clone );
-
+
attr.remove( "a" );
assertNotSame( attr, clone );
-
+
clone = attr.clone();
assertEquals( attr, clone );
}
-
-
+
+
/**
* Test the serialization of a complete client attribute
*/
@@ -1459,8 +1464,8 @@ public class DefaultAttributeTest
assertTrue( dcaSer.contains( "test2", "test1" ) );
assertTrue( dcaSer.isHumanReadable() );
}
-
-
+
+
/**
* Test the serialization of a client attribute with no value
*/
@@ -1477,8 +1482,8 @@ public class DefaultAttributeTest
assertEquals( 0, dcaSer.size() );
assertFalse( dcaSer.isHumanReadable() );
}
-
-
+
+
/**
* Test the serialization of a client attribute with a null value
*/
@@ -1487,7 +1492,7 @@ public class DefaultAttributeTest
{
DefaultAttribute dca = new DefaultAttribute( "CommonName" );
dca.setUpId( "CN" );
- dca.add( (String)null );
+ dca.add( ( String ) null );
DefaultAttribute dcaSer = deserializeValue( serializeValue( dca ) );
assertEquals( dca.toString(), dcaSer.toString() );
@@ -1495,11 +1500,11 @@ public class DefaultAttributeTest
assertEquals( "CN", dcaSer.getUpId() );
assertEquals( "", dcaSer.getString() );
assertEquals( 1, dcaSer.size() );
- assertTrue( dcaSer.contains( (String)null ) );
+ assertTrue( dcaSer.contains( ( String ) null ) );
assertTrue( dcaSer.isHumanReadable() );
}
-
-
+
+
/**
* Test the serialization of a client attribute with a binary value
*/
@@ -1507,7 +1512,7 @@ public class DefaultAttributeTest
public void testSerializeAttributeBinaryValue() throws LdapException, IOException, ClassNotFoundException
{
DefaultAttribute dca = new DefaultAttribute( "UserPassword" );
- byte[] password = Strings.getBytesUtf8("secret");
+ byte[] password = Strings.getBytesUtf8( "secret" );
dca.add( password );
DefaultAttribute dcaSer = deserializeValue( serializeValue( dca ) );
Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntrySerializationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntrySerializationTest.java?rev=1235374&r1=1235373&r2=1235374&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntrySerializationTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntrySerializationTest.java Tue Jan 24 17:44:03 2012
@@ -19,6 +19,7 @@
*/
package org.apache.directory.shared.ldap.model.entry;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -35,6 +36,7 @@ import org.junit.runner.RunWith;
import com.mycila.junit.concurrent.Concurrency;
import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
/**
* Test the Entry Serialization
*
@@ -47,18 +49,18 @@ public class EntrySerializationTest
@Test
public void testEntryFullSerialization() throws IOException, LdapException, ClassNotFoundException
{
- Entry entry1 = new DefaultEntry(
- "dc=example, dc=com",
+ Entry entry1 = new DefaultEntry(
+ "dc=example, dc=com",
"ObjectClass: top",
"ObjectClass: domain",
"dc: example",
"l: test" );
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
entry1.writeExternal( out );
-
+
ObjectInputStream in = null;
byte[] data = baos.toByteArray();
@@ -70,23 +72,23 @@ public class EntrySerializationTest
assertEquals( entry1, entry2 );
assertTrue( entry2.contains( "ObjectClass", "top", "domain" ) );
}
-
-
+
+
@Test
public void testEntryNoDnSerialization() throws IOException, LdapException, ClassNotFoundException
{
- Entry entry1 = new DefaultEntry(
- "",
+ Entry entry1 = new DefaultEntry(
+ "",
"ObjectClass: top",
"ObjectClass: domain",
"dc: example",
"l: test" );
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
entry1.writeExternal( out );
-
+
ObjectInputStream in = null;
byte[] data = baos.toByteArray();
@@ -104,13 +106,13 @@ public class EntrySerializationTest
@Test
public void testEntryNoAttributesSerialization() throws IOException, LdapException, ClassNotFoundException
{
- Entry entry1 = new DefaultEntry( "dc=example, dc=com" );
-
+ Entry entry1 = new DefaultEntry( "dc=example, dc=com" );
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
entry1.writeExternal( out );
-
+
ObjectInputStream in = null;
byte[] data = baos.toByteArray();
@@ -127,13 +129,13 @@ public class EntrySerializationTest
@Test
public void testEntryNoAttributesNoDnSerialization() throws IOException, LdapException, ClassNotFoundException
{
- Entry entry1 = new DefaultEntry( "" );
-
+ Entry entry1 = new DefaultEntry( "" );
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
entry1.writeExternal( out );
-
+
ObjectInputStream in = null;
byte[] data = baos.toByteArray();
Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntryUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntryUtils.java?rev=1235374&r1=1235373&r2=1235374&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntryUtils.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/EntryUtils.java Tue Jan 24 17:44:03 2012
@@ -19,6 +19,7 @@
*/
package org.apache.directory.shared.ldap.model.entry;
+
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.exception.LdapException;
import org.apache.directory.shared.ldap.model.schema.AttributeType;
@@ -31,6 +32,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer;
import org.apache.directory.shared.util.Strings;
+
/**
* Some common declaration used by the serverEntry tests.
*
@@ -45,18 +47,21 @@ public class EntryUtils
{
private static final long serialVersionUID = 0L;
+
protected AT( String oid )
{
super( oid );
}
}
+
public static MatchingRule matchingRuleFactory( String oid )
{
MatchingRule matchingRule = new MatchingRule( oid );
-
+
return matchingRule;
}
+
/**
* A local MatchingRule class for tests
*/
@@ -76,11 +81,12 @@ public class EntryUtils
public static LdapSyntax syntaxFactory( String oid, boolean humanReadable )
{
LdapSyntax ldapSyntax = new LdapSyntax( oid );
-
+
ldapSyntax.setHumanReadable( humanReadable );
-
+
return ldapSyntax;
}
+
static class S extends LdapSyntax
{
public S( String oid, boolean humanReadible )
@@ -89,7 +95,8 @@ public class EntryUtils
}
}
- /* no protection*/ static AttributeType getCaseIgnoringAttributeNoNumbersType()
+
+ /* no protection*/static AttributeType getCaseIgnoringAttributeNoNumbersType()
{
AttributeType attributeType = new AttributeType( "1.1.3.1" );
LdapSyntax syntax = new LdapSyntax( "1.1.1.1", "", true );
@@ -102,15 +109,15 @@ public class EntryUtils
{
return true;
}
-
+
if ( !( value instanceof String ) )
{
return false;
}
String strval = ( String ) value;
-
- for ( char c:strval.toCharArray() )
+
+ for ( char c : strval.toCharArray() )
{
if ( Character.isDigit( c ) )
{
@@ -120,21 +127,20 @@ public class EntryUtils
return true;
}
} );
-
+
MatchingRule matchingRule = new MatchingRule( "1.1.2.1" );
matchingRule.setSyntax( syntax );
-
matchingRule.setLdapComparator( new LdapComparator<String>( matchingRule.getOid() )
{
public int compare( String o1, String o2 )
{
- return ( o1 == null ?
+ return ( o1 == null ?
( o2 == null ? 0 : -1 ) :
( o2 == null ? 1 : o1.compareTo( o2 ) ) );
}
} );
-
+
Normalizer normalizer = new Normalizer( "1.1.1" )
{
public Value<?> normalize( Value<?> value ) throws LdapException
@@ -146,24 +152,24 @@ public class EntryUtils
throw new IllegalStateException( I18n.err( I18n.ERR_04474 ) );
}
-
-
+
+
public String normalize( String value ) throws LdapException
{
return Strings.toLowerCase( value );
}
};
-
+
matchingRule.setNormalizer( normalizer );
-
+
attributeType.setEquality( matchingRule );
attributeType.setSyntax( syntax );
-
+
return attributeType;
}
- /* no protection*/ static AttributeType getIA5StringAttributeType()
+ /* no protection*/static AttributeType getIA5StringAttributeType()
{
AttributeType attributeType = new AttributeType( "1.1" );
attributeType.addName( "1.1" );
@@ -173,34 +179,33 @@ public class EntryUtils
{
public boolean isValidSyntax( Object value )
{
- return ((String)value == null) || (((String)value).length() < 7) ;
+ return ( ( String ) value == null ) || ( ( ( String ) value ).length() < 7 );
}
} );
-
+
MatchingRule matchingRule = new MatchingRule( "1.1.2" );
matchingRule.setSyntax( syntax );
-
matchingRule.setLdapComparator( new LdapComparator<String>( matchingRule.getOid() )
{
public int compare( String o1, String o2 )
{
- return ( ( o1 == null ) ?
+ return ( ( o1 == null ) ?
( o2 == null ? 0 : -1 ) :
( o2 == null ? 1 : o1.compareTo( o2 ) ) );
}
} );
-
+
matchingRule.setNormalizer( new DeepTrimToLowerNormalizer( matchingRule.getOid() ) );
-
+
attributeType.setEquality( matchingRule );
attributeType.setSyntax( syntax );
-
+
return attributeType;
}
- /* No protection */ static AttributeType getBytesAttributeType()
+ /* No protection */static AttributeType getBytesAttributeType()
{
AttributeType attributeType = new AttributeType( "1.2" );
LdapSyntax syntax = new LdapSyntax( "1.2.1", "", false );
@@ -209,7 +214,7 @@ public class EntryUtils
{
public boolean isValidSyntax( Object value )
{
- return ( value == null ) || ( ((byte[])value).length < 5 );
+ return ( value == null ) || ( ( ( byte[] ) value ).length < 5 );
}
} );
@@ -217,7 +222,7 @@ public class EntryUtils
matchingRule.setSyntax( syntax );
matchingRule.setLdapComparator( new ByteArrayComparator( "1.2.2" ) );
-
+
matchingRule.setNormalizer( new Normalizer( "1.1.1" )
{
public Value<?> normalize( Value<?> value ) throws LdapException
@@ -225,29 +230,30 @@ public class EntryUtils
if ( !value.isHumanReadable() )
{
byte[] val = value.getBytes();
-
+
// each byte will be changed to be > 0, and spaces will be trimmed
- byte[] newVal = new byte[ val.length ];
-
+ byte[] newVal = new byte[val.length];
+
int i = 0;
-
- for ( byte b:val )
+
+ for ( byte b : val )
{
- newVal[i++] = (byte)(b & 0x007F);
+ newVal[i++] = ( byte ) ( b & 0x007F );
}
-
- return new BinaryValue( Strings.trim(newVal) );
+
+ return new BinaryValue( Strings.trim( newVal ) );
}
throw new IllegalStateException( I18n.err( I18n.ERR_04475 ) );
}
+
public String normalize( String value ) throws LdapException
{
throw new IllegalStateException( I18n.err( I18n.ERR_04475 ) );
}
} );
-
+
attributeType.setEquality( matchingRule );
attributeType.setSyntax( syntax );
Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ModificationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ModificationTest.java?rev=1235374&r1=1235373&r2=1235374&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ModificationTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ModificationTest.java Tue Jan 24 17:44:03 2012
@@ -19,6 +19,7 @@
*/
package org.apache.directory.shared.ldap.model.entry;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -77,11 +78,11 @@ public class ModificationTest
throw ioe;
}
}
-
+
return out;
}
-
-
+
+
/**
* Deserialize a DefaultModification
*/
@@ -93,7 +94,7 @@ public class ModificationTest
try
{
Modification modification = new DefaultModification();
-
+
oIn = new ObjectInputStream( in );
modification.readExternal( oIn );
@@ -119,21 +120,21 @@ public class ModificationTest
}
}
}
-
-
- @Test
+
+
+ @Test
public void testCreateServerModification() throws LdapException
{
Attribute attribute = new DefaultAttribute( "cn" );
attribute.add( "test1", "test2" );
-
+
Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
Modification clone = mod.clone();
-
+
attribute.remove( "test2" );
-
+
Attribute clonedAttribute = clone.getAttribute();
-
+
assertEquals( 1, mod.getAttribute().size() );
assertTrue( mod.getAttribute().contains( "test1" ) );
@@ -141,59 +142,59 @@ public class ModificationTest
assertTrue( clone.getAttribute().contains( "test1" ) );
assertTrue( clone.getAttribute().contains( "test2" ) );
}
-
-
+
+
@Test
public void testSerializationModificationADD() throws ClassNotFoundException, IOException, LdapException
{
Attribute attribute = new DefaultAttribute( "cn" );
attribute.add( "test1", "test2" );
-
+
DefaultModification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attribute );
-
+
Modification modSer = deserializeValue( serializeValue( mod ) );
-
+
assertEquals( mod, modSer );
}
-
-
+
+
@Test
public void testSerializationModificationREPLACE() throws ClassNotFoundException, IOException, LdapException
{
Attribute attribute = new DefaultAttribute( "cn" );
attribute.add( "test1", "test2" );
-
+
DefaultModification mod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attribute );
-
+
Modification modSer = deserializeValue( serializeValue( mod ) );
-
+
assertEquals( mod, modSer );
}
-
-
+
+
@Test
public void testSerializationModificationREMOVE() throws ClassNotFoundException, IOException, LdapException
{
Attribute attribute = new DefaultAttribute( "cn" );
attribute.add( "test1", "test2" );
-
+
DefaultModification mod = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attribute );
-
+
Modification modSer = deserializeValue( serializeValue( mod ) );
-
+
assertEquals( mod, modSer );
}
-
-
+
+
@Test
public void testSerializationModificationNoAttribute() throws ClassNotFoundException, IOException
{
DefaultModification mod = new DefaultModification();
-
+
mod.setOperation( ModificationOperation.ADD_ATTRIBUTE );
-
+
Modification modSer = deserializeValue( serializeValue( mod ) );
-
+
assertEquals( mod, modSer );
}
}
Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueAttributeTypeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueAttributeTypeTest.java?rev=1235374&r1=1235373&r2=1235374&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueAttributeTypeTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueAttributeTypeTest.java Tue Jan 24 17:44:03 2012
@@ -75,7 +75,7 @@ public class StringValueAttributeTypeTes
private EntryUtils.AT at;
private EntryUtils.MR mr;
-
+
/**
* Initialize an AttributeType and the associated MatchingRule
* and Syntax
@@ -95,8 +95,8 @@ public class StringValueAttributeTypeTes
at.setSubstring( mr );
at.setSyntax( s );
}
-
-
+
+
/**
* Serialize a StringValue
*/
@@ -129,11 +129,11 @@ public class StringValueAttributeTypeTes
throw ioe;
}
}
-
+
return out;
}
-
-
+
+
/**
* Deserialize a StringValue
*/
@@ -145,7 +145,7 @@ public class StringValueAttributeTypeTes
try
{
oIn = new ObjectInputStream( in );
-
+
StringValue value = new StringValue( at );
value.readExternal( oIn );
@@ -171,33 +171,33 @@ public class StringValueAttributeTypeTes
}
}
}
-
-
+
+
/**
* Test the constructor with a null value
*/
- @Test
+ @Test
public void testClientStringValueNullValue() throws LdapInvalidAttributeValueException
{
AttributeType attribute = EntryUtils.getIA5StringAttributeType();
-
+
StringValue value = new StringValue( attribute, null );
-
+
assertNull( value.getValue() );
assertTrue( value.isNull() );
}
-
-
+
+
/**
* Test the getNormValue method
*/
- @Test
+ @Test
public void testGetNormalizedValue() throws LdapInvalidAttributeValueException
{
AttributeType attribute = EntryUtils.getIA5StringAttributeType();
-
+
StringValue sv = new StringValue( attribute, null );
-
+
assertTrue( sv.isSchemaAware() );
assertNull( sv.getNormValue() );
assertTrue( sv.isSchemaAware() );
@@ -211,18 +211,18 @@ public class StringValueAttributeTypeTes
assertTrue( sv.isSchemaAware() );
assertEquals( "test", sv.getNormValue() );
}
-
+
/**
* Test the isValid method
*
* The SyntaxChecker does not accept values longer than 5 chars.
*/
- @Test
+ @Test
public void testIsValid() throws LdapInvalidAttributeValueException
{
AttributeType attribute = EntryUtils.getIA5StringAttributeType();
-
+
new StringValue( attribute, null );
new StringValue( attribute, "" );
new StringValue( attribute, "TEST" );
@@ -237,8 +237,8 @@ public class StringValueAttributeTypeTes
assertTrue( true );
}
}
-
-
+
+
/**
* Test the normalize method
*/
@@ -250,7 +250,7 @@ public class StringValueAttributeTypeTes
sv.apply( at );
assertEquals( null, sv.getNormValue() );
-
+
sv = new StringValue( attribute, "" );
sv.apply( at );
assertEquals( "", sv.getNormValue() );
@@ -258,7 +258,7 @@ public class StringValueAttributeTypeTes
sv = new StringValue( attribute, " A TEST " );
assertEquals( "a test", sv.getNormValue() );
}
-
+
/**
* Test the instanceOf method
@@ -268,14 +268,14 @@ public class StringValueAttributeTypeTes
{
AttributeType attribute = EntryUtils.getIA5StringAttributeType();
StringValue ssv = new StringValue( attribute );
-
+
assertTrue( ssv.isInstanceOf( attribute ) );
-
+
attribute = EntryUtils.getBytesAttributeType();
-
+
assertFalse( ssv.isInstanceOf( attribute ) );
- }
-
+ }
+
/**
* Test the getAttributeType method
@@ -285,28 +285,29 @@ public class StringValueAttributeTypeTes
{
AttributeType attribute = EntryUtils.getIA5StringAttributeType();
StringValue ssv = new StringValue( attribute );
-
+
assertEquals( attribute, ssv.getAttributeType() );
- }
+ }
+
-
/**
* Test the equals method
*/
- @Test
+ @Test
public void testEquals() throws LdapInvalidAttributeValueException
{
AttributeType at1 = EntryUtils.getIA5StringAttributeType();
AttributeType at2 = EntryUtils.getBytesAttributeType();
-
+
StringValue value1 = new StringValue( at1, "test" );
StringValue value2 = new StringValue( at1, "test" );
StringValue value3 = new StringValue( at1, "TEST" );
StringValue value4 = new StringValue( at1, "tes" );
StringValue value5 = new StringValue( at1, null );
- BinaryValue valueBytes = new BinaryValue( at2, new byte[]{0x01} );
+ BinaryValue valueBytes = new BinaryValue( at2, new byte[]
+ { 0x01 } );
StringValue valueString = new StringValue( at, "test" );
-
+
assertTrue( value1.equals( value1 ) );
assertTrue( value1.equals( value2 ) );
assertTrue( value1.equals( value3 ) );
@@ -314,21 +315,21 @@ public class StringValueAttributeTypeTes
assertFalse( value1.equals( value5 ) );
assertFalse( value1.equals( "test" ) );
assertFalse( value1.equals( null ) );
-
+
assertTrue( value1.equals( valueString ) );
assertFalse( value1.equals( valueBytes ) );
}
-
-
+
+
/**
* Test the constructor with bad AttributeType
*/
- @Test
+ @Test
public void testBadConstructor()
{
// create a AT without any syntax
AttributeType attribute = new EntryUtils.AT( "1.1.3.1" );
-
+
try
{
new StringValue( attribute );
@@ -345,32 +346,32 @@ public class StringValueAttributeTypeTes
* Tests to make sure the hashCode method is working properly.
* @throws Exception on errors
*/
- @Test
+ @Test
public void testHashCode() throws LdapInvalidAttributeValueException
{
AttributeType at1 = EntryUtils.getCaseIgnoringAttributeNoNumbersType();
StringValue v0 = new StringValue( at1, "Alex" );
StringValue v1 = new StringValue( at1, "ALEX" );
StringValue v2 = new StringValue( at1, "alex" );
-
+
assertEquals( v0.hashCode(), v1.hashCode() );
assertEquals( v0.hashCode(), v2.hashCode() );
assertEquals( v1.hashCode(), v2.hashCode() );
-
+
assertEquals( v0, v1 );
assertEquals( v0, v2 );
assertEquals( v1, v2 );
-
+
StringValue v3 = new StringValue( at1, "Timber" );
-
+
assertNotSame( v0.hashCode(), v3.hashCode() );
StringValue v4 = new StringValue( at, "Alex" );
-
+
assertNotSame( v0.hashCode(), v4.hashCode() );
}
-
-
+
+
/**
* Test the compareTo method
*/
@@ -380,12 +381,12 @@ public class StringValueAttributeTypeTes
AttributeType at1 = EntryUtils.getCaseIgnoringAttributeNoNumbersType();
StringValue v0 = new StringValue( at1, "Alex" );
StringValue v1 = new StringValue( at1, "ALEX" );
-
+
assertEquals( 0, v0.compareTo( v1 ) );
assertEquals( 0, v1.compareTo( v0 ) );
StringValue v2 = new StringValue( at1, null );
-
+
assertEquals( 1, v0.compareTo( v2 ) );
assertEquals( -1, v2.compareTo( v0 ) );
}
@@ -399,23 +400,23 @@ public class StringValueAttributeTypeTes
{
AttributeType at1 = EntryUtils.getCaseIgnoringAttributeNoNumbersType();
StringValue sv = new StringValue( at1, "Test" );
-
+
StringValue sv1 = sv.clone();
-
+
assertEquals( sv, sv1 );
-
+
sv = new StringValue( "" );
-
+
assertNotSame( sv, sv1 );
assertEquals( "", sv.getString() );
-
+
sv = new StringValue( " This is a TEST " );
sv1 = sv.clone();
-
+
assertEquals( sv, sv1 );
assertEquals( sv, sv1 );
}
-
+
/**
* Presumes an attribute which constrains it's values to some constant
@@ -424,10 +425,11 @@ public class StringValueAttributeTypeTes
*
* @throws Exception on errors
*/
- @Test
+ @Test
public void testConstrainedString() throws LdapInvalidAttributeValueException
{
- s.setSyntaxChecker( new SyntaxChecker( "1.1.1.1" ) {
+ s.setSyntaxChecker( new SyntaxChecker( "1.1.1.1" )
+ {
public boolean isValidSyntax( Object value )
{
if ( value instanceof String )
@@ -437,7 +439,7 @@ public class StringValueAttributeTypeTes
}
return false;
}
- });
+ } );
mr.setSyntax( s );
mr.setLdapComparator( new LdapComparator<String>( mr.getOid() )
@@ -463,22 +465,41 @@ public class StringValueAttributeTypeTes
int i1 = getValue( o1 );
int i2 = getValue( o2 );
- if ( i1 == i2 ) { return 0; }
- if ( i1 > i2 ) { return 1; }
- if ( i1 < i2 ) { return -1; }
+ if ( i1 == i2 )
+ {
+ return 0;
+ }
+ if ( i1 > i2 )
+ {
+ return 1;
+ }
+ if ( i1 < i2 )
+ {
+ return -1;
+ }
throw new IllegalStateException( "should not get here at all" );
}
+
public int getValue( String val )
{
- if ( val.equals( "LOW" ) ) { return 0; }
- if ( val.equals( "MEDIUM" ) ) { return 1; }
- if ( val.equals( "HIGH" ) ) { return 2; }
+ if ( val.equals( "LOW" ) )
+ {
+ return 0;
+ }
+ if ( val.equals( "MEDIUM" ) )
+ {
+ return 1;
+ }
+ if ( val.equals( "HIGH" ) )
+ {
+ return 2;
+ }
throw new IllegalArgumentException( "Not a valid value" );
}
} );
-
+
mr.setNormalizer( new NoOpNormalizer( mr.getOid() ) );
at.setEquality( mr );
at.setSyntax( s );
@@ -486,9 +507,9 @@ public class StringValueAttributeTypeTes
// check that normalization and syntax checks work as expected
StringValue value = new StringValue( at, "HIGH" );
assertEquals( value.getValue(), value.getValue() );
-
+
try
- {
+ {
new StringValue( at, "high" );
fail();
}
@@ -551,7 +572,7 @@ public class StringValueAttributeTypeTes
* is still OK.
* @throws Exception on errors
*/
- @Test
+ @Test
public void testAcceptAllNoNormalization() throws LdapInvalidAttributeValueException
{
// check that normalization and syntax checks work as expected
@@ -600,7 +621,7 @@ public class StringValueAttributeTypeTes
{
String n1 = null;
String n2 = null;
-
+
if ( o1 != null )
{
n1 = o1.getString();
@@ -642,83 +663,83 @@ public class StringValueAttributeTypeTes
assertEquals( 6, list.size() );
}
-
+
/**
* Test serialization of a StringValue which has a normalized value
*/
- @Test
+ @Test
public void testNormalizedStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
{
// First check with a value which will be normalized
StringValue ssv = new StringValue( at, " Test Test " );
-
+
String normalized = ssv.getNormValue();
-
+
assertEquals( "test test", normalized );
assertEquals( " Test Test ", ssv.getString() );
-
+
StringValue ssvSer = deserializeValue( serializeValue( ssv ) );
-
+
assertEquals( ssv, ssvSer );
- }
+ }
/**
* Test serialization of a StringValue which does not have a normalized value
*/
- @Test
+ @Test
public void testNoNormalizedStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
{
// First check with a value which will be normalized
StringValue ssv = new StringValue( at, "test" );
-
+
String normalized = ssv.getNormValue();
-
+
assertEquals( "test", normalized );
assertEquals( "test", ssv.getString() );
-
+
StringValue ssvSer = deserializeValue( serializeValue( ssv ) );
-
+
assertEquals( ssv, ssvSer );
- }
+ }
/**
* Test serialization of a null StringValue
*/
- @Test
+ @Test
public void testNullStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
{
// First check with a value which will be normalized
StringValue ssv = new StringValue( at );
-
+
String normalized = ssv.getNormValue();
-
+
assertNull( normalized );
assertNull( ssv.getValue() );
-
+
StringValue ssvSer = deserializeValue( serializeValue( ssv ) );
-
+
assertEquals( ssv, ssvSer );
- }
+ }
/**
* Test serialization of an empty StringValue
*/
- @Test
+ @Test
public void testEmptyStringValueSerialization() throws LdapException, IOException, ClassNotFoundException
{
// First check with a value which will be normalized
StringValue ssv = new StringValue( at, "" );
-
+
String normalized = ssv.getNormValue();
-
+
assertEquals( "", normalized );
assertEquals( "", ssv.getString() );
-
+
StringValue ssvSer = deserializeValue( serializeValue( ssv ) );
-
+
assertEquals( ssv, ssvSer );
}
@@ -726,16 +747,16 @@ public class StringValueAttributeTypeTes
/**
* Test serialization of an empty StringValue
*/
- @Test
+ @Test
public void testStringValueEmptyNormalizedSerialization() throws LdapException, IOException, ClassNotFoundException
{
// First check with a value which will be normalized
StringValue ssv = new StringValue( " " );
-
+
assertEquals( " ", ssv.getString() );
-
+
StringValue ssvSer = deserializeValue( serializeValue( ssv ) );
-
+
assertEquals( ssv, ssvSer );
}
}