tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwilli...@apache.org
Subject svn commit: r441239 - in /incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test: ./ data/ framework/ suites/
Date Thu, 07 Sep 2006 21:44:48 GMT
Author: kwilliams
Date: Thu Sep  7 14:44:47 2006
New Revision: 441239

URL: http://svn.apache.org/viewvc?view=rev&rev=441239
Log:
Adding Kennel schema for more comlex testing

Added:
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/KennelTests.java   (with props)
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/DogData.java   (with props)
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/KennelData.java   (with props)
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/OwnerData.java   (with props)
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/OwnerDogData.java   (with props)
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/VisitData.java   (with props)
Modified:
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ImpliedRelationshipTests.java
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/TypesData.java
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DatabaseSetup.java
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/TestData.java
    incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/suites/AllCommonTests.java

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ImpliedRelationshipTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ImpliedRelationshipTests.java?view=diff&rev=441239&r1=441238&r2=441239
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ImpliedRelationshipTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ImpliedRelationshipTests.java Thu Sep  7 14:44:47 2006
@@ -14,78 +14,77 @@
 import commonj.sdo.Property;
 
 public class ImpliedRelationshipTests extends DasTest {
-	protected void setUp() throws Exception {
-		super.setUp();
+    protected void setUp() throws Exception {
+        super.setUp();
 
-		new CustomerData(getAutoConnection()).refresh();
-		new OrderData(getAutoConnection()).refresh();
-	}
-
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
-
-	/**
-	 * Ensure that an implied relationship is not created when a defined one already exists
-	 * @throws Exception
-	 */
-	public void testRelationshipAlreadyDefined() throws Exception {
-		ConfigHelper helper = new ConfigHelper();
-		Relationship r = helper.addRelationship("CUSTOMER.ID", "ANORDER.CUSTOMER_ID");
-		r.setName("definedRelationship");
-		
-		DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
-		Command select = das.createCommand("select * from CUSTOMER left join ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID");
-		
-		DataObject root = select.executeQuery();
-		DataObject cust = root.getDataObject("CUSTOMER[1]");
-		Iterator i = cust.getType().getProperties().iterator();
-		while ( i.hasNext()) {
-			Property p = (Property)i.next();
-			if ( !p.getType().isDataType() ) 
-				assertEquals(p.getName(), "definedRelationship");			
-		}
-	}
-	
-	/**
-	 * Add a new Order to a list of Customers without defining any config information
-	 * @throws Exception
-	 */
-	public void testAddNewOrder() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-
-		Command select = das
-				.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID");
-
-		DataObject root = select.executeQuery();
-
-		DataObject cust = root.getDataObject("CUSTOMER[1]");
-
-		// Save ID and Order Count
-		int custID = cust.getInt("ID");
-		int custOrderCount = cust.getList("ANORDER").size();
-
-		// Create a new Order and add to customer1
-		DataObject order = root.createDataObject("ANORDER");
-
-		order.set("ID", new Integer(99));
-		order.set("PRODUCT", "The 99th product");
-		order.set("QUANTITY", new Integer(99));
-		cust.getList("ANORDER").add(order);
-
-		assertEquals(custOrderCount + 1, cust.getList("ANORDER").size());
-
-		// Build apply changes command
-		das.applyChanges(root);
-
-		// verify cust1 relationship updates
-		select = das
-				.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?");
-
-		select.setParameter(1, new Integer(custID));
-		root = select.executeQuery();
-
-		assertEquals(custOrderCount + 1, root.getList("CUSTOMER[1]/ANORDER")
-				.size());
-	}
+        new CustomerData(getAutoConnection()).refresh();
+        new OrderData(getAutoConnection()).refresh();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /**
+     * Ensure that an implied relationship is not created when a defined one already exists
+     * 
+     * @throws Exception
+     */
+    public void testRelationshipAlreadyDefined() throws Exception {
+        ConfigHelper helper = new ConfigHelper();
+        Relationship r = helper.addRelationship("CUSTOMER.ID", "ANORDER.CUSTOMER_ID");
+        r.setName("definedRelationship");
+
+        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
+        Command select = das.createCommand("select * from CUSTOMER left join ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID");
+
+        DataObject root = select.executeQuery();
+        DataObject cust = root.getDataObject("CUSTOMER[1]");
+        Iterator i = cust.getType().getProperties().iterator();
+        while (i.hasNext()) {
+            Property p = (Property) i.next();
+            if (!p.getType().isDataType())
+                assertEquals(p.getName(), "definedRelationship");
+        }
+    }
+
+    /**
+     * Add a new Order to a list of Customers without defining any config information
+     * 
+     * @throws Exception
+     */
+    public void testAddNewOrder() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+
+        Command select = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID");
+
+        DataObject root = select.executeQuery();
+
+        DataObject cust = root.getDataObject("CUSTOMER[1]");
+
+        // Save ID and Order Count
+        int custID = cust.getInt("ID");
+        int custOrderCount = cust.getList("ANORDER").size();
+
+        // Create a new Order and add to customer1
+        DataObject order = root.createDataObject("ANORDER");
+
+        order.set("ID", new Integer(99));
+        order.set("PRODUCT", "The 99th product");
+        order.set("QUANTITY", new Integer(99));
+        cust.getList("ANORDER").add(order);
+
+        assertEquals(custOrderCount + 1, cust.getList("ANORDER").size());
+
+        // Build apply changes command
+        das.applyChanges(root);
+
+        // verify cust1 relationship updates
+        select = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?");
+
+        select.setParameter(1, new Integer(custID));
+        root = select.executeQuery();
+
+        assertEquals(custOrderCount + 1, root.getList("CUSTOMER[1]/ANORDER").size());
+    }
 }

