tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdan...@apache.org
Subject svn commit: r451460 [5/6] - in /incubator/tuscany/java/das/rdb/src: main/java/org/apache/tuscany/das/rdb/ main/java/org/apache/tuscany/das/rdb/config/wrapper/ main/java/org/apache/tuscany/das/rdb/generator/impl/ main/java/org/apache/tuscany/das/rdb/gra...
Date Fri, 29 Sep 2006 21:36:41 GMT
Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CrudWithChangeHistory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CrudWithChangeHistory.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CrudWithChangeHistory.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/CrudWithChangeHistory.java Fri Sep 29 14:36:37 2006
@@ -19,8 +19,7 @@
 package org.apache.tuscany.das.rdb.test;
 
 /*
- * This provdes the simplest examples that make use of the change history. The
- * assumptions are:
+ * This provdes the simplest examples that make use of the change history. The assumptions are:
  * 
  * Single type Change history utilized Dynamic DataObjects
  * 
@@ -52,51 +51,48 @@
     }
 
     public void testDeleteAndCreate() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(
-				getConfig("basicCustomerMappingWithCUD2.xml"), getConnection());
-		// Read customer 1
-		Command select = das
-				.createCommand("Select * from CUSTOMER");
-		DataObject root = select.executeQuery();
-
-		DataObject customer = (DataObject) root.get("CUSTOMER[1]");
-
-		int customerId = customer.getInt("ID");
-		// Modify customer
-		customer.delete();
-
-		DataObject newCustomer = root.createDataObject("CUSTOMER");
-		newCustomer.setInt("ID", 9999);
-		newCustomer.setString("LASTNAME", "Jones");
-		
-		// Build apply changes command
-		das.applyChanges(root);
-
-		// Verify changes
-		root = select.executeQuery();
-		boolean found = false;
-		Iterator i = root.getList("CUSTOMER").iterator();
-		while ( i.hasNext()) {
-			customer = (DataObject)i.next();
-			assertFalse(customerId == customer.getInt("ID"));
-			if ( customer.getInt("ID") == 9999 )
-				found = true;
-		}
-		
-		assertTrue(found);
+        DAS das = DAS.FACTORY.createDAS(getConfig("basicCustomerMappingWithCUD2.xml"), getConnection());
+        // Read customer 1
+        Command select = das.createCommand("Select * from CUSTOMER");
+        DataObject root = select.executeQuery();
+
+        DataObject customer = (DataObject) root.get("CUSTOMER[1]");
+
+        int customerId = customer.getInt("ID");
+        // Modify customer
+        customer.delete();
+
+        DataObject newCustomer = root.createDataObject("CUSTOMER");
+        newCustomer.setInt("ID", 9999);
+        newCustomer.setString("LASTNAME", "Jones");
+
+        // Build apply changes command
+        das.applyChanges(root);
+
+        // Verify changes
+        root = select.executeQuery();
+        boolean found = false;
+        Iterator i = root.getList("CUSTOMER").iterator();
+        while (i.hasNext()) {
+            customer = (DataObject) i.next();
+            assertFalse(customerId == customer.getInt("ID"));
+            if (customer.getInt("ID") == 9999)
+                found = true;
+        }
+
+        assertTrue(found);
+
+    }
 
-	}
     /**
-     * Read and modify a customer. Provide needed Create/Update/Delete
-     * statements programatically
+     * Read and modify a customer. Provide needed Create/Update/Delete statements programatically
      */
     public void testReadModifyApply() throws Exception {
 
         // Provide updatecommand programmatically via config
         ConfigHelper helper = new ConfigHelper();
         Table customerTable = helper.addTable("CUSTOMER", "CUSTOMER");
-        helper.addUpdateStatement(customerTable, "update CUSTOMER set LASTNAME = ?, ADDRESS = ? where ID = ?",
-                "LASTNAME ADDRESS ID");
+        helper.addUpdateStatement(customerTable, "update CUSTOMER set LASTNAME = ?, ADDRESS = ? where ID = ?", "LASTNAME ADDRESS ID");
 
         DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
         // Read customer 1
@@ -118,8 +114,7 @@
     }
 
     /**
-     * Read and modify a customer. Provide needed Create/Update/Delete
-     * statements via xml file
+     * Read and modify a customer. Provide needed Create/Update/Delete statements via xml file
      */
     public void testReadModifyApply1() throws Exception {
 
@@ -143,8 +138,7 @@
     }
 
     /**
-     * Same as previous but: Utilizes generated CUD statements Key info provided
-     * programatically
+     * Same as previous but: Utilizes generated CUD statements Key info provided programatically
      */
     public void testReadModifyApply2() throws Exception {
 
@@ -191,8 +185,7 @@
     }
 
     /**
-     * Test ability to handle multiple changes to the graph including
-     * Creates/Updates/Deletes Employs generated CUD
+     * Test ability to handle multiple changes to the graph including Creates/Updates/Deletes Employs generated CUD
      */
     public void testReadModifyDeleteInsertApply() throws Exception {
 
@@ -261,7 +254,7 @@
         // Modify customer
         customer.set("LASTNAME", "Pavick");
 
-        DataObject customerForDelete = getCustomerByLastName(root, "Daniel");       
+        DataObject customerForDelete = getCustomerByLastName(root, "Daniel");
         customerForDelete.delete();
 
         DataObject newCustomer = root.createDataObject("CUSTOMER");

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ExceptionTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ExceptionTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ExceptionTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ExceptionTests.java Fri Sep 29 14:36:37 2006
@@ -135,7 +135,7 @@
 
 		try {
 			read.executeQuery();
-		} catch ( Exception ex ) {
+		} catch (Exception ex) {
 			assertEquals("The parent table (xxx) in relationship ORDERDETAILS was not found.", ex.getMessage());
 		}	
 

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/GeneratedId.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/GeneratedId.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/GeneratedId.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/GeneratedId.java Fri Sep 29 14:36:37 2006
@@ -107,7 +107,7 @@
     // Test insert into row with generated ID and generated insert
     public void testInsert4() throws Exception {
 
-    	DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"),getConnection());
+    	DAS das = DAS.FACTORY.createDAS(getConfig("CompanyConfig.xml"), getConnection());
         Command select = das.getCommand("all companies");       
         DataObject root = select.executeQuery();
 
@@ -123,9 +123,9 @@
 
         assertEquals(4, root.getList("COMPANY").size());
         Iterator i = root.getList("COMPANY").iterator();
-        while ( i.hasNext()) {
+        while (i.hasNext()) {
         	DataObject comp = (DataObject)i.next();
-        	assertFalse( comp.getInt("ID") == 999);
+        	assertFalse(comp.getInt("ID") == 999);
         }        
 
     }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/GraphMergeTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/GraphMergeTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/GraphMergeTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/GraphMergeTests.java Fri Sep 29 14:36:37 2006
@@ -19,6 +19,7 @@
 package org.apache.tuscany.das.rdb.test;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.tuscany.das.rdb.Command;
 import org.apache.tuscany.das.rdb.ConfigHelper;
@@ -34,151 +35,148 @@
 import commonj.sdo.DataObject;
 
 public class GraphMergeTests extends DasTest {
-	
-	protected void setUp() throws Exception {
-		super.setUp();
-		
-		new CustomerData(getAutoConnection()).refresh();
-		new OrderData(getAutoConnection()).refresh();
-		
-	}
-
-	public void testCreateEmptyGraph() throws Exception {
-		String typeUri = "http:///org.apache.tuscany.das.rdb.test/customer.xsd";
-		SDOUtil.registerStaticTypes(CustomerFactory.class);
-		ConfigHelper helper = new ConfigHelper();
-		helper.setDataObjectModel(typeUri);
-		DataObject graph = new GraphMerger().emptyGraph(helper.getConfig());
-		assertEquals(0, graph.getList("Customer").size());
-		assertEquals(0, graph.getList("AnOrder").size());
-		
-	}
-	
-	public void testCreateEmptyGraphAndAddCustomer() throws Exception {
-		String typeUri = "http:///org.apache.tuscany.das.rdb.test/customer.xsd";
-		SDOUtil.registerStaticTypes(CustomerFactory.class);
-		ConfigHelper helper = new ConfigHelper();
-		helper.setDataObjectModel(typeUri);
-		helper.addTable("CUSTOMER", "Customer");
-		helper.addPrimaryKey("CUSTOMER.ID");
-		
-		DataObject graph = new GraphMerger().emptyGraph(helper.getConfig());
-		Customer c = (Customer) graph.createDataObject("Customer");
-		c.setID(4000);
-		c.setLastName("Smith");
-		c.setAddress("400 Fourth Street");
-		
-		DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
-		das.applyChanges(graph);
-		
-		Command cmd = das.createCommand("select * from CUSTOMER order by ID desc");
-		graph = cmd.executeQuery();
-		assertEquals(6, graph.getList("Customer").size());
-		assertEquals("Smith", graph.getDataObject("Customer[1]").getString("lastName"));
-		assertEquals("400 Fourth Street", graph.getDataObject("Customer[1]").getString("address"));
-		
-	}
-	
-	public void testSingleTableMerge() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		Command select = das
-				.createCommand("Select ID, LASTNAME, ADDRESS from CUSTOMER where ID <= ?");	
-		select.setParameter(1, "3");
-		DataObject graph1 = select.executeQuery();
-		assertEquals(3, graph1.getList("CUSTOMER").size());
-
-		select.setParameter(1, "5");
-		DataObject graph2 = select.executeQuery();
-		assertEquals(5, graph2.getList("CUSTOMER").size());
-
-		GraphMerger merger = new GraphMerger();
-		merger.addPrimaryKey("CUSTOMER.ID");
-		DataObject mergedGraph = merger.merge(graph1, graph2);
-
-		assertEquals(5, mergedGraph.getList("CUSTOMER").size());
-	}
-
-	public void testSingleTableMergeThreeGraphs() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		Command select = das
-				.createCommand("Select ID, LASTNAME, ADDRESS from CUSTOMER where ID <= ?");		
-		select.setParameter(1, "3");
-		DataObject graph1 = select.executeQuery();
-		assertEquals(3, graph1.getList("CUSTOMER").size());
-
-		select.setParameter(1, "4");
-		DataObject graph2 = select.executeQuery();
-		assertEquals(4, graph2.getList("CUSTOMER").size());
-
-		select.setParameter(1, "5");
-		DataObject graph3 = select.executeQuery();
-		assertEquals(5, graph3.getList("CUSTOMER").size());
-
-		GraphMerger merger = new GraphMerger();
-		merger.addPrimaryKey("CUSTOMER.ID");
-		ArrayList graphs = new ArrayList();
-		graphs.add(graph1);
-		graphs.add(graph2);
-		graphs.add(graph3);
-		DataObject mergedGraph = merger.merge(graphs);
 
-		assertEquals(5, mergedGraph.getList("CUSTOMER").size());
+    protected void setUp() throws Exception {
+        super.setUp();
 
-	}
+        new CustomerData(getAutoConnection()).refresh();
+        new OrderData(getAutoConnection()).refresh();
+
+    }
+
+    public void testCreateEmptyGraph() throws Exception {
+        String typeUri = "http:///org.apache.tuscany.das.rdb.test/customer.xsd";
+        SDOUtil.registerStaticTypes(CustomerFactory.class);
+        ConfigHelper helper = new ConfigHelper();
+        helper.setDataObjectModel(typeUri);
+        DataObject graph = new GraphMerger().emptyGraph(helper.getConfig());
+        assertEquals(0, graph.getList("Customer").size());
+        assertEquals(0, graph.getList("AnOrder").size());
+
+    }
+
+    public void testCreateEmptyGraphAndAddCustomer() throws Exception {
+        String typeUri = "http:///org.apache.tuscany.das.rdb.test/customer.xsd";
+        SDOUtil.registerStaticTypes(CustomerFactory.class);
+        ConfigHelper helper = new ConfigHelper();
+        helper.setDataObjectModel(typeUri);
+        helper.addTable("CUSTOMER", "Customer");
+        helper.addPrimaryKey("CUSTOMER.ID");
+
+        DataObject graph = new GraphMerger().emptyGraph(helper.getConfig());
+        Customer c = (Customer) graph.createDataObject("Customer");
+        c.setID(4000);
+        c.setLastName("Smith");
+        c.setAddress("400 Fourth Street");
+
+        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
+        das.applyChanges(graph);
+
+        Command cmd = das.createCommand("select * from CUSTOMER order by ID desc");
+        graph = cmd.executeQuery();
+        assertEquals(6, graph.getList("Customer").size());
+        assertEquals("Smith", graph.getDataObject("Customer[1]").getString("lastName"));
+        assertEquals("400 Fourth Street", graph.getDataObject("Customer[1]").getString("address"));
+
+    }
+
+    public void testSingleTableMerge() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command select = das.createCommand("Select ID, LASTNAME, ADDRESS from CUSTOMER where ID <= ?");
+        select.setParameter(1, "3");
+        DataObject graph1 = select.executeQuery();
+        assertEquals(3, graph1.getList("CUSTOMER").size());
+
+        select.setParameter(1, "5");
+        DataObject graph2 = select.executeQuery();
+        assertEquals(5, graph2.getList("CUSTOMER").size());
+
+        GraphMerger merger = new GraphMerger();
+        merger.addPrimaryKey("CUSTOMER.ID");
+        DataObject mergedGraph = merger.merge(graph1, graph2);
+
+        assertEquals(5, mergedGraph.getList("CUSTOMER").size());
+    }
+
+    public void testSingleTableMergeThreeGraphs() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command select = das.createCommand("Select ID, LASTNAME, ADDRESS from CUSTOMER where ID <= ?");
+        select.setParameter(1, "3");
+        DataObject graph1 = select.executeQuery();
+        assertEquals(3, graph1.getList("CUSTOMER").size());
+
+        select.setParameter(1, "4");
+        DataObject graph2 = select.executeQuery();
+        assertEquals(4, graph2.getList("CUSTOMER").size());
+
+        select.setParameter(1, "5");
+        DataObject graph3 = select.executeQuery();
+        assertEquals(5, graph3.getList("CUSTOMER").size());
+
+        GraphMerger merger = new GraphMerger();
+        merger.addPrimaryKey("CUSTOMER.ID");
+        List graphs = new ArrayList();
+        graphs.add(graph1);
+        graphs.add(graph2);
+        graphs.add(graph3);
+        DataObject mergedGraph = merger.merge(graphs);
+
+        assertEquals(5, mergedGraph.getList("CUSTOMER").size());
+
+    }
 
