db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject [db-jdo] 15/43: JDO-369 Completeness test doesn't clean up instances of persistent interfaces
Date Fri, 07 May 2021 23:11:57 GMT
This is an automated email from the ASF dual-hosted git repository.

clr pushed a commit to branch origin/2.0.1
in repository https://gitbox.apache.org/repos/asf/db-jdo.git

commit c0a57a740c13f5dcb22dcb278e1e3cd4b531f15c
Author: Michael Bouschen <mbo@apache.org>
AuthorDate: Thu Apr 20 11:51:36 2006 +0000

    JDO-369 Completeness test doesn't clean up instances of persistent interfaces
---
 .../apache/jdo/tck/mapping/CompletenessTest.java   | 13 ++++----
 .../apache/jdo/tck/pc/company/CompanyFactory.java  |  1 +
 .../pc/company/CompanyFactoryConcreteClass.java    | 12 ++++++++
 .../jdo/tck/pc/company/CompanyFactoryPMClass.java  | 11 +++++++
 .../tck/pc/company/CompanyFactoryPMInterface.java  | 11 +++++++
 .../jdo/tck/pc/company/CompanyModelReader.java     | 35 ++++++++--------------
 .../apache/jdo/tck/pc/company/package-standard.orm | 18 +++++++++++
 .../apache/jdo/tck/pc/company/package-standard.orm | 18 +++++++++++
 tck20/src/sql/derby/applicationidentity/schema.sql |  3 ++
 tck20/src/sql/derby/datastoreidentity/schema.sql   |  3 ++
 10 files changed, 97 insertions(+), 28 deletions(-)

