db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r581000 - /db/ojb/trunk/src/xdoclet/test/xdoclet/modules/ojb/tests/InheritanceTests.java
Date Mon, 01 Oct 2007 16:07:39 GMT
Author: arminw
Date: Mon Oct  1 09:07:38 2007
New Revision: 581000

URL: http://svn.apache.org/viewvc?rev=581000&view=rev
Log:
add new test

Modified:
    db/ojb/trunk/src/xdoclet/test/xdoclet/modules/ojb/tests/InheritanceTests.java

Modified: db/ojb/trunk/src/xdoclet/test/xdoclet/modules/ojb/tests/InheritanceTests.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/xdoclet/test/xdoclet/modules/ojb/tests/InheritanceTests.java?rev=581000&r1=580999&r2=581000&view=diff
==============================================================================
--- db/ojb/trunk/src/xdoclet/test/xdoclet/modules/ojb/tests/InheritanceTests.java (original)
+++ db/ojb/trunk/src/xdoclet/test/xdoclet/modules/ojb/tests/InheritanceTests.java Mon Oct
 1 09:07:38 2007
@@ -19,8 +19,6 @@
  * under the License.
  */
 
-import java.lang.Object;
-
 /**
  * Inheritance tests.
  */
@@ -614,6 +612,246 @@
                 "        />\n" +
                 "    </table>\n" +
                 "</database>",
