directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r896579 [14/14] - in /directory/shared/trunk: ./ ldap/ ldap/src/main/antlr/ ldap/src/main/java/org/apache/directory/shared/ldap/ ldap/src/main/java/org/apache/directory/shared/ldap/codec/ ldap/src/main/java/org/apache/directory/shared/ldap/...
Date Wed, 06 Jan 2010 17:52:31 GMT
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SchemaParserTestUtils.java
Wed Jan  6 17:52:15 2010
@@ -24,9 +24,13 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import junit.framework.Assert;
+import static junit.framework.Assert.fail;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.assertFalse;
 
-import org.apache.directory.shared.ldap.schema.parsers.AbstractSchemaDescription;
+import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.shared.ldap.schema.parsers.AbstractSchemaParser;
 
 
@@ -48,14 +52,13 @@
     public static void testNumericOid( AbstractSchemaParser parser, String required ) throws
ParseException
     {
         String value = null;
-        AbstractSchemaDescription asd = null;
+        SchemaObject asd = null;
 
         // null test
-        value = null;
         try
         {
             parser.parse( value );
-            Assert.fail( "Exception expected, null" );
+            fail( "Exception expected, null" );
         }
         catch ( ParseException pe )
         {
@@ -67,7 +70,7 @@
         try
         {
             parser.parse( value );
-            Assert.fail( "Exception expected, no NUMERICOID" );
+            fail( "Exception expected, no NUMERICOID" );
         }
         catch ( ParseException pe )
         {
@@ -77,44 +80,44 @@
         // simple
         value = "( 0.1.2.3.4.5.6.7.8.9 " + required + " )";
         asd = parser.parse( value );
-        Assert.assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getNumericOid() );
+        assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getOid() );
 
         // simple
         value = "( 123.4567.890 " + required + ")";
         asd = parser.parse( value );
-        Assert.assertEquals( "123.4567.890", asd.getNumericOid() );
+        assertEquals( "123.4567.890", asd.getOid() );
 
         // simple with multiple spaces
         value = "(          0.1.2.3.4.5.6.7.8.9         " + required + " )";
         asd = parser.parse( value );
-        Assert.assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getNumericOid() );
+        assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getOid() );
 
         // simple w/o spaces
         value = "(0.1.2.3.4.5.6.7.8.9 " + required + ")";
         asd = parser.parse( value );
-        Assert.assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getNumericOid() );
+        assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getOid() );
 
         // simple with tabs, newline, comment.
         value = "(\t0.1.2.3.4.5.6.7.8.9\n#comment\n" + required + "\r\n)\r";
         asd = parser.parse( value );
-        Assert.assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getNumericOid() );
+        assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getOid() );
 
         // quoted OID
         value = "( '0.1.2.3.4.5.6.7.8.9' " + required + " )";
         asd = parser.parse( value );
-        Assert.assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getNumericOid() );
+        assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getOid() );
 
         // quoted OID in parentheses
         value = "( ('0.1.2.3.4.5.6.7.8.9') " + required + " )";
         asd = parser.parse( value );