diff --git a/tck20/src/java/org/apache/jdo/tck/mapping/CompletenessTest.java b/tck20/src/java/org/apache/jdo/tck/mapping/CompletenessTest.java
index cb01de4..de9d90f 100644
--- a/tck20/src/java/org/apache/jdo/tck/mapping/CompletenessTest.java
+++ b/tck20/src/java/org/apache/jdo/tck/mapping/CompletenessTest.java
@@ -47,6 +47,9 @@ public class CompletenessTest extends JDO_Test {
     
     /** */
     private final boolean isTestToBePerformed = isTestToBePerformed();
+
+    /** */
+    private CompanyModelReader reader;
     
     /** */
     protected List rootOids;
@@ -68,7 +71,11 @@ public class CompletenessTest extends JDO_Test {
      */
     protected void localSetUp() {
         if (isTestToBePerformed) {
-            addTearDownClass(CompanyModelReader.getTearDownClasses());
+            // register the default factory
+            CompanyFactoryRegistry.registerFactory();
+            // get new obj graph to compare persistent graph with
+            reader = new CompanyModelReader(inputFilename);
+            addTearDownClass(reader.getTearDownClassesFromFactory());
             getPM();
             CompanyFactoryRegistry.registerFactory(pm);
             CompanyModelReader reader = new CompanyModelReader(inputFilename);
@@ -89,10 +96,6 @@ public class CompletenessTest extends JDO_Test {
     /** */
     public void test() {
         if (isTestToBePerformed) {
-            // register the default factory
-            CompanyFactoryRegistry.registerFactory();
-            // get new obj graph to compare persistent graph with
-            CompanyModelReader reader = new CompanyModelReader(inputFilename);
             List rootList = reader.getRootList();
             
             getPM();
diff --git a/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactory.java b/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactory.java
index 7009cd0..9f01799 100644
--- a/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactory.java
+++ b/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactory.java
@@ -63,4 +63,5 @@ public interface CompanyFactory {
             String first, String last, String middle,
             Date born, IAddress addr, Date hired, double wage); 
     IProject newProject(long projid, String name, BigDecimal budget);
+    Class[] getTearDownClasses();
 }
diff --git a/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactoryConcreteClass.java
b/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactoryConcreteClass.java
index e077b9c..61f06c6 100644
--- a/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactoryConcreteClass.java
+++ b/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactoryConcreteClass.java
@@ -28,6 +28,14 @@ import javax.jdo.PersistenceManager;
  */
 public  class CompanyFactoryConcreteClass implements CompanyFactory {
 
+    /** */
+    public static final Class[] tearDownClasses = new Class[] {
+        DentalInsurance.class, MedicalInsurance.class,
+        Person.class, Employee.class, 
+        PartTimeEmployee.class, FullTimeEmployee.class,  
+        Project.class, Department.class, Company.class
+    };
+
     public CompanyFactoryConcreteClass(PersistenceManager pm) {
     }
 
@@ -131,4 +139,8 @@ public  class CompanyFactoryConcreteClass implements CompanyFactory {
             BigDecimal budget) {
         return new Project(projid, name, budget);
     }
+
+    public Class[] getTearDownClasses() {
+        return tearDownClasses;
+    }
 }
diff --git a/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMClass.java b/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMClass.java
index 632933c..a54113e 100644
--- a/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMClass.java
+++ b/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMClass.java
@@ -27,6 +27,14 @@ import javax.jdo.PersistenceManager;
 public class CompanyFactoryPMClass 
         extends CompanyFactoryAbstractImpl {
     
+    /** */
+    public static final Class[] tearDownClasses = new Class[] {
+        DentalInsurance.class, IMedicalInsurance.class,
+        Person.class, Employee.class, 
+        PartTimeEmployee.class, FullTimeEmployee.class,  
+        Project.class, Department.class, Company.class
+    };
+
     /**
      * Creates a new instance of CompanyFactoryPMInterface 
      */
@@ -66,4 +74,7 @@ public class CompanyFactoryPMClass
         return (IProject)pm.newInstance(Project.class);
     }
 
+    public Class[] getTearDownClasses() {
+        return tearDownClasses;
+    }
 }
diff --git a/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMInterface.java b/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMInterface.java
index 7de5d58..ba4067c 100644
--- a/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMInterface.java
+++ b/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMInterface.java
@@ -27,6 +27,14 @@ import javax.jdo.PersistenceManager;
 public class CompanyFactoryPMInterface 
         extends CompanyFactoryAbstractImpl {
     
+    /** */
+    public static final Class[] tearDownClasses = new Class[] {
+        IDentalInsurance.class, IMedicalInsurance.class,
+        IPerson.class, IEmployee.class, 
+        IPartTimeEmployee.class, IFullTimeEmployee.class,  
+        IProject.class, IDepartment.class, ICompany.class
+    };
+
     /**
      * Creates a new instance of CompanyFactoryPMInterface 
      */
@@ -66,4 +74,7 @@ public class CompanyFactoryPMInterface
         return (IProject)pm.newInstance(IProject.class);
     }
 
+    public Class[] getTearDownClasses() {
+        return tearDownClasses;
+    }
 }
diff --git a/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java b/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java
index fe01d2d..1780614 100644
--- a/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java
+++ b/tck20/src/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java
@@ -47,24 +47,9 @@ public class CompanyModelReader extends XmlBeanFactory {
      */
     public static final String BEAN_FACTORY_NAME = "companyFactory";
 
-    /** All classes in the model 
-     */
-    private static final Class[] allClasses = new Class[] {
-        Address.class, Company.class, 
-        DentalInsurance.class, Department.class, Employee.class,
-        FullTimeEmployee.class, Insurance.class, 
-        MedicalInsurance.class, PartTimeEmployee.class, Person.class, 
-        Project.class
-    };
-    
-    /** All classes in the model 
-     */
-    private static final Class[] tearDownClasses = new Class[] {
-        DentalInsurance.class, MedicalInsurance.class,
-        Person.class, Employee.class, PartTimeEmployee.class, FullTimeEmployee.class,  
-        Project.class, Department.class, Company.class
-    };
-    
+    /** The company factory instance. */
+    private CompanyFactory companyFactory;
+
     /** 
      * Create a CompanyModelReader for the specified resourceName. 
      * @param resourceName the name of the resource
@@ -112,7 +97,8 @@ public class CompanyModelReader extends XmlBeanFactory {
         CustomDateEditor dateEditor = 
             new CustomDateEditor(formatter, true);
         registerCustomEditor(Date.class, dateEditor);
-        addSingleton(BEAN_FACTORY_NAME, CompanyFactoryRegistry.getInstance());
+        companyFactory = CompanyFactoryRegistry.getInstance();
+        addSingleton(BEAN_FACTORY_NAME, companyFactory);
     }
     
     // Convenience methods
@@ -249,17 +235,20 @@ public class CompanyModelReader extends XmlBeanFactory {
         return (Project)getBean(name, Project.class);
     }
     
-    public static Class[] getAllClasses() {
-        return allClasses;
+    /**
+     * @return Returns the tearDownClasses.
+     */
+    public Class[] getTearDownClassesFromFactory() {
+        return companyFactory.getTearDownClasses();
     }
     
     /**
      * @return Returns the tearDownClasses.
      */
     public static Class[] getTearDownClasses() {
-        return tearDownClasses;
+        return CompanyFactoryConcreteClass.tearDownClasses;
     }
-    
+
     public static Date stringToUtilDate(String value) {
         return ConversionHelper.toUtilDate(DATE_PATTERN, "America/New_York", Locale.US, value);
     }
diff --git a/tck20/src/orm/applicationidentity/org/apache/jdo/tck/pc/company/package-standard.orm
b/tck20/src/orm/applicationidentity/org/apache/jdo/tck/pc/company/package-standard.orm
index 86f0a82..02838de 100644
--- a/tck20/src/orm/applicationidentity/org/apache/jdo/tck/pc/company/package-standard.orm
+++ b/tck20/src/orm/applicationidentity/org/apache/jdo/tck/pc/company/package-standard.orm
@@ -10,6 +10,9 @@ has application identity.
     <package name="org.apache.jdo.tck.pc.company">
 
         <class name="Company" table="companies">
+            <inheritance strategy="new-table">
+                <discriminator strategy="class-name" column="DISCRIMINATOR"/>
+            </inheritance>
             <field name="companyid" column="ID"/>
             <field name="name" column="NAME">
               <column name="NAME" sql-type="VARCHAR"/>
@@ -29,6 +32,9 @@ has application identity.
         </class>
 
         <class name="Department" table="departments">
+            <inheritance strategy="new-table">
+                <discriminator strategy="class-name" column="DISCRIMINATOR"/>
+            </inheritance>
             <field name="deptid" column="ID"/>
             <field name="name" column="NAME"/>
             <field name="company" column="COMPANYID"/>
@@ -144,6 +150,9 @@ has application identity.
         </class>
 
         <class name="Project" table="projects">
+            <inheritance strategy="new-table">
+                <discriminator strategy="class-name" column="DISCRIMINATOR"/>
+            </inheritance>
             <field name="projid" column="PROJID"/>
             <field name="name" column="NAME"/>
             <field name="budget">
@@ -164,6 +173,9 @@ has application identity.
         </class>
 
         <interface name="ICompany" table="companies">
+            <inheritance strategy="new-table">
+                <discriminator strategy="class-name" column="DISCRIMINATOR"/>
+            </inheritance>
             <property name="companyid" column="ID"/>
             <property name="name" column="NAME">
               <column name="NAME" sql-type="VARCHAR"/>
@@ -183,6 +195,9 @@ has application identity.
         </interface>
 
         <interface name="IDepartment" table="departments">
+            <inheritance strategy="new-table">
+                <discriminator strategy="class-name" column="DISCRIMINATOR"/>
+            </inheritance>
             <property name="deptid" column="ID"/>
             <property name="name" column="NAME"/>
             <property name="company" column="COMPANYID"/>
@@ -298,6 +313,9 @@ has application identity.
         </interface>
 
         <interface name="IProject" table="projects">
+            <inheritance strategy="new-table">
+                <discriminator strategy="class-name" column="DISCRIMINATOR"/>
+            </inheritance>
             <property name="projid" column="PROJID"/>
             <property name="name" column="NAME"/>
             <property name="budget">
diff --git a/tck20/src/orm/datastoreidentity/org/apache/jdo/tck/pc/company/package-standard.orm
b/tck20/src/orm/datastoreidentity/org/apache/jdo/tck/pc/company/package-standard.orm
index 3a22898..2f5b888 100644
--- a/tck20/src/orm/datastoreidentity/org/apache/jdo/tck/pc/company/package-standard.orm
+++ b/tck20/src/orm/datastoreidentity/org/apache/jdo/tck/pc/company/package-standard.orm
@@ -11,6 +11,9 @@ has datastore identity.
 
         <class name="Company" table="companies">
             <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+            <inheritance strategy="new-table">
+                <discriminator strategy="class-name" column="DISCRIMINATOR"/>
+            </inheritance>
             <field name="companyid" column="ID"/>
             <field name="name" column="NAME">
               <column name="NAME" sql-type="VARCHAR"/>
@@ -43,6 +46,9 @@ has datastore identity.
 
         <class name="Department" table="departments">
             <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+            <inheritance strategy="new-table">
+                <discriminator strategy="class-name" column="DISCRIMINATOR"/>
+            </inheritance>
             <field name="deptid" column="ID"/>
             <field name="name" column="NAME"/>
             <field name="company" column="COMPANYID"/>
@@ -149,6 +155,9 @@ has datastore identity.
 
         <class name="Project" table="projects">
             <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+            <inheritance strategy="new-table">
+                <discriminator strategy="class-name" column="DISCRIMINATOR"/>
+            </inheritance>
             <field name="projid" column="PROJID"/>
             <field name="name" column="NAME"/>
             <field name="budget">
@@ -168,6 +177,9 @@ has datastore identity.
 
         <interface name="ICompany" table="companies">
             <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+            <inheritance strategy="new-table">
+                <discriminator strategy="class-name" column="DISCRIMINATOR"/>
+            </inheritance>
             <property name="companyid" column="ID"/>
             <property name="name" column="NAME">
               <column name="NAME" sql-type="VARCHAR"/>
@@ -188,6 +200,9 @@ has datastore identity.
 
         <interface name="IDepartment" table="departments">
             <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+            <inheritance strategy="new-table">
+                <discriminator strategy="class-name" column="DISCRIMINATOR"/>
+            </inheritance>
             <property name="deptid" column="ID"/>
             <property name="name" column="NAME"/>
             <property name="company" column="COMPANYID"/>
@@ -306,6 +321,9 @@ has datastore identity.
 
         <interface name="IProject" table="projects">
             <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+            <inheritance strategy="new-table">
+                <discriminator strategy="class-name" column="DISCRIMINATOR"/>
+            </inheritance>
             <property name="projid" column="PROJID"/>
             <property name="name" column="NAME"/>
             <property name="budget">
diff --git a/tck20/src/sql/derby/applicationidentity/schema.sql b/tck20/src/sql/derby/applicationidentity/schema.sql
index f075c68..5be13c8 100644
--- a/tck20/src/sql/derby/applicationidentity/schema.sql
+++ b/tck20/src/sql/derby/applicationidentity/schema.sql
@@ -182,6 +182,7 @@ CREATE TABLE companies (
     STATE CHAR(2),
     ZIPCODE CHAR(5),
     COUNTRY VARCHAR(64),
+    DISCRIMINATOR VARCHAR(255),
     CONSTRAINT COMPS_PK PRIMARY KEY (ID)
 );
 
@@ -190,6 +191,7 @@ CREATE TABLE departments (
     NAME VARCHAR(32) NOT NULL,
     EMP_OF_THE_MONTH INTEGER,
     COMPANYID INTEGER REFERENCES companies,
+    DISCRIMINATOR VARCHAR(255),
     CONSTRAINT DEPTS_PK PRIMARY KEY (ID)
 );
 
@@ -232,6 +234,7 @@ CREATE TABLE projects (
     PROJID INTEGER NOT NULL,
     NAME VARCHAR(32) NOT NULL,
     BUDGET DECIMAL(11,2) NOT NULL,
+    DISCRIMINATOR VARCHAR(255),
     CONSTRAINT PROJS_PK PRIMARY KEY (PROJID)
 );
 
diff --git a/tck20/src/sql/derby/datastoreidentity/schema.sql b/tck20/src/sql/derby/datastoreidentity/schema.sql
index adbaa09..bdc376a 100644
--- a/tck20/src/sql/derby/datastoreidentity/schema.sql
+++ b/tck20/src/sql/derby/datastoreidentity/schema.sql
@@ -130,6 +130,7 @@ CREATE TABLE companies (
     STATE CHAR(2),
     ZIPCODE CHAR(5),
     COUNTRY VARCHAR(64),
+    DISCRIMINATOR VARCHAR(255),
     CONSTRAINT COMPS_PK PRIMARY KEY (DATASTORE_IDENTITY)
 );
 
@@ -139,6 +140,7 @@ CREATE TABLE departments (
     NAME VARCHAR(32) NOT NULL,
     EMP_OF_THE_MONTH INTEGER,
     COMPANYID INTEGER REFERENCES companies,
+    DISCRIMINATOR VARCHAR(255),
     CONSTRAINT DEPTS_PK PRIMARY KEY (DATASTORE_IDENTITY)
 );
 
@@ -185,6 +187,7 @@ CREATE TABLE projects (
     PROJID INTEGER NOT NULL,
     NAME VARCHAR(32) NOT NULL,
     BUDGET DECIMAL(11,2) NOT NULL,
+    DISCRIMINATOR VARCHAR(255),
     CONSTRAINT PROJS_UK UNIQUE (PROJID),
     CONSTRAINT PROJS_PK PRIMARY KEY (DATASTORE_IDENTITY)
 );

Mime
View raw message