Index: test1742/JdoConfTest.java
===================================================================
RCS file: test1742/JdoConfTest.java
diff -N test1742/JdoConfTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test1742/JdoConfTest.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,205 @@
+package test1742;
+
+import junit.framework.TestCase;
+
+import org.exolab.castor.jdo.Database;
+import org.exolab.castor.jdo.JDO;
+import org.exolab.castor.jdo.OQLQuery;
+import org.exolab.castor.jdo.QueryResults;
+import org.exolab.castor.jdo.engine.DatabaseRegistry;
+
+public class JdoConfTest extends TestCase {
+ public JdoConfTest() { super("test1742"); }
+
+ public void setUp() throws Exception { super.setUp(); }
+
+ public void tearDown() throws Exception {
+ DatabaseRegistry.clear();
+
+ super.tearDown();
+ }
+
+ public void testLoadConfA() throws Exception {
+ JDO.loadConfiguration(getClass().getResource("jdo-conf-a.xml").toString());
+
+ JDO jdoA = new JDO("test-a");
+ Database dbA = jdoA.getDatabase();
+ dbA.begin();
+
+ OQLQuery oqlA = dbA.getOQLQuery(
+ "select p from " + Product.class.getName() + " p");
+ QueryResults resultsA = oqlA.execute();
+ resultsA.close();
+
+ dbA.commit();
+ dbA.close();
+
+ jdoA = null;
+ }
+
+ public void testLoadConfB() throws Exception {
+ JDO.loadConfiguration(getClass().getResource("jdo-conf-b.xml").toString());
+
+ JDO jdoB = new JDO("test-b");
+ Database dbB = jdoB.getDatabase();
+ dbB.begin();
+
+ OQLQuery oqlB = dbB.getOQLQuery(
+ "select p from " + Product.class.getName() + " p");
+ QueryResults resultsB = oqlB.execute();
+ resultsB.close();
+
+ dbB.commit();
+ dbB.close();
+
+ jdoB = null;
+ }
+
+ public void testLoadConfAB() throws Exception {
+ JDO.loadConfiguration(getClass().getResource("jdo-conf-ab.xml").toString());
+
+ JDO jdoA = new JDO("test-a");
+ Database dbA = jdoA.getDatabase();
+ dbA.begin();
+
+ OQLQuery oqlA = dbA.getOQLQuery(
+ "select p from " + Product.class.getName() + " p");
+ QueryResults resultsA = oqlA.execute();
+ resultsA.close();
+
+ dbA.commit();
+ dbA.close();
+
+ jdoA = null;
+
+ JDO jdoB = new JDO("test-b");
+ Database dbB = jdoB.getDatabase();
+ dbB.begin();
+
+ OQLQuery oqlB = dbB.getOQLQuery(
+ "select p from " + Product.class.getName() + " p");
+ QueryResults resultsB = oqlB.execute();
+ resultsB.close();
+
+ dbB.commit();
+ dbB.close();
+
+ jdoB = null;
+ }
+
+ public void testLoadConfAandB() throws Exception {
+ // Load configuration for A first followed by B.
+ // Why should this behave different as loading A and B
+ // from one configuration containing both?
+ JDO.loadConfiguration(getClass().getResource("jdo-conf-a.xml").toString());
+ JDO.loadConfiguration(getClass().getResource("jdo-conf-b.xml").toString());
+
+ JDO jdoA = new JDO("test-a");
+ Database dbA = jdoA.getDatabase();
+ dbA.begin();
+
+ OQLQuery oqlA = dbA.getOQLQuery(
+ "select p from " + Product.class.getName() + " p");
+ QueryResults resultsA = oqlA.execute();
+ resultsA.close();
+
+ dbA.commit();
+ dbA.close();
+
+ jdoA = null;
+
+ JDO jdoB = new JDO("test-b");
+ Database dbB = jdoB.getDatabase();
+ dbB.begin();
+
+ OQLQuery oqlB = dbB.getOQLQuery(
+ "select p from " + Product.class.getName() + " p");
+ QueryResults resultsB = oqlB.execute();
+ resultsB.close();
+
+ dbB.commit();
+ dbB.close();
+
+ jdoB = null;
+ }
+
+ public void testLoadConfBandAB() throws Exception {
+ // Load configuration for B first followed by a configuration
+ // containing A and B. This means B is loaded twice.
+ // What shell we do with the second configuration containg A and B?
+ // Ignore it completely, only ignore second configuration of B or
+ // or replace the first configuration of B with the second one.
+ JDO.loadConfiguration(getClass().getResource("jdo-conf-b.xml").toString());
+ JDO.loadConfiguration(getClass().getResource("jdo-conf-ab.xml").toString());
+
+ JDO jdoA = new JDO("test-a");
+ Database dbA = jdoA.getDatabase();
+ dbA.begin();
+
+ OQLQuery oqlA = dbA.getOQLQuery(
+ "select p from " + Product.class.getName() + " p");
+ QueryResults resultsA = oqlA.execute();
+ resultsA.close();
+
+ dbA.commit();
+ dbA.close();
+
+ jdoA = null;
+
+ JDO jdoB = new JDO("test-b");
+ Database dbB = jdoB.getDatabase();
+ dbB.begin();
+
+ OQLQuery oqlB = dbB.getOQLQuery(
+ "select p from " + Product.class.getName() + " p");
+ QueryResults resultsB = oqlB.execute();
+ resultsB.close();
+
+ dbB.commit();
+ dbB.close();
+
+ jdoB = null;
+ }
+
+ public void testConfABandA() throws Exception {
+ JDO jdoA = new JDO();
+ jdoA.setDatabaseName("test-a");
+ jdoA.setConfiguration(getClass().getResource("jdo-conf-ab.xml").toString());
+ jdoA.setClassLoader(getClass().getClassLoader());
+
+ // Configurations A and B are loaded here.
+ Database dbA = jdoA.getDatabase();
+ dbA.begin();
+
+ OQLQuery oqlA = dbA.getOQLQuery(
+ "select p from " + Product.class.getName() + " p");
+ QueryResults resultsA = oqlA.execute();
+ resultsA.close();
+
+ dbA.commit();
+ dbA.close();
+
+ jdoA = null;
+
+ // That's really strange. We want a B and we get a B but the configuration
+ // only contains a A. It uses the B from the AB configuration above.
+ JDO jdoB = new JDO();
+ jdoB.setDatabaseName("test-b");
+ jdoB.setConfiguration(getClass().getResource("jdo-conf-a.xml").toString());
+ jdoB.setClassLoader(getClass().getClassLoader());
+
+ // Second configuration is always ignored as one had been loaded above.
+ Database dbB = jdoB.getDatabase();
+ dbB.begin();
+
+ OQLQuery oqlB = dbB.getOQLQuery(
+ "select p from " + Product.class.getName() + " p");
+ QueryResults resultsB = oqlB.execute();
+ resultsB.close();
+
+ dbB.commit();
+ dbB.close();
+
+ jdoB = null;
+ }
+}
Index: test1742/Product.java
===================================================================
RCS file: test1742/Product.java
diff -N test1742/Product.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test1742/Product.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,12 @@
+package test1742;
+
+public class Product {
+ private int _id;
+ private String _name;
+
+ public int getId() { return _id; }
+ public void setId(int id) { _id = id; }
+
+ public String getName() { return _name; }
+ public void setName(String name) { _name = name; }
+}
Index: test1742/jdo-conf-a.xml
===================================================================
RCS file: test1742/jdo-conf-a.xml
diff -N test1742/jdo-conf-a.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test1742/jdo-conf-a.xml 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: test1742/jdo-conf-ab.xml
===================================================================
RCS file: test1742/jdo-conf-ab.xml
diff -N test1742/jdo-conf-ab.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test1742/jdo-conf-ab.xml 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: test1742/jdo-conf-b.xml
===================================================================
RCS file: test1742/jdo-conf-b.xml
diff -N test1742/jdo-conf-b.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test1742/jdo-conf-b.xml 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: test1742/mapping.xml
===================================================================
RCS file: test1742/mapping.xml
diff -N test1742/mapping.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test1742/mapping.xml 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+