Added: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/KennelTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/KennelTests.java?view=auto&rev=441239
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/KennelTests.java (added)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/KennelTests.java Thu Sep  7 14:44:47 2006
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tuscany.das.rdb.test;
+
+import java.sql.Timestamp;
+
+import org.apache.tuscany.das.rdb.Command;
+import org.apache.tuscany.das.rdb.DAS;
+import org.apache.tuscany.das.rdb.test.data.DogData;
+import org.apache.tuscany.das.rdb.test.data.KennelData;
+import org.apache.tuscany.das.rdb.test.data.OwnerData;
+import org.apache.tuscany.das.rdb.test.data.OwnerDogData;
+import org.apache.tuscany.das.rdb.test.data.TypesData;
+import org.apache.tuscany.das.rdb.test.data.VisitData;
+import org.apache.tuscany.das.rdb.test.framework.DasTest;
+import org.apache.tuscany.das.rdb.test.framework.TestData;
+
+import commonj.sdo.DataObject;
+
+public class KennelTests extends DasTest {
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        new DogData(getAutoConnection()).refresh();
+        new OwnerData(getAutoConnection()).refresh();
+        new OwnerDogData(getAutoConnection()).refresh();
+        new KennelData(getAutoConnection()).refresh();
+        new VisitData(getAutoConnection()).refresh();
+                
+
+    }
+
+    public void testSimple() throws Exception {
+
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+
+        // Build the select command
+        Command selectCommand = das.createCommand("select * from DOG");
+
+        // Get the graph
+        DataObject root = selectCommand.executeQuery();
+
+        assertEquals(3, root.getList("DOG").size());
+
+    }
+    
+    public void testSimple2() throws Exception {
+
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+
+        // Build the select command
+        Command selectCommand = das.createCommand("select * from OWNER");
+
+        // Get the graph
+        DataObject root = selectCommand.executeQuery();
+
+        assertEquals(3, root.getList("OWNER").size());
+
+    }
+    
+    public void testSimple3() throws Exception {
+
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+
+        // Build the select command
+        Command selectCommand = das.createCommand("select * from OWNER, DOG where DOG.OWNER_ID = OWNER.ID and OWNER.NAME = 'Fanny'");
+
+        // Get the graph
+        DataObject root = selectCommand.executeQuery();
+        
+        //Get Fanny
+        DataObject fanny = root.getDataObject("OWNER[1]");
+        assertEquals("Fido", fanny.getString("DOG[1]/NAME"));
+
+    }
+
+    public void testSimple4() throws Exception {
+
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+
+        // Build the select command
+        Command selectCommand = das.createCommand("select * from KENNEL");
+
+        // Get the graph
+        DataObject root = selectCommand.executeQuery();
+        
+        assertEquals(3, root.getList("KENNEL").size());
+ 
+    }
+    
+    public void testSimple5() throws Exception {
+
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+
+        // Build the select command
+        Command selectCommand = das.createCommand("select * from VISIT");
+
+        // Get the graph
+        DataObject root = selectCommand.executeQuery();
+        
+        assertEquals(3, root.getList("VISIT").size());
+        assertEquals(TestData.getTimestamp("2006-10-20 00:00:00.0"), (Timestamp)root.get("VISIT[1]/CHECK_IN"));
+ 
+    }
+
+}

Propchange: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/KennelTests.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/KennelTests.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/DogData.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/DogData.java?view=auto&rev=441239
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/DogData.java (added)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/DogData.java Thu Sep  7 14:44:47 2006
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tuscany.das.rdb.test.data;
+
+import java.sql.Connection;
+import java.sql.Types;
+
+import org.apache.tuscany.das.rdb.test.framework.TestDataWithExplicitColumns;
+
+
+public class DogData extends TestDataWithExplicitColumns {
+
+/*    CREATE TABLE DOG (
+            ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+            OWNER_ID INTEGER UNSIGNED NOT NULL,
+            NAME VARCHAR(20) NOT NULL,
+            BREED VARCHAR(20) NULL,
+            OCC_COUNT INTEGER UNSIGNED NULL,
+            PRIMARY KEY(ID),
+          );*/
+    
+	//id and owner_id omitted.  id is auto-generated. owner_id is filled in by DogOwner data
+    private static int[] columnTypes = {Types.VARCHAR, Types.VARCHAR, Types.INTEGER}; 
+	
+	private static Object[][] data = { 
+            { "Fido", "Mutt", new Integer(1) },
+			{ "Max", "German Shepherd", new Integer(1) },
+			{ "Saddie", "Collie", new Integer(1)} };
+
+	private static String[] columns = { "NAME", "BREED", "OCC_COUNT" };
+
+	public DogData(Connection connection) {
+		super(connection, data, columns, columnTypes);
+	}
+
+	public String getTableName() {
+		return "DOG";
+	}
+
+}