-        Assert.assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getNumericOid() );
+        assertEquals( "0.1.2.3.4.5.6.7.8.9", asd.getOid() );
 
         // too short
         value = "( 1 " + required + " )";
         try
         {
             parser.parse( value );
-            Assert.fail( "Exception expected, invalid NUMERICOID 1" );
+            fail( "Exception expected, invalid NUMERICOID 1" );
         }
         catch ( ParseException pe )
         {
@@ -126,7 +129,7 @@
         try
         {
             parser.parse( value );
-            Assert.fail( "Exception expected, invalid NUMERICOID ." );
+            fail( "Exception expected, invalid NUMERICOID ." );
         }
         catch ( ParseException pe )
         {
@@ -138,7 +141,7 @@
         try
         {
             parser.parse( value );
-            Assert.fail( "Exception expected, invalid NUMERICOID 1.1." );
+            fail( "Exception expected, invalid NUMERICOID 1.1." );
         }
         catch ( ParseException pe )
         {
@@ -150,7 +153,7 @@
         try
         {
             parser.parse( value );
-            Assert.fail( "Exception expected, invalid multiple OIDs not allowed.)" );
+            fail( "Exception expected, invalid multiple OIDs not allowed.)" );
         }
         catch ( ParseException pe )
         {
@@ -164,7 +167,7 @@
             try
             {
                 parser.parse( value );
-                Assert.fail( "Exception expected, invalid NUMERICOID test" );
+                fail( "Exception expected, invalid NUMERICOID test" );
             }
             catch ( ParseException pe )
             {
@@ -176,7 +179,7 @@
             try
             {
                 parser.parse( value );
-                Assert.fail( "Exception expected, invalid NUMERICOID 01.1 (leading zero)"
);
+                fail( "Exception expected, invalid NUMERICOID 01.1 (leading zero)" );
             }
             catch ( ParseException pe )
             {
@@ -188,7 +191,7 @@
             try
             {
                 parser.parse( value );
-                Assert.fail( "Exception expected, invalid NUMERICOID 1.2.a.4 (alpha not allowed)"
);
+                fail( "Exception expected, invalid NUMERICOID 1.2.a.4 (alpha not allowed)"
);
             }
             catch ( ParseException pe )
             {
@@ -207,92 +210,91 @@
     public static void testNames( AbstractSchemaParser parser, String oid, String required
) throws ParseException
     {
         String value = null;
-        AbstractSchemaDescription asd = null;
+        SchemaObject asd = null;
 
         // alpha
         value = "( " + oid + " " + required + " NAME 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
)";
         asd = parser.parse( value );
-        Assert.assertEquals( 1, asd.getNames().size() );
-        Assert.assertEquals( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", asd.getNames().get(
0 ) );
+        assertEquals( 1, asd.getNames().size() );
+        assertEquals( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", asd.getNames().get(
0 ) );
 
         // alpha-num-hypen
         value = "( " + oid + " " + required
             + " NAME 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789' )";
         asd = parser.parse( value );
-        Assert.assertEquals( 1, asd.getNames().size() );
-        Assert
-            .assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789",
asd.getNames().get( 0 ) );
+        assertEquals( 1, asd.getNames().size() );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789",
asd.getNames().get( 0 ) );
 
         // with parentheses
         value = "( " + oid + " " + required + " NAME ( 'a-z-0-9' ) )";
         asd = parser.parse( value );
-        Assert.assertEquals( 1, asd.getNames().size() );
-        Assert.assertEquals( "a-z-0-9", asd.getNames().get( 0 ) );
+        assertEquals( 1, asd.getNames().size() );
+        assertEquals( "a-z-0-9", asd.getNames().get( 0 ) );
 
         // with parentheses, without space
         value = "(" + oid + " " + required + " NAME('a-z-0-9'))";
         asd = parser.parse( value );
-        Assert.assertEquals( 1, asd.getNames().size() );
-        Assert.assertEquals( "a-z-0-9", asd.getNames().get( 0 ) );
+        assertEquals( 1, asd.getNames().size() );
+        assertEquals( "a-z-0-9", asd.getNames().get( 0 ) );
 
         // multi with space
         value = " ( " + oid + " " + required + " NAME ( 'test1' 'test2' ) ) ";
         asd = parser.parse( value );
-        Assert.assertEquals( 2, asd.getNames().size() );
-        Assert.assertEquals( "test1", asd.getNames().get( 0 ) );
-        Assert.assertEquals( "test2", asd.getNames().get( 1 ) );
+        assertEquals( 2, asd.getNames().size() );
+        assertEquals( "test1", asd.getNames().get( 0 ) );
+        assertEquals( "test2", asd.getNames().get( 1 ) );
 
         // multi without space
         value = "(" + oid + " " + required + " NAME('test1''test2''test3'))";
         asd = parser.parse( value );
-        Assert.assertEquals( 3, asd.getNames().size() );
-        Assert.assertEquals( "test1", asd.getNames().get( 0 ) );
-        Assert.assertEquals( "test2", asd.getNames().get( 1 ) );
-        Assert.assertEquals( "test3", asd.getNames().get( 2 ) );
+        assertEquals( 3, asd.getNames().size() );
+        assertEquals( "test1", asd.getNames().get( 0 ) );
+        assertEquals( "test2", asd.getNames().get( 1 ) );
+        assertEquals( "test3", asd.getNames().get( 2 ) );
 
         // multi with many spaces
         value = "(          " + oid + " " + required
             + "          NAME          (          'test1'          'test2'          'test3'
         )          )";
         asd = parser.parse( value );
-        Assert.assertEquals( 3, asd.getNames().size() );
-        Assert.assertEquals( "test1", asd.getNames().get( 0 ) );
-        Assert.assertEquals( "test2", asd.getNames().get( 1 ) );
-        Assert.assertEquals( "test3", asd.getNames().get( 2 ) );
+        assertEquals( 3, asd.getNames().size() );
+        assertEquals( "test1", asd.getNames().get( 0 ) );
+        assertEquals( "test2", asd.getNames().get( 1 ) );
+        assertEquals( "test3", asd.getNames().get( 2 ) );
 
         // multi with tabs, newline, comment, etc.
         value = "(\r\n" + oid + "\r" + required
             + "\nNAME\t(\t\t\t'test1'\t\n\t'test2'\t\r\t'test3'\t\r\n\t)\n#comment\n)";
         asd = parser.parse( value );
-        Assert.assertEquals( 3, asd.getNames().size() );
-        Assert.assertEquals( "test1", asd.getNames().get( 0 ) );
-        Assert.assertEquals( "test2", asd.getNames().get( 1 ) );
-        Assert.assertEquals( "test3", asd.getNames().get( 2 ) );
+        assertEquals( 3, asd.getNames().size() );
+        assertEquals( "test1", asd.getNames().get( 0 ) );
+        assertEquals( "test2", asd.getNames().get( 1 ) );
+        assertEquals( "test3", asd.getNames().get( 2 ) );
 
         // lowercase NAME
         value = "( " + oid + " " + required + " name 'test' )";
         asd = parser.parse( value );
-        Assert.assertEquals( 1, asd.getNames().size() );
-        Assert.assertEquals( "test", asd.getNames().get( 0 ) );
+        assertEquals( 1, asd.getNames().size() );
+        assertEquals( "test", asd.getNames().get( 0 ) );
 
         // unquoted NAME value
         value = "( " + oid + " " + required + " NAME test )";
         asd = parser.parse( value );
-        Assert.assertEquals( 1, asd.getNames().size() );
-        Assert.assertEquals( "test", asd.getNames().get( 0 ) );
+        assertEquals( 1, asd.getNames().size() );
+        assertEquals( "test", asd.getNames().get( 0 ) );
 
         // multi unquoted NAME values
         value = " ( " + oid + " " + required + " NAME (test1 test2) ) ";
         asd = parser.parse( value );
-        Assert.assertEquals( 2, asd.getNames().size() );
-        Assert.assertEquals( "test1", asd.getNames().get( 0 ) );
-        Assert.assertEquals( "test2", asd.getNames().get( 1 ) );
+        assertEquals( 2, asd.getNames().size() );
+        assertEquals( "test1", asd.getNames().get( 0 ) );
+        assertEquals( "test2", asd.getNames().get( 1 ) );
 
         // NAM unknown
         value = "( " + oid + " " + required + " NAM 'test' )";
         try
         {
             parser.parse( value );
-            Assert.fail( "Exception expected, invalid token NAM" );
+            fail( "Exception expected, invalid token NAM" );
         }
         catch ( ParseException pe )
         {
@@ -306,7 +308,7 @@
             try
             {
                 parser.parse( value );
-                Assert.fail( "Exception expected, invalid NAME 1test (starts with number)"
);
+                fail( "Exception expected, invalid NAME 1test (starts with number)" );
             }
             catch ( ParseException pe )
             {
@@ -318,7 +320,7 @@
             try
             {
                 parser.parse( value );
-                Assert.fail( "Exception expected, invalid NAME -test (starts with hypen)"
);
+                fail( "Exception expected, invalid NAME -test (starts with hypen)" );
             }
             catch ( ParseException pe )
             {
@@ -330,7 +332,7 @@
             try
             {
                 parser.parse( value );
-                Assert.fail( "Exception expected, invalid NAME te_st (contains invalid character)"
);
+                fail( "Exception expected, invalid NAME te_st (contains invalid character)"
);
             }
             catch ( ParseException pe )
             {
@@ -342,7 +344,7 @@
             try
             {
                 parser.parse( value );
-                Assert.fail( "Exception expected, invalid NAME te_st (contains invalid character)"
);
+                fail( "Exception expected, invalid NAME te_st (contains invalid character)"
);
             }
             catch ( ParseException pe )
             {
@@ -361,63 +363,63 @@
         throws ParseException
     {
         String value = null;
-        AbstractSchemaDescription asd = null;
+        SchemaObject asd = null;
 
         // simple
         value = "(" + oid + " " + required + " DESC 'Descripton')";
         asd = parser.parse( value );
-        Assert.assertEquals( "Descripton", asd.getDescription() );
+        assertEquals( "Descripton", asd.getDescription() );
 
         // simple with tabs, newline, comment, etc.
         value = "(" + oid + "\n" + required + "\tDESC#comment\n\n\r\n\r\t'Descripton')";
         asd = parser.parse( value );
-        Assert.assertEquals( "Descripton", asd.getDescription() );
+        assertEquals( "Descripton", asd.getDescription() );
 
         // simple w/o space
         value = "(" + oid + " " + required + " DESC'Descripton')";
         asd = parser.parse( value );
-        Assert.assertEquals( "Descripton", asd.getDescription() );
+        assertEquals( "Descripton", asd.getDescription() );
 
         // simple parentheses and quotes
         value = "(" + oid + " " + required + " DESC ('Descripton') )";
         asd = parser.parse( value );
-        Assert.assertEquals( "Descripton", asd.getDescription() );
+        assertEquals( "Descripton", asd.getDescription() );
 
         // unicode
         value = "( " + oid + " " + required + " DESC 'Descripton \u00E4\u00F6\u00FC\u00DF
\u90E8\u9577' )";
         asd = parser.parse( value );
-        Assert.assertEquals( "Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577", asd.getDescription()
);
+        assertEquals( "Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577", asd.getDescription()
);
 
         // escaped characters
         value = "( " + oid + " " + required + " DESC 'test\\5Ctest' )";
         asd = parser.parse( value );
-        Assert.assertEquals( "test\\test", asd.getDescription() );
+        assertEquals( "test\\test", asd.getDescription() );
         value = "( " + oid + " " + required + " DESC 'test\\5ctest' )";
         asd = parser.parse( value );
-        Assert.assertEquals( "test\\test", asd.getDescription() );
+        assertEquals( "test\\test", asd.getDescription() );
         value = "( " + oid + " " + required + " DESC 'test\\27test' )";
         asd = parser.parse( value );
-        Assert.assertEquals( "test'test", asd.getDescription() );
+        assertEquals( "test'test", asd.getDescription() );
         value = "( " + oid + " " + required + " DESC '\\5C\\27\\5c' )";
         asd = parser.parse( value );
-        Assert.assertEquals( "\\'\\", asd.getDescription() );
+        assertEquals( "\\'\\", asd.getDescription() );
 
         // lowercase DESC
         value = "( " + oid + " " + required + " desc 'Descripton' )";
         asd = parser.parse( value );
-        Assert.assertEquals( "Descripton", asd.getDescription() );
+        assertEquals( "Descripton", asd.getDescription() );
 
         // empty DESC
         value = "( " + oid + " " + required + " DESC '' )";
         asd = parser.parse( value );
-        Assert.assertEquals( "", asd.getDescription() );
+        assertEquals( "", asd.getDescription() );
 
         // multiple not allowed
         value = "(" + oid + " " + required + " DESC ( 'Descripton1' 'Description 2' )  )";
         try
         {
             parser.parse( value );
-            Assert.fail( "Exception expected, invalid multiple DESC not allowed.)" );
+            fail( "Exception expected, invalid multiple DESC not allowed.)" );
         }
         catch ( ParseException pe )
         {
@@ -434,81 +436,81 @@
     public static void testExtensions( AbstractSchemaParser parser, String oid, String required
) throws ParseException
     {
         String value = null;
-        AbstractSchemaDescription asd = null;
+        SchemaObject asd = null;
 
         // no extension
         value = "( " + oid + " " + required + " )";
         asd = parser.parse( value );
-        Assert.assertEquals( 0, asd.getExtensions().size() );
+        assertEquals( 0, asd.getExtensions().size() );
 
         // single extension with one value
         value = "( " + oid + " " + required + " X-TEST 'test' )";
         asd = parser.parse( value );
-        Assert.assertEquals( 1, asd.getExtensions().size() );
-        Assert.assertNotNull( asd.getExtensions().get( "X-TEST" ) );
-        Assert.assertEquals( 1, asd.getExtensions().get( "X-TEST" ).size() );
-        Assert.assertEquals( "test", asd.getExtensions().get( "X-TEST" ).get( 0 ) );
+        assertEquals( 1, asd.getExtensions().size() );
+        assertNotNull( asd.getExtensions().get( "X-TEST" ) );
+        assertEquals( 1, asd.getExtensions().get( "X-TEST" ).size() );
+        assertEquals( "test", asd.getExtensions().get( "X-TEST" ).get( 0 ) );
 
         // single extension with multiple values
         value = "( " + oid + " " + required
             + " X-TEST-ABC ('test1' 'test \u00E4\u00F6\u00FC\u00DF'       'test \u90E8\u9577'
) )";
         asd = parser.parse( value );
-        Assert.assertEquals( 1, asd.getExtensions().size() );
-        Assert.assertNotNull( asd.getExtensions().get( "X-TEST-ABC" ) );
-        Assert.assertEquals( 3, asd.getExtensions().get( "X-TEST-ABC" ).size() );
-        Assert.assertEquals( "test1", asd.getExtensions().get( "X-TEST-ABC" ).get( 0 ) );
-        Assert.assertEquals( "test \u00E4\u00F6\u00FC\u00DF", asd.getExtensions().get( "X-TEST-ABC"
).get( 1 ) );
-        Assert.assertEquals( "test \u90E8\u9577", asd.getExtensions().get( "X-TEST-ABC" ).get(
2 ) );
+        assertEquals( 1, asd.getExtensions().size() );
+        assertNotNull( asd.getExtensions().get( "X-TEST-ABC" ) );
+        assertEquals( 3, asd.getExtensions().get( "X-TEST-ABC" ).size() );
+        assertEquals( "test1", asd.getExtensions().get( "X-TEST-ABC" ).get( 0 ) );
+        assertEquals( "test \u00E4\u00F6\u00FC\u00DF", asd.getExtensions().get( "X-TEST-ABC"
).get( 1 ) );
+        assertEquals( "test \u90E8\u9577", asd.getExtensions().get( "X-TEST-ABC" ).get( 2
) );
 
         // multiple extensions
         value = "(" + oid + " " + required + " X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1'
'test2-2'))";
         asd = parser.parse( value );
-        Assert.assertEquals( 2, asd.getExtensions().size() );
-        Assert.assertNotNull( asd.getExtensions().get( "X-TEST-a" ) );
-        Assert.assertEquals( 2, asd.getExtensions().get( "X-TEST-a" ).size() );
-        Assert.assertEquals( "test1-1", asd.getExtensions().get( "X-TEST-a" ).get( 0 ) );
-        Assert.assertEquals( "test1-2", asd.getExtensions().get( "X-TEST-a" ).get( 1 ) );
-        Assert.assertNotNull( asd.getExtensions().get( "X-TEST-b" ) );
-        Assert.assertEquals( 2, asd.getExtensions().get( "X-TEST-b" ).size() );
-        Assert.assertEquals( "test2-1", asd.getExtensions().get( "X-TEST-b" ).get( 0 ) );
-        Assert.assertEquals( "test2-2", asd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
+        assertEquals( 2, asd.getExtensions().size() );
+        assertNotNull( asd.getExtensions().get( "X-TEST-a" ) );
+        assertEquals( 2, asd.getExtensions().get( "X-TEST-a" ).size() );
+        assertEquals( "test1-1", asd.getExtensions().get( "X-TEST-a" ).get( 0 ) );
+        assertEquals( "test1-2", asd.getExtensions().get( "X-TEST-a" ).get( 1 ) );
+        assertNotNull( asd.getExtensions().get( "X-TEST-b" ) );
+        assertEquals( 2, asd.getExtensions().get( "X-TEST-b" ).size() );
+        assertEquals( "test2-1", asd.getExtensions().get( "X-TEST-b" ).get( 0 ) );
+        assertEquals( "test2-2", asd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
 
         // multiple extensions, no spaces
         value = "(" + oid + " " + required + " X-TEST-a('test1-1''test1-2')X-TEST-b('test2-1''test2-2'))";
         asd = parser.parse( value );
-        Assert.assertEquals( 2, asd.getExtensions().size() );
-        Assert.assertNotNull( asd.getExtensions().get( "X-TEST-a" ) );
-        Assert.assertEquals( 2, asd.getExtensions().get( "X-TEST-a" ).size() );
-        Assert.assertEquals( "test1-1", asd.getExtensions().get( "X-TEST-a" ).get( 0 ) );
-        Assert.assertEquals( "test1-2", asd.getExtensions().get( "X-TEST-a" ).get( 1 ) );
-        Assert.assertNotNull( asd.getExtensions().get( "X-TEST-b" ) );
-        Assert.assertEquals( 2, asd.getExtensions().get( "X-TEST-b" ).size() );
-        Assert.assertEquals( "test2-1", asd.getExtensions().get( "X-TEST-b" ).get( 0 ) );
-        Assert.assertEquals( "test2-2", asd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
+        assertEquals( 2, asd.getExtensions().size() );
+        assertNotNull( asd.getExtensions().get( "X-TEST-a" ) );
+        assertEquals( 2, asd.getExtensions().get( "X-TEST-a" ).size() );
+        assertEquals( "test1-1", asd.getExtensions().get( "X-TEST-a" ).get( 0 ) );
+        assertEquals( "test1-2", asd.getExtensions().get( "X-TEST-a" ).get( 1 ) );
+        assertNotNull( asd.getExtensions().get( "X-TEST-b" ) );
+        assertEquals( 2, asd.getExtensions().get( "X-TEST-b" ).size() );
+        assertEquals( "test2-1", asd.getExtensions().get( "X-TEST-b" ).get( 0 ) );
+        assertEquals( "test2-2", asd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
 
         // multiple extensions, tabs, newline, comments
         value = "(" + oid + "\n#comment\n" + required
             + "\nX-TEST-a\n(\t'test1-1'\t\n'test1-2'\n\r)\tX-TEST-b\n(\n'test2-1'\t'test2-2'\t)\r)";
         asd = parser.parse( value );
-        Assert.assertEquals( 2, asd.getExtensions().size() );
-        Assert.assertNotNull( asd.getExtensions().get( "X-TEST-a" ) );
-        Assert.assertEquals( 2, asd.getExtensions().get( "X-TEST-a" ).size() );
-        Assert.assertEquals( "test1-1", asd.getExtensions().get( "X-TEST-a" ).get( 0 ) );
-        Assert.assertEquals( "test1-2", asd.getExtensions().get( "X-TEST-a" ).get( 1 ) );
-        Assert.assertNotNull( asd.getExtensions().get( "X-TEST-b" ) );
-        Assert.assertEquals( 2, asd.getExtensions().get( "X-TEST-b" ).size() );
-        Assert.assertEquals( "test2-1", asd.getExtensions().get( "X-TEST-b" ).get( 0 ) );
-        Assert.assertEquals( "test2-2", asd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
+        assertEquals( 2, asd.getExtensions().size() );
+        assertNotNull( asd.getExtensions().get( "X-TEST-a" ) );
+        assertEquals( 2, asd.getExtensions().get( "X-TEST-a" ).size() );
+        assertEquals( "test1-1", asd.getExtensions().get( "X-TEST-a" ).get( 0 ) );
+        assertEquals( "test1-2", asd.getExtensions().get( "X-TEST-a" ).get( 1 ) );
+        assertNotNull( asd.getExtensions().get( "X-TEST-b" ) );
+        assertEquals( 2, asd.getExtensions().get( "X-TEST-b" ).size() );
+        assertEquals( "test2-1", asd.getExtensions().get( "X-TEST-b" ).get( 0 ) );
+        assertEquals( "test2-2", asd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
 
         // some more complicated
         value = "(" + oid + " " + required
             + " X-_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ('\\5C\\27\\5c'))";
         asd = parser.parse( value );
-        Assert.assertEquals( 1, asd.getExtensions().size() );
-        Assert.assertNotNull( asd.getExtensions().get( "X-_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
) );
-        Assert.assertEquals( 1, asd.getExtensions().get( "X-_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)
+        assertEquals( 1, asd.getExtensions().size() );
+        assertNotNull( asd.getExtensions().get( "X-_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
) );
+        assertEquals( 1, asd.getExtensions().get( "X-_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)
             .size() );
-        Assert.assertEquals( "\\'\\", asd.getExtensions().get(
+        assertEquals( "\\'\\", asd.getExtensions().get(
             "X-_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ).get( 0 ) );
 
         // invalid extension, no number allowed
@@ -516,11 +518,11 @@
         try
         {
             asd = parser.parse( value );
-            Assert.fail( "Exception expected, invalid extension X-TEST1 (no number allowed)"
);
+            fail( "Exception expected, invalid extension X-TEST1 (no number allowed)" );
         }
         catch ( ParseException pe )
         {
-            Assert.assertTrue( true );
+            assertTrue( true );
         }
 
     }
@@ -534,39 +536,39 @@
     public static void testObsolete( AbstractSchemaParser parser, String oid, String required
) throws ParseException
     {
         String value = null;
-        AbstractSchemaDescription asd = null;
+        SchemaObject asd = null;
 
         // not obsolete
         value = "( " + oid + " " + required + " )";
         asd = parser.parse( value );
-        Assert.assertFalse( asd.isObsolete() );
+        assertFalse( asd.isObsolete() );
 
         // not obsolete
         value = "( " + oid + " " + required + " NAME 'test' DESC 'Descripton' )";
         asd = parser.parse( value );
-        Assert.assertFalse( asd.isObsolete() );
+        assertFalse( asd.isObsolete() );
 
         // obsolete
         value = "(" + oid + " " + required + " NAME 'test' DESC 'Descripton' OBSOLETE)";
         asd = parser.parse( value );
-        Assert.assertTrue( asd.isObsolete() );
+        assertTrue( asd.isObsolete() );
 
         // obsolete 
         value = "(" + oid + " " + required + " OBSOLETE)";
         asd = parser.parse( value );
-        Assert.assertTrue( asd.isObsolete() );
+        assertTrue( asd.isObsolete() );
 
         // lowercased obsolete 
         value = "(" + oid + " " + required + " obsolete)";
         asd = parser.parse( value );
-        Assert.assertTrue( asd.isObsolete() );
+        assertTrue( asd.isObsolete() );
 
         // invalid
         value = "(" + oid + " " + required + " NAME 'test' DESC 'Descripton' OBSOLET )";
         try
         {
             asd = parser.parse( value );
-            Assert.fail( "Exception expected, invalid OBSOLETE value" );
+            fail( "Exception expected, invalid OBSOLETE value" );
         }
         catch ( ParseException pe )
         {
@@ -578,11 +580,11 @@
         try
         {
             asd = parser.parse( value );
-            Assert.fail( "Exception expected, trailing value ('true') now allowed" );
+            fail( "Exception expected, trailing value ('true') now allowed" );
         }
         catch ( ParseException pe )
         {
-            Assert.assertTrue( true );
+            assertTrue( true );
         }
 
     }
@@ -601,11 +603,11 @@
             try
             {
                 parser.parse( testValue );
-                Assert.fail( "Exception expected, element appears twice in " + testValue
);
+                fail( "Exception expected, element appears twice in " + testValue );
             }
             catch ( ParseException pe )
             {
-                Assert.assertTrue( true );
+                assertTrue( true );
             }
         }
 
@@ -647,7 +649,7 @@
         while ( hasLiveThreads );
 
         // check that no one thread failed to parse and generate a SS object
-        Assert.assertTrue( isSuccessMultithreaded[0] );
+        assertTrue( isSuccessMultithreaded[0] );
 
     }
 
@@ -660,30 +662,30 @@
         try
         {
             String value = null;
-            AbstractSchemaDescription asd = null;
+            SchemaObject asd = null;
             
             parser.setQuirksMode( true );
             
             // alphanum OID
             value = "( abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789 "
+ required + " )";
             asd = parser.parse( value );
-            Assert.assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789",
asd
-                .getNumericOid() );
+            assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789",
asd
+                .getOid() );
 
             // start with hypen
             value = "( -oid " + required + " )";
             asd = parser.parse( value );
-            Assert.assertEquals( "-oid", asd.getNumericOid() );
+            assertEquals( "-oid", asd.getOid() );
 
             // start with number
             value = "( 1oid " + required + " )";
             asd = parser.parse( value );
-            Assert.assertEquals( "1oid", asd.getNumericOid() );
+            assertEquals( "1oid", asd.getOid() );
 
             // start with dot
             value = "( .oid " + required + " )";
             asd = parser.parse( value );
-            Assert.assertEquals( ".oid", asd.getNumericOid() );
+            assertEquals( ".oid", asd.getOid() );
         }
         finally
         {
@@ -697,7 +699,7 @@
         private final String value;
         private final boolean[] isSuccessMultithreaded;
 
-        private AbstractSchemaDescription result;
+        private SchemaObject result;
 
 
         public ParseSpecification( AbstractSchemaParser parser, String value, boolean[] isSuccessMultithreaded
)

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParserTest.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParserTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/SyntaxCheckerDescriptionSchemaParserTest.java
Wed Jan  6 17:52:15 2010
@@ -20,6 +20,10 @@
 package org.apache.directory.shared.ldap.schema.syntax.parser;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
 import java.text.ParseException;
 
 import org.apache.directory.shared.ldap.schema.parsers.SyntaxCheckerDescription;
@@ -27,9 +31,6 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 
 
 /**
@@ -81,13 +82,13 @@
     public void testFqcn() throws ParseException
     {
         String value = null;
-        SyntaxCheckerDescription scd = null;
+        SyntaxCheckerDescription syntaxCheckerDescription = null;
 
         // FQCN simple p
         value = "( 1.1 FQCN org.apache.directory.SimpleSyntaxChecker )";
-        scd = parser.parseSyntaxCheckerDescription( value );
-        assertNotNull( scd.getFqcn() );
-        assertEquals( "org.apache.directory.SimpleSyntaxChecker", scd.getFqcn() );
+        syntaxCheckerDescription = parser.parseSyntaxCheckerDescription( value );
+        assertNotNull( syntaxCheckerDescription.getFqcn() );
+        assertEquals( "org.apache.directory.SimpleSyntaxChecker", syntaxCheckerDescription.getFqcn()
);
     }
 
 
@@ -95,13 +96,14 @@
     public void testBytecode() throws ParseException
     {
         String value = null;
-        SyntaxCheckerDescription scd = null;
+        SyntaxCheckerDescription syntaxCheckerDescription = null;
 
         // FQCN simple p
         value = "( 1.1 FQCN org.apache.directory.SimpleSyntaxChecker BYTECODE ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====
)";
-        scd = parser.parseSyntaxCheckerDescription( value );
-        assertNotNull( scd.getBytecode() );
-        assertEquals( "ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====",
scd.getBytecode() );
+        syntaxCheckerDescription = parser.parseSyntaxCheckerDescription( value );
+        assertNotNull( syntaxCheckerDescription.getBytecode() );
+        assertEquals( "ABCDEFGHIJKLMNOPQRSTUVWXYZ+/abcdefghijklmnopqrstuvwxyz0123456789====",

+        		syntaxCheckerDescription.getBytecode() );
     }
 
 
@@ -147,12 +149,12 @@
     public void testSimpleSyntaxChecker() throws ParseException
     {
         String simple = "( " + OID + " FQCN " + FQCN + " )";
-        SyntaxCheckerDescription desc = parser.parseSyntaxCheckerDescription( simple );
-        assertNotNull( desc );
-        assertEquals( OID, desc.getNumericOid() );
-        assertEquals( FQCN, desc.getFqcn() );
-        assertNull( desc.getBytecode() );
-        assertNull( desc.getDescription() );
+        SyntaxCheckerDescription syntaxCheckerDescription = parser.parseSyntaxCheckerDescription(
simple );
+        assertNotNull( syntaxCheckerDescription );
+        assertEquals( OID, syntaxCheckerDescription.getOid() );
+        assertEquals( FQCN, syntaxCheckerDescription.getFqcn() );
+        assertNull( syntaxCheckerDescription.getBytecode() );
+        assertNull( syntaxCheckerDescription.getDescription() );
     }
 
 
@@ -160,12 +162,12 @@
     public void testSyntaxCheckerWithDesc() throws ParseException
     {
         String simple = "( " + OID + " DESC '" + DESC + "' FQCN " + FQCN + " )";
-        SyntaxCheckerDescription desc = parser.parseSyntaxCheckerDescription( simple );
-        assertNotNull( desc );
-        assertEquals( OID, desc.getNumericOid() );
-        assertEquals( FQCN, desc.getFqcn() );
-        assertNull( desc.getBytecode() );
-        assertEquals( DESC, desc.getDescription() );
+        SyntaxCheckerDescription syntaxCheckerDescription = parser.parseSyntaxCheckerDescription(
simple );
+        assertNotNull( syntaxCheckerDescription );
+        assertEquals( OID, syntaxCheckerDescription.getOid() );
+        assertEquals( FQCN, syntaxCheckerDescription.getFqcn() );
+        assertNull( syntaxCheckerDescription.getBytecode() );
+        assertEquals( DESC, syntaxCheckerDescription.getDescription() );
     }
 
 
@@ -173,21 +175,21 @@
     public void testSyntaxCheckerWithDescAndByteCode() throws ParseException
     {
         String simple = "( " + OID + " DESC '" + DESC + "' FQCN " + FQCN + " BYTECODE " +
BYTECODE + " )";
-        SyntaxCheckerDescription desc = parser.parseSyntaxCheckerDescription( simple );
-        assertNotNull( desc );
-        assertEquals( OID, desc.getNumericOid() );
-        assertEquals( FQCN, desc.getFqcn() );
-        assertEquals( BYTECODE, desc.getBytecode() );
-        assertEquals( DESC, desc.getDescription() );
+        SyntaxCheckerDescription syntaxCheckerDescription = parser.parseSyntaxCheckerDescription(
simple );
+        assertNotNull( syntaxCheckerDescription );
+        assertEquals( OID, syntaxCheckerDescription.getOid() );
+        assertEquals( FQCN, syntaxCheckerDescription.getFqcn() );
+        assertEquals( BYTECODE, syntaxCheckerDescription.getBytecode() );
+        assertEquals( DESC, syntaxCheckerDescription.getDescription() );
     }
 
 
     @Test
     public void testSyntaxCheckerExample() throws ParseException
     {
-        String simple = "( 1.3.6.1.4.1.18060.0.4.1.0.10000 DESC 'bogus desc' FQCN org.apache.directory.shared.ldap.schema.syntax.AcceptAllSyntaxChecker
)";
-        SyntaxCheckerDescription desc = parser.parseSyntaxCheckerDescription( simple );
-        assertNotNull( desc );
+        String simple = "( 1.3.6.1.4.1.18060.0.4.1.0.10000 DESC 'bogus desc' FQCN org.apache.directory.shared.ldap.schema.syntax.OctetStringSyntaxChecker
)";
+        SyntaxCheckerDescription syntaxCheckerDescription = parser.parseSyntaxCheckerDescription(
simple );
+        assertNotNull( syntaxCheckerDescription );
     }
 
 
@@ -208,12 +210,12 @@
             + "gAPAAEACgAAAB0AAQABAAAABSq0AAKwAAAAAQALAAAABgABAAAAHQABABAAEQABAAoAAAAaAAEAAgAAAAIErAAA"
             + "AAEACwAAAAYAAQAAACMAAQASABMAAgAKAAAAGQAAAAIAAAABsQAAAAEACwAAAAYAAQAAACkAFAAAAAQAAQAVAAE"
             + "AFgAAAAIAFw== X-SCHEMA 'nis' )";
-        SyntaxCheckerDescription desc = parser.parseSyntaxCheckerDescription( simple );
-        assertNotNull( desc );
-        assertEquals( "1.3.6.1.4.1.18060.0.4.1.0.10002", desc.getNumericOid() );
-        assertEquals( "DummySyntaxChecker", desc.getFqcn() );
-        assertNotNull( desc.getBytecode() );
-        assertEquals( "bogus desc", desc.getDescription() );
+        SyntaxCheckerDescription syntaxCheckerDescription = parser.parseSyntaxCheckerDescription(
simple );
+        assertNotNull( syntaxCheckerDescription );
+        assertEquals( "1.3.6.1.4.1.18060.0.4.1.0.10002", syntaxCheckerDescription.getOid()
);
+        assertEquals( "DummySyntaxChecker", syntaxCheckerDescription.getFqcn() );
+        assertNotNull( syntaxCheckerDescription.getBytecode() );
+        assertEquals( "bogus desc", syntaxCheckerDescription.getDescription() );
     }
 
 

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/AttributeUtilsTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/AttributeUtilsTest.java?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/AttributeUtilsTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/AttributeUtilsTest.java
Wed Jan  6 17:52:15 2010
@@ -19,10 +19,18 @@
  */
 package org.apache.directory.shared.ldap.util;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.util.HashSet;
 import java.util.Set;
 
 import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.InvalidAttributeValueException;
 
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
@@ -32,12 +40,7 @@
 import org.apache.directory.shared.ldap.entry.client.ClientModification;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
-
 import org.junit.Test;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNull;
 
 /**
  * A test case for the AttributeUtils methods 
@@ -394,5 +397,37 @@
         assertNotNull( entry.get( "cn" ) );
         assertNull( entry.get( "ou" ) );
     }
+    
+    @Test
+    public void testCreateAttributesVarargs() throws NamingException
+    {
+        String mOid = "m-oid: 1.2.3.4";
+        String description = "description";
+        
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaSyntax",
+            mOid,
+            "m-description", description );
+        
+        assertEquals( "top", attrs.get( "objectClass" ).get( 0 ) );
+        assertEquals( "metaTop", attrs.get( "objectClass" ).get( 1 ) );
+        assertEquals( "metaSyntax", attrs.get( "objectClass" ).get( 2 ) );
+        assertEquals( "1.2.3.4", attrs.get( "m-oid" ).get() );
+        assertEquals( "description", attrs.get( "m-description" ).get() );
+
+        try
+        {
+            AttributeUtils.createAttributes( 
+                "objectClass", "top",
+                "objectClass" );
+            fail();
+        }
+        catch ( InvalidAttributeValueException iave )
+        {
+            assertTrue( true );
+        }
+    }
 }
 

Modified: directory/shared/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/shared/trunk/pom.xml?rev=896579&r1=896578&r2=896579&view=diff
==============================================================================
--- directory/shared/trunk/pom.xml (original)
+++ directory/shared/trunk/pom.xml Wed Jan  6 17:52:15 2010
@@ -34,6 +34,7 @@
     <projectName>ApacheDS-Shared</projectName>
     <distMgmtSiteUrl>scpexe://people.apache.org/www/directory.apache.org/shared/gen-docs/${version}/</distMgmtSiteUrl>
     <skin.version>1.0.0</skin.version>
+    <org.apache.directory.shared.version>0.9.18-SNAPSHOT</org.apache.directory.shared.version>
   </properties>
   
   <distributionManagement>
@@ -53,9 +54,13 @@
     <module>ldap</module>
     <module>ldap-jndi</module>
     <module>ldap-constants</module>
+    <module>ldap-schema</module>
+    <module>ldap-schema-loader</module>
+    <module>ldap-schema-dao</module>
+    <module>ldap-schema-manager</module>
     <module>asn1-codec</module>
-    <module>convert</module>
-    <module>client-api</module>
+    <module>ldap-convert</module>
+    <module>ldap-client-api</module>
     <module>cursor</module>
     <module>dsml-parser</module>
   </modules>
@@ -69,6 +74,12 @@
       </dependency>
 
       <dependency>
+        <groupId>commons-io</groupId>
+        <artifactId>commons-io</artifactId>
+        <version>1.4</version>
+      </dependency>
+
+      <dependency>
         <groupId>commons-lang</groupId>
         <artifactId>commons-lang</artifactId>
         <version>2.4</version>
@@ -93,6 +104,13 @@
       </dependency>
 
       <dependency>
+        <groupId>commons-pool</groupId>
+        <artifactId>commons-pool</artifactId>
+        <version>1.5.2</version>
+      </dependency>
+
+
+      <dependency>
         <groupId>antlr</groupId>
         <artifactId>antlr</artifactId>
         <version>2.7.7</version>
@@ -107,7 +125,7 @@
       <dependency>
         <groupId>org.apache.mina</groupId>
         <artifactId>mina-core</artifactId>
-        <version>2.0.0-M6</version>
+        <version>2.0.0-RC1</version>
       </dependency>
       
       <dependency>



Mime
View raw message