+            result);
+    }
+
+    /**
+     * Test: inherited autoincrement attribute with 'database' value and
+     * table per class inheritance via "extent" attribute in the super-class.
+     * Use an abstract base class for common fields.
+     * Expect autoincrement=true for all subclasses and
+     * the extent-class element must be declared and all
+     * the super-class fields must be declared in the sub-classes.
+     */
+    public void testTablePerClassAutoincrementDatabase_2()
+    {
+        addClass(
+            "test.Base",
+            "package test;\n"+
+            "/**  */\n"+
+            "public class Base {\n"+
+            "  /** @ojb.field primarykey=\"true\"\n"+
+            "    *            autoincrement=\"database\"\n"+
+            "    *            access=\"readonly\"\n"+
+            "    */\n"+
+            "  private int attr;\n"+
+            "  /** @ojb.field length=\"128\" */\n"+
+            "  private String nameBase;\n"+
+            "}\n");
+        addClass(
+            "test.A",
+            "package test;\n"+
+            "/** @ojb.class */\n"+
+            "public class A extends Base {\n"+
+            "  /** @ojb.field length=\"128\" */\n"+
+            "  private String nameA;\n"+
+            "}\n");
+        addClass(
+            "test.B",
+            "package test;\n"+
+            "/** @ojb.class\n"+
+            "  */\n"+
+            "public class B extends A {\n"+
+            "  /** @ojb.field length=\"128\" */\n"+
+            "  private String nameB;\n"+
+            "}\n");
+        addClass(
+            "test.C",
+            "package test;\n"+
+            "/** @ojb.class\n"+
+            "  */\n"+
+            "public class C extends B {\n"+
+            "  /** @ojb.field length=\"128\" */\n"+
+            "  private String nameC;\n"+
+            "}\n");
+        String result = runOjbXDoclet(OJB_DEST_FILE);
+        //System.out.println("##" + result);
+        assertEqualsOjbDescriptorFile(
+            "<class-descriptor\n" +
+            "    class=\"test.A\"\n" +
+            "    table=\"A\"\n" +
+            ">\n" +
+            "    <extent-class class-ref=\"test.B\"/>\n" +
+            "    <field-descriptor\n" +
+            "        name=\"attr\"\n" +
+            "        column=\"attr\"\n" +
+            "        jdbc-type=\"INTEGER\"\n" +
+            "        primarykey=\"true\"\n" +
+            "        autoincrement=\"true\"\n" +
+            "        access=\"readonly\"\n" +
+            "    >\n" +
+            "    </field-descriptor>\n" +
+            "    <field-descriptor\n" +
+            "        name=\"nameBase\"\n" +
+            "        column=\"nameBase\"\n" +
+            "        jdbc-type=\"VARCHAR\"\n" +
+            "        length=\"128\"\n" +
+            "    >\n" +
+            "    </field-descriptor>\n" +
+            "    <field-descriptor\n" +
+            "        name=\"nameA\"\n" +
+            "        column=\"nameA\"\n" +
+            "        jdbc-type=\"VARCHAR\"\n" +
+            "        length=\"128\"\n" +
+            "    >\n" +
+            "    </field-descriptor>\n" +
+            "</class-descriptor>\n" +
+            "<class-descriptor\n" +
+            "    class=\"test.B\"\n" +
+            "    table=\"B\"\n" +
+            ">\n" +
+            "    <extent-class class-ref=\"test.C\"/>\n" +
+            "    <field-descriptor\n" +
+            "        name=\"attr\"\n" +
+            "        column=\"attr\"\n" +
+            "        jdbc-type=\"INTEGER\"\n" +
+            "        primarykey=\"true\"\n" +
+            "        autoincrement=\"true\"\n" +
+            "        access=\"readonly\"\n" +
+            "    >\n" +
+            "    </field-descriptor>\n" +
+            "    <field-descriptor\n" +
+            "        name=\"nameBase\"\n" +
+            "        column=\"nameBase\"\n" +
+            "        jdbc-type=\"VARCHAR\"\n" +
+            "        length=\"128\"\n" +
+            "    >\n" +
+            "    </field-descriptor>\n" +
+            "    <field-descriptor\n" +
+            "        name=\"nameA\"\n" +
+            "        column=\"nameA\"\n" +
+            "        jdbc-type=\"VARCHAR\"\n" +
+            "        length=\"128\"\n" +
+            "    >\n" +
+            "    </field-descriptor>\n" +
+            "    <field-descriptor\n" +
+            "        name=\"nameB\"\n" +
+            "        column=\"nameB\"\n" +
+            "        jdbc-type=\"VARCHAR\"\n" +
+            "        length=\"128\"\n" +
+            "    >\n" +
+            "    </field-descriptor>\n" +
+            "</class-descriptor>\n" +
+            "<class-descriptor\n" +
+            "    class=\"test.C\"\n" +
+            "    table=\"C\"\n" +
+            ">\n" +
+            "    <field-descriptor\n" +
+            "        name=\"attr\"\n" +
+            "        column=\"attr\"\n" +
+            "        jdbc-type=\"INTEGER\"\n" +
+            "        primarykey=\"true\"\n" +
+            "        autoincrement=\"true\"\n" +
+            "        access=\"readonly\"\n" +
+            "    >\n" +
+            "    </field-descriptor>\n" +
+            "    <field-descriptor\n" +
+            "        name=\"nameBase\"\n" +
+            "        column=\"nameBase\"\n" +
+            "        jdbc-type=\"VARCHAR\"\n" +
+            "        length=\"128\"\n" +
+            "    >\n" +
+            "    </field-descriptor>\n" +
+            "    <field-descriptor\n" +
+            "        name=\"nameA\"\n" +
+            "        column=\"nameA\"\n" +
+            "        jdbc-type=\"VARCHAR\"\n" +
+            "        length=\"128\"\n" +
+            "    >\n" +
+            "    </field-descriptor>\n" +
+            "    <field-descriptor\n" +
+            "        name=\"nameB\"\n" +
+            "        column=\"nameB\"\n" +
+            "        jdbc-type=\"VARCHAR\"\n" +
+            "        length=\"128\"\n" +
+            "    >\n" +
+            "    </field-descriptor>\n" +
+            "    <field-descriptor\n" +
+            "        name=\"nameC\"\n" +
+            "        column=\"nameC\"\n" +
+            "        jdbc-type=\"VARCHAR\"\n" +
+            "        length=\"128\"\n" +
+            "    >\n" +
+            "    </field-descriptor>\n" +
+            "</class-descriptor>",
+            result);
+        result = runTorqueXDoclet(TORQUE_DEST_FILE, "ojbtest");
+        //System.out.println("##" + result);
+        assertEqualsTorqueSchemaFile(
+            "<database name=\"ojbtest\">\n" +
+            "    <table name=\"A\">\n" +
+            "        <column name=\"attr\"\n" +
+            "                javaName=\"attr\"\n" +
+            "                type=\"INTEGER\"\n" +
+            "                primaryKey=\"true\"\n" +
+            "                required=\"true\"\n" +
+            "                autoIncrement=\"true\"\n" +
+            "        />\n" +
+            "        <column name=\"nameBase\"\n" +
+            "                javaName=\"nameBase\"\n" +
+            "                type=\"VARCHAR\"\n" +
+            "                size=\"128\"\n" +
+            "        />\n" +
+            "        <column name=\"nameA\"\n" +
+            "                javaName=\"nameA\"\n" +
+            "                type=\"VARCHAR\"\n" +
+            "                size=\"128\"\n" +
+            "        />\n" +
+            "    </table>\n" +
+            "    <table name=\"B\">\n" +
+            "        <column name=\"attr\"\n" +
+            "                javaName=\"attr\"\n" +
+            "                type=\"INTEGER\"\n" +
+            "                primaryKey=\"true\"\n" +
+            "                required=\"true\"\n" +
+            "                autoIncrement=\"true\"\n" +
+            "        />\n" +
+            "        <column name=\"nameBase\"\n" +
+            "                javaName=\"nameBase\"\n" +
+            "                type=\"VARCHAR\"\n" +
+            "                size=\"128\"\n" +
+            "        />\n" +
+            "        <column name=\"nameA\"\n" +
+            "                javaName=\"nameA\"\n" +
+            "                type=\"VARCHAR\"\n" +
+            "                size=\"128\"\n" +
+            "        />\n" +
+            "        <column name=\"nameB\"\n" +
+            "                javaName=\"nameB\"\n" +
+            "                type=\"VARCHAR\"\n" +
+            "                size=\"128\"\n" +
+            "        />\n" +
+            "    </table>\n" +
+            "    <table name=\"C\">\n" +
+            "        <column name=\"attr\"\n" +
+            "                javaName=\"attr\"\n" +
+            "                type=\"INTEGER\"\n" +
+            "                primaryKey=\"true\"\n" +
+            "                required=\"true\"\n" +
+            "                autoIncrement=\"true\"\n" +
+            "        />\n" +
+            "        <column name=\"nameBase\"\n" +
+            "                javaName=\"nameBase\"\n" +
+            "                type=\"VARCHAR\"\n" +
+            "                size=\"128\"\n" +
+            "        />\n" +
+            "        <column name=\"nameA\"\n" +
+            "                javaName=\"nameA\"\n" +
+            "                type=\"VARCHAR\"\n" +
+            "                size=\"128\"\n" +
+            "        />\n" +
+            "        <column name=\"nameB\"\n" +
+            "                javaName=\"nameB\"\n" +
+            "                type=\"VARCHAR\"\n" +
+            "                size=\"128\"\n" +
+            "        />\n" +
+            "        <column name=\"nameC\"\n" +
+            "                javaName=\"nameC\"\n" +
+            "                type=\"VARCHAR\"\n" +
+            "                size=\"128\"\n" +
+            "        />\n" +
+            "    </table>\n" +
+            "</database>",
             result);
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message