Propchange: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/DogData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/DogData.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/KennelData.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/KennelData.java?view=auto&rev=441239
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/KennelData.java (added)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/KennelData.java Thu Sep  7 14:44:47 2006
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tuscany.das.rdb.test.data;
+
+import java.sql.Connection;
+import java.sql.Types;
+
+import org.apache.tuscany.das.rdb.test.framework.TestDataWithExplicitColumns;
+
+
+public class KennelData extends TestDataWithExplicitColumns {
+
+/*    CREATE TABLE KENNEL (
+            ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+            NUMBER INTEGER UNSIGNED NULL,
+            KIND VARCHAR(20) NULL,
+            OCC_COUNT INTEGER UNSIGNED NULL,
+            PRIMARY KEY(ID)
+          );*/
+    
+	//id omitted.  id is auto-generated.
+    private static int[] columnTypes = {Types.INTEGER, Types.VARCHAR, Types.INTEGER}; 
+	
+	private static Object[][] data = { 
+            { new Integer(100), "Small", new Integer(1) },
+			{ new Integer(101), "Small", new Integer(1) },
+			{ new Integer(102), "Large", new Integer(1)} };
+
+	private static String[] columns = { "NUMBER", "KIND", "OCC_COUNT" };
+
+	public KennelData(Connection connection) {
+		super(connection, data, columns, columnTypes);
+	}
+
+	public String getTableName() {
+		return "KENNEL";
+	}
+
+}

Propchange: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/KennelData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/KennelData.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/OwnerData.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/OwnerData.java?view=auto&rev=441239
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/OwnerData.java (added)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/OwnerData.java Thu Sep  7 14:44:47 2006
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tuscany.das.rdb.test.data;
+
+import java.sql.Connection;
+import java.sql.Types;
+
+import org.apache.tuscany.das.rdb.test.framework.TestDataWithExplicitColumns;
+
+
+public class OwnerData extends TestDataWithExplicitColumns {
+
+/*    CREATE TABLE OWNER (
+            ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+            NAME VARCHAR(20) NULL,
+            CONTACT_PHONE VARCHAR(20) NULL,
+            OCC_COUNT INTEGER UNSIGNED NULL,
+            PRIMARY KEY(ID)
+          );*/
+    
+	//id omitted.  id is auto-generated.
+    private static int[] columnTypes = {Types.VARCHAR, Types.VARCHAR, Types.INTEGER}; 
+	
+	private static Object[][] data = { 
+            { "Fanny", "222-2222", new Integer(1) },
+			{ "Manny", "333-3333", new Integer(1) },
+			{ "Sammy", "444-4444", new Integer(1)} };
+
+	private static String[] columns = { "NAME", "CONTACT_PHONE", "OCC_COUNT" };
+
+	public OwnerData(Connection connection) {
+		super(connection, data, columns, columnTypes);
+	}
+
+	public String getTableName() {
+		return "OWNER";
+	}
+
+}

Propchange: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/OwnerData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/OwnerData.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/OwnerDogData.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/OwnerDogData.java?view=auto&rev=441239
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/OwnerDogData.java (added)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/OwnerDogData.java Thu Sep  7 14:44:47 2006
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tuscany.das.rdb.test.data;
+
+import java.sql.Connection;
+
+import org.apache.tuscany.das.rdb.test.framework.RelationshipData;
+
+public class OwnerDogData extends RelationshipData {
+
+    public static Object[][] data = { { "Fanny", "Fido" }, { "Manny", "Max" }, { "Sammy", "Saddie" } };
+
+    public OwnerDogData(Connection c) {
+        super(c, data);
+    }
+
+    protected String getParentRetrievalStatement() {
+        return "select ID from OWNER where NAME = ?";
+    }
+
+    protected String getChildUpdateStatement() {
+        return "update DOG set OWNER_ID = ? where NAME = ?";
+    }
+
+}

Propchange: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/OwnerDogData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/OwnerDogData.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/TypesData.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/TypesData.java?view=diff&rev=441239&r1=441238&r2=441239
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/TypesData.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/TypesData.java Thu Sep  7 14:44:47 2006
@@ -19,20 +19,12 @@
 package org.apache.tuscany.das.rdb.test.data;
 
 import java.sql.Connection;
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
 
 import org.apache.tuscany.das.rdb.test.framework.TestData;
 
 
 public class TypesData extends TestData {
-	
-	private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:ss:mm.SSS");
-	private static Timestamp timestamp = getTimestamp();
-		
+			
 	private static Object[][] customerData = {
 			{new Integer(1), timestamp, new Float(1234567.89), new Float(1234567.89)}
 			};
@@ -45,22 +37,5 @@
 		return "TYPETEST";
 	}
 
-	
-	//Utilities
-	private static Date getDate() {
-		
-		try {
-			return dateFormat.parse("1966-12-20 00:00:00.0");
-		} catch (ParseException e) {
-			throw new RuntimeException(e);
-		}
-
-	}
-	
-	public static Timestamp getTimestamp() {
-		
-		return new Timestamp(getDate().getTime());
-		
-	}
 	
 }

Added: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/VisitData.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/VisitData.java?view=auto&rev=441239
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/VisitData.java (added)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/VisitData.java Thu Sep  7 14:44:47 2006
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tuscany.das.rdb.test.data;
+
+import java.sql.Connection;
+import java.sql.Types;
+
+import org.apache.tuscany.das.rdb.test.framework.TestDataWithExplicitColumns;
+
+
+public class VisitData extends TestDataWithExplicitColumns {
+
+/*    CREATE TABLE VISIT (
+            ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+            CHECK_IN TIMESTAMP NULL,
+            CHECK_OUT TIMESTAMP NULL,
+            OCC_COUNT INTEGER UNSIGNED NULL,
+            PRIMARY KEY(ID)
+          );*/
+    
+	//id omitted.  id is auto-generated.
+    private static int[] columnTypes = {Types.TIMESTAMP, Types.TIMESTAMP, Types.INTEGER}; 
+	
+	private static Object[][] data = { 
+            { getTimestamp("2006-10-20 00:00:00.0"), getTimestamp("2006-10-22 00:00:00.0"), new Integer(1) },
+            { getTimestamp("2006-10-20 00:00:00.0"), getTimestamp("2006-10-22 00:00:00.0"), new Integer(1) },
+            { getTimestamp("2006-10-20 00:00:00.0"), getTimestamp("2006-10-22 00:00:00.0"), new Integer(1) }
+    };
+
+	private static String[] columns = { "CHECK_IN", "CHECK_OUT", "OCC_COUNT" };
+
+	public VisitData(Connection connection) {
+		super(connection, data, columns, columnTypes);
+	}
+
+	public String getTableName() {
+		return "VISIT";
+	}
+
+}