-    
     public void testMultiTableMerge2() throws Exception {
-    	DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
-        //Read some customers and related orders
-        Command select = das.createCommand(
-                "SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?");  
-      
+        DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
+        // Read some customers and related orders
+        Command select = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON " 
+                + "CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?");
+
         select.setParameter(1, new Integer(1));
         DataObject graph1 = select.executeQuery();
-        
-        DataObject customer = (DataObject)graph1.getList("CUSTOMER").get(0);
-        assertEquals(2, customer.getList("orders").size());    
-        
+
+        DataObject customer = (DataObject) graph1.getList("CUSTOMER").get(0);
+        assertEquals(2, customer.getList("orders").size());
+
         select.setParameter(1, new Integer(2));
         DataObject graph2 = select.executeQuery();
-        DataObject customer2 = (DataObject)graph2.getList("CUSTOMER").get(0);
+        DataObject customer2 = (DataObject) graph2.getList("CUSTOMER").get(0);
         assertEquals(1, graph2.getList("CUSTOMER").size());
         assertEquals(1, customer2.getList("orders").size());
         assertEquals(2, customer2.getInt("ID"));
-        
+
         GraphMerger merger = new GraphMerger();
         merger.addPrimaryKey("CUSTOMER.ID");
         merger.addPrimaryKey("ANORDER.ID");
         DataObject mergedGraph = merger.merge(graph1, graph2);
-        
+
         assertEquals(3, mergedGraph.getList("ANORDER").size());
         assertEquals(2, mergedGraph.getList("CUSTOMER").size());
-        
+
         DataObject mergedCustomer = (DataObject) mergedGraph.getList("CUSTOMER").get(1);
         assertEquals(2, mergedCustomer.getInt("ID"));
         assertEquals(1, mergedCustomer.getList("orders").size());
         DataObject mergedOrder = (DataObject) mergedCustomer.getList("orders").get(0);
         assertEquals(4, mergedOrder.getInt("ID"));
-        
+
     }
-    
+
     public void testMultiTableAppendSingleTable2() throws Exception {
-    	DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
-        //Read some customers and related orders
-        Command select = das.createCommand(
-                "SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?");  
-     
+        DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
+        // Read some customers and related orders
+        Command select = das.createCommand("SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON " 
+                + "CUSTOMER.ID = ANORDER.CUSTOMER_ID where CUSTOMER.ID = ?");
+
         select.setParameter(1, new Integer(1));
         DataObject graph1 = select.executeQuery();
-        
-        DataObject customer = (DataObject)graph1.getList("CUSTOMER").get(0);
+
+        DataObject customer = (DataObject) graph1.getList("CUSTOMER").get(0);
         assertEquals(2, customer.getList("orders").size());
-        
+
         DAS das2 = DAS.FACTORY.createDAS(getConnection());
-        Command select2 = das2.createCommand("select * from ANORDER");     
+        Command select2 = das2.createCommand("select * from ANORDER");
         DataObject graph2 = select2.executeQuery();
         assertEquals(4, graph2.getList("ANORDER").size());
-        
+
         GraphMerger merger = new GraphMerger();
         merger.addPrimaryKey("CUSTOMER.ID");
         merger.addPrimaryKey("ANORDER.ID");
@@ -186,6 +184,5 @@
         assertEquals(4, mergedGraph.getList("ANORDER").size());
         assertEquals(1, mergedGraph.getList("CUSTOMER").size());
     }
-
 
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/OCCTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/OCCTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/OCCTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/OCCTests.java Fri Sep 29 14:36:37 2006
@@ -56,7 +56,7 @@
 			das.applyChanges(root);
 			fail("An OCCException should be thrown");
 		} catch (RuntimeException ex) {
-			if ( !ex.getMessage().equals("OCC Exception") )
+			if (!ex.getMessage().equals("OCC Exception"))
 				throw ex;
 		}
 	}
@@ -88,7 +88,7 @@
 		
 		DAS das2 = DAS.FACTORY.createDAS(getConfig("ManagedBooksConfig.xml"), getConnection());
 		//Read a book instance
-        Command select2= das2.getCommand("select book 1");
+        Command select2 = das2.getCommand("select book 1");
 		DataObject root2 = select2.executeQuery();
 		DataObject book2 = root2.getDataObject("BOOK[1]");
 		//Change a field to mark the instance 'dirty'
@@ -100,7 +100,7 @@
 			das.applyChanges(root);
 			fail("An OCCException should be thrown");
 		} catch (RuntimeException ex) {
-			if ( !ex.getMessage().equals("OCC Exception") )
+			if (!ex.getMessage().equals("OCC Exception"))
 				throw ex;
 		}
 	}

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/OneToOneRelationshipTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/OneToOneRelationshipTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/OneToOneRelationshipTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/OneToOneRelationshipTests.java Fri Sep 29 14:36:37 2006
@@ -135,7 +135,7 @@
         
         //Create a new employee
         DataObject employee = root.createDataObject("EMPLOYEE");
-        employee.setString ("NAME", "Joe Hotshot");
+        employee.setString("NAME", "Joe Hotshot");
         
       //Assigne a EOTM
         //Strangely this statement results in "Could not find relationships" error

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/OperationOrderingTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/OperationOrderingTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/OperationOrderingTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/OperationOrderingTests.java Fri Sep 29 14:36:37 2006
@@ -20,6 +20,7 @@
 
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 import org.apache.tuscany.das.rdb.Command;
 import org.apache.tuscany.das.rdb.DAS;
