Author: akarasulu
Date: Sat Oct  9 01:14:54 2004
New Revision: 54153

Added:
   
incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypeParserTest.java
   (contents, props changed)
Modified:
   incubator/directory/eve/trunk/backend/tools/src/antlr/openldap.g
Log:
adding a temporary test case

Modified: incubator/directory/eve/trunk/backend/tools/src/antlr/openldap.g
==============================================================================
--- incubator/directory/eve/trunk/backend/tools/src/antlr/openldap.g    
(original)
+++ incubator/directory/eve/trunk/backend/tools/src/antlr/openldap.g    Sat Oct 
 9 01:14:54 2004
@@ -61,6 +61,9 @@
         {$setType(Token.SKIP);} //ignore this token
     ;
 
+QUOTE              : '\''
+    ;
+
 OPEN_PAREN         : '(' 
     ;
 
@@ -272,7 +275,7 @@
         type = new MutableAttributeType( oid.getText() );
     }
         ( names[type] )?
-        ( "DESC" "'" desc:IDENTIFIER { type.setDescription( desc.getText() ); 
} "'" )?
+        ( "DESC" QUOTE desc:IDENTIFIER { type.setDescription( desc.getText() 
); } QUOTE )?
         ( "OBSOLETE" { type.setObsolete( true ); } )?
         ( superior[type] )?
         ( equality[type] )?
@@ -364,25 +367,25 @@
     ArrayList list = new ArrayList();
 }
     :
-//    (
-        "NAME" "'" id0:IDENTIFIER "'"
+    (
+        "NAME" QUOTE id0:IDENTIFIER QUOTE
         {
             list.add( id0.getText() );
             registry.register( id0.getText(), type.getOid() );
-//        }
-//        |
-//        ( OPEN_PAREN "'" id1:IDENTIFIER
-//        {
-//            list.add( id1.getText() );
-//            registry.register( id1.getText(), type.getOid() );
-//        } "'"
-//        ( "'" id2:IDENTIFIER "'"
-//        {
-//            list.add( id2.getText() );
-//            registry.register( id2.getText(), type.getOid() );
-//        } )* CLOSE_PAREN )
-//    )
-//    {
+        }
+        |
+        ( OPEN_PAREN QUOTE id1:IDENTIFIER
+        {
+            list.add( id1.getText() );
+            registry.register( id1.getText(), type.getOid() );
+        } QUOTE
+        ( QUOTE id2:IDENTIFIER QUOTE
+        {
+            list.add( id2.getText() );
+            registry.register( id2.getText(), type.getOid() );
+        } )* CLOSE_PAREN )
+    )
+    {
         type.setAllNames( ( String[] ) list.toArray( EMPTY ) );
     }
     ;

Added: 
incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypeParserTest.java
==============================================================================
--- (empty file)
+++ 
incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypeParserTest.java
       Sat Oct  9 01:14:54 2004
@@ -0,0 +1,53 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.eve.tools.schema;
+
+import junit.framework.TestCase;
+
+import java.io.ByteArrayInputStream;
+
+import org.apache.ldap.common.schema.AttributeType;
+import org.apache.eve.schema.DefaultOidRegistry;
+
+/**
+ * Tests the parser for AttributeTypes.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class AttributeTypeParserTest extends TestCase
+{
+    public void testParser() throws Exception
+    {
+        String attributeTypeData = "attributetype ( 2.5.4.2 NAME 
'someIdentifier' )";
+        ByteArrayInputStream in = new ByteArrayInputStream( 
attributeTypeData.getBytes() );
+        antlrOpenLdapSchemaLexer lexer = new antlrOpenLdapSchemaLexer( in );
+        antlrOpenLdapSchemaParser parser = new antlrOpenLdapSchemaParser( 
lexer );
+        parser.setParserMonitor( new ParserMonitor()
+        {
+            public void matchedProduction( String prod )
+            {
+                System.out.println( prod );
+            }
+        });
+
+        DefaultOidRegistry registry = new DefaultOidRegistry();
+        registry.register( "caseIgnoreMatch", "1.1.1.1.1.1" );
+        parser.setOidRegistry( registry );
+        AttributeType type = parser.attributeType();
+    }
+}

Reply via email to