Propchange: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/VisitData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/data/VisitData.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DatabaseSetup.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DatabaseSetup.java?view=diff&rev=441239&r1=441238&r2=441239
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DatabaseSetup.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/DatabaseSetup.java Thu Sep  7 14:44:47 2006
@@ -33,21 +33,25 @@
     protected String driverName = "Not initialized";
 
     protected String databaseURL = "Not initialized";
-    
+
     protected String userName = null;
+
     protected String password = null;
 
     private Connection connection;
 
     protected Statement s;
 
-    
     // Data Types
     protected String stringType = "VARCHAR";
+
     protected String integerType = "INT";
-	protected String timestampType = "TIMESTAMP";
-	protected String floatType = "FLOAT";
-	protected String decimalType = "DECIMAL";
+
+    protected String timestampType = "TIMESTAMP";
+
+    protected String floatType = "FLOAT";
+
+    protected String decimalType = "DECIMAL";
     
     public DatabaseSetup(Test test) {
         super(test);
@@ -65,22 +69,22 @@
         try {
 
             Class.forName(driverName).newInstance();
-            if ( userName != null ) {
-            	connection = DriverManager.getConnection(databaseURL, userName, password);
+            if (userName != null) {
+                connection = DriverManager.getConnection(databaseURL, userName, password);
             } else {
-            	connection = DriverManager.getConnection(databaseURL);
+                connection = DriverManager.getConnection(databaseURL);
             }
             connection.setAutoCommit(false);
 
         } catch (Exception e) {
             if (e instanceof SQLException) {
-            	if ( ((SQLException) e).getNextException() != null )
-            		((SQLException) e).getNextException().printStackTrace();
-            	else	
-            		e.printStackTrace();
-            			
+                if (((SQLException) e).getNextException() != null)
+                    ((SQLException) e).getNextException().printStackTrace();
+                else
+                    e.printStackTrace();
+
             }
-                
+
             throw new RuntimeException(e);
         }
 
@@ -93,12 +97,12 @@
         s = connection.createStatement();
 
         try {
-        	dropTriggers();
-        	dropSequences();
+            dropTriggers();
+            dropSequences();
             dropTables();
             dropProcedures();
-           
-            createSequences();            
+
+            createSequences();
             createTables();
             createTriggers();
             createProcedures();
@@ -118,14 +122,13 @@
 
     private void dropTables() {
 
-//        System.out.println("Dropping tables");
+        // System.out.println("Dropping tables");
 
         String[] statements = {
 
-        "DROP TABLE CUSTOMER", "DROP TABLE ANORDER", "DROP TABLE ORDERDETAILS", "DROP TABLE ITEM",
-                "DROP TABLE COMPANY", "DROP TABLE EMPLOYEE", "DROP TABLE DEPARTMENT", "DROP TABLE BOOK",
-                "DROP TABLE PART", "DROP TABLE TYPETEST", "DROP TABLE CITIES", "DROP TABLE STATES",
-                "DROP TABLE conmgt.SERVERSTATUS"
+        "DROP TABLE CUSTOMER", "DROP TABLE ANORDER", "DROP TABLE ORDERDETAILS", "DROP TABLE ITEM", "DROP TABLE COMPANY", "DROP TABLE EMPLOYEE",
+                "DROP TABLE DEPARTMENT", "DROP TABLE BOOK", "DROP TABLE PART", "DROP TABLE TYPETEST", "DROP TABLE CITIES", "DROP TABLE STATES",
+                "DROP TABLE conmgt.SERVERSTATUS", "DROP TABLE DOG", "DROP TABLE OWNER", "DROP TABLE KENNEL", "DROP TABLE VISIT"
 
         };
 
@@ -134,37 +137,36 @@
                 s.execute(statements[i]);
             } catch (SQLException e) {
                 // If the table does not exist then ignore the exception on drop
-                if ((!e.getMessage().contains("does not exist")) &&
-                		(!e.getMessage().contains("Unknown table")))
+                if ((!e.getMessage().contains("does not exist")) && (!e.getMessage().contains("Unknown table")))
                     throw new RuntimeException(e);
             }
         }
     }
 
     protected void dropTriggers() {
-    	
+
     }
-    
+
     protected void createTriggers() {
-    	
+
     }
-    
+
     protected void dropSequences() {
-    	
+
     }
-    
-  protected void createSequences() {
-    	
+
+    protected void createSequences() {
+
     }
-    
+
     protected void dropProcedures() {
 
-//        System.out.println("Dropping procedures");
+        // System.out.println("Dropping procedures");
 
         String[] statements = {
 
-        "DROP PROCEDURE GETALLCOMPANIES", "DROP PROCEDURE DELETECUSTOMER", "DROP PROCEDURE GETNAMEDCOMPANY",
-                "DROP PROCEDURE GETCUSTOMERANDORDERS", "DROP PROCEDURE GETNAMEDCUSTOMERS", "DROP PROCEDURE GETALLCUSTOMERSANDORDERS"
+        "DROP PROCEDURE GETALLCOMPANIES", "DROP PROCEDURE DELETECUSTOMER", "DROP PROCEDURE GETNAMEDCOMPANY", "DROP PROCEDURE GETCUSTOMERANDORDERS",
+                "DROP PROCEDURE GETNAMEDCUSTOMERS", "DROP PROCEDURE GETALLCUSTOMERSANDORDERS"
 
         };
 
@@ -181,7 +183,7 @@
 
     private void createTables() {
 
-//        System.out.println("Creating tables");
+        // System.out.println("Creating tables");
 
         try {
 
@@ -199,6 +201,11 @@
             s.execute(getCreateCities());
             s.execute(getCreateServerStatus());
 
+            s.execute(getCreateDog());
+            s.execute(getCreateOwner());
+            s.execute(getCreateKennel());
+            s.execute(getCreateVisit());
+
         } catch (SQLException e) {
             throw new RuntimeException(e);
         }
@@ -206,15 +213,21 @@
 
     protected void createProcedures() {
 
-//        System.out.println("Creating procedures");
+        // System.out.println("Creating procedures");
         try {
 
-            s.execute("CREATE PROCEDURE GETALLCOMPANIES() PARAMETER STYLE JAVA LANGUAGE JAVA READS SQL DATA DYNAMIC RESULT SETS 1 EXTERNAL NAME 'org.apache.tuscany.das.rdb.test.framework.JavaStoredProcs.getAllCompanies'");
-            s.execute("CREATE PROCEDURE DELETECUSTOMER(theId int) PARAMETER STYLE JAVA LANGUAGE JAVA MODIFIES SQL DATA EXTERNAL NAME 'org.apache.tuscany.das.rdb.test.framework.JavaStoredProcs.deleteCustomer'");
-            s.execute("CREATE PROCEDURE GETNAMEDCOMPANY(theName VARCHAR(100)) PARAMETER STYLE JAVA LANGUAGE JAVA READS SQL DATA DYNAMIC RESULT SETS 1 EXTERNAL NAME 'org.apache.tuscany.das.rdb.test.framework.JavaStoredProcs.getNamedCompany'");
-            s.execute("CREATE PROCEDURE GETCUSTOMERANDORDERS(theID INTEGER) PARAMETER STYLE JAVA LANGUAGE JAVA READS SQL DATA DYNAMIC RESULT SETS 1 EXTERNAL NAME 'org.apache.tuscany.das.rdb.test.framework.JavaStoredProcs.getCustomerAndOrders'");
-            s.execute("CREATE PROCEDURE GETNAMEDCUSTOMERS(theName VARCHAR(100), OUT theCount INTEGER) PARAMETER STYLE JAVA LANGUAGE JAVA READS SQL DATA DYNAMIC RESULT SETS 1 EXTERNAL NAME 'org.apache.tuscany.das.rdb.test.framework.JavaStoredProcs.getNamedCustomers'");
-            s.execute("CREATE PROCEDURE GETALLCUSTOMERSANDORDERS() PARAMETER STYLE JAVA LANGUAGE JAVA READS SQL DATA DYNAMIC RESULT SETS 2 EXTERNAL NAME 'org.apache.tuscany.das.rdb.test.framework.JavaStoredProcs.getAllCustomersAndAllOrders'");
+            s
+                    .execute("CREATE PROCEDURE GETALLCOMPANIES() PARAMETER STYLE JAVA LANGUAGE JAVA READS SQL DATA DYNAMIC RESULT SETS 1 EXTERNAL NAME 'org.apache.tuscany.das.rdb.test.framework.JavaStoredProcs.getAllCompanies'");
+            s
+                    .execute("CREATE PROCEDURE DELETECUSTOMER(theId int) PARAMETER STYLE JAVA LANGUAGE JAVA MODIFIES SQL DATA EXTERNAL NAME 'org.apache.tuscany.das.rdb.test.framework.JavaStoredProcs.deleteCustomer'");
+            s
+                    .execute("CREATE PROCEDURE GETNAMEDCOMPANY(theName VARCHAR(100)) PARAMETER STYLE JAVA LANGUAGE JAVA READS SQL DATA DYNAMIC RESULT SETS 1 EXTERNAL NAME 'org.apache.tuscany.das.rdb.test.framework.JavaStoredProcs.getNamedCompany'");
+            s
+                    .execute("CREATE PROCEDURE GETCUSTOMERANDORDERS(theID INTEGER) PARAMETER STYLE JAVA LANGUAGE JAVA READS SQL DATA DYNAMIC RESULT SETS 1 EXTERNAL NAME 'org.apache.tuscany.das.rdb.test.framework.JavaStoredProcs.getCustomerAndOrders'");
+            s
+                    .execute("CREATE PROCEDURE GETNAMEDCUSTOMERS(theName VARCHAR(100), OUT theCount INTEGER) PARAMETER STYLE JAVA LANGUAGE JAVA READS SQL DATA DYNAMIC RESULT SETS 1 EXTERNAL NAME 'org.apache.tuscany.das.rdb.test.framework.JavaStoredProcs.getNamedCustomers'");
+            s
+                    .execute("CREATE PROCEDURE GETALLCUSTOMERSANDORDERS() PARAMETER STYLE JAVA LANGUAGE JAVA READS SQL DATA DYNAMIC RESULT SETS 2 EXTERNAL NAME 'org.apache.tuscany.das.rdb.test.framework.JavaStoredProcs.getAllCustomersAndAllOrders'");
             // TODO - "GETNAMEDCUSTOMERS" is failing on DB2 with SQLCODE: 42723. Need to investigate
         } catch (SQLException e) {
             throw new RuntimeException(e);
@@ -228,132 +241,140 @@
     //
 
     protected String getCreateCustomer() {
-		return "CREATE TABLE CUSTOMER (" + getIntegerColumn("ID")
-				+ " PRIMARY KEY NOT NULL, " + getStringColumn("LASTNAME", 30)
-				+ " DEFAULT 'Garfugengheist', "
-				+ getStringColumn("ADDRESS", 30) + ")";
-	}
-
-	protected String getCreateAnOrder() {
-		return "CREATE TABLE ANORDER (" + getIntegerColumn("ID")
-				+ " PRIMARY KEY NOT NULL, " + getStringColumn("PRODUCT", 30)
-				+ ", " + getIntegerColumn("QUANTITY") + ","
-				+ getIntegerColumn("CUSTOMER_ID") + ")";
-	}
-
-	protected String getCreateOrderDetails() {
-		return "CREATE TABLE ORDERDETAILS (" + getIntegerColumn("ORDERID")
-				+ " NOT NULL, " + getIntegerColumn("PRODUCTID")
-				+ " NOT NULL, PRICE FLOAT, PRIMARY KEY (ORDERID, PRODUCTID))";
-	}
-
-	protected String getCreateItem() {
-		return "CREATE TABLE ITEM (" + getIntegerColumn("ID")
-				+ " PRIMARY KEY NOT NULL, " + getStringColumn("NAME", 30) + ")";
-	}
-
-	protected String getCreateCompany() {
-		return "CREATE TABLE COMPANY (" + getIntegerColumn("ID")
-				+ " PRIMARY KEY NOT NULL " + getGeneratedKeyClause() + " , "
-				+ getStringColumn("NAME", 30) + ", "
-				+ getIntegerColumn("EOTMID") + ")";
-	}
-
-	protected String getCreateEmployee() {
-		return "CREATE TABLE EMPLOYEE (" + getIntegerColumn("ID")
-				+ " PRIMARY KEY NOT NULL " + getGeneratedKeyClause() + ","
-				+ getStringColumn("NAME", 30) + "," + getStringColumn("SN", 10)
-				+ ", MANAGER SMALLINT, " + getIntegerColumn("DEPARTMENTID")
-				+ ")";
-	}
-
-	protected String getCreateDepartment() {
-		return "CREATE TABLE DEPARTMENT (" + getIntegerColumn("ID")
-				+ " PRIMARY KEY NOT NULL " + getGeneratedKeyClause() + ", "
-				+ getStringColumn("NAME", 30) + ","
-				+ getStringColumn("LOCATION", 30) + ", "
-				+ getStringColumn("DEPNUMBER", 10) + ","
-				+ getIntegerColumn("COMPANYID") + ")";
-	}
-
-	protected String getCreateBook() {
-		return "CREATE TABLE BOOK (" + getIntegerColumn("BOOK_ID")
-				+ " PRIMARY KEY NOT NULL, " + getStringColumn("NAME", 50) + ","
-				+ getStringColumn("AUTHOR", 30) + ", "
-				+ getIntegerColumn("QUANTITY") + "," + getIntegerColumn("OCC")
-				+ ")";
-	}
-
-	protected String getCreatePart() {
-		return "CREATE TABLE PART (" + getIntegerColumn("ID")
-				+ " PRIMARY KEY NOT NULL, NAME VARCHAR(50),  "
-				+ getIntegerColumn("QUANTITY") + ","
-				+ getIntegerColumn("PARENT_ID") + " )";
-	}
-
-	protected String getCreateTypeTest() {
-		return "CREATE TABLE TYPETEST (" + getIntegerColumn("ID")
-				+ " PRIMARY KEY NOT NULL, " + getTimeStampColumn("ATIMESTAMP")
-				+ "," + getDecimalColumn("ADECIMAL", 9, 2) + "," + getFloatColumn("AFLOAT") + ")";
-	}
-
-	
-
-	protected String getCreateStates() {
-		return "CREATE TABLE STATES (" + getIntegerColumn("ID")
-				+ " PRIMARY KEY NOT NULL, " + getStringColumn("NAME", 2) + ")";
-	}
-
-	protected String getCreateCities() {
-		return "CREATE TABLE CITIES (" + getIntegerColumn("ID")
-				+ " PRIMARY KEY NOT NULL," + getStringColumn("NAME", 50) + ","
-				+ getIntegerColumn("STATE_ID") + ","
-				+ getForeignKeyConstraint("STATES", "ID", "STATE_ID") + ")";
-	}
-
-	protected String getCreateServerStatus() {
-
-		return "CREATE TABLE CONMGT.SERVERSTATUS (STATUSID INTEGER PRIMARY KEY NOT NULL "
-				+ getGeneratedKeyClause()
-				+ "  (START WITH 1 ,INCREMENT BY 1), MANAGEDSERVERID INTEGER NOT NULL, TIMESTAMP TIMESTAMP NOT NULL)";
-
-	}
-
-	
-	protected String getForeignKeyConstraint(String pkTable, String pkColumn, String foreignKey) {
-		StringBuffer buffer = new StringBuffer();
-		buffer.append("CONSTRAINT FK1 FOREIGN KEY (");
-		buffer.append(foreignKey);
-		buffer.append(") REFERENCES ");
-		buffer.append(pkTable);
-		buffer.append("(");
-		buffer.append(pkColumn);
-		buffer.append(") ON DELETE NO ACTION ON UPDATE NO ACTION");
-		return buffer.toString();
-	}
-	
-	protected String getStringColumn(String name, int length) {
-		return name + ' ' + stringType + "(" + new Integer(length).toString() + ")";
-	}
-	
-	protected String getIntegerColumn(String name) {
-		return name + ' ' + integerType;
-	}
-	
-	protected String getGeneratedKeyClause() {
-		return "GENERATED ALWAYS AS IDENTITY";
-	}
-	
-	protected String getTimeStampColumn(String name) {
-		return name + ' ' + timestampType;
-	}
-	
-	protected String getDecimalColumn(String name, int size1, int size2) {
-		return name + ' ' + decimalType + "(" + new Integer(size1).toString() + ',' + new Integer(size2).toString() + ")";
-	}
-	
-	protected String getFloatColumn(String name) {
-		return name + ' ' + floatType;
-	}
+        return "CREATE TABLE CUSTOMER (" + getIntegerColumn("ID") + " PRIMARY KEY NOT NULL, " + getStringColumn("LASTNAME", 30)
+                + " DEFAULT 'Garfugengheist', " + getStringColumn("ADDRESS", 30) + ")";
+    }
+
+    protected String getCreateAnOrder() {
+        return "CREATE TABLE ANORDER (" + getIntegerColumn("ID") + " PRIMARY KEY NOT NULL, " + getStringColumn("PRODUCT", 30) + ", "
+                + getIntegerColumn("QUANTITY") + "," + getIntegerColumn("CUSTOMER_ID") + ")";
+    }
+
+    protected String getCreateOrderDetails() {
+        return "CREATE TABLE ORDERDETAILS (" + getIntegerColumn("ORDERID") + " NOT NULL, " + getIntegerColumn("PRODUCTID")
+                + " NOT NULL, PRICE FLOAT, PRIMARY KEY (ORDERID, PRODUCTID))";
+    }
+
+    protected String getCreateItem() {
+        return "CREATE TABLE ITEM (" + getIntegerColumn("ID") + " PRIMARY KEY NOT NULL, " + getStringColumn("NAME", 30) + ")";
+    }
+
+    protected String getCreateCompany() {
+        return "CREATE TABLE COMPANY (" + getIntegerColumn("ID") + " PRIMARY KEY NOT NULL " + getGeneratedKeyClause() + " , "
+                + getStringColumn("NAME", 30) + ", " + getIntegerColumn("EOTMID") + ")";
+    }
+
+    protected String getCreateEmployee() {
+        return "CREATE TABLE EMPLOYEE (" + getIntegerColumn("ID") + " PRIMARY KEY NOT NULL " + getGeneratedKeyClause() + ","
+                + getStringColumn("NAME", 30) + "," + getStringColumn("SN", 10) + ", MANAGER SMALLINT, " + getIntegerColumn("DEPARTMENTID") + ")";
+    }
+
+    protected String getCreateDepartment() {
+        return "CREATE TABLE DEPARTMENT (" + getIntegerColumn("ID") + " PRIMARY KEY NOT NULL " + getGeneratedKeyClause() + ", "
+                + getStringColumn("NAME", 30) + "," + getStringColumn("LOCATION", 30) + ", " + getStringColumn("DEPNUMBER", 10) + ","
+                + getIntegerColumn("COMPANYID") + ")";
+    }
+
+    protected String getCreateBook() {
+        return "CREATE TABLE BOOK (" + getIntegerColumn("BOOK_ID") + " PRIMARY KEY NOT NULL, " + getStringColumn("NAME", 50) + ","
+                + getStringColumn("AUTHOR", 30) + ", " + getIntegerColumn("QUANTITY") + "," + getIntegerColumn("OCC") + ")";
+    }
+
+    protected String getCreatePart() {
+        return "CREATE TABLE PART (" + getIntegerColumn("ID") + " PRIMARY KEY NOT NULL, NAME VARCHAR(50),  " + getIntegerColumn("QUANTITY") + ","
+                + getIntegerColumn("PARENT_ID") + " )";
+    }
+
+    protected String getCreateTypeTest() {
+        return "CREATE TABLE TYPETEST (" + getIntegerColumn("ID") + " PRIMARY KEY NOT NULL, " + getTimestampColumn("ATIMESTAMP") + ","
+                + getDecimalColumn("ADECIMAL", 9, 2) + "," + getFloatColumn("AFLOAT") + ")";
+    }
+
+    protected String getCreateStates() {
+        return "CREATE TABLE STATES (" + getIntegerColumn("ID") + " PRIMARY KEY NOT NULL, " + getStringColumn("NAME", 2) + ")";
+    }
+
+    protected String getCreateCities() {
+        return "CREATE TABLE CITIES (" + getIntegerColumn("ID") + " PRIMARY KEY NOT NULL," + getStringColumn("NAME", 50) + ","
+                + getIntegerColumn("STATE_ID") + "," + getForeignKeyConstraint("STATES", "ID", "STATE_ID") + ")";
+    }
+
+    protected String getCreateServerStatus() {
+
+        return "CREATE TABLE CONMGT.SERVERSTATUS (STATUSID INTEGER PRIMARY KEY NOT NULL " + getGeneratedKeyClause()
+                + "  (START WITH 1 ,INCREMENT BY 1), MANAGEDSERVERID INTEGER NOT NULL, TIMESTAMP TIMESTAMP NOT NULL)";
+
+    }
+
+    // Dog Kennel Schema
+
+    protected String getCreateDog() {
+        return "CREATE TABLE DOG (" + getIntegerColumn("ID") + " NOT NULL " + getGeneratedKeyClause() + " , " + getIntegerColumn("OWNER_ID") + " , "
+                + getStringColumn("NAME", 20) + ", " + getStringColumn("BREED", 20) + ", " + getIntegerColumn("OCC_COUNT") + ", "
+                + "PRIMARY KEY(ID))";
+    }
+
+    protected String getCreateOwner() {
+        return "CREATE TABLE OWNER (" + getIntegerColumn("ID") + " NOT NULL " + getGeneratedKeyClause() + " , " + getStringColumn("NAME", 20) + ", "
+                + getStringColumn("CONTACT_PHONE", 20) + ", " + getIntegerColumn("OCC_COUNT") + ", " + "PRIMARY KEY(ID))";
+    }
+    
+    protected String getCreateKennel() {
+        return "CREATE TABLE KENNEL (" 
+        + getIntegerColumn("ID") + " NOT NULL " + getGeneratedKeyClause() + " , " 
+        + getIntegerColumn("NUMBER") + ", "
+        + getStringColumn("KIND", 20) + ", " 
+        + getIntegerColumn("OCC_COUNT") + ", " 
+        + "PRIMARY KEY(ID))";
+    }
+    
+    protected String getCreateVisit() {
+        return "CREATE TABLE VISIT (" 
+        + getIntegerColumn("ID") + " NOT NULL " + getGeneratedKeyClause() + " , " 
+        + getTimestampColumn("CHECK_IN") + ", "
+        + getTimestampColumn("CHECK_OUT") + ", "
+        + getIntegerColumn("OCC_COUNT") + ", " 
+        + "PRIMARY KEY(ID))";
+    }
+    
+    
+    // /////////////////
 
+    protected String getForeignKeyConstraint(String pkTable, String pkColumn, String foreignKey) {
+        StringBuffer buffer = new StringBuffer();
+        buffer.append("CONSTRAINT FK1 FOREIGN KEY (");
+        buffer.append(foreignKey);
+        buffer.append(") REFERENCES ");
+        buffer.append(pkTable);
+        buffer.append("(");
+        buffer.append(pkColumn);
+        buffer.append(") ON DELETE NO ACTION ON UPDATE NO ACTION");
+        return buffer.toString();
+    }
+
+    protected String getStringColumn(String name, int length) {
+        return name + ' ' + stringType + "(" + new Integer(length).toString() + ")";
+    }
+
+    protected String getIntegerColumn(String name) {
+        return name + ' ' + integerType;
+    }
+
+    protected String getGeneratedKeyClause() {
+        return "GENERATED ALWAYS AS IDENTITY";
+    }
+
+    protected String getDecimalColumn(String name, int size1, int size2) {
+        return name + ' ' + decimalType + "(" + new Integer(size1).toString() + ',' + new Integer(size2).toString() + ")";
+    }
+
+    protected String getFloatColumn(String name) {
+        return name + ' ' + floatType;
+    }
+
+    protected String getTimestampColumn(String name) {
+        return name + ' ' + timestampType;
+    }   
+    
+    
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/TestData.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/TestData.java?view=diff&rev=441239&r1=441238&r2=441239
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/TestData.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/framework/TestData.java Thu Sep  7 14:44:47 2006
@@ -21,13 +21,21 @@
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 public abstract class TestData {
 	
 	protected Object[][] data;
 	private int currentRow = -1;
 	protected Connection connection;
-	
+    
+    
+    protected static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:ss:mm.SSS");
+    protected static Timestamp timestamp = getTimestamp();
 
 	public TestData(Connection c, Object[][] customerData) {
 		this.connection = c; 
@@ -88,4 +96,32 @@
 		}
 		ps.close();
 	}
+    
+    //Utilities
+    protected static Date getDate() {
+        
+        try {
+            return dateFormat.parse("1966-12-20 00:00:00.0");
+        } catch (ParseException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+    protected static Date getDate(String timeStamp) {
+        
+        try {
+            return dateFormat.parse("1966-12-20 00:00:00.0");
+        } catch (ParseException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+    public static Timestamp getTimestamp() {
+        return new Timestamp(getDate().getTime());
+    }
+    
+    public static Timestamp getTimestamp(String timeStamp) {
+        return new Timestamp(getDate(timeStamp).getTime());
+    }
+    
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/suites/AllCommonTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/suites/AllCommonTests.java?view=diff&rev=441239&r1=441238&r2=441239
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/suites/AllCommonTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/suites/AllCommonTests.java Thu Sep  7 14:44:47 2006
@@ -35,6 +35,7 @@
 import org.apache.tuscany.das.rdb.test.GeneratedId;
 import org.apache.tuscany.das.rdb.test.GraphMergeTests;
 import org.apache.tuscany.das.rdb.test.ImpliedRelationshipTests;
+import org.apache.tuscany.das.rdb.test.KennelTests;
 import org.apache.tuscany.das.rdb.test.NameMappingTests;
 import org.apache.tuscany.das.rdb.test.OCCTests;
 import org.apache.tuscany.das.rdb.test.OneToOneRelationshipTests;
@@ -97,6 +98,10 @@
         suite.addTest(new TestSuite (AliasTests.class));
        
         suite.addTest(new TestSuite (ImpliedRelationshipTests.class));
+        
+        suite.addTest(new TestSuite (KennelTests.class));
+    
+        
 		//$JUnit-END$
 		return suite;
 	}



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message