@@ -31,93 +32,85 @@
 
 public class OperationOrderingTests extends DasTest {
 
-	protected void setUp() throws Exception {
-		super.setUp();
+    public OperationOrderingTests() {
+        super();
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        CityData city = new CityData(getAutoConnection());
+        StateData state = new StateData(getAutoConnection());
+
+        city.doDeletes();
+        state.doDeletes();
+        state.doInserts();
+        city.doInserts();
+
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testInsert() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConfig("cityStates.xml"), getConnection());
+        Command select = das.createCommand("Select * from STATES inner join CITIES on STATES.ID = CITIES.STATE_ID");
+        DataObject root = select.executeQuery();
+
+        int numberOfStates = root.getList("STATES").size();
+        int numberOfCities = root.getList("CITIES").size();
+
+        DataObject atlanta = root.createDataObject("CITIES");
+        atlanta.setString("NAME", "Atlanta");
+        atlanta.setInt("ID", 6);
+
+        // Create a new Company
+        DataObject georgia = root.createDataObject("STATES");
+        georgia.setInt("ID", 4);
+        georgia.setString("NAME", "GA");
+
+        georgia.getList("cities").add(atlanta);
+
+        das.applyChanges(root);
+
+        root = select.executeQuery();
+        assertEquals(numberOfCities + 1, root.getList("CITIES").size());
+        assertEquals(numberOfStates + 1, root.getList("STATES").size());
+    }
+
+    public void testDeletes() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConfig("cityStates.xml"), getConnection());
+        Command select = das.createCommand("Select * from STATES inner join CITIES on STATES.ID = CITIES.STATE_ID");
+        DataObject root = select.executeQuery();
+
+        DataObject firstState = root.getDataObject("STATES[1]");
+        String stateName = firstState.getString("NAME");
+
+        List cityNames = new ArrayList();
+        Iterator i = firstState.getList("cities").iterator();
+        while (i.hasNext()) {
+            DataObject firstCity = (DataObject) i.next();
+            cityNames.add(firstCity.getString("NAME"));
+            firstCity.delete();
+        }
+        firstState.delete();
+
+        das.applyChanges(root);
+
+        root = select.executeQuery();
+
+        Iterator iter = root.getList("STATES").iterator();
+        while (iter.hasNext()) {
+            DataObject state = (DataObject) iter.next();
+            assertFalse(state.getString("NAME").equals(stateName));
+        }
+
+        iter = root.getList("CITIES").iterator();
+        while (iter.hasNext()) {
+            DataObject city = (DataObject) iter.next();
+            assertFalse(cityNames.contains(city.getString("NAME")));
+        }
 
