You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/10/08 02:51:05 UTC

svn commit: rev 54037 - in incubator/directory/eve/trunk/backend/tools: . src/java/org/apache/eve/schema src/java/org/apache/eve/schema/config src/template src/test/org/apache/eve/tools/schema

Author: akarasulu
Date: Thu Oct  7 17:51:05 2004
New Revision: 54037

Added:
   incubator/directory/eve/trunk/backend/tools/src/java/org/apache/eve/schema/
   incubator/directory/eve/trunk/backend/tools/src/java/org/apache/eve/schema/config/
Modified:
   incubator/directory/eve/trunk/backend/tools/project.xml
   incubator/directory/eve/trunk/backend/tools/src/template/AttributeTypes.template
   incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypesTemplateTest.java
Log:
correcting issues with the template

Modified: incubator/directory/eve/trunk/backend/tools/project.xml
==============================================================================
--- incubator/directory/eve/trunk/backend/tools/project.xml	(original)
+++ incubator/directory/eve/trunk/backend/tools/project.xml	Thu Oct  7 17:51:05 2004
@@ -42,6 +42,12 @@
     </dependency>
 
     <dependency>
+      <groupId>incubator-directory</groupId>
+      <artifactId>eve-backend</artifactId>
+      <version>SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
       <groupId>velocity</groupId>
       <artifactId>velocity-dep</artifactId>
       <version>1.4</version>

Modified: incubator/directory/eve/trunk/backend/tools/src/template/AttributeTypes.template
==============================================================================
--- incubator/directory/eve/trunk/backend/tools/src/template/AttributeTypes.template	(original)
+++ incubator/directory/eve/trunk/backend/tools/src/template/AttributeTypes.template	Thu Oct  7 17:51:05 2004
@@ -14,20 +14,31 @@
  *   limitations under the License.
  *
  */
-package $PACKAGE$;
+package $package;
+
+
+import org.apache.ldap.common.schema.*;
+//import org.apache.eve.schema.config.*;
+
 
 /**
- * Document me.
+ * A configuration set of schema attributeType definations for the $schema
+ * schema.  This code has been automatically generated from velocity templates
+ * and the OpenLDAP syntax specified $schema.schema file.  This has been done
+ * to facilitate Eve<->OpenLDAP schema interoperability.
  *
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
- * @version $Rev$
+ * @version \$Rev\$
  */
-public class $SCHEMA$AttributeTypes implements AttributeTypeConfigSet
+public class $classname implements AttributeTypeConfigSet
 {
     /** the DN of the owner of the objects within this SyntaxConfigSet */
-    private static final String OWNER = "$OWNER$";
+    private static final String OWNER = "$owner";
     /** the logical schema the objects within this SyntaxConfigSet belong to */
-    private static final String SCHEMA = "$SCHEMA$";
+    private static final String SCHEMA = "$schema";
+
+
+    private String[] schemaDeps;
 
 
     // ------------------------------------------------------------------------
@@ -49,7 +60,18 @@
 
     public String[] getDependentSchemas()
     {
-        return EMPTY_ARRAY;
+        if ( schemaDeps == null )
+        {
+            schemaDeps = new String[$schemaDepCount];
+
+            #foreach ( $dep in $schemaDeps )
+            #set ( $ii = $velocityCount - 1 )
+schemaDeps[$ii] = "$dep";
+            #end
+
+        }
+
+        return schemaDeps;
     }
 
 
@@ -60,13 +82,22 @@
 
     public AttributeType[] load()
     {
-        AttributeType[] attributeTypes = new AttributeType[$COUNT$];
+        AttributeType[] attributeTypes = new AttributeType[$attrTypeCount];
 
-        $CODE$
+        #foreach ( $attrType in $attrTypes )
+        #set ( $ii = $velocityCount - 1 )
+attributeTypes[$ii] = new MutableAttributeType( "$attrType.getOid()" );
+        #end
 
         return attributeTypes;
     }
 
 
-
+    private static class MutableAttributeType extends BaseAttributeType
+    {
+        public MutableAttributeType( String oid )
+        {
+            super( oid );
+        }
+    }
 }

Modified: incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypesTemplateTest.java
==============================================================================
--- incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypesTemplateTest.java	(original)
+++ incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypesTemplateTest.java	Thu Oct  7 17:51:05 2004
@@ -19,8 +19,11 @@
 import junit.framework.TestCase;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.Velocity;
+import org.apache.ldap.common.schema.BaseAttributeType;
 
 import java.io.StringWriter;
+import java.io.FileReader;
+import java.io.FileWriter;
 
 
 /**
@@ -33,13 +36,36 @@
 {
     public void testGeneration() throws Exception
     {
+        TestAttributeType[] attributeTypes = new TestAttributeType[2];
+        attributeTypes[0] = new TestAttributeType( "1.1.1.1" );
+        attributeTypes[1] = new TestAttributeType( "1.1.1.2" );
+
         VelocityContext context = new VelocityContext();
-        context.put( "args", new String[] { "uno", "dos", "tres" } );
-        String template = "args = #foreach($arg in $args)$arg #end";
-        StringWriter writer = new StringWriter();
+        context.put( "package", "org.apache.eve.schema.config" );
+        context.put( "classname", "CoreAttributeTypes" );
+        context.put( "schema", "core" );
+        context.put( "owner", "uid=admin,ou=system" ) ;
+        context.put( "schemaDepCount", new Integer( 2 ) );
+        context.put( "schemaDeps", new String[] { "dep1", "dep2" }  ) ;
+        context.put( "attrTypeCount", new Integer( attributeTypes.length ) );
+        context.put( "attrTypes", attributeTypes );
+
+        FileReader template = new FileReader(
+            "c:\\projects\\home\\akarasulu\\projects\\directory\\eve\\trunk\\backend\\tools\\src\\template\\AttributeTypes.template" );
+        FileWriter writer = new FileWriter(
+            "c:\\projects\\home\\akarasulu\\projects\\directory\\eve\\trunk\\backend\\tools\\src\\java\\org\\apache\\eve\\schema\\config\\CoreAttributeTypes.java" );
         Velocity.init();
         Velocity.evaluate( context, writer, "LOG", template );
-        String generated = writer.getBuffer().toString();
-        assertEquals( "args = uno dos tres", generated.trim() );
+        writer.flush();
+        writer.close();
+    }
+
+
+    class TestAttributeType extends BaseAttributeType
+    {
+        protected TestAttributeType( String oid )
+        {
+            super( oid );
+        }
     }
 }