You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by kw...@apache.org on 2006/03/07 19:17:09 UTC
svn commit: r383953 -
/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/BestPracticeTests.java
Author: kwilliams
Date: Tue Mar 7 10:17:07 2006
New Revision: 383953
URL: http://svn.apache.org/viewcvs?rev=383953&view=rev
Log:
New "best practice" test case to demonstrate generated id's
Modified:
incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/BestPracticeTests.java
Modified: incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/BestPracticeTests.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/BestPracticeTests.java?rev=383953&r1=383952&r2=383953&view=diff
==============================================================================
--- incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/BestPracticeTests.java (original)
+++ incubator/tuscany/java/das/rdb/src/test/java/org/apache/tuscany/das/rdb/test/BestPracticeTests.java Tue Mar 7 10:17:07 2006
@@ -85,5 +85,50 @@
assertEquals (deptCount + 1, firstCustomer.getList("departments").size());
}
+ /**
+ * Test ability to correctly flush heirarchy of objects that have generated
+ * keys
+ */
+ public void testFlushCreateHeirarchy() throws Exception {
+
+ CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(getConfig("CompanyConfig.xml"));
+ Command select = commandGroup.getCommand("all companies and departments");
+ select.setConnection(getConnection());
+ DataObject root = select.executeQuery();
+
+ // Create a new Company
+ DataObject company = root.createDataObject("COMPANY");
+ company.setString("NAME", "Do-rite Pest Control");
+
+ // Create a new Department
+ //Do not set ID or CompanyID since these are generated
+ DataObject department = root.createDataObject("DEPARTMENT");
+ department.setString("NAME", "Do-rite Pest Control");
+ department.setString("LOCATION", "The boonies");
+ department.setString("NUMBER", "101");
+ department.setInt("EOTM", 1);
+
+ // Associate the new department with the new company
+ company.getList("departments").add(department);
+
+ // Get apply command
+ ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
+ apply.setConnection(getConnection());
+
+ // Flush changes
+ apply.execute(root);
+
+ // Save the id
+ Integer id = (Integer) company.get("ID");
+
+ // Verify the change
+
+ select = commandGroup.getCommand("company by id with departments");
+ select.setParameterValue("ID", id);
+ root = select.executeQuery();
+ assertEquals("Do-rite Pest Control", root.getDataObject("COMPANY[1]")
+ .getString("NAME"));
+
+ }
}