-		CityData city = new CityData(getAutoConnection());
-		StateData state = new StateData(getAutoConnection());
-
-		city.doDeletes();
-		state.doDeletes();
-		state.doInserts();
-		city.doInserts();
-
-	}
-
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
-
-	public OperationOrderingTests() {
-		super();
-	}
-
-	public void testInsert() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConfig("cityStates.xml"), getConnection());
-		Command select = das
-				.createCommand(
-						"Select * from STATES inner join CITIES on STATES.ID = CITIES.STATE_ID");		
-		DataObject root = select.executeQuery();
-
-		int numberOfStates = root.getList("STATES").size();
-		int numberOfCities = root.getList("CITIES").size();
-
-		DataObject atlanta = root.createDataObject("CITIES");
-		atlanta.setString("NAME", "Atlanta");
-		atlanta.setInt("ID", 6);
-
-		// Create a new Company
-		DataObject georgia = root.createDataObject("STATES");
-		georgia.setInt("ID", 4);
-		georgia.setString("NAME", "GA");
-
-		georgia.getList("cities").add(atlanta);
-		
-		das.applyChanges(root);
-	
-		root = select.executeQuery();
-		assertEquals(numberOfCities + 1, root.getList("CITIES").size());
-		assertEquals(numberOfStates + 1, root.getList("STATES").size());
-	}
-
-	public void testDeletes() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConfig("cityStates.xml"), getConnection());
-		Command select = das
-				.createCommand(
-						"Select * from STATES inner join CITIES on STATES.ID = CITIES.STATE_ID");		
-		DataObject root = select.executeQuery();
-
-		
-		DataObject firstState = root.getDataObject("STATES[1]");
-		String stateName = firstState.getString("NAME");
-		
-		ArrayList cityNames = new ArrayList();
-		Iterator i = firstState.getList("cities").iterator();
-		while ( i.hasNext()) {
-			DataObject firstCity = (DataObject) i.next();
-			cityNames.add(firstCity.getString("NAME"));			
-			firstCity.delete();					
-		}
-		firstState.delete();
-	
-		
-		
-		
-		das.applyChanges(root);
-	
-		root = select.executeQuery();
-		
-		Iterator iter = root.getList("STATES").iterator();
-		while ( iter.hasNext()) {
-			DataObject state = (DataObject)iter.next();
-			assertFalse(state.getString("NAME").equals(stateName));
-		}
-		
-		iter = root.getList("CITIES").iterator();
-		while ( iter.hasNext()) {
-			DataObject city = (DataObject)iter.next();
-			assertFalse(cityNames.contains(city.getString("NAME")));
-		}
-		
-	}
+    }
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/PartialUpdateTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/PartialUpdateTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/PartialUpdateTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/PartialUpdateTests.java Fri Sep 29 14:36:37 2006
@@ -29,6 +29,10 @@
 
 public class PartialUpdateTests extends DasTest {
 
+    public PartialUpdateTests() {
+        super();
+    }
+
     protected void setUp() throws Exception {
         super.setUp();
         new CustomerData(getAutoConnection()).refresh();
@@ -38,13 +42,9 @@
         super.tearDown();
     }
 
-    public PartialUpdateTests() {
-        super();
-    }
-
     public void testPartialUpdate() throws SQLException {
-    	DAS das = DAS.FACTORY.createDAS(getConnection());
-        Command readCustomers = das.createCommand("select * from CUSTOMER where ID = 1");       
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command readCustomers = das.createCommand("select * from CUSTOMER where ID = 1");
 
         // Read
         DataObject root = readCustomers.executeQuery();
@@ -53,11 +53,11 @@
         // Verify
         assertEquals(1, customer.getInt("ID"));
 
-        Command update = das.createCommand("update CUSTOMER set LASTNAME = 'modified' where ID = 1");       
+        Command update = das.createCommand("update CUSTOMER set LASTNAME = 'modified' where ID = 1");
         update.execute();
 
         customer.setString("ADDRESS", "main street");
-    
+
         das.applyChanges(root);
 
         root = readCustomers.executeQuery();
@@ -70,8 +70,8 @@
     }
 
     public void testPartialInsert() throws SQLException {
-    	DAS das = DAS.FACTORY.createDAS(getConnection());
-        Command readCustomers = das.createCommand("select * from CUSTOMER where ID = 1");     
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command readCustomers = das.createCommand("select * from CUSTOMER where ID = 1");
 
         // Read
         DataObject root = readCustomers.executeQuery();
@@ -82,10 +82,10 @@
         newCust.set("ADDRESS", "5528 Wells Fargo Drive");
         // Purposely do not set lastname to let it default to 'Garfugengheist'
         // newCust.set("LASTNAME", "Gerkin" );
-        
+
         das.applyChanges(root);
 
-        Command readNewCust = das.createCommand("select * from CUSTOMER where ID = 100");      
+        Command readNewCust = das.createCommand("select * from CUSTOMER where ID = 100");
         root = readNewCust.executeQuery();
 
         // If partial insert was not used, LASTNAME would not be

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/RecursiveTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/RecursiveTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/RecursiveTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/RecursiveTests.java Fri Sep 29 14:36:37 2006
@@ -29,43 +29,42 @@
 
 public class RecursiveTests extends DasTest {
 
-	protected void setUp() throws Exception {
-		super.setUp();
-		new PartData(getAutoConnection()).refresh();
-	}
-
-	public void testReadEngineParts() throws Exception {
-		
-		DAS das = DAS.FACTORY.createDAS(getConfig("PartsConfig.xml"), getConnection());		
-		//Table definition
-		//CREATE TABLE PART (ID INT PRIMARY KEY NOT NULL, NAME VARCHAR(50), QUANTITY INT, PARENT_ID INT );
-
-	
-		Command select = das.getCommand("readEngineParts");				
-		
-		// Need to set the key explicitly. The aggregate of columns not working
-		// because of null values
-		DataObject root = select.executeQuery();
-
-		assertEquals(5, root.getList("PART").size());
-	//	printList(root.getList("PART"));
-		DataObject engine = root.getDataObject("PART.0");
-		assertEquals("Engine", engine.getString("NAME"));
-		
-		assertEquals(3, engine.getList("subparts").size());
-		
-		DataObject piston = null;
-		Iterator i = engine.getList("subparts").iterator();
-		while ( i.hasNext() ) {
-			DataObject obj = (DataObject)i.next();
-			if ( obj.getString("NAME").equals("Piston"))
-				piston = obj;
-		}
-		
-		assertEquals("Piston", piston.getString("NAME"));
-		assertEquals(1, piston.getList("subparts").size());
-		assertEquals("Piston Ring", piston.getDataObject("subparts.0").getString("NAME"));
+    protected void setUp() throws Exception {
+        super.setUp();
+        new PartData(getAutoConnection()).refresh();
+    }
+
+    public void testReadEngineParts() throws Exception {
+
+        DAS das = DAS.FACTORY.createDAS(getConfig("PartsConfig.xml"), getConnection());
+        // Table definition
+        // CREATE TABLE PART (ID INT PRIMARY KEY NOT NULL, NAME VARCHAR(50), QUANTITY INT, PARENT_ID INT );
+
+        Command select = das.getCommand("readEngineParts");
+
+        // Need to set the key explicitly. The aggregate of columns not working
+        // because of null values
+        DataObject root = select.executeQuery();
+
+        assertEquals(5, root.getList("PART").size());
+        // printList(root.getList("PART"));
+        DataObject engine = root.getDataObject("PART.0");
+        assertEquals("Engine", engine.getString("NAME"));
+
+        assertEquals(3, engine.getList("subparts").size());
+
+        DataObject piston = null;
+        Iterator i = engine.getList("subparts").iterator();
+        while (i.hasNext()) {
+            DataObject obj = (DataObject) i.next();
+            if (obj.getString("NAME").equals("Piston"))
+                piston = obj;
+        }
+
+        assertEquals("Piston", piston.getString("NAME"));
+        assertEquals(1, piston.getList("subparts").size());
+        assertEquals("Piston Ring", piston.getDataObject("subparts.0").getString("NAME"));
+
+    }
 
-	}
-	
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ResultSetShapeTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ResultSetShapeTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ResultSetShapeTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/ResultSetShapeTests.java Fri Sep 29 14:36:37 2006
@@ -48,7 +48,7 @@
      */
     public void testReadSingle() throws Exception {
 
-        DAS das = DAS.FACTORY.createDAS(getConfig("CustomerConfigWithIDConverter.xml"),getConnection());    
+        DAS das = DAS.FACTORY.createDAS(getConfig("CustomerConfigWithIDConverter.xml"), getConnection());    
         // Create and initialize command to read customers
         Command readCustomers = das.getCommand("literal");          
 

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/SerializationTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/SerializationTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/SerializationTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/SerializationTests.java Fri Sep 29 14:36:37 2006
@@ -19,11 +19,9 @@
 package org.apache.tuscany.das.rdb.test;
 
 /*
- * This class provides tests for all supported "types". The current plan is to
- * use the Data type definitions provided in the SDO 2 specification. We must
- * test the ability to use all of these types as well as different mapping from
- * thse types to types used in the database. For example, a SDO Data Type
- * "STRING", might be staored as a "TIMESTAMP" in DB2.
+ * This class provides tests for all supported "types". The current plan is to use the Data type definitions provided in the SDO 2 specification. We
+ * must test the ability to use all of these types as well as different mapping from thse types to types used in the database. For example, a SDO Data
+ * Type "STRING", might be staored as a "TIMESTAMP" in DB2.
  * 
  */
 
@@ -32,61 +30,36 @@
 
 public class SerializationTests extends DasTest {
 
-	protected void setUp() throws Exception {
-		super.setUp();
-		new TypesData(getAutoConnection()).refresh();
-	}
-
-	/**
-	 * Read various types.
-	 */
-	
-	
-public void testReadandSerialize() throws Exception {
-	/** Currently failing because of TUSCANY-22
-		Command select = Command.FACTORY
-				.createCommand("Select * from TYPETEST where ID = 1");
-		select.setConnection(getConnection());
-		DataObject root = select.executeQuery();
-		
-		DataObject obj = root.getDataObject("TYPETEST[1]");
-		
-		assertTrue(obj.isSet("ID"));
-		assertTrue(obj.isSet("ATIMESTAMP"));
-		assertTrue(obj.isSet("ADECIMAL"));
-		assertTrue(obj.isSet("AFLOAT"));
-
-		//Java serilaization to file
-		FileOutputStream fos = null;
-		ObjectOutputStream out = null;
-		try {
-			fos = new FileOutputStream("serializedGraph.xml");
-			out = new ObjectOutputStream(fos);
-			out.writeObject(root);
-			out.flush();
-		} finally {
-			out.close();
-			fos.close();
-		} 
-
-		//Reconstruct the graph
-		FileInputStream fis = null;
-		ObjectInputStream in = null;
-		DataObject root2;
-		try {
-			fis = new FileInputStream("serializedGraph.xml");
-			in = new ObjectInputStream(fis);
-			root2 = (DataObject) in.readObject();
-		} finally {
-			in.close();
-			fis.close();
-		} 
-
-		assertEquals(1, root.getInt("TYPETEST[1]/ID"));			
-		assertEquals(TypesData.getTimestamp(), (java.sql.Timestamp)root.get("TYPETEST[1]/ATIMESTAMP"));			
-		assertEquals(1234567.89f, root2.getFloat("TYPETEST[1]/ADECIMAL"), .001);
-		assertEquals(1234567.89f, root2.getFloat("TYPETEST[1]/AFLOAT"), .001);
-
-	*/	
-	}
+    protected void setUp() throws Exception {
+        super.setUp();
+        new TypesData(getAutoConnection()).refresh();
+    }
+
+    /**
+     * Read various types.
+     */
+
+    public void testReadandSerialize() throws Exception {
+        /**
+         * Currently failing because of TUSCANY-22 Command select = Command.FACTORY .createCommand("Select * from TYPETEST where ID = 1");
+         * select.setConnection(getConnection()); DataObject root = select.executeQuery();
+         * 
+         * DataObject obj = root.getDataObject("TYPETEST[1]");
+         * 
+         * assertTrue(obj.isSet("ID")); assertTrue(obj.isSet("ATIMESTAMP")); assertTrue(obj.isSet("ADECIMAL")); assertTrue(obj.isSet("AFLOAT"));
+         * 
+         * //Java serilaization to file FileOutputStream fos = null; ObjectOutputStream out = null; try { fos = new
+         * FileOutputStream("serializedGraph.xml"); out = new ObjectOutputStream(fos); out.writeObject(root); out.flush(); } finally { out.close();
+         * fos.close(); }
+         * 
+         * //Reconstruct the graph FileInputStream fis = null; ObjectInputStream in = null; DataObject root2; try { fis = new
+         * FileInputStream("serializedGraph.xml"); in = new ObjectInputStream(fis); root2 = (DataObject) in.readObject(); } finally { in.close();
+         * fis.close(); }
+         * 
+         * assertEquals(1, root.getInt("TYPETEST[1]/ID")); assertEquals(TypesData.getTimestamp(),
+         * (java.sql.Timestamp)root.get("TYPETEST[1]/ATIMESTAMP")); assertEquals(1234567.89f, root2.getFloat("TYPETEST[1]/ADECIMAL"), .001);
+         * assertEquals(1234567.89f, root2.getFloat("TYPETEST[1]/AFLOAT"), .001);
+         * 
+         */
+    }
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/SimplestCrud.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/SimplestCrud.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/SimplestCrud.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/SimplestCrud.java Fri Sep 29 14:36:37 2006
@@ -19,17 +19,13 @@
 package org.apache.tuscany.das.rdb.test;
 
 /*
- * These are the simplest possible uses of the JDBC DAS.  In this mode, the
- * programming model is not much more than JDBC
+ * These are the simplest possible uses of the JDBC DAS. In this mode, the programming model is not much more than JDBC
  * 
  * The assumptions for these tests are:
  * 
- * Single type
- * Client explicitly Read/Create/Update/Delete commands
- * No O/R mapping metadata
- * SDO change history is not used
- * Dynamic DataObjects
- * No specified graph model
+ * Single type Client explicitly Read/Create/Update/Delete commands 
+ * No O/R mapping metadata SDO change history is not used Dynamic DataObjects No
+ * specified graph model
  * 
  * 
  */
@@ -41,197 +37,192 @@
 
 import commonj.sdo.DataObject;
 
-
 public class SimplestCrud extends DasTest {
 
-	protected void setUp() throws Exception {
-		super.setUp();
-		new CustomerData(getAutoConnection()).refresh();	
-	}
-
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
-	
-	/**
-	 * Read a specific customer
-	 */
-	public void testReadSingle() throws Exception {
-
-		//Create and initialize command to read customers
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		Command readCustomers = das.createCommand("select * from CUSTOMER where ID = 1");		
-
-		//Read
-		DataObject root = readCustomers.executeQuery();
-		
-		//Verify 
-		assertEquals(1, root.getInt("CUSTOMER[1]/ID"));
-	}
-	
-	/**
-	 * Read a specific customer
-	 */
-	public void testReadSingle2() throws Exception {
-
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		//Create and initialize command to read customers
-		Command readCustomers = das.createCommand("select * from CUSTOMER where ID = 1");		
-
-		//Read
-		DataObject root = readCustomers.executeQuery();			
-		
-		//Verify 
-		assertEquals(1, root.getInt("CUSTOMER[1]/ID"));
-	}
-	
-	/**
-	 * Read a specific customer
-	 * Same as above but tests tolerance of white space in provided SQL
-	 */
-	public void testReadSingleWithWhiteSpace() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		//Create and initialize command to read customers
-		Command readCustomers = das.createCommand("   select * from CUSTOMER where ID = 1");		
-
-		//Read
-		DataObject root = readCustomers.executeQuery();
-		
-		//Verify 
-		assertEquals(1, root.getInt("CUSTOMER[1]/ID"));
-	}
-	
-	/**
-	 * Read all customers with a specific last name
-	 */
-	public void testReadMultiple() throws Exception {
-
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		//Create and initialize command to read customers
-		Command readCustomers = das.createCommand("select * from CUSTOMER where LASTNAME = 'Williams'");	
-	
-		//Read
-		DataObject root = readCustomers.executeQuery();
-		
-		//Verify 
-		assertEquals(4, root.getList("CUSTOMER").size());
-	}
-	
-	/**
-	 * Read all customers with a specific last name 
-	 * LASTNAME value is provided via a parameter
-	 */
-	public void testReadMultipleWithParameters() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		//Create and initialize command to read customers
-		Command readCustomers = das.createCommand("select * from CUSTOMER where LASTNAME = ?");		
-
-		//Parameterize the command
-		readCustomers.setParameter(1, "Williams");
-		DataObject root = readCustomers.executeQuery();
-		
-		//Verify 
-		assertEquals(4, root.getList("CUSTOMER").size());
-	}
-
-	public void testInsert() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		Command insert = das.createCommand("insert into CUSTOMER values (10, 'Williams', '5528 Wells Fargo Dr')");		
-		insert.execute();
-
-		//Verify
-		Command select = das.createCommand("Select * from CUSTOMER where ID = 10");	
-		DataObject root = select.executeQuery();	
-		assertEquals(1, root.getList("CUSTOMER").size());
-		assertEquals("5528 Wells Fargo Dr", root.get("CUSTOMER[1]/ADDRESS"));
-
-	}
-
-	public void testInsertWithParameters() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		Command insert = das.createCommand("insert into CUSTOMER values (?, ?, ?)");	
-		insert.setParameter(1, new Integer(10));
-		insert.setParameter(2, "Williams");
-		insert.setParameter(3, "5528 Wells Fargo Dr");
-		insert.execute();
-
-		//Verify
-		Command select = das.createCommand("Select * from CUSTOMER where ID = 10");
-		DataObject root = select.executeQuery();	
-		assertEquals(1, root.getList("CUSTOMER").size());
-		assertEquals("5528 Wells Fargo Dr", root.get("CUSTOMER[1]/ADDRESS"));
-
-	}
-
-	
-	public void testDelete() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		//Verify pre-condition
-		Command select = das.createCommand("Select * from CUSTOMER where ID = 1");	
-		DataObject root = select.executeQuery();	
-		assertEquals(1, root.getList("CUSTOMER").size());	
-		
-		//Create and execute the delete command
-		Command delete = das.createCommand("delete from CUSTOMER where ID = 1");	
-		delete.execute();
-		
-		//Verify delete by reusing the original select command
-		root = select.executeQuery();	
-		assertEquals(0, root.getList("CUSTOMER").size());
-		
-	}
-	
-	
-	public void testUpdate() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		//Verify pre-condition
-		Command select = das.createCommand("Select * from CUSTOMER where ID = 1");	
-		DataObject root = select.executeQuery();	
-		assertFalse(root.get("CUSTOMER[1]/LASTNAME").equals("Pavick"));
-
-		Command update = das.createCommand("update CUSTOMER set LASTNAME = 'Pavick' where ID = 1");		
-		update.execute();
-		
-		//Verify update - reuse select command
-		root = select.executeQuery();	
-		assertEquals("Pavick", root.get("CUSTOMER[1]/LASTNAME"));
-		
-	}
-	
-	public void testUpdateWithParameters() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		//Verify pre-condition
-		Command select = das.createCommand("Select * from CUSTOMER where ID = 1");	
-		DataObject root = select.executeQuery();	
-		assertFalse(root.get("CUSTOMER[1]/LASTNAME").equals("Pavick"));
-		
-		Command update = das.createCommand("update CUSTOMER set LASTNAME = ? where ID = ?");		
-		update.setParameter(1, "Pavick");
-		update.setParameter(2, new Integer(1));
-		update.execute();
-		
-		//Verify update - reuse select command
-		root = select.executeQuery();	
-		assertEquals("Pavick", root.get("CUSTOMER[1]/LASTNAME"));
-		
-	}
-    
+    protected void setUp() throws Exception {
+        super.setUp();
+        new CustomerData(getAutoConnection()).refresh();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /**
+     * Read a specific customer
+     */
+    public void testReadSingle() throws Exception {
+
+        // Create and initialize command to read customers
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command readCustomers = das.createCommand("select * from CUSTOMER where ID = 1");
+
+        // Read
+        DataObject root = readCustomers.executeQuery();
+
+        // Verify
+        assertEquals(1, root.getInt("CUSTOMER[1]/ID"));
+    }
+
+    /**
+     * Read a specific customer
+     */
+    public void testReadSingle2() throws Exception {
+
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        // Create and initialize command to read customers
+        Command readCustomers = das.createCommand("select * from CUSTOMER where ID = 1");
+
+        // Read
+        DataObject root = readCustomers.executeQuery();
+
+        // Verify
+        assertEquals(1, root.getInt("CUSTOMER[1]/ID"));
+    }
+
+    /**
+     * Read a specific customer Same as above but tests tolerance of white space in provided SQL
+     */
+    public void testReadSingleWithWhiteSpace() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        // Create and initialize command to read customers
+        Command readCustomers = das.createCommand("   select * from CUSTOMER where ID = 1");
+
+        // Read
+        DataObject root = readCustomers.executeQuery();
+
+        // Verify
+        assertEquals(1, root.getInt("CUSTOMER[1]/ID"));
+    }
+
+    /**
+     * Read all customers with a specific last name
+     */
+    public void testReadMultiple() throws Exception {
+
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        // Create and initialize command to read customers
+        Command readCustomers = das.createCommand("select * from CUSTOMER where LASTNAME = 'Williams'");
+
+        // Read
+        DataObject root = readCustomers.executeQuery();
+
+        // Verify
+        assertEquals(4, root.getList("CUSTOMER").size());
+    }
+
+    /**
+     * Read all customers with a specific last name LASTNAME value is provided via a parameter
+     */
+    public void testReadMultipleWithParameters() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        // Create and initialize command to read customers
+        Command readCustomers = das.createCommand("select * from CUSTOMER where LASTNAME = ?");
+
+        // Parameterize the command
+        readCustomers.setParameter(1, "Williams");
+        DataObject root = readCustomers.executeQuery();
+
+        // Verify
+        assertEquals(4, root.getList("CUSTOMER").size());
+    }
+
+    public void testInsert() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command insert = das.createCommand("insert into CUSTOMER values (10, 'Williams', '5528 Wells Fargo Dr')");
+        insert.execute();
+
+        // Verify
+        Command select = das.createCommand("Select * from CUSTOMER where ID = 10");
+        DataObject root = select.executeQuery();
+        assertEquals(1, root.getList("CUSTOMER").size());
+        assertEquals("5528 Wells Fargo Dr", root.get("CUSTOMER[1]/ADDRESS"));
+
+    }
+
+    public void testInsertWithParameters() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command insert = das.createCommand("insert into CUSTOMER values (?, ?, ?)");
+        insert.setParameter(1, new Integer(10));
+        insert.setParameter(2, "Williams");
+        insert.setParameter(3, "5528 Wells Fargo Dr");
+        insert.execute();
+
+        // Verify
+        Command select = das.createCommand("Select * from CUSTOMER where ID = 10");
+        DataObject root = select.executeQuery();
+        assertEquals(1, root.getList("CUSTOMER").size());
+        assertEquals("5528 Wells Fargo Dr", root.get("CUSTOMER[1]/ADDRESS"));
+
+    }
+
+    public void testDelete() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        // Verify pre-condition
+        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
+        DataObject root = select.executeQuery();
+        assertEquals(1, root.getList("CUSTOMER").size());
+
+        // Create and execute the delete command
+        Command delete = das.createCommand("delete from CUSTOMER where ID = 1");
+        delete.execute();
+
+        // Verify delete by reusing the original select command
+        root = select.executeQuery();
+        assertEquals(0, root.getList("CUSTOMER").size());
+
+    }
+
+    public void testUpdate() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        // Verify pre-condition
+        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
+        DataObject root = select.executeQuery();
+        assertFalse(root.get("CUSTOMER[1]/LASTNAME").equals("Pavick"));
+
+        Command update = das.createCommand("update CUSTOMER set LASTNAME = 'Pavick' where ID = 1");
+        update.execute();
+
+        // Verify update - reuse select command
+        root = select.executeQuery();
+        assertEquals("Pavick", root.get("CUSTOMER[1]/LASTNAME"));
+
+    }
+
+    public void testUpdateWithParameters() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        // Verify pre-condition
+        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
+        DataObject root = select.executeQuery();
+        assertFalse(root.get("CUSTOMER[1]/LASTNAME").equals("Pavick"));
+
+        Command update = das.createCommand("update CUSTOMER set LASTNAME = ? where ID = ?");
+        update.setParameter(1, "Pavick");
+        update.setParameter(2, new Integer(1));
+        update.execute();
+
+        // Verify update - reuse select command
+        root = select.executeQuery();
+        assertEquals("Pavick", root.get("CUSTOMER[1]/LASTNAME"));
+
+    }
+
     public void testUpdateWithParmarkers() throws Exception {
-    	DAS das = DAS.FACTORY.createDAS(getConnection());
-        //Verify pre-condition
-        Command select = das.createCommand("Select * from CUSTOMER where ID = 1"); 
-        DataObject root = select.executeQuery();    
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        // Verify pre-condition
+        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
+        DataObject root = select.executeQuery();
         assertFalse(root.get("CUSTOMER[1]/LASTNAME").equals("Pavick"));
-        
-        Command update = das.createCommand("update CUSTOMER set LASTNAME = ? where ID = ?");      
+
+        Command update = das.createCommand("update CUSTOMER set LASTNAME = ? where ID = ?");
         update.setParameter(1, "Pavick");
         update.setParameter(2, new Integer(1));
         update.execute();
-        
+
         //Verify update - reuse select command
-        root = select.executeQuery();   
+        root = select.executeQuery();
         assertEquals("Pavick", root.get("CUSTOMER[1]/LASTNAME"));
-        
+
     }
 
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/StoredProcs.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/StoredProcs.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/StoredProcs.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/StoredProcs.java Fri Sep 29 14:36:37 2006
@@ -18,185 +18,148 @@
  */
 package org.apache.tuscany.das.rdb.test;
 
