directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r807570 - in /directory/shared/branches/shared-schema/ldap/src: main/java/org/apache/directory/shared/ldap/schema/parsers/ test/java/org/apache/directory/shared/ldap/schema/syntax/parser/
Date Tue, 25 Aug 2009 11:31:24 GMT
Author: elecharny
Date: Tue Aug 25 11:31:24 2009
New Revision: 807570

URL: http://svn.apache.org/viewvc?rev=807570&view=rev
Log:
Removed the DitStructureRuleDescription class
Fixed the parser tests

Removed:
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescription.java
Modified:
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITContentRuleDescriptionSchemaParser.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescriptionSchemaParser.java
    directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java
    directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITContentRuleDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITContentRuleDescriptionSchemaParser.java?rev=807570&r1=807569&r2=807570&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITContentRuleDescriptionSchemaParser.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITContentRuleDescriptionSchemaParser.java
Tue Aug 25 11:31:24 2009
@@ -22,6 +22,10 @@
 
 import java.text.ParseException;
 
+import org.apache.directory.shared.ldap.schema.DITContentRule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 
 import antlr.RecognitionException;
 import antlr.TokenStreamException;
@@ -35,6 +39,9 @@
  */
 public class DITContentRuleDescriptionSchemaParser extends AbstractSchemaParser
 {
+    /** The LoggerFactory used by this class */
+    protected static final Logger LOG = LoggerFactory.getLogger( DITContentRuleDescriptionSchemaParser.class
);
+
 
     /**
      * Creates a schema parser instance.
@@ -64,12 +71,13 @@
      * @return the parsed DITContentRuleDescription bean
      * @throws ParseException if there are any recognition errors (bad syntax)
      */
-    public synchronized DITContentRuleDescription parseDITContentRuleDescription( String
ditContentRuleDescription )
+    public synchronized DITContentRule parseDITContentRuleDescription( String ditContentRuleDescription
)
         throws ParseException
     {
 
         if ( ditContentRuleDescription == null )
         {
+            LOG.error( "Cannot parse a null DITContentRule" );
             throw new ParseException( "Null", 0 );
         }
 
@@ -77,27 +85,35 @@
 
         try
         {
-            DITContentRuleDescription dcrd = parser.ditContentRuleDescription();
-            return dcrd;
+            DITContentRule ditContentRule = parser.ditContentRuleDescription();
+            return ditContentRule;
         }
         catch ( RecognitionException re )
         {
-            String msg = "Parser failure on DIT content rule description:\n\t" + ditContentRuleDescription;
-            msg += "\nAntlr message: " + re.getMessage();
-            msg += "\nAntlr column: " + re.getColumn();
+            String msg = "Parser failure on DIT content rule description:\n\t" + ditContentRuleDescription
+
+                "\nAntlr message: " + re.getMessage() +
+                "\nAntlr column: " + re.getColumn();
+            LOG.error( msg );
             throw new ParseException( msg, re.getColumn() );
         }
         catch ( TokenStreamException tse )
         {
-            String msg = "Parser failure on DIT content rule description:\n\t" + ditContentRuleDescription;
-            msg += "\nAntlr message: " + tse.getMessage();
+            String msg = "Parser failure on DIT content rule description:\n\t" + ditContentRuleDescription
+
+                "\nAntlr message: " + tse.getMessage();
+            LOG.error( msg );
             throw new ParseException( msg, 0 );
         }
 
     }
 
 
-    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    /**
+     * Parses a DITContentRule description
+     * 
+     * @param The DITContentRule description to parse
+     * @return An instance of DITContentRule
+     */
+    public DITContentRule parse( String schemaDescription ) throws ParseException
     {
         return parseDITContentRuleDescription( schemaDescription );
     }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescriptionSchemaParser.java?rev=807570&r1=807569&r2=807570&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescriptionSchemaParser.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITStructureRuleDescriptionSchemaParser.java
Tue Aug 25 11:31:24 2009
@@ -22,6 +22,7 @@
 
 import java.text.ParseException;
 
+import org.apache.directory.shared.ldap.schema.DITStructureRule;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -73,7 +74,7 @@
      * @return the parsed DITStructureRuleDescription bean
      * @throws ParseException if there are any recognition errors (bad syntax)
      */
-    public synchronized DITStructureRuleDescription parseDITStructureRuleDescription( String
ditStructureRuleDescription )
+    public synchronized DITStructureRule parseDITStructureRuleDescription( String ditStructureRuleDescription
)
         throws ParseException
     {
 
@@ -87,8 +88,8 @@
 
         try
         {
-            DITStructureRuleDescription dsrd = parser.ditStructureRuleDescription();
-            return dsrd;
+            DITStructureRule ditStructureRule = parser.ditStructureRuleDescription();
+            return ditStructureRule;
         }
         catch ( RecognitionException re )
         {
@@ -113,9 +114,9 @@
      * Parses a DITStructureRule description
      * 
      * @param The DITStructureRule description to parse
-     * @return An instance of SyntaxCheckerDescription
+     * @return An instance of DITStructureRule
      */
-    public DITStructureRuleDescription parse( String schemaDescription ) throws ParseException
+    public DITStructureRule parse( String schemaDescription ) throws ParseException
     {
         return parseDITStructureRuleDescription( schemaDescription );
     }

Modified: directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java?rev=807570&r1=807569&r2=807570&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITContentRuleDescriptionSchemaParserTest.java
Tue Aug 25 11:31:24 2009
@@ -482,7 +482,7 @@
 
     /**
      * Tests the multithreaded use of a single parser.
-     */
+     *
     @Test
     public void testMultiThreaded() throws ParseException
     {

Modified: directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java?rev=807570&r1=807569&r2=807570&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/DITStructureRuleDescriptionSchemaParserTest.java
Tue Aug 25 11:31:24 2009
@@ -22,7 +22,7 @@
 
 import java.text.ParseException;
 
-import org.apache.directory.shared.ldap.schema.parsers.DITStructureRuleDescription;
+import org.apache.directory.shared.ldap.schema.DITStructureRule;
 import org.apache.directory.shared.ldap.schema.parsers.DITStructureRuleDescriptionSchemaParser;
 import org.junit.After;
 import org.junit.Before;
@@ -67,7 +67,7 @@
     public void testNumericRuleId() throws ParseException
     {
         String value = null;
-        DITStructureRuleDescription dsrd = null;
+        DITStructureRule ditStructureRule = null;
 
         // null test
         value = null;
@@ -95,18 +95,18 @@
 
         // simple
         value = "( 1 FORM 1.1 )";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( 1, dsrd.getRuleId() );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertEquals( 1, ditStructureRule.getRuleId() );
 
         // simple
         value = "( 1234567890 FORM 1.1 )";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( 1234567890, dsrd.getRuleId() );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertEquals( 1234567890, ditStructureRule.getRuleId() );
 
         // simple with spaces
         value = "(      1234567890   FORM   1.1     )";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( 1234567890, dsrd.getRuleId() );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertEquals( 1234567890, ditStructureRule.getRuleId() );
 
         // non-numeric not allowed
         value = "( test FORM 1.1 )";
@@ -192,48 +192,48 @@
     public void testForm() throws ParseException
     {
         String value = null;
-        DITStructureRuleDescription dsrd = null;
+        DITStructureRule ditStructureRule = null;
 
         // numeric oid
         value = "( 1 FORM 1.2.3.4.5.6.7.8.9.0 )";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( "1.2.3.4.5.6.7.8.9.0", dsrd.getForm() );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertEquals( "1.2.3.4.5.6.7.8.9.0", ditStructureRule.getForm() );
 
         // numeric oid
         value = "(   1    FORM    123.4567.890    )";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( "123.4567.890", dsrd.getForm() );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertEquals( "123.4567.890", ditStructureRule.getForm() );
 
         // descr
         value = "( 1 FORM abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789
)";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789",
dsrd.getForm() );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789",
ditStructureRule.getForm() );
 
         // descr, no space
         value = "(1 FORMabc)";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( "abc", dsrd.getForm() );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertEquals( "abc", ditStructureRule.getForm() );
 
         // descr, tab
         value = "\t(\t1\tFORM\tabc\t)\t";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( "abc", dsrd.getForm() );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertEquals( "abc", ditStructureRule.getForm() );
 
         // quoted value
         value = "( 1 FORM '1.2.3.4.5.6.7.8.9.0' )";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( "1.2.3.4.5.6.7.8.9.0", dsrd.getForm() );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertEquals( "1.2.3.4.5.6.7.8.9.0", ditStructureRule.getForm() );
 
         // no quote allowed
         value = "( 1 FORM ('test') )";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( "test", dsrd.getForm() );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertEquals( "test", ditStructureRule.getForm() );
 
         // invalid character
         value = "( 1 FORM 1.2.3.4.A )";
         try
         {
-            dsrd = parser.parseDITStructureRuleDescription( value );
+            ditStructureRule = parser.parseDITStructureRuleDescription( value );
             fail( "Exception expected, invalid FORM 1.2.3.4.A (invalid character)" );
         }
         catch ( ParseException pe )
@@ -245,7 +245,7 @@
         value = "( 1 FORM ( test1 test2 ) )";
         try
         {
-            dsrd = parser.parseDITStructureRuleDescription( value );
+            ditStructureRule = parser.parseDITStructureRuleDescription( value );
             fail( "Exception expected, FORM must be single valued" );
         }
         catch ( ParseException pe )
@@ -259,7 +259,7 @@
             value = "( 1 FORM -test ) )";
             try
             {
-                dsrd = parser.parseDITStructureRuleDescription( value );
+                ditStructureRule = parser.parseDITStructureRuleDescription( value );
                 fail( "Exception expected, invalid FORM '-test' (starts with hypen)" );
             }
             catch ( ParseException pe )
@@ -279,31 +279,31 @@
     public void testSup() throws ParseException
     {
         String value = null;
-        DITStructureRuleDescription dsrd = null;
+        DITStructureRule ditStructureRule = null;
 
         // no SUP
         value = "( 1 FORM 1.1 )";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( 0, dsrd.getSuperRules().size() );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertEquals( 0, ditStructureRule.getSuperRules().size() );
 
         // SUP simple number
         value = "( 1 FORM 1.1 SUP 1 )";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( 1, dsrd.getSuperRules().size() );
-        assertEquals( new Integer( 1 ), dsrd.getSuperRules().get( 0 ) );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertEquals( 1, ditStructureRule.getSuperRules().size() );
+        assertEquals( new Integer( 1 ), ditStructureRule.getSuperRules().get( 0 ) );
 
         // SUP single number
         value = "( 1 FORM 1.1 SUP ( 1 ) )";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( 1, dsrd.getSuperRules().size() );
-        assertEquals( new Integer( 1 ), dsrd.getSuperRules().get( 0 ) );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertEquals( 1, ditStructureRule.getSuperRules().size() );
+        assertEquals( new Integer( 1 ), ditStructureRule.getSuperRules().get( 0 ) );
 
         // SUP multi number
         value = "( 1 FORM 1.1 SUP(12345 67890))";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertEquals( 2, dsrd.getSuperRules().size() );
-        assertEquals( new Integer( 12345 ), dsrd.getSuperRules().get( 0 ) );
-        assertEquals( new Integer( 67890 ), dsrd.getSuperRules().get( 1 ) );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertEquals( 2, ditStructureRule.getSuperRules().size() );
+        assertEquals( new Integer( 12345 ), ditStructureRule.getSuperRules().get( 0 ) );
+        assertEquals( new Integer( 67890 ), ditStructureRule.getSuperRules().get( 1 ) );
 
         // non-numeric not allowed
         value = "( 1 FORM 1.1 SUP test )";
@@ -354,31 +354,31 @@
     public void testFull() throws ParseException
     {
         String value = null;
-        DITStructureRuleDescription dsrd = null;
+        DITStructureRule ditStructureRule = null;
 
         value = "( 1234567890 NAME ( 'abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789'
'test' ) DESC 'Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577' OBSOLETE FORM 2.3.4.5.6.7.8.9.0.1
SUP ( 1 1234567890 5 ) X-TEST-a ('test1-1' 'test1-2') X-TEST-b ('test2-1' 'test2-2') )";
-        dsrd = parser.parseDITStructureRuleDescription( value );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
 
-        assertEquals( 1234567890, dsrd.getRuleId() );
-        assertEquals( 2, dsrd.getNames().size() );
-        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789",
dsrd.getNames().get( 0 ) );
-        assertEquals( "test", dsrd.getNames().get( 1 ) );
-        assertEquals( "Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577", dsrd.getDescription()
);
-        assertTrue( dsrd.isObsolete() );
-        assertEquals( "2.3.4.5.6.7.8.9.0.1", dsrd.getForm() );
-        assertEquals( 3, dsrd.getSuperRules().size() );
-        assertEquals( new Integer( 1 ), dsrd.getSuperRules().get( 0 ) );
-        assertEquals( new Integer( 1234567890 ), dsrd.getSuperRules().get( 1 ) );
-        assertEquals( new Integer( 5 ), dsrd.getSuperRules().get( 2 ) );
-        assertEquals( 2, dsrd.getExtensions().size() );
-        assertNotNull( dsrd.getExtensions().get( "X-TEST-a" ) );
-        assertEquals( 2, dsrd.getExtensions().get( "X-TEST-a" ).size() );
-        assertEquals( "test1-1", dsrd.getExtensions().get( "X-TEST-a" ).get( 0 ) );
-        assertEquals( "test1-2", dsrd.getExtensions().get( "X-TEST-a" ).get( 1 ) );
-        assertNotNull( dsrd.getExtensions().get( "X-TEST-b" ) );
-        assertEquals( 2, dsrd.getExtensions().get( "X-TEST-b" ).size() );
-        assertEquals( "test2-1", dsrd.getExtensions().get( "X-TEST-b" ).get( 0 ) );
-        assertEquals( "test2-2", dsrd.getExtensions().get( "X-TEST-b" ).get( 1 ) );
+        assertEquals( 1234567890, ditStructureRule.getRuleId() );
+        assertEquals( 2, ditStructureRule.getNames().size() );
+        assertEquals( "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789",
ditStructureRule.getNames().get( 0 ) );
+        assertEquals( "test", ditStructureRule.getNames().get( 1 ) );
+        assertEquals( "Descripton \u00E4\u00F6\u00FC\u00DF \u90E8\u9577", ditStructureRule.getDescription()
);
+        assertTrue( ditStructureRule.isObsolete() );
+        assertEquals( "2.3.4.5.6.7.8.9.0.1", ditStructureRule.getForm() );
+        assertEquals( 3, ditStructureRule.getSuperRules().size() );
+        assertEquals( new Integer( 1 ), ditStructureRule.getSuperRules().get( 0 ) );
+        assertEquals( new Integer( 1234567890 ), ditStructureRule.getSuperRules().get( 1
) );
+        assertEquals( new Integer( 5 ), ditStructureRule.getSuperRules().get( 2 ) );
+        assertEquals( 2, ditStructureRule.getExtensions().size() );
+        assertNotNull( ditStructureRule.getExtensions().get( "X-TEST-a" ) );
+        assertEquals( 2, ditStructureRule.getExtensions().get( "X-TEST-a" ).size() );
+        assertEquals( "test1-1", ditStructureRule.getExtensions().get( "X-TEST-a" ).get(
0 ) );
+        assertEquals( "test1-2", ditStructureRule.getExtensions().get( "X-TEST-a" ).get(
1 ) );
+        assertNotNull( ditStructureRule.getExtensions().get( "X-TEST-b" ) );
+        assertEquals( 2, ditStructureRule.getExtensions().get( "X-TEST-b" ).size() );
+        assertEquals( "test2-1", ditStructureRule.getExtensions().get( "X-TEST-b" ).get(
0 ) );
+        assertEquals( "test2-2", ditStructureRule.getExtensions().get( "X-TEST-b" ).get(
1 ) );
     }
 
 
@@ -407,11 +407,11 @@
     public void testRequiredElements() throws ParseException
     {
         String value = null;
-        DITStructureRuleDescription dsrd = null;
+        DITStructureRule ditStructureRule = null;
 
         value = "( 1 FORM 1.1 )";
-        dsrd = parser.parseDITStructureRuleDescription( value );
-        assertNotNull( dsrd.getForm() );
+        ditStructureRule = parser.parseDITStructureRuleDescription( value );
+        assertNotNull( ditStructureRule.getForm() );
 
         value = "( 1 )";
         try



Mime
View raw message