Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7694D9BAF for ; Tue, 24 Jan 2012 17:46:36 +0000 (UTC) Received: (qmail 13642 invoked by uid 500); 24 Jan 2012 17:46:36 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 13593 invoked by uid 500); 24 Jan 2012 17:46:36 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 13584 invoked by uid 99); 24 Jan 2012 17:46:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Jan 2012 17:46:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Jan 2012 17:46:06 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A348B2388C2C for ; Tue, 24 Jan 2012 17:44:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1235374 [17/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... Date: Tue, 24 Jan 2012 17:44:32 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120124174458.A348B2388C2C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueTest.java?rev=1235374&r1=1235373&r2=1235374&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueTest.java (original) +++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueTest.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.assertNotNull; @@ -44,6 +45,7 @@ import org.junit.runner.RunWith; import com.mycila.junit.concurrent.Concurrency; import com.mycila.junit.concurrent.ConcurrentJunitRunner; + /** * * Test the StringValue class @@ -63,7 +65,7 @@ public class StringValueTest * Initialize an AttributeType and the associated MatchingRule * and Syntax */ - @BeforeClass + @BeforeClass public static void initAT() { s = new EntryUtils.S( "1.1.1.1", true ); @@ -78,8 +80,8 @@ public class StringValueTest at.setSubstring( mr ); at.setSyntax( s ); } - - + + //---------------------------------------------------------------------------------- // Helper method //---------------------------------------------------------------------------------- @@ -93,15 +95,16 @@ public class StringValueTest oOut = new ObjectOutputStream( out ); value.writeExternal( oOut ); - + return out; } - - + + /** * Deserialize a StringValue */ - private StringValue deserializeValue( AttributeType at, ByteArrayOutputStream out ) throws IOException, ClassNotFoundException + private StringValue deserializeValue( AttributeType at, ByteArrayOutputStream out ) throws IOException, + ClassNotFoundException { ObjectInputStream oIn = null; ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() ); @@ -134,8 +137,8 @@ public class StringValueTest } } } - - + + //---------------------------------------------------------------------------------- // Test the clone() method //---------------------------------------------------------------------------------- @@ -145,14 +148,14 @@ public class StringValueTest @Test public void testCloneEmptyValue() throws LdapException { - StringValue sv = new StringValue( (String)null ); - - StringValue sv1 = (StringValue)sv.clone(); - + StringValue sv = new StringValue( ( String ) null ); + + StringValue sv1 = ( StringValue ) sv.clone(); + assertEquals( sv, sv1 ); - + StringValue sv2 = new StringValue( "" ); - + assertNotSame( sv2, sv1 ); assertNull( sv1.getValue() ); assertEquals( "", sv2.getString() ); @@ -166,16 +169,16 @@ public class StringValueTest public void testCloneValue() throws LdapException { StringValue sv = new StringValue( " This is a TEST " ); - - StringValue sv1 = (StringValue)sv.clone(); - + + StringValue sv1 = ( StringValue ) sv.clone(); + sv1 = sv.clone(); - + assertEquals( sv, sv1 ); assertEquals( " This is a TEST ", sv.getString() ); sv.apply( at ); - + assertNotSame( sv, sv1 ); assertEquals( " This is a TEST ", sv1.getString() ); assertEquals( " This is a TEST ", sv1.getNormValue() ); @@ -191,11 +194,11 @@ public class StringValueTest public void testHashCode() { StringValue csv = new StringValue( "test" ); - + int hash = "test".hashCode(); assertEquals( hash, csv.hashCode() ); - - csv = new StringValue( (String)null ); + + csv = new StringValue( ( String ) null ); hash = "".hashCode(); assertEquals( hash, csv.hashCode() ); } @@ -207,8 +210,8 @@ public class StringValueTest @Test public void testClientStringValueNull() throws LdapException { - StringValue csv = new StringValue( (String)null ); - + StringValue csv = new StringValue( ( String ) null ); + assertNull( csv.getValue() ); assertFalse( csv.isSchemaAware() ); assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) ); @@ -224,7 +227,7 @@ public class StringValueTest public void testClientStringValueEmpty() throws LdapException { StringValue csv = new StringValue( "" ); - + assertNotNull( csv.getValue() ); assertEquals( "", csv.getString() ); assertFalse( csv.isSchemaAware() ); @@ -242,7 +245,7 @@ public class StringValueTest public void testClientStringValueString() throws LdapException { StringValue csv = new StringValue( "test" ); - + assertEquals( "test", csv.getValue() ); assertFalse( csv.isSchemaAware() ); assertTrue( csv.isValid( new Ia5StringSyntaxChecker() ) ); @@ -260,7 +263,7 @@ public class StringValueTest { StringValue sv = new StringValue( "test" ); assertEquals( "test", sv.getValue() ); - + StringValue sv2 = new StringValue( "" ); assertEquals( "", sv2.getValue() ); } @@ -273,9 +276,9 @@ public class StringValueTest public void testGetCopy() { StringValue sv = new StringValue( "test" ); - + assertEquals( "test", sv.getValue() ); - + StringValue sv2 = new StringValue( "" ); assertEquals( "", sv2.getValue() ); } @@ -287,8 +290,8 @@ public class StringValueTest @Test public void testSet() throws LdapException { - StringValue sv = new StringValue( (String)null ); - + StringValue sv = new StringValue( ( String ) null ); + assertNull( sv.getValue() ); assertFalse( sv.isSchemaAware() ); assertTrue( sv.isValid( new Ia5StringSyntaxChecker() ) ); @@ -316,14 +319,14 @@ public class StringValueTest @Test public void testIsNull() { - StringValue sv = new StringValue( (String)null ); + StringValue sv = new StringValue( ( String ) null ); assertTrue( sv.isNull() ); - + sv = new StringValue( "test" ); assertFalse( sv.isNull() ); } - + /** * Test method for {@link org.apache.directory.shared.ldap.model.entry.StringValue#isSchemaAware()}. */ @@ -331,14 +334,14 @@ public class StringValueTest public void testIsNormalized() throws LdapException { StringValue sv = new StringValue( " This is a TEST " ); - + assertFalse( sv.isSchemaAware() ); - + sv.apply( at ); - + assertEquals( "this is a test", sv.getNormValue() ); assertTrue( sv.isSchemaAware() ); - + sv = new StringValue( "test" ); assertFalse( sv.isSchemaAware() ); } @@ -350,15 +353,15 @@ public class StringValueTest @Test public void testSetNormalized() throws LdapException { - StringValue sv = new StringValue( (String)null ); - + StringValue sv = new StringValue( ( String ) null ); + assertFalse( sv.isSchemaAware() ); - + sv = new StringValue( " This is a TEST " ); assertFalse( sv.isSchemaAware() ); - + sv.apply( at ); - + assertEquals( "this is a test", sv.getNormValue() ); assertTrue( sv.isSchemaAware() ); } @@ -370,15 +373,15 @@ public class StringValueTest @Test public void testGetNormalizedValue() throws LdapException { - StringValue sv = new StringValue( (String)null ); - + StringValue sv = new StringValue( ( String ) null ); + assertEquals( null, sv.getNormValue() ); - + sv = new StringValue( " This is a TEST " ); assertEquals( " This is a TEST ", sv.getNormValue() ); - + sv.apply( at ); - + assertEquals( "this is a test", sv.getNormValue() ); } @@ -389,39 +392,39 @@ public class StringValueTest @Test public void getNormValueCopy() throws LdapException { - StringValue sv = new StringValue( (String)null ); - + StringValue sv = new StringValue( ( String ) null ); + assertEquals( null, sv.getNormValue() ); - + sv = new StringValue( " This is a TEST " ); assertEquals( " This is a TEST ", sv.getNormValue() ); - + sv.apply( at ); - + assertEquals( "this is a test", sv.getNormValue() ); } - + /** * Test method for {@link org.apache.directory.shared.ldap.model.entry.StringValue#normalize(org.apache.directory.shared.ldap.model.schema.Normalizer)}. */ @Test public void testNormalize() throws LdapException { - StringValue sv = new StringValue( (String)null ); + StringValue sv = new StringValue( ( String ) null ); sv.apply( at ); assertEquals( null, sv.getNormValue() ); - + sv = new StringValue( "" ); sv.apply( at ); assertEquals( "", sv.getNormValue() ); - sv = new StringValue( " This is a TEST " ); + sv = new StringValue( " This is a TEST " ); assertEquals( " This is a TEST ", sv.getNormValue() ); - + sv.apply( at ); - + assertEquals( "this is a test", sv.getNormValue() ); } @@ -433,9 +436,9 @@ public class StringValueTest public void testIsValid() throws LdapException { StringValue sv = new StringValue( "Test" ); - + assertTrue( sv.isValid( new Ia5StringSyntaxChecker() ) ); - + sv = new StringValue( "é" ); assertFalse( sv.isValid( new Ia5StringSyntaxChecker() ) ); } @@ -447,24 +450,24 @@ public class StringValueTest @Test public void testCompareTo() throws LdapException { - StringValue sv1 = new StringValue( (String)null ); - StringValue sv2 = new StringValue( (String)null ); - + StringValue sv1 = new StringValue( ( String ) null ); + StringValue sv2 = new StringValue( ( String ) null ); + assertEquals( 0, sv1.compareTo( sv2 ) ); - + sv1 = new StringValue( "Test" ); assertEquals( 1, sv1.compareTo( sv2 ) ); assertEquals( -1, sv2.compareTo( sv1 ) ); - + sv2 = new StringValue( "Test" ); assertEquals( 0, sv1.compareTo( sv2 ) ); // Now check that the equals method works on normalized values. - sv1 = new StringValue( " This is a TEST " ); + sv1 = new StringValue( " This is a TEST " ); sv2 = new StringValue( "this is a test" ); sv1.apply( at ); assertEquals( 0, sv1.compareTo( sv2 ) ); - + sv1 = new StringValue( "a" ); sv2 = new StringValue( "b" ); assertEquals( -1, sv1.compareTo( sv2 ) ); @@ -481,14 +484,14 @@ public class StringValueTest @Test public void testEquals() throws LdapException { - StringValue sv1 = new StringValue( (String)null ); - StringValue sv2 = new StringValue( (String)null ); - + StringValue sv1 = new StringValue( ( String ) null ); + StringValue sv2 = new StringValue( ( String ) null ); + assertEquals( sv1, sv2 ); - + sv1 = new StringValue( "Test" ); assertNotSame( sv1, sv2 ); - + sv2 = new StringValue( "Test" ); assertEquals( sv1, sv2 ); @@ -506,8 +509,8 @@ public class StringValueTest @Test public void testToString() { - StringValue sv = new StringValue( (String)null ); - + StringValue sv = new StringValue( ( String ) null ); + assertEquals( "null", sv.toString() ); sv = new StringValue( "" ); @@ -516,15 +519,15 @@ public class StringValueTest sv = new StringValue( "Test" ); assertEquals( "Test", sv.toString() ); } - - + + /** * Test the serialization of a CSV with a value and a normalized value */ @Test public void testSerializeStandard() throws LdapException, IOException, ClassNotFoundException { - StringValue csv = new StringValue( "TEST"); + StringValue csv = new StringValue( "TEST" ); csv.apply( at ); csv.isValid( new Ia5StringSyntaxChecker() ); @@ -534,8 +537,8 @@ public class StringValueTest assertEquals( csv.getNormValue(), csvSer.getNormValue() ); assertTrue( csvSer.isSchemaAware() ); } - - + + /** * Test the serialization of a CSV with a value and no normalized value */ @@ -551,8 +554,8 @@ public class StringValueTest assertEquals( csv.getValue(), csvSer.getNormValue() ); assertFalse( csvSer.isSchemaAware() ); } - - + + /** * Test the serialization of a CSV with a value and an empty normalized value */ @@ -564,31 +567,31 @@ public class StringValueTest csv.apply( at ); StringValue csvSer = deserializeValue( at, serializeValue( csv ) ); - assertNotSame( csv, csvSer ); - assertEquals( csv.getValue(), csvSer.getValue() ); - assertEquals( csv.getNormValue(), csvSer.getNormValue() ); - assertTrue( csvSer.isSchemaAware() ); + assertNotSame( csv, csvSer ); + assertEquals( csv.getValue(), csvSer.getValue() ); + assertEquals( csv.getNormValue(), csvSer.getNormValue() ); + assertTrue( csvSer.isSchemaAware() ); } - - + + /** * Test the serialization of a CSV with a null value */ @Test public void testSerializeNullValue() throws LdapException, IOException, ClassNotFoundException { - StringValue csv = new StringValue( (String)null ); + StringValue csv = new StringValue( ( String ) null ); csv.isValid( new Ia5StringSyntaxChecker() ); csv.apply( at ); StringValue csvSer = deserializeValue( at, serializeValue( csv ) ); - assertNotSame( csv, csvSer ); - assertEquals( csv.getValue(), csvSer.getValue() ); - assertEquals( csv.getNormValue(), csvSer.getNormValue() ); - assertTrue( csvSer.isSchemaAware() ); + assertNotSame( csv, csvSer ); + assertEquals( csv.getValue(), csvSer.getValue() ); + assertEquals( csv.getNormValue(), csvSer.getNormValue() ); + assertTrue( csvSer.isSchemaAware() ); } - - + + /** * Test the serialization of a CSV with an empty value */ @@ -600,13 +603,13 @@ public class StringValueTest csv.apply( at ); StringValue csvSer = deserializeValue( at, serializeValue( csv ) ); - assertNotSame( csv, csvSer ); - assertEquals( csv.getValue(), csvSer.getValue() ); - assertEquals( csv.getNormValue(), csvSer.getNormValue() ); - assertTrue( csvSer.isSchemaAware() ); + assertNotSame( csv, csvSer ); + assertEquals( csv.getValue(), csvSer.getValue() ); + assertEquals( csv.getNormValue(), csvSer.getNormValue() ); + assertTrue( csvSer.isSchemaAware() ); } - - + + /** * Test the serialization of a CSV with an empty value not normalized */ @@ -617,9 +620,9 @@ public class StringValueTest csv.isValid( new Ia5StringSyntaxChecker() ); StringValue csvSer = deserializeValue( null, serializeValue( csv ) ); - assertNotSame( csv, csvSer ); - assertEquals( csv.getValue(), csvSer.getValue() ); - assertEquals( csv.getNormValue(), csvSer.getNormValue() ); - assertFalse( csvSer.isSchemaAware() ); + assertNotSame( csv, csvSer ); + assertEquals( csv.getValue(), csvSer.getValue() ); + assertEquals( csv.getNormValue(), csvSer.getNormValue() ); + assertFalse( csvSer.isSchemaAware() ); } } Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ValueSerializationTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ValueSerializationTest.java?rev=1235374&r1=1235373&r2=1235374&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ValueSerializationTest.java (original) +++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ValueSerializationTest.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 java.io.ByteArrayInputStream; @@ -43,6 +44,7 @@ import org.junit.runner.RunWith; import com.mycila.junit.concurrent.Concurrency; import com.mycila.junit.concurrent.ConcurrentJunitRunner; + /** * Test the Value Serialization * @@ -52,20 +54,21 @@ import com.mycila.junit.concurrent.Concu @Concurrency() public class ValueSerializationTest { - private static byte[] data = new byte[] {0x01, 0x02, 0x03, 0x04}; + private static byte[] data = new byte[] + { 0x01, 0x02, 0x03, 0x04 }; BinaryValue bv1 = new BinaryValue( data ); BinaryValue bv2 = new BinaryValue( StringConstants.EMPTY_BYTES ); - BinaryValue bv3 = new BinaryValue( (byte[])null ); + BinaryValue bv3 = new BinaryValue( ( byte[] ) null ); BinaryValue bv1n = new BinaryValue( data ); BinaryValue bv2n = new BinaryValue( StringConstants.EMPTY_BYTES ); - BinaryValue bv3n = new BinaryValue( (byte[])null ); + BinaryValue bv3n = new BinaryValue( ( byte[] ) null ); StringValue sv1 = new StringValue( "test" ); StringValue sv2 = new StringValue( "" ); - StringValue sv3 = new StringValue( (String)null ); + StringValue sv3 = new StringValue( ( String ) null ); StringValue sv1n = new StringValue( "test" ); StringValue sv2n = new StringValue( "" ); - StringValue sv3n = new StringValue( (String)null ); - + StringValue sv3n = new StringValue( ( String ) null ); + private EntryUtils.S sb; private EntryUtils.AT atb; private EntryUtils.MR mrb; @@ -74,6 +77,7 @@ public class ValueSerializationTest private EntryUtils.AT ats; private EntryUtils.MR mrs; + /** * Initialize an AttributeType and the associated MatchingRule * and Syntax @@ -85,7 +89,7 @@ public class ValueSerializationTest sb.setSyntaxChecker( new OctetStringSyntaxChecker() ); mrb = new EntryUtils.MR( "1.1.2.1" ); mrb.setSyntax( sb ); - + mrb.setLdapComparator( new ByteArrayComparator( "1.1.1" ) ); mrb.setNormalizer( new Normalizer( "1.1.1" ) { @@ -95,33 +99,33 @@ public class ValueSerializationTest { 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( "expected byte[] to normalize" ); } - + public String normalize( String value ) throws LdapException { throw new IllegalStateException( "expected byte[] to normalize" ); } - }); - + } ); + atb = new EntryUtils.AT( "1.1.3.1" ); atb.setEquality( mrb ); atb.setOrdering( mrb ); atb.setSubstring( mrb ); atb.setSyntax( sb ); - + ss = new EntryUtils.S( "1.1.1.1", true ); ss.setSyntaxChecker( new OctetStringSyntaxChecker() ); mrs = new EntryUtils.MR( "1.1.2.1" ); @@ -135,7 +139,7 @@ public class ValueSerializationTest ats.setSyntax( ss ); } - + @Test public void testBinaryValueWithDataSerialization() throws IOException, ClassNotFoundException { @@ -143,19 +147,19 @@ public class ValueSerializationTest ObjectOutputStream out = new ObjectOutputStream( baos ); bv1.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream( new ByteArrayInputStream( data ) ); - BinaryValue bvDeser = new BinaryValue( (AttributeType)null ); + BinaryValue bvDeser = new BinaryValue( ( AttributeType ) null ); bvDeser.readExternal( in ); assertEquals( bv1, bvDeser ); } - - + + @Test public void testBinaryValueWithEmptyDataSerialization() throws IOException, ClassNotFoundException { @@ -163,19 +167,19 @@ public class ValueSerializationTest ObjectOutputStream out = new ObjectOutputStream( baos ); bv2.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream( new ByteArrayInputStream( data ) ); - BinaryValue bvDeser = new BinaryValue( (AttributeType)null ); + BinaryValue bvDeser = new BinaryValue( ( AttributeType ) null ); bvDeser.readExternal( in ); assertEquals( bv2, bvDeser ); } - - + + @Test public void testBinaryValueNoDataSerialization() throws IOException, ClassNotFoundException { @@ -183,19 +187,19 @@ public class ValueSerializationTest ObjectOutputStream out = new ObjectOutputStream( baos ); bv3.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream( new ByteArrayInputStream( data ) ); - BinaryValue bvDeser = new BinaryValue( (AttributeType)null ); + BinaryValue bvDeser = new BinaryValue( ( AttributeType ) null ); bvDeser.readExternal( in ); assertEquals( bv3, bvDeser ); } - - + + @Test public void testStringValueWithDataSerialization() throws IOException, ClassNotFoundException { @@ -203,19 +207,19 @@ public class ValueSerializationTest ObjectOutputStream out = new ObjectOutputStream( baos ); sv1.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream( new ByteArrayInputStream( data ) ); - StringValue svDeser = new StringValue( (AttributeType)null ); + StringValue svDeser = new StringValue( ( AttributeType ) null ); svDeser.readExternal( in ); assertEquals( sv1, svDeser ); } - - + + @Test public void testStringValueWithEmptyDataSerialization() throws IOException, ClassNotFoundException { @@ -223,19 +227,19 @@ public class ValueSerializationTest ObjectOutputStream out = new ObjectOutputStream( baos ); sv2.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream( new ByteArrayInputStream( data ) ); - StringValue svDeser = new StringValue( (AttributeType)null ); + StringValue svDeser = new StringValue( ( AttributeType ) null ); svDeser.readExternal( in ); assertEquals( sv2, svDeser ); } - - + + @Test public void testStringValueNoDataSerialization() throws IOException, ClassNotFoundException { @@ -243,139 +247,145 @@ public class ValueSerializationTest ObjectOutputStream out = new ObjectOutputStream( baos ); sv3.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream( new ByteArrayInputStream( data ) ); - StringValue svDeser = new StringValue( (AttributeType)null ); + StringValue svDeser = new StringValue( ( AttributeType ) null ); svDeser.readExternal( in ); assertEquals( sv3, svDeser ); } - - + + @Test - public void testBinaryValueWithDataNormalizedSerialization() throws IOException, LdapException, ClassNotFoundException + public void testBinaryValueWithDataNormalizedSerialization() throws IOException, LdapException, + ClassNotFoundException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream( baos ); bv1n.apply( atb ); bv1n.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream( new ByteArrayInputStream( data ) ); - BinaryValue bvDeser = new BinaryValue( (AttributeType)null ); + BinaryValue bvDeser = new BinaryValue( ( AttributeType ) null ); bvDeser.readExternal( in ); assertEquals( bv1n, bvDeser ); } - - + + @Test - public void testBinaryValueWithEmptyDataNormalizedSerialization() throws IOException, LdapException, ClassNotFoundException + public void testBinaryValueWithEmptyDataNormalizedSerialization() throws IOException, LdapException, + ClassNotFoundException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream( baos ); bv2n.apply( atb ); bv2n.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream( new ByteArrayInputStream( data ) ); - BinaryValue bvDeser = new BinaryValue( (AttributeType)null ); + BinaryValue bvDeser = new BinaryValue( ( AttributeType ) null ); bvDeser.readExternal( in ); assertEquals( bv2n, bvDeser ); } - - + + @Test - public void testBinaryValueNoDataNormalizedSerialization() throws IOException, LdapException, ClassNotFoundException + public void testBinaryValueNoDataNormalizedSerialization() throws IOException, LdapException, + ClassNotFoundException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream( baos ); bv3n.apply( atb ); bv3n.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream( new ByteArrayInputStream( data ) ); - BinaryValue bvDeser = new BinaryValue( (AttributeType)null ); + BinaryValue bvDeser = new BinaryValue( ( AttributeType ) null ); bvDeser.readExternal( in ); assertEquals( bv3n, bvDeser ); } - - + + @Test - public void testStringValueWithDataNormalizedSerialization() throws IOException, LdapException, ClassNotFoundException + public void testStringValueWithDataNormalizedSerialization() throws IOException, LdapException, + ClassNotFoundException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream( baos ); sv1n.apply( ats ); sv1n.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream( new ByteArrayInputStream( data ) ); - StringValue svDeser = new StringValue( (AttributeType)null ); + StringValue svDeser = new StringValue( ( AttributeType ) null ); svDeser.readExternal( in ); assertEquals( sv1n, svDeser ); } - - + + @Test - public void testStringValueWithEmptyDataNormalizedSerialization() throws IOException, LdapException, ClassNotFoundException + public void testStringValueWithEmptyDataNormalizedSerialization() throws IOException, LdapException, + ClassNotFoundException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream( baos ); sv2n.apply( ats ); sv2n.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream( new ByteArrayInputStream( data ) ); - StringValue svDeser = new StringValue( (AttributeType)null ); + StringValue svDeser = new StringValue( ( AttributeType ) null ); svDeser.readExternal( in ); assertEquals( sv2n, svDeser ); } - - + + @Test - public void testStringValueNoDataNormalizedSerialization() throws IOException, LdapException, ClassNotFoundException + public void testStringValueNoDataNormalizedSerialization() throws IOException, LdapException, + ClassNotFoundException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream( baos ); sv3n.apply( ats ); sv3n.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); in = new ObjectInputStream( new ByteArrayInputStream( data ) ); - StringValue svDeser = new StringValue( (AttributeType)null ); + StringValue svDeser = new StringValue( ( AttributeType ) null ); svDeser.readExternal( in ); assertEquals( sv3n, svDeser ); Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/BranchNormalizedVisitorTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/BranchNormalizedVisitorTest.java?rev=1235374&r1=1235373&r2=1235374&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/BranchNormalizedVisitorTest.java (original) +++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/BranchNormalizedVisitorTest.java Tue Jan 24 17:44:03 2012 @@ -83,7 +83,7 @@ public class BranchNormalizedVisitorTest filter += "(|(uid=akarasulu)(ou=Human Resources))) "; - ExprNode ori = FilterParser.parse(filter); + ExprNode ori = FilterParser.parse( filter ); ExprNode altered = FilterParser.parse( filter ); @@ -128,19 +128,19 @@ public class BranchNormalizedVisitorTest assertEquals( normalizedFilter1, normalizedFilter2 ); } - public void testBranchNormalizedVisitor4() throws Exception - { - ExprNode ori = FilterParser.parse( "(&(!(sn=Bob))(ou=Human Resources)(uid=akarasulu))" ); - ExprNode altered = FilterParser.parse( "(&(ou=Human Resources)(uid=akarasulu)(!(sn=Bob)))" ); + public void testBranchNormalizedVisitor4() throws Exception + { + ExprNode ori = FilterParser.parse( "(&(!(sn=Bob))(ou=Human Resources)(uid=akarasulu))" ); - BranchNormalizedVisitor visitor = new BranchNormalizedVisitor(); + ExprNode altered = FilterParser.parse( "(&(ou=Human Resources)(uid=akarasulu)(!(sn=Bob)))" ); - visitor.visit( altered ); + BranchNormalizedVisitor visitor = new BranchNormalizedVisitor(); + + visitor.visit( altered ); + + assertTrue( ori.toString().equals( altered.toString() ) ); + + } - assertTrue( ori.toString().equals( altered.toString() ) ); - - } - - } Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/FilterCloneTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/FilterCloneTest.java?rev=1235374&r1=1235373&r2=1235374&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/FilterCloneTest.java (original) +++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/FilterCloneTest.java Tue Jan 24 17:44:03 2012 @@ -45,15 +45,15 @@ public class FilterCloneTest @Test public void testItemFilter() throws ParseException { - SimpleNode node= ( SimpleNode ) FilterParser.parse( null, "(ou~=people)" ); + SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(ou~=people)" ); // just check that it doesn't throw for now - node = ( SimpleNode )node.clone(); + node = ( SimpleNode ) node.clone(); assertEquals( "ou", node.getAttribute() ); assertEquals( "people", node.getValue().getString() ); assertTrue( node instanceof ApproximateNode ); } - + @Test public void testAndFilter() throws ParseException { @@ -64,7 +64,7 @@ public class FilterCloneTest assertTrue( node instanceof AndNode ); } - + @Test public void testAndFilterOneChildOnly() throws ParseException { @@ -72,7 +72,7 @@ public class FilterCloneTest // just check that it doesn't throw for now node = ( BranchNode ) node.clone(); assertEquals( 1, node.getChildren().size() ); - assertTrue( node instanceof AndNode); + assertTrue( node instanceof AndNode ); } @@ -92,7 +92,7 @@ public class FilterCloneTest { BranchNode node = ( BranchNode ) FilterParser.parse( null, "(|(age>=30))" ); // just check that it doesn't throw for now - node = ( BranchNode ) node.clone(); + node = ( BranchNode ) node.clone(); assertEquals( 1, node.getChildren().size() ); assertTrue( node instanceof OrNode ); } @@ -114,7 +114,7 @@ public class FilterCloneTest { SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(ou;lang-de>=\\23\\42asdl fkajsd)" ); // just check that it doesn't throw for now - node = (SimpleNode)node.clone(); + node = ( SimpleNode ) node.clone(); assertEquals( "ou;lang-de", node.getAttribute() ); assertEquals( "#Basdl fkajsd", node.getValue().getString() ); } @@ -123,9 +123,10 @@ public class FilterCloneTest @Test public void testOptionsAndEscapesFilter() throws ParseException { - SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(ou;lang-de;version-124>=\\23\\42asdl fkajsd)" ); + SimpleNode node = ( SimpleNode ) FilterParser.parse( null, + "(ou;lang-de;version-124>=\\23\\42asdl fkajsd)" ); // just check that it doesn't throw for now - node = ( SimpleNode )node.clone(); + node = ( SimpleNode ) node.clone(); assertEquals( "ou;lang-de;version-124", node.getAttribute() ); assertEquals( "#Basdl fkajsd", node.getValue().getString() ); } @@ -134,7 +135,8 @@ public class FilterCloneTest @Test public void testNumericoidOptionsAndEscapesFilter() throws ParseException { - SimpleNode node= ( SimpleNode ) FilterParser.parse( null, "(1.3.4.2;lang-de;version-124>=\\23\\42asdl fkajsd)" ); + SimpleNode node = ( SimpleNode ) FilterParser.parse( null, + "(1.3.4.2;lang-de;version-124>=\\23\\42asdl fkajsd)" ); // just check that it doesn't throw for now node = ( SimpleNode ) node.clone(); assertEquals( "1.3.4.2;lang-de;version-124", node.getAttribute() ); @@ -147,7 +149,7 @@ public class FilterCloneTest { PresenceNode node = ( PresenceNode ) FilterParser.parse( null, "(ou=*)" ); // just check that it doesn't throw for now - node = (PresenceNode) node.clone(); + node = ( PresenceNode ) node.clone(); assertEquals( "ou", node.getAttribute() ); assertTrue( node instanceof PresenceNode ); } @@ -156,9 +158,9 @@ public class FilterCloneTest @Test public void testNumericoidPresentFilter() throws ParseException { - PresenceNode node = (PresenceNode) FilterParser.parse( null, "(1.2.3.4=*)" ); + PresenceNode node = ( PresenceNode ) FilterParser.parse( null, "(1.2.3.4=*)" ); // just check that it doesn't throw for now - node = ( PresenceNode )node.clone(); + node = ( PresenceNode ) node.clone(); assertEquals( "1.2.3.4", node.getAttribute() ); assertTrue( node instanceof PresenceNode ); } @@ -167,7 +169,7 @@ public class FilterCloneTest @Test public void testEqualsFilter() throws ParseException { - SimpleNode node= ( SimpleNode ) FilterParser.parse( null, "(ou=people)" ); + SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(ou=people)" ); // just check that it doesn't throw for now node = ( SimpleNode ) node.clone(); assertEquals( "ou", node.getAttribute() ); @@ -179,7 +181,7 @@ public class FilterCloneTest @Test public void testEqualsWithForwardSlashFilter() throws ParseException { - SimpleNode node= ( SimpleNode ) FilterParser.parse( null, "(ou=people/in/my/company)" ); + SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(ou=people/in/my/company)" ); // just check that it doesn't throw for now node = ( SimpleNode ) node.clone(); assertEquals( "ou", node.getAttribute() ); @@ -191,7 +193,8 @@ public class FilterCloneTest @Test public void testExtensibleFilterForm1() throws ParseException { - ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( null, "(ou:dn:stupidMatch:=dummyAssertion\\23\\2A)" ); + ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( null, + "(ou:dn:stupidMatch:=dummyAssertion\\23\\2A)" ); // just check that it doesn't throw for now node = ( ExtensibleNode ) node.clone(); assertEquals( "ou", node.getAttribute() ); @@ -205,9 +208,10 @@ public class FilterCloneTest @Test public void testExtensibleFilterForm1WithNumericOid() throws ParseException { - ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( null, "(1.2.3.4:dn:1.3434.23.2:=dummyAssertion\\23\\2A)" ); + ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( null, + "(1.2.3.4:dn:1.3434.23.2:=dummyAssertion\\23\\2A)" ); // just check that it doesn't throw for now - node = ( ExtensibleNode )node.clone(); + node = ( ExtensibleNode ) node.clone(); assertEquals( "1.2.3.4", node.getAttribute() ); assertEquals( "dummyAssertion#*", node.getValue().getString() ); assertEquals( "1.3434.23.2", node.getMatchingRuleId() ); @@ -230,13 +234,12 @@ public class FilterCloneTest } - @Test public void testExtensibleFilterForm1NoAttrNoMatchingRule() throws ParseException { ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( null, "(ou:=dummyAssertion\\23\\2A)" ); // just check that it doesn't throw for now - node = (ExtensibleNode) node.clone(); + node = ( ExtensibleNode ) node.clone(); assertEquals( "ou", node.getAttribute() ); assertEquals( "dummyAssertion#*", node.getValue().getString() ); assertEquals( null, node.getMatchingRuleId() ); @@ -276,7 +279,7 @@ public class FilterCloneTest { ExtensibleNode node1 = ( ExtensibleNode ) FilterParser.parse( null, "(:stupidMatch:=dummyAssertion\\23\\2A)" ); // just check that it doesn't throw for now - ExtensibleNode node = ( ExtensibleNode )node1.clone(); + ExtensibleNode node = ( ExtensibleNode ) node1.clone(); assertEquals( null, node.getAttribute() ); assertEquals( "dummyAssertion#*", node.getValue().getString() ); assertEquals( "stupidMatch", node.getMatchingRuleId() ); @@ -290,7 +293,7 @@ public class FilterCloneTest { ExtensibleNode node = ( ExtensibleNode ) FilterParser.parse( null, "(:1.3434.23.2:=dummyAssertion\\23\\2A)" ); // just check that it doesn't throw for now - node = ( ExtensibleNode) node.clone(); + node = ( ExtensibleNode ) node.clone(); assertEquals( null, node.getAttribute() ); assertEquals( "dummyAssertion#*", node.getValue().getString() ); assertEquals( "1.3434.23.2", node.getMatchingRuleId() ); @@ -334,7 +337,7 @@ public class FilterCloneTest { SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=*bar)" ); // just check that it doesn't throw for now - node = ( SubstringNode )node.clone(); + node = ( SubstringNode ) node.clone(); assertEquals( "ou", node.getAttribute() ); assertTrue( node instanceof SubstringNode ); assertEquals( 0, node.getAny().size() ); @@ -349,7 +352,7 @@ public class FilterCloneTest { SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=foo*guy*bar)" ); // just check that it doesn't throw for now - node = ( SubstringNode )node.clone(); + node = ( SubstringNode ) node.clone(); assertEquals( "ou", node.getAttribute() ); assertTrue( node instanceof SubstringNode ); assertEquals( 1, node.getAny().size() ); @@ -365,7 +368,7 @@ public class FilterCloneTest { SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=a*b*c*d*e*f)" ); // just check that it doesn't throw for now - node = ( SubstringNode )node.clone(); + node = ( SubstringNode ) node.clone(); assertEquals( "ou", node.getAttribute() ); assertTrue( node instanceof SubstringNode ); assertEquals( 4, node.getAny().size() ); @@ -384,7 +387,7 @@ public class FilterCloneTest { SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=*b*c*d*e*f)" ); // just check that it doesn't throw for now - node = ( SubstringNode )node.clone(); + node = ( SubstringNode ) node.clone(); assertEquals( "ou", node.getAttribute() ); assertTrue( node instanceof SubstringNode ); assertEquals( 4, node.getAny().size() ); @@ -403,7 +406,7 @@ public class FilterCloneTest { SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=a*b*c*d*e*)" ); // just check that it doesn't throw for now - node = ( SubstringNode )node.clone(); + node = ( SubstringNode ) node.clone(); assertEquals( "ou", node.getAttribute() ); assertTrue( node instanceof SubstringNode ); assertEquals( 4, node.getAny().size() ); @@ -423,7 +426,7 @@ public class FilterCloneTest SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=*b*c*d*e*)" ); // just check that it doesn't throw for now node = ( SubstringNode ) node.clone(); - + assertEquals( "ou", node.getAttribute() ); assertTrue( node instanceof SubstringNode ); assertEquals( 4, node.getAny().size() ); @@ -442,8 +445,8 @@ public class FilterCloneTest { SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=foo* *bar)" ); // just check that it doesn't throw for now - node = ( SubstringNode )node.clone(); - + node = ( SubstringNode ) node.clone(); + assertEquals( "ou", node.getAttribute() ); assertTrue( node instanceof SubstringNode ); assertEquals( 1, node.getAny().size() ); @@ -457,10 +460,10 @@ public class FilterCloneTest @Test public void testSubstringAnyDoubleSpaceStar() throws ParseException { - SubstringNode node = (SubstringNode) FilterParser.parse( null, "(ou=foo* a *bar)" ); + SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=foo* a *bar)" ); // just check that it doesn't throw for now node = ( SubstringNode ) node.clone(); - + assertEquals( "ou", node.getAttribute() ); assertTrue( node instanceof SubstringNode ); assertEquals( 1, node.getAny().size() ); @@ -481,8 +484,8 @@ public class FilterCloneTest { SubstringNode node = ( SubstringNode ) FilterParser.parse( null, "(ou=*foo*)" ); // just check that it doesn't throw for now - node = ( SubstringNode )node.clone(); - + node = ( SubstringNode ) node.clone(); + assertEquals( "ou", node.getAttribute() ); assertTrue( node instanceof SubstringNode ); assertEquals( 1, node.getAny().size() ); @@ -490,15 +493,15 @@ public class FilterCloneTest assertNull( node.getInitial() ); assertNull( node.getFinal() ); } - - + + @Test public void testEqualsFilterNullValue() throws ParseException { - SimpleNode node= ( SimpleNode ) FilterParser.parse( null, "(ou=)" ); + SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(ou=)" ); // just check that it doesn't throw for now - node = ( SimpleNode )node.clone(); - + node = ( SimpleNode ) node.clone(); + assertEquals( "ou", node.getAttribute() ); assertEquals( "", node.getValue().getString() ); assertTrue( node instanceof EqualityNode ); @@ -511,7 +514,7 @@ public class FilterCloneTest @Test public void testEqualsFilterWithPoundInValue() throws ParseException { - SimpleNode node= ( SimpleNode ) FilterParser.parse( null, "(uid=#f1)" ); + SimpleNode node = ( SimpleNode ) FilterParser.parse( null, "(uid=#f1)" ); // just check that it doesn't throw for now node = ( SimpleNode ) node.clone(); assertEquals( "uid", node.getAttribute() ); @@ -519,14 +522,17 @@ public class FilterCloneTest assertTrue( node instanceof EqualityNode ); } - + @Test public void testLargeBusyFilter() throws ParseException { - ExprNode node1 = FilterParser.parse( null, "(&(|(2.5.4.3=h*)(2.5.4.4=h*)(2.16.840.1.113730.3.1.241=h*)(2.5.4.42=h*))(!(objectClass=computer))(|(objectClass=person)(objectClass=group)(objectClass=organizationalUnit)(objectClass=domain))(!(&(userAccountControl:1.2.840.113556.1.4.803:=2))))" ); + ExprNode node1 = FilterParser + .parse( + null, + "(&(|(2.5.4.3=h*)(2.5.4.4=h*)(2.16.840.1.113730.3.1.241=h*)(2.5.4.42=h*))(!(objectClass=computer))(|(objectClass=person)(objectClass=group)(objectClass=organizationalUnit)(objectClass=domain))(!(&(userAccountControl:1.2.840.113556.1.4.803:=2))))" ); // just check that it doesn't throw for now ExprNode node = node1.clone(); - assertTrue(node instanceof AndNode); + assertTrue( node instanceof AndNode ); //TODO test full structure } } Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/FilterParserTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/FilterParserTest.java?rev=1235374&r1=1235373&r2=1235374&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/FilterParserTest.java (original) +++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/FilterParserTest.java Tue Jan 24 17:44:03 2012 @@ -58,12 +58,13 @@ public class FilterParserTest } } + /** * Tests to avoid deadlocks for invalid filters. * */ @Test - public void testInvalidFilters() + public void testInvalidFilters() { assertTrue( checkWrongFilter( "" ) ); assertTrue( checkWrongFilter( " " ) ); @@ -94,7 +95,7 @@ public class FilterParserTest assertEquals( str, str2 ); } - + @Test public void testAndFilter() throws ParseException { @@ -106,7 +107,7 @@ public class FilterParserTest assertEquals( str, str2 ); } - + @Test public void testAndFilterOneChildOnly() throws ParseException { @@ -135,7 +136,7 @@ public class FilterParserTest public void testOrFilterOneChildOnly() throws ParseException { String str = "(|(age>=30))"; - BranchNode node = ( BranchNode ) FilterParser.parse(str); + BranchNode node = ( BranchNode ) FilterParser.parse( str ); assertEquals( 1, node.getChildren().size() ); assertTrue( node instanceof OrNode ); String str2 = node.toString(); @@ -158,11 +159,11 @@ public class FilterParserTest @Test public void testOptionAndEscapesFilter() throws ParseException { - String str = "(ou;lang-de>=\\23\\42asdl fkajsd)"; // \23 = '#' + String str = "(ou;lang-de>=\\23\\42asdl fkajsd)"; // \23 = '#' SimpleNode node = ( SimpleNode ) FilterParser.parse( str ); assertEquals( "ou;lang-de", node.getAttribute() ); assertEquals( "#Basdl fkajsd", node.getValue().getString() ); - String str2 = node.toString(); + String str2 = node.toString(); assertEquals( "(ou;lang-de>=#Basdl fkajsd)", str2 ); } @@ -174,7 +175,7 @@ public class FilterParserTest SimpleNode node = ( SimpleNode ) FilterParser.parse( str ); assertEquals( "ou;lang-de;version-124", node.getAttribute() ); assertEquals( "#Basdl fkajsd", node.getValue().getString() ); - String str2 = node.toString(); + String str2 = node.toString(); assertEquals( "(ou;lang-de;version-124>=#Basdl fkajsd)", str2 ); } @@ -186,7 +187,7 @@ public class FilterParserTest SimpleNode node = ( SimpleNode ) FilterParser.parse( str ); assertEquals( "1.3.4.2;lang-de;version-124", node.getAttribute() ); assertEquals( "#Bafdl fkajsd", node.getValue().getString() ); - String str2 = node.toString(); + String str2 = node.toString(); assertEquals( "(1.3.4.2;lang-de;version-124>=#Bafdl fkajsd)", str2 ); } @@ -198,7 +199,7 @@ public class FilterParserTest PresenceNode node = ( PresenceNode ) FilterParser.parse( str ); assertEquals( "ou", node.getAttribute() ); assertTrue( node instanceof PresenceNode ); - String str2 = node.toString(); + String str2 = node.toString(); assertEquals( str, str2 ); } @@ -210,7 +211,7 @@ public class FilterParserTest PresenceNode node = ( PresenceNode ) FilterParser.parse( str ); assertEquals( "1.2.3.4", node.getAttribute() ); assertTrue( node instanceof PresenceNode ); - String str2 = node.toString(); + String str2 = node.toString(); assertEquals( str, str2 ); } @@ -223,7 +224,7 @@ public class FilterParserTest assertEquals( "ou", node.getAttribute() ); assertEquals( "people", node.getValue().getString() ); assertTrue( node instanceof EqualityNode ); - String str2 = node.toString(); + String str2 = node.toString(); assertEquals( str, str2 ); } @@ -443,7 +444,7 @@ public class FilterParserTest FilterParser.parse( "(ou;lang-de>=\\23\\42asdl fkajsd)" ); FilterParser.parse( "(ou;lang-de;version-124>=\\23\\42asdl fkajsd)" ); FilterParser.parse( "(1.3.4.2;lang-de;version-124>=\\23\\42asdl fkajsd)" ); - + try { FilterParser.parse( "(ou:stupidMatch;lang-de:=dummyAssertion\\23\\ac)" ); @@ -489,7 +490,7 @@ public class FilterParserTest FilterParser.parse( null ); fail( "Should not reach this point " ); } - catch( ParseException pe ) + catch ( ParseException pe ) { assertTrue( true ); } @@ -499,7 +500,7 @@ public class FilterParserTest FilterParser.parse( "" ); fail( "Should not reach this point " ); } - catch( ParseException pe ) + catch ( ParseException pe ) { assertTrue( true ); } @@ -665,7 +666,7 @@ public class FilterParserTest String str = "(ou=foo* *bar)"; SubstringNode node = ( SubstringNode ) FilterParser.parse( str ); assertEquals( "ou", node.getAttribute() ); - assertTrue( node instanceof SubstringNode); + assertTrue( node instanceof SubstringNode ); assertEquals( 1, node.getAny().size() ); assertFalse( node.getAny().contains( "" ) ); @@ -894,7 +895,8 @@ public class FilterParserTest { try { - FilterParser.parse( "(memberOf=1.2.840.113556.1.4.1301=$#@&*()==,2.5.4.11=local,2.5.4.11=users,2.5.4.11=readimanager)" ); + FilterParser + .parse( "(memberOf=1.2.840.113556.1.4.1301=$#@&*()==,2.5.4.11=local,2.5.4.11=users,2.5.4.11=readimanager)" ); fail(); } catch ( ParseException pe ) @@ -912,39 +914,40 @@ public class FilterParserTest { try { - BranchNode node = ( BranchNode ) FilterParser.parse( "(&(objectClass=nisNetgroup)(|(nisNetGroupTriple=a*a)(nisNetGroupTriple=\\28*,acc1,*\\29)))"); + BranchNode node = ( BranchNode ) FilterParser + .parse( "(&(objectClass=nisNetgroup)(|(nisNetGroupTriple=a*a)(nisNetGroupTriple=\\28*,acc1,*\\29)))" ); assertEquals( 2, node.getChildren().size() ); - + assertTrue( node instanceof AndNode ); - + // Check the (a=b) part ExprNode aEqb = node.getFirstChild(); assertTrue( aEqb instanceof EqualityNode ); - assertEquals( "objectClass", ((EqualityNode)aEqb).getAttribute() ); - assertEquals( "nisNetgroup", ((EqualityNode)aEqb).getValue().getString() ); - + assertEquals( "objectClass", ( ( EqualityNode ) aEqb ).getAttribute() ); + assertEquals( "nisNetgroup", ( ( EqualityNode ) aEqb ).getValue().getString() ); + // Check the or node ExprNode orNode = node.getChildren().get( 1 ); assertTrue( orNode instanceof OrNode ); - - assertEquals( 2, ((OrNode)orNode).getChildren().size() ); - - ExprNode leftNode = ((OrNode)orNode).getChildren().get( 0 ); - + + assertEquals( 2, ( ( OrNode ) orNode ).getChildren().size() ); + + ExprNode leftNode = ( ( OrNode ) orNode ).getChildren().get( 0 ); + assertTrue( leftNode instanceof SubstringNode ); - assertEquals( "nisNetGroupTriple", ((SubstringNode)leftNode).getAttribute() ); - assertEquals( "a", ((SubstringNode)leftNode).getInitial() ); - assertEquals( 0, ((SubstringNode)leftNode).getAny().size() ); - assertEquals( "a", ((SubstringNode)leftNode).getFinal() ); - - ExprNode rightNode = ((OrNode)orNode).getChildren().get( 1 ); - + assertEquals( "nisNetGroupTriple", ( ( SubstringNode ) leftNode ).getAttribute() ); + assertEquals( "a", ( ( SubstringNode ) leftNode ).getInitial() ); + assertEquals( 0, ( ( SubstringNode ) leftNode ).getAny().size() ); + assertEquals( "a", ( ( SubstringNode ) leftNode ).getFinal() ); + + ExprNode rightNode = ( ( OrNode ) orNode ).getChildren().get( 1 ); + assertTrue( rightNode instanceof SubstringNode ); - assertEquals( "nisNetGroupTriple", ((SubstringNode)rightNode).getAttribute() ); - assertEquals( "(", ((SubstringNode)rightNode).getInitial() ); - assertEquals( 1, ((SubstringNode)rightNode).getAny().size() ); - assertEquals( ",acc1,", ((SubstringNode)rightNode).getAny().get( 0 ) ); - assertEquals( ")", ((SubstringNode)rightNode).getFinal() ); + assertEquals( "nisNetGroupTriple", ( ( SubstringNode ) rightNode ).getAttribute() ); + assertEquals( "(", ( ( SubstringNode ) rightNode ).getInitial() ); + assertEquals( 1, ( ( SubstringNode ) rightNode ).getAny().size() ); + assertEquals( ",acc1,", ( ( SubstringNode ) rightNode ).getAny().get( 0 ) ); + assertEquals( ")", ( ( SubstringNode ) rightNode ).getFinal() ); } catch ( ParseException pe ) { @@ -983,7 +986,7 @@ public class FilterParserTest String str = "(cn='~%\\28'$'\\5Cac)"; // note \28='(' and \5c='\' ExprNode node = FilterParser.parse( str ); assertTrue( node instanceof EqualityNode ); - assertEquals( "'~%('$'\\ac", (( EqualityNode )node).getValue().getString() ); + assertEquals( "'~%('$'\\ac", ( ( EqualityNode ) node ).getValue().getString() ); String str2 = node.toString(); assertEquals( str.toUpperCase(), str2.toUpperCase() ); } @@ -1039,7 +1042,6 @@ public class FilterParserTest } */ - @Test public void testBinaryValueEscaped() throws ParseException { @@ -1087,7 +1089,7 @@ public class FilterParserTest // Second child : (!(jagplayUserGroup=Banned)) ExprNode child2 = children1.get( 1 ); - assertTrue( child2 instanceof NotNode); + assertTrue( child2 instanceof NotNode ); NotNode notNode1 = ( NotNode ) child2; ExprNode notNodeChild1 = notNode1.getFirstChild(); Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/FilterToStringTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/FilterToStringTest.java?rev=1235374&r1=1235373&r2=1235374&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/FilterToStringTest.java (original) +++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/FilterToStringTest.java Tue Jan 24 17:44:03 2012 @@ -57,22 +57,22 @@ public class FilterToStringTest assertEquals( str, node.toString() ); str = "(ou<=test)"; - node = FilterParser.parse(str); + node = FilterParser.parse( str ); assertEquals( str, node.toString() ); - str="(ou=)"; + str = "(ou=)"; node = FilterParser.parse( str ); assertEquals( str, node.toString() ); - str="(ou~=)"; + str = "(ou~=)"; node = FilterParser.parse( str ); assertEquals( str, node.toString() ); - str="(ou>=)"; + str = "(ou>=)"; node = FilterParser.parse( str ); assertEquals( str, node.toString() ); - str="(ou<=)"; + str = "(ou<=)"; node = FilterParser.parse( str ); assertEquals( str, node.toString() ); } Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/SubstringNodeTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/SubstringNodeTest.java?rev=1235374&r1=1235373&r2=1235374&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/SubstringNodeTest.java (original) +++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/filter/SubstringNodeTest.java Tue Jan 24 17:44:03 2012 @@ -36,15 +36,15 @@ import static org.junit.Assert.*; * * @author Apache Directory Project */ -@RunWith( ConcurrentJunitRunner.class ) +@RunWith(ConcurrentJunitRunner.class) @Concurrency() public class SubstringNodeTest { @Test public void testGetRegexpEmpty() throws Exception { - Pattern pattern = SubstringNode.getRegex("", new String[] - {""}, ""); + Pattern pattern = SubstringNode.getRegex( "", new String[] + { "" }, "" ); boolean b1 = pattern.matcher( "" ).matches(); @@ -55,8 +55,8 @@ public class SubstringNodeTest @Test public void testGetRegexpInitial() throws Exception { - Pattern pattern = SubstringNode.getRegex("Test", new String[] - {""}, ""); + Pattern pattern = SubstringNode.getRegex( "Test", new String[] + { "" }, "" ); boolean b1 = pattern.matcher( "Test just a test" ).matches(); @@ -71,8 +71,8 @@ public class SubstringNodeTest @Test public void testGetRegexpFinal() throws Exception { - Pattern pattern = SubstringNode.getRegex("", new String[] - {""}, "Test"); + Pattern pattern = SubstringNode.getRegex( "", new String[] + { "" }, "Test" ); boolean b1 = pattern.matcher( "test just a Test" ).matches(); @@ -87,8 +87,8 @@ public class SubstringNodeTest @Test public void testGetRegexpAny() throws Exception { - Pattern pattern = SubstringNode.getRegex("", new String[] - {"just", "a"}, ""); + Pattern pattern = SubstringNode.getRegex( "", new String[] + { "just", "a" }, "" ); boolean b1 = pattern.matcher( "test just a Test" ).matches(); @@ -103,8 +103,8 @@ public class SubstringNodeTest @Test public void testGetRegexpFull() throws Exception { - Pattern pattern = SubstringNode.getRegex("Test", new String[] - {"just", "a"}, "test"); + Pattern pattern = SubstringNode.getRegex( "Test", new String[] + { "just", "a" }, "test" ); boolean b1 = pattern.matcher( "Test (this is) just (truly !) a (little) test" ).matches(); @@ -123,11 +123,11 @@ public class SubstringNodeTest public void testGetRegexpWithLdapFilterSpecialChars() throws Exception { Pattern[] patterns = new Pattern[] - { SubstringNode.getRegex(null, new String[] - {"("}, null), SubstringNode.getRegex(null, new String[] - {")"}, null), SubstringNode.getRegex(null, new String[] - {"*"}, null), SubstringNode.getRegex(null, new String[] - {"\\"}, null), }; + { SubstringNode.getRegex( null, new String[] + { "(" }, null ), SubstringNode.getRegex( null, new String[] + { ")" }, null ), SubstringNode.getRegex( null, new String[] + { "*" }, null ), SubstringNode.getRegex( null, new String[] + { "\\" }, null ), }; for ( Pattern pattern : patterns ) { Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifAttributesReaderTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifAttributesReaderTest.java?rev=1235374&r1=1235373&r2=1235374&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifAttributesReaderTest.java (original) +++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifAttributesReaderTest.java Tue Jan 24 17:44:03 2012 @@ -505,8 +505,8 @@ public class LdifAttributesReaderTest { "ou;lang-ja", "\u55b6\u696d\u90e8" }, { "ou;lang-ja;phonetic", "\u3048\u3044\u304e\u3087\u3046\u3076" }, // 3048 = ���, 3044 = ���, 304e = ��� // 3087 = ���, 3046 = ���, 3076 = ��� - { "ou;lang-en", "Sales" }, - { "description", "Japanese office" } }; + { "ou;lang-en", "Sales" }, + { "description", "Japanese office" } }; for ( int j = 0; j < values.length; j++ ) { @@ -551,7 +551,7 @@ public class LdifAttributesReaderTest if ( "jpegphoto".equalsIgnoreCase( values[i][0] ) ) { javax.naming.directory.Attribute attr = attributes.get( values[i][0] ); - assertEquals( Strings.dumpBytes(data), Strings.dumpBytes((byte[]) attr.get()) ); + assertEquals( Strings.dumpBytes( data ), Strings.dumpBytes( ( byte[] ) attr.get() ) ); } else { Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifControlSerializationTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifControlSerializationTest.java?rev=1235374&r1=1235373&r2=1235374&view=diff ============================================================================== --- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifControlSerializationTest.java (original) +++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifControlSerializationTest.java Tue Jan 24 17:44:03 2012 @@ -19,6 +19,7 @@ */ package org.apache.directory.shared.ldap.model.ldif; + import static org.junit.Assert.assertEquals; import java.io.ByteArrayInputStream; @@ -37,6 +38,7 @@ import org.junit.runner.RunWith; import com.mycila.junit.concurrent.Concurrency; import com.mycila.junit.concurrent.ConcurrentJunitRunner; + /** * Test the LdifControlSerializer class * @@ -52,25 +54,27 @@ public class LdifControlSerializationTes private static Control controlNoCriticalWithData; private static Control controlNoCriticalNoData; private static Control controlNoCriticalEmptyData; - private static byte[] data = new byte[] {0x01, 0x02, 0x03, 0x04}; - + private static byte[] data = new byte[] + { 0x01, 0x02, 0x03, 0x04 }; + + @BeforeClass public static void setup() { controlCriticalWithData = new OpaqueControl( "1.2.3.4.1" ); controlCriticalWithData.setCritical( true ); - ((OpaqueControl)controlCriticalWithData).setEncodedValue( data ); + ( ( OpaqueControl ) controlCriticalWithData ).setEncodedValue( data ); controlCriticalNoData = new OpaqueControl( "1.2.3.4.2" ); controlCriticalNoData.setCritical( true ); controlCriticalEmptyData = new OpaqueControl( "1.2.3.4.3" ); controlCriticalEmptyData.setCritical( true ); - ((OpaqueControl)controlCriticalEmptyData).setEncodedValue( StringConstants.EMPTY_BYTES ); + ( ( OpaqueControl ) controlCriticalEmptyData ).setEncodedValue( StringConstants.EMPTY_BYTES ); controlNoCriticalWithData = new OpaqueControl( "1.2.3.4.4" ); controlNoCriticalWithData.setCritical( false ); - ((OpaqueControl)controlNoCriticalWithData).setEncodedValue( data ); + ( ( OpaqueControl ) controlNoCriticalWithData ).setEncodedValue( data ); controlNoCriticalNoData = new OpaqueControl( "1.2.3.4.5" ); controlNoCriticalNoData.setCritical( false ); @@ -78,20 +82,20 @@ public class LdifControlSerializationTes controlNoCriticalEmptyData = new OpaqueControl( "1.2.3.4.6" ); controlNoCriticalEmptyData.setCritical( false ); } - - + + @Test public void testControlCriticalWithDataSerialization() throws IOException, ClassNotFoundException { LdifControl ldifControl1 = new LdifControl( controlCriticalWithData.getOid() ); ldifControl1.setCritical( controlCriticalWithData.isCritical() ); - ldifControl1.setValue( ((OpaqueControl)controlCriticalWithData).getEncodedValue() ); - + ldifControl1.setValue( ( ( OpaqueControl ) controlCriticalWithData ).getEncodedValue() ); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream( baos ); ldifControl1.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); @@ -102,19 +106,19 @@ public class LdifControlSerializationTes assertEquals( ldifControl1, ldifControl2 ); } - - + + @Test public void testControlCriticalNoDataSerialization() throws IOException, ClassNotFoundException { LdifControl ldifControl1 = new LdifControl( controlCriticalNoData.getOid() ); ldifControl1.setCritical( controlCriticalNoData.isCritical() ); - + ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream( baos ); ldifControl1.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); @@ -125,20 +129,20 @@ public class LdifControlSerializationTes assertEquals( ldifControl1, ldifControl2 ); } - - + + @Test public void testControlCriticalEmptyDataSerialization() throws IOException, ClassNotFoundException { LdifControl ldifControl1 = new LdifControl( controlCriticalEmptyData.getOid() ); ldifControl1.setCritical( controlCriticalEmptyData.isCritical() ); - ldifControl1.setValue( ((OpaqueControl)controlCriticalEmptyData).getEncodedValue() ); - + ldifControl1.setValue( ( ( OpaqueControl ) controlCriticalEmptyData ).getEncodedValue() ); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream( baos ); ldifControl1.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); @@ -149,20 +153,20 @@ public class LdifControlSerializationTes assertEquals( ldifControl1, ldifControl2 ); } - - + + @Test public void testControlNoCriticalWithDataSerialization() throws IOException, ClassNotFoundException { LdifControl ldifControl1 = new LdifControl( controlNoCriticalWithData.getOid() ); ldifControl1.setCritical( controlNoCriticalWithData.isCritical() ); - ldifControl1.setValue( ((OpaqueControl)controlNoCriticalWithData).getEncodedValue() ); - + ldifControl1.setValue( ( ( OpaqueControl ) controlNoCriticalWithData ).getEncodedValue() ); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream( baos ); ldifControl1.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); @@ -173,19 +177,19 @@ public class LdifControlSerializationTes assertEquals( ldifControl1, ldifControl2 ); } - - + + @Test public void testControlNoCriticalNoDataSerialization() throws IOException, ClassNotFoundException { LdifControl ldifControl1 = new LdifControl( controlNoCriticalNoData.getOid() ); ldifControl1.setCritical( controlNoCriticalNoData.isCritical() ); - + ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream( baos ); ldifControl1.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray(); @@ -196,20 +200,20 @@ public class LdifControlSerializationTes assertEquals( ldifControl1, ldifControl2 ); } - - + + @Test public void testControlNoCriticalEmptyDataSerialization() throws IOException, ClassNotFoundException { LdifControl ldifControl1 = new LdifControl( controlNoCriticalEmptyData.getOid() ); ldifControl1.setCritical( controlNoCriticalEmptyData.isCritical() ); - ldifControl1.setValue( ((OpaqueControl)controlNoCriticalEmptyData).getEncodedValue() ); - + ldifControl1.setValue( ( ( OpaqueControl ) controlNoCriticalEmptyData ).getEncodedValue() ); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream( baos ); ldifControl1.writeExternal( out ); - + ObjectInputStream in = null; byte[] data = baos.toByteArray();