-
 import org.apache.tuscany.das.rdb.Command;
 import org.apache.tuscany.das.rdb.DAS;
-import org.apache.tuscany.das.rdb.impl.ParameterImpl;
 import org.apache.tuscany.das.rdb.test.data.CompanyData;
 import org.apache.tuscany.das.rdb.test.data.CustomerData;
 import org.apache.tuscany.das.rdb.test.data.OrderData;
 import org.apache.tuscany.das.rdb.test.framework.DasTest;
 
 import commonj.sdo.DataObject;
-import commonj.sdo.helper.TypeHelper;
-
 
 public class StoredProcs extends DasTest {
 
-	protected void setUp() throws Exception {
-		super.setUp();
+    protected void setUp() throws Exception {
+        super.setUp();
 
-		new CompanyData(getAutoConnection()).refresh();
-		new CustomerData(getAutoConnection()).refresh();
-		new OrderData(getAutoConnection()).refresh();
-		
-	}
-
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
-
-	public void testMultipleResultSets() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		Command read = das.createCommand("{call GETALLCUSTOMERSANDORDERS()}");
-		
-		DataObject root = read.executeQuery();
-
-		//Verify
-		assertEquals(5, root.getList("CUSTOMER").size());
-		assertEquals(4, root.getList("ANORDER").size());
-	}
-	
-	// Call a simple stored proc to read all companies
-	public void testGetCompanies() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		Command read = das.createCommand("{call GETALLCOMPANIES()}");
-
-		DataObject root = read.executeQuery();
-
-		//Verify
-		assertEquals(3, root.getList("COMPANY").size());
-		assertTrue(root.getInt("COMPANY[1]/ID") > 0);
-
-	}
-
-	public void testGetNamedCompany() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		Command read = das.createCommand("{call GETNAMEDCOMPANY(?)}");
-	
-		read.setParameter(1, "MegaCorp");
-		DataObject root = read.executeQuery();
-
-		assertEquals("MegaCorp", root.getString("COMPANY[1]/NAME"));
-
-	}
-
-	public void testGetNamedCompanyByName() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		Command read = das
-				.createCommand("{call GETNAMEDCOMPANY(?)}");
-	
-		read.setParameter(1, "MegaCorp");
-		DataObject root = read.executeQuery();
-
-		assertEquals("MegaCorp", root.getString("COMPANY[1]/NAME"));
-	}
-
-
-	// Retreive heirarchy using a stored proc ... new programming model
-	public void testGetCustomersAndOrder() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
-		Command read = das.createCommand("{call getCustomerAndOrders(?)}");
-		read.setParameter(1, new Integer(1));
-		
-		DataObject root = read.executeQuery();
-
-		DataObject customer = (DataObject) root.getList("CUSTOMER").get(0);
-		assertEquals(2, customer.getList("orders").size());
-
-	}
-
-	/**
-	 * Call a stored proc requiring an in parameter and producing an out
-	 * parameter and a resultset
-	 * 
-	 * This stored proc takes a lastname argument and returns a graph of
-	 * customers with that last name. The number of read customers is returned
-	 * in the out parameter
-	 */
-	public void testGetNamedCustomers() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConfig("storedProcTest.xml"), getConnection());	
-		Command read = das.getCommand("getNamedCustomers");		
-		read.setParameter(1, "Williams");	
-		DataObject root = read.executeQuery();		
-		
-		Integer customersRead = (Integer) read.getParameter(2);
-
-		assertEquals(4, customersRead.intValue());
-		assertEquals(customersRead.intValue(), root.getList("CUSTOMER").size());
-
-	}
-	
-	//TODO - Resolve issue with programmatic creation of GETNAMEDCUSTOMERS on DB2 and
-	//re-enable this test
-	
-	
-	// Simplest possible SP write
-	public void testDelete() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		Command delete = das.createCommand("{call DELETECUSTOMER(?)}");		
-		delete.setParameter(1, new Integer(1));
-		delete.execute();
-
-		// Verify DELETE
-		Command select = das.createCommand("Select * from CUSTOMER where ID = 1");		
-		DataObject root = select.executeQuery();
-		assertTrue(root.getList("CUSTOMER").isEmpty());
-
-	}
-
-/*	// For debug
-	public void testRawCall() throws Exception {
-
-		Connection c = getConnection();
-		CallableStatement cs = c.prepareCall("{call GETNAMEDCUSTOMERS(?,?)}");
-		ParameterMetaData pm = cs.getParameterMetaData();
-		int count = pm.getParameterCount();
-		for (int i = 1; i <= count; i++) {
-			int mode = pm.getParameterMode(i);
-			if (mode == ParameterMetaData.parameterModeOut
-					|| mode == ParameterMetaData.parameterModeInOut)
-				cs.registerOutParameter(i, pm.getParameterType(i));
-		}
-		cs.setString(1, "Williams");
-		// cs.registerOutParameter(2,java.sql.Types.INTEGER);
-		boolean isResultSet = cs.execute();
-		System.out.println("Has a result set => " + isResultSet);
-		ResultSet rs = cs.getResultSet();
-
-		if (isResultSet) {
-			System.out.println("Results are: ");
-			while (rs.next()) {
-				System.out.println(rs.getObject(2));
-			}
-		}
-		System.out.println("Count is =>" + cs.getObject(2));
-		c.commit();
-	}
-
-	// For debug
-	public void testRawCall2() throws Exception {
-
-		Connection c = getConnection();
-		CallableStatement cs = c.prepareCall("{call getCustomerAndOrders(?)}");
-		cs.setObject(1, new Integer(1));
-		boolean isResultSet = cs.execute();
-		System.out.println("call getCustomerAndOrders(?) has a result set => "
-				+ isResultSet);
-		ResultSet rs = cs.getResultSet();
-
-		write(rs);
-		c.commit();
-	}
-
-	public void testGetAllOrders() throws Exception {
-
-		System.out.println("all orders");
-		Connection c = getConnection();
-		PreparedStatement s = c.prepareStatement("select * from anorder");
-		write (s.executeQuery());
-		c.commit();
+        new CompanyData(getAutoConnection()).refresh();
+        new CustomerData(getAutoConnection()).refresh();
+        new OrderData(getAutoConnection()).refresh();
+
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testMultipleResultSets() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command read = das.createCommand("{call GETALLCUSTOMERSANDORDERS()}");
+
+        DataObject root = read.executeQuery();
+
+        // Verify
+        assertEquals(5, root.getList("CUSTOMER").size());
+        assertEquals(4, root.getList("ANORDER").size());
+    }
+
+    // Call a simple stored proc to read all companies
+    public void testGetCompanies() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command read = das.createCommand("{call GETALLCOMPANIES()}");
+
+        DataObject root = read.executeQuery();
+
+        // Verify
+        assertEquals(3, root.getList("COMPANY").size());
+        assertTrue(root.getInt("COMPANY[1]/ID") > 0);
+
+    }
+
+    public void testGetNamedCompany() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command read = das.createCommand("{call GETNAMEDCOMPANY(?)}");
+
+        read.setParameter(1, "MegaCorp");
+        DataObject root = read.executeQuery();
+
+        assertEquals("MegaCorp", root.getString("COMPANY[1]/NAME"));
+
+    }
+
+    public void testGetNamedCompanyByName() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command read = das.createCommand("{call GETNAMEDCOMPANY(?)}");
+
+        read.setParameter(1, "MegaCorp");
+        DataObject root = read.executeQuery();
+
+        assertEquals("MegaCorp", root.getString("COMPANY[1]/NAME"));
+    }
+
+    // Retreive heirarchy using a stored proc ... new programming model
+    public void testGetCustomersAndOrder() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConfig("CustomersOrdersConfig.xml"), getConnection());
+        Command read = das.createCommand("{call getCustomerAndOrders(?)}");
+        read.setParameter(1, new Integer(1));
+
+        DataObject root = read.executeQuery();
+
+        DataObject customer = (DataObject) root.getList("CUSTOMER").get(0);
+        assertEquals(2, customer.getList("orders").size());
+
+    }
+
+    /**
+     * Call a stored proc requiring an in parameter and producing an out parameter and a resultset
+     * 
+     * This stored proc takes a lastname argument and returns a graph of customers with that last name. The number of read customers is returned in
+     * the out parameter
+     */
+    public void testGetNamedCustomers() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConfig("storedProcTest.xml"), getConnection());
+        Command read = das.getCommand("getNamedCustomers");
+        read.setParameter(1, "Williams");
+        DataObject root = read.executeQuery();
+
+        Integer customersRead = (Integer) read.getParameter(2);
+
+        assertEquals(4, customersRead.intValue());
+        assertEquals(customersRead.intValue(), root.getList("CUSTOMER").size());
+
+    }
+
+    // TODO - Resolve issue with programmatic creation of GETNAMEDCUSTOMERS on DB2 and
+    // re-enable this test
+
+    // Simplest possible SP write
+    public void testDelete() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        Command delete = das.createCommand("{call DELETECUSTOMER(?)}");
+        delete.setParameter(1, new Integer(1));
+        delete.execute();
+
+        // Verify DELETE
+        Command select = das.createCommand("Select * from CUSTOMER where ID = 1");
+        DataObject root = select.executeQuery();
+        assertTrue(root.getList("CUSTOMER").isEmpty());
+
+    }
+
+    /*
+     * // For debug public void testRawCall() throws Exception {
+     * 
+     * Connection c = getConnection(); CallableStatement cs = c.prepareCall("{call GETNAMEDCUSTOMERS(?,?)}"); ParameterMetaData pm =
+     * cs.getParameterMetaData(); int count = pm.getParameterCount(); for (int i = 1; i <= count; i++) { int mode = pm.getParameterMode(i); if (mode ==
+     * ParameterMetaData.parameterModeOut || mode == ParameterMetaData.parameterModeInOut) cs.registerOutParameter(i, pm.getParameterType(i)); }
+     * cs.setString(1, "Williams"); // cs.registerOutParameter(2,java.sql.Types.INTEGER); boolean isResultSet = cs.execute(); System.out.println("Has
+     * a result set => " + isResultSet); ResultSet rs = cs.getResultSet();
+     * 
+     * if (isResultSet) { System.out.println("Results are: "); while (rs.next()) { System.out.println(rs.getObject(2)); } } System.out.println("Count
+     * is =>" + cs.getObject(2)); c.commit(); }
+     *  // For debug public void testRawCall2() throws Exception {
+     * 
+     * Connection c = getConnection(); CallableStatement cs = c.prepareCall("{call getCustomerAndOrders(?)}"); cs.setObject(1, new Integer(1));
+     * boolean isResultSet = cs.execute(); System.out.println("call getCustomerAndOrders(?) has a result set => " + isResultSet); ResultSet rs =
+     * cs.getResultSet();
+     * 
+     * write(rs); c.commit(); }
+     * 
+     * public void testGetAllOrders() throws Exception {
+     * 
+     * System.out.println("all orders"); Connection c = getConnection(); PreparedStatement s = c.prepareStatement("select * from anorder"); write
+     * (s.executeQuery()); c.commit();
+     *  }
+     */
 
-	}*/
-	
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/TopDown.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/TopDown.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/TopDown.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/TopDown.java Fri Sep 29 14:36:37 2006
@@ -35,41 +35,40 @@
 
 public class TopDown extends DasTest {
 
-	protected void setUp() throws Exception {
-		super.setUp();
-		
-		new CustomerData(getAutoConnection()).refresh();
-		new OrderData(getAutoConnection()).refresh();
+    protected void setUp() throws Exception {
+        super.setUp();
 
-	}
+        new CustomerData(getAutoConnection()).refresh();
+        new OrderData(getAutoConnection()).refresh();
 
-	// Uses dynamic SDOs but user provides the model
-	public void testUserProvidedModelDynamic() throws SQLException, IOException {
+    }
+
+    // Uses dynamic SDOs but user provides the model
+    public void testUserProvidedModelDynamic() throws SQLException, IOException {
 
         DAS das = DAS.FACTORY.createDAS(getConfig("staticCustomerOrder.xml"), getConnection());
 
         Command select = das.getCommand("Customer and Orders");
-        
-        SDOUtil.registerStaticTypes(CustomerFactory.class);		
 
-		// Parameterize the command	
-		select.setParameter(1, new Integer(1));
+        SDOUtil.registerStaticTypes(CustomerFactory.class);
 
-		// Get the graph - DataGraphRoot is from the typed package
-		DataObject root = select.executeQuery();
+        // Parameterize the command
+        select.setParameter(1, new Integer(1));
 
-		// Modify a customer
-        Customer customer = (Customer)root.getDataObject("Customer[1]");
-		customer.setLastName("Pavick");
+        // Get the graph - DataGraphRoot is from the typed package
+        DataObject root = select.executeQuery();
 
-		// Modify an order
-		AnOrder order = (AnOrder) customer.getOrders().get(0);
-		order.setProduct("Kitchen Sink 001");
+        // Modify a customer
+        Customer customer = (Customer) root.getDataObject("Customer[1]");
+        customer.setLastName("Pavick");
 
-		// Flush changes
-		das.applyChanges((DataObject) root);
+        // Modify an order
+        AnOrder order = (AnOrder) customer.getOrders().get(0);
+        order.setProduct("Kitchen Sink 001");
 
-	}
+        // Flush changes
+        das.applyChanges((DataObject) root);
 
+    }
 
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/TypeTests.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/TypeTests.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/TypeTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/TypeTests.java Fri Sep 29 14:36:37 2006
@@ -33,61 +33,58 @@
 
 import commonj.sdo.DataObject;
 
-
 public class TypeTests extends DasTest {
 
-	
-	protected void setUp() throws Exception {
-		super.setUp();
-		new TypesData(getAutoConnection()).refresh();
-	}
-	
-	/**
-	 * Read various types.  
-	 */
-	public void testRead() throws Exception {
-		DAS das = DAS.FACTORY.createDAS(getConnection());
-		//Read customer 1
-		Command select = das.createCommand("Select * from TYPETEST where ID = 1");		
-		DataObject root = select.executeQuery();
-		
-		DataObject types = (DataObject)root.get("TYPETEST[1]");
-		
-		java.sql.Timestamp ts = (java.sql.Timestamp)types.get("ATIMESTAMP");
-		assertEquals(ts, TypesData.getTimestamp());
-		
-		float decimal = types.getFloat("ADECIMAL");
-		assertEquals(1234567.89f, decimal, .0001);
+    protected void setUp() throws Exception {
+        super.setUp();
+        new TypesData(getAutoConnection()).refresh();
+    }
+
+    /**
+     * Read various types.
+     */
+    public void testRead() throws Exception {
+        DAS das = DAS.FACTORY.createDAS(getConnection());
+        // Read customer 1
+        Command select = das.createCommand("Select * from TYPETEST where ID = 1");
+        DataObject root = select.executeQuery();
+
+        DataObject types = (DataObject) root.get("TYPETEST[1]");
+
+        java.sql.Timestamp ts = (java.sql.Timestamp) types.get("ATIMESTAMP");
+        assertEquals(ts, TypesData.getTimestamp());
+
+        float decimal = types.getFloat("ADECIMAL");
+        assertEquals(1234567.89f, decimal, .0001);
 
-	}
-	
+    }
 
     /**
      * Write various types.  
      * TODO - Need to rethink the Timestamp write.  My current thinking id that writes of non-SDO2 defined types 
      * require a converter
      */
-/*    public void testWrite() throws Exception {
+    /*    public void testWrite() throws Exception {
+
+     //Read customer 1
+     Command select = Command.FACTORY.createCommand("Select * from TYPETEST where ID = 1");  
+     select.setConnection(getConnection());
+     DataObject root = select.executeQuery();
+     
+     DataObject types = (DataObject)root.get("TYPETEST[1]");
+     Date now = new Date();
+     types.set("ATIMESTAMP", now);
+     
+     ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand();
+     apply.setConnection(getConnection());
+     apply.addPrimaryKey("TYPETEST.ID");
+     apply.execute(root);
+     
+     //Verify
+     root = select.executeQuery();
+     java.sql.Timestamp ts = (java.sql.Timestamp)types.get("ATIMESTAMP");
+     assertEquals(now, ts);
+     
+     }*/
 
-        //Read customer 1
-        Command select = Command.FACTORY.createCommand("Select * from TYPETEST where ID = 1");  
-        select.setConnection(getConnection());
-        DataObject root = select.executeQuery();
-        
-        DataObject types = (DataObject)root.get("TYPETEST[1]");
-        Date now = new Date();
-        types.set("ATIMESTAMP", now);
-        
-        ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand();
-        apply.setConnection(getConnection());
-        apply.addPrimaryKey("TYPETEST.ID");
-        apply.execute(root);
-        
-        //Verify
-        root = select.executeQuery();
-        java.sql.Timestamp ts = (java.sql.Timestamp)types.get("ATIMESTAMP");
-        assertEquals(now, ts);
-        
-    }*/
-	
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersByLastnameCommand.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersByLastnameCommand.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersByLastnameCommand.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersByLastnameCommand.java Fri Sep 29 14:36:37 2006
@@ -25,32 +25,32 @@
 import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper;
 import org.apache.tuscany.das.rdb.impl.ReadCommandImpl;
 
-
 public class ReadCustomersByLastnameCommand extends ReadCommandImpl {
 
-	private static final String sqlString = "select * from CUSTOMER where LASTNAME = ?";
-	private static final Config mapping;
-	
-	static {
-		ConfigFactory factory = ConfigFactory.INSTANCE;
-		mapping = factory.createConfig();
-		Table t = factory.createTable();
-		Column id = factory.createColumn();
-		id.setColumnName("ID");
-		id.setPrimaryKey(true);
-		Column lastname = factory.createColumn();
-		lastname.setColumnName("LASTNAME");
-		Column address = factory.createColumn();
-		address.setColumnName("ADDRESS");
-		
-		t.getColumn().add(id);
-		t.getColumn().add(lastname);
-		t.getColumn().add(address);
-		t.setTableName("CUSTOMER");
-		mapping.getTable().add(t);
-	}
-	
-	public ReadCustomersByLastnameCommand() {
-		super(sqlString, new MappingWrapper(mapping), null);
-	}
+    private static final String SQL_STRING = "select * from CUSTOMER where LASTNAME = ?";
+
+    private static final Config CONFIG;
+
+    static {
+        ConfigFactory factory = ConfigFactory.INSTANCE;
+        CONFIG = factory.createConfig();
+        Table t = factory.createTable();
+        Column id = factory.createColumn();
+        id.setColumnName("ID");
+        id.setPrimaryKey(true);
+        Column lastname = factory.createColumn();
+        lastname.setColumnName("LASTNAME");
+        Column address = factory.createColumn();
+        address.setColumnName("ADDRESS");
+
+        t.getColumn().add(id);
+        t.getColumn().add(lastname);
+        t.getColumn().add(address);
+        t.setTableName("CUSTOMER");
+        CONFIG.getTable().add(t);
+    }
+
+    public ReadCustomersByLastnameCommand() {
+        super(SQL_STRING, new MappingWrapper(CONFIG), null);
+    }
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersCommand.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersCommand.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersCommand.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersCommand.java Fri Sep 29 14:36:37 2006
@@ -25,33 +25,33 @@
 import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper;
 import org.apache.tuscany.das.rdb.impl.ReadCommandImpl;
 
-
 public class ReadCustomersCommand extends ReadCommandImpl {
 
-	private static final String sqlString = "select * from CUSTOMER";
-	private static final Config mapping;
-	
-	static {
-		ConfigFactory factory = ConfigFactory.INSTANCE;
-		mapping = factory.createConfig();
-		Table t = factory.createTable();
-		Column id = factory.createColumn();
-		id.setColumnName("ID");
-		id.setPrimaryKey(true);
-		Column lastname = factory.createColumn();
-		lastname.setColumnName("LASTNAME");
-		Column address = factory.createColumn();
-		address.setColumnName("ADDRESS");
-	
-		t.getColumn().add(id);
-		t.getColumn().add(lastname);
-		t.getColumn().add(address);
-		t.setTableName("CUSTOMER");
-		mapping.getTable().add(t);
-	}
-	
-	public ReadCustomersCommand() {
-		super(sqlString, new MappingWrapper(mapping), null);
-	}
+    private static final String SQL_STRING = "select * from CUSTOMER";
+
+    private static final Config CONFIG;
+
+    static {
+        ConfigFactory factory = ConfigFactory.INSTANCE;
+        CONFIG = factory.createConfig();
+        Table t = factory.createTable();
+        Column id = factory.createColumn();
+        id.setColumnName("ID");
+        id.setPrimaryKey(true);
+        Column lastname = factory.createColumn();
+        lastname.setColumnName("LASTNAME");
+        Column address = factory.createColumn();
+        address.setColumnName("ADDRESS");
+
+        t.getColumn().add(id);
+        t.getColumn().add(lastname);
+        t.getColumn().add(address);
+        t.setTableName("CUSTOMER");
+        CONFIG.getTable().add(t);
+    }
+
+    public ReadCustomersCommand() {
+        super(SQL_STRING, new MappingWrapper(CONFIG), null);
+    }
 
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersStaticTypesCommand.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersStaticTypesCommand.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersStaticTypesCommand.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersStaticTypesCommand.java Fri Sep 29 14:36:37 2006
@@ -25,38 +25,36 @@
 import org.apache.tuscany.das.rdb.config.wrapper.MappingWrapper;
 import org.apache.tuscany.das.rdb.impl.ReadCommandImpl;
 
-
 public class ReadCustomersStaticTypesCommand extends ReadCommandImpl {
 
-	private static final String sqlString = "Select ID, LASTNAME, ADDRESS from CUSTOMER where LASTNAME = ?";
-	private static final Config mapping;
-	
-	static {
-		ConfigFactory factory = ConfigFactory.INSTANCE;
-		mapping = factory.createConfig();
-		Table t = factory.createTable();
-		Column id = factory.createColumn();
-		id.setColumnName("ID");
-		id.setPrimaryKey(true);
-		Column lastname = factory.createColumn();
-		lastname.setColumnName("LASTNAME");
-		Column address = factory.createColumn();
-		address.setColumnName("ADDRESS");
-		
-		t.getColumn().add(id);
-		t.getColumn().add(lastname);
-		t.getColumn().add(address);
-		t.setTableName("CUSTOMER");
-		t.setTypeName("Customer");
-		mapping.getTable().add(t);
-		
-		mapping.setDataObjectModel("http:///org.apache.tuscany.das.rdb.test/customer.xsd");
-	}
-	
-	public ReadCustomersStaticTypesCommand() {
-		super(sqlString, new MappingWrapper(mapping), null);		
-	}
+    private static final String SQL_STRING = "Select ID, LASTNAME, ADDRESS from CUSTOMER where LASTNAME = ?";
+
+    private static final Config CONFIG;
+
+    static {
+        ConfigFactory factory = ConfigFactory.INSTANCE;
+        CONFIG = factory.createConfig();
+        Table t = factory.createTable();
+        Column id = factory.createColumn();
+        id.setColumnName("ID");
+        id.setPrimaryKey(true);
+        Column lastname = factory.createColumn();
+        lastname.setColumnName("LASTNAME");
+        Column address = factory.createColumn();
+        address.setColumnName("ADDRESS");
+
+        t.getColumn().add(id);
+        t.getColumn().add(lastname);
+        t.getColumn().add(address);
+        t.setTableName("CUSTOMER");
+        t.setTypeName("Customer");
+        CONFIG.getTable().add(t);
 
+        CONFIG.setDataObjectModel("http:///org.apache.tuscany.das.rdb.test/customer.xsd");
+    }
 
+    public ReadCustomersStaticTypesCommand() {
+        super(SQL_STRING, new MappingWrapper(CONFIG), null);
+    }
 
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersWithShapeCommand.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersWithShapeCommand.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersWithShapeCommand.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/ReadCustomersWithShapeCommand.java Fri Sep 29 14:36:37 2006
@@ -19,6 +19,7 @@
 package org.apache.tuscany.das.rdb.test.commands;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.tuscany.das.rdb.config.ConfigFactory;
 import org.apache.tuscany.das.rdb.config.ResultDescriptor;
@@ -26,35 +27,37 @@
 import org.apache.tuscany.das.rdb.impl.ReadCommandImpl;
 
 public class ReadCustomersWithShapeCommand extends ReadCommandImpl {
-//	 This sql string ensures that we won't have resultset metadata
-	static String sqlString = "select * from customer union select * from customer";	
-	static ArrayList descriptor = new ArrayList();
-	
-	static {
-		ConfigFactory factory = ConfigFactory.INSTANCE;
-		
-		ResultDescriptor desc1 = factory.createResultDescriptor();
-		desc1.setColumnName("ID");
-		desc1.setColumnType("commonj.sdo.Int");
-		desc1.setTableName("CUSTOMER");
-		
-		ResultDescriptor desc2 = factory.createResultDescriptor();
-		desc2.setColumnName("LASTNAME");
-		desc2.setColumnType("commonj.sdo.String");
-		desc2.setTableName("CUSTOMER");
-		
-		ResultDescriptor desc3 = factory.createResultDescriptor();
-		desc3.setColumnName("ADDRESS");
-		desc3.setColumnType("commonj.sdo.String");
-		desc3.setTableName("CUSTOMER");
-		
-		descriptor.add(desc1);
-		descriptor.add(desc2);
-		descriptor.add(desc3);
-		
-	}
-	public ReadCustomersWithShapeCommand() {
-		super(sqlString, new MappingWrapper(), descriptor);		
-	}
+    // This sql string ensures that we won't have resultset metadata
+    static String sqlString = "select * from customer union select * from customer";
+
+    static List descriptor = new ArrayList();
+
+    static {
+        ConfigFactory factory = ConfigFactory.INSTANCE;
+
+        ResultDescriptor desc1 = factory.createResultDescriptor();
+        desc1.setColumnName("ID");
+        desc1.setColumnType("commonj.sdo.Int");
+        desc1.setTableName("CUSTOMER");
+
+        ResultDescriptor desc2 = factory.createResultDescriptor();
+        desc2.setColumnName("LASTNAME");
+        desc2.setColumnType("commonj.sdo.String");
+        desc2.setTableName("CUSTOMER");
+
+        ResultDescriptor desc3 = factory.createResultDescriptor();
+        desc3.setColumnName("ADDRESS");
+        desc3.setColumnType("commonj.sdo.String");
+        desc3.setTableName("CUSTOMER");
+
+        descriptor.add(desc1);
+        descriptor.add(desc2);
+        descriptor.add(desc3);
+
+    }
+
+    public ReadCustomersWithShapeCommand() {
+        super(sqlString, new MappingWrapper(), descriptor);
+    }
 
 }

Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/SimpleReadCustomersWithShapeCommand.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/SimpleReadCustomersWithShapeCommand.java?view=diff&rev=451460&r1=451459&r2=451460
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/SimpleReadCustomersWithShapeCommand.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/commands/SimpleReadCustomersWithShapeCommand.java Fri Sep 29 14:36:37 2006
@@ -19,6 +19,7 @@
 package org.apache.tuscany.das.rdb.test.commands;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.tuscany.das.rdb.config.Column;
 import org.apache.tuscany.das.rdb.config.Config;
@@ -30,52 +31,53 @@
 
 public class SimpleReadCustomersWithShapeCommand extends ReadCommandImpl {
 
-	// This sql string ensures that we won't have resultset metadata
-	private static final String sqlString = "Select * from customer union select * from customer";
-	private static final ArrayList descriptor = new ArrayList();
-	
-	private static final Config config;
-
-	static {
-		ConfigFactory factory = ConfigFactory.INSTANCE;
-		config = factory.createConfig();
-		Table t = factory.createTable();
-		Column id = factory.createColumn();
-		id.setColumnName("ID");
-		id.setPrimaryKey(true);
-		Column lastname = factory.createColumn();
-		lastname.setColumnName("LASTNAME");
-		Column address = factory.createColumn();
-		address.setColumnName("ADDRESS");
-	
-		t.getColumn().add(id);
-		t.getColumn().add(lastname);
-		t.getColumn().add(address);
-		t.setTableName("CUSTOMER");
-		config.getTable().add(t);
-		
-		ResultDescriptor desc1 = factory.createResultDescriptor();
-		desc1.setColumnName("ID");
-		desc1.setColumnType("commonj.sdo.Int");
-		desc1.setTableName("CUSTOMER");
-		
-		ResultDescriptor desc2 = factory.createResultDescriptor();
-		desc2.setColumnName("LASTNAME");
-		desc2.setColumnType("commonj.sdo.String");
-		desc2.setTableName("CUSTOMER");
-		
-		ResultDescriptor desc3 = factory.createResultDescriptor();
-		desc3.setColumnName("ADDRESS");
-		desc3.setColumnType("commonj.sdo.String");
-		desc3.setTableName("CUSTOMER");
-		
-		descriptor.add(desc1);
-		descriptor.add(desc2);
-		descriptor.add(desc3);
-	}
-
-	public SimpleReadCustomersWithShapeCommand() {
-		super(sqlString, new MappingWrapper(config), descriptor);		
-	}
+    // This sql string ensures that we won't have resultset metadata
+    private static final String SQL_STRING = "Select * from customer union select * from customer";
+
+    private static final List DESCRIPTOR = new ArrayList();
+
+    private static final Config CONFIG;
+
+    static {
+        ConfigFactory factory = ConfigFactory.INSTANCE;
+        CONFIG = factory.createConfig();
+        Table t = factory.createTable();
+        Column id = factory.createColumn();
+        id.setColumnName("ID");
+        id.setPrimaryKey(true);
+        Column lastname = factory.createColumn();
+        lastname.setColumnName("LASTNAME");
+        Column address = factory.createColumn();
+        address.setColumnName("ADDRESS");
+
+        t.getColumn().add(id);
+        t.getColumn().add(lastname);
+        t.getColumn().add(address);
+        t.setTableName("CUSTOMER");
+        CONFIG.getTable().add(t);
+
+        ResultDescriptor desc1 = factory.createResultDescriptor();
+        desc1.setColumnName("ID");
+        desc1.setColumnType("commonj.sdo.Int");
+        desc1.setTableName("CUSTOMER");
+
+        ResultDescriptor desc2 = factory.createResultDescriptor();
+        desc2.setColumnName("LASTNAME");
+        desc2.setColumnType("commonj.sdo.String");
+        desc2.setTableName("CUSTOMER");
+
+        ResultDescriptor desc3 = factory.createResultDescriptor();
+        desc3.setColumnName("ADDRESS");
+        desc3.setColumnType("commonj.sdo.String");
+        desc3.setTableName("CUSTOMER");
+
+        DESCRIPTOR.add(desc1);
+        DESCRIPTOR.add(desc2);
+        DESCRIPTOR.add(desc3);
+    }
+
+    public SimpleReadCustomersWithShapeCommand() {
+        super(SQL_STRING, new MappingWrapper(CONFIG), DESCRIPTOR);
+    }
 
 }



---------------------------------------------------------------------
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