You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by fr...@apache.org on 2006/12/11 18:36:28 UTC

svn commit: r485768 - in /incubator/tuscany/java/sdo/impl/src/test: java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java resources/simpleWithChangeSummary.xsd

Author: frankb
Date: Mon Dec 11 09:36:27 2006
New Revision: 485768

URL: http://svn.apache.org/viewvc?view=rev&rev=485768
Log:
New ChangeSummary test case

Added:
    incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java
Modified:
    incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java
    incubator/tuscany/java/sdo/impl/src/test/resources/simpleWithChangeSummary.xsd

Modified: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java?view=diff&rev=485768&r1=485767&r2=485768
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java (original)
+++ incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java Mon Dec 11 09:36:27 2006
@@ -50,12 +50,7 @@
   XSDHelper xh;
   TypeHelper th;
 
-  public void testNothing()
-  {
-    // just to keep junit happy whilst all other tests are commented out
-  }
-  
-  public void dont_testBasicsDO() {
+  public void testBasicsDO() {
     Type cst = TypeHelper.INSTANCE.getType("commonj.sdo","ChangeSummaryType");
     Type strt = TypeHelper.INSTANCE.getType("commonj.sdo", "String");
     
@@ -68,7 +63,7 @@
     testBasicsBody(strProp, iNewt);
 }
 
-  public void dont_testBasicsDG() {
+  public void testBasicsDG() {
 
     Type strt = TypeHelper.INSTANCE.getType("commonj.sdo", "String");
     
@@ -114,7 +109,7 @@
 
 
 
-  public void dont_testDynamicNestedDataObjectsDG() throws Exception {
+  public void testDynamicNestedDataObjectsDG() throws Exception {
     DataGraph dataGraph = SDOUtil.createDataGraph();
     DataObject quote = dataGraph.createRootObject(th.getType("http://www.example.com/simple", "Quote"));
 
@@ -137,8 +132,8 @@
 
   }
   
-  public void dont_testDynamicNestedDataObjectsDO() throws Exception {
-    Type quoteType = th.getType("http://www.example.com/simpleCS", "QuoteBase");
+  public void testDynamicNestedDataObjectsDO() throws Exception {
+    Type quoteType = th.getType("http://www.example.com/simpleCS", "RootQuote");
     DataObject quote = DataFactory.INSTANCE.create(quoteType);
 
     testDynamicNestedDOBody(quote);   

Added: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java?view=auto&rev=485768
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java (added)
+++ incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java Mon Dec 11 09:36:27 2006
@@ -0,0 +1,100 @@
+/**
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import commonj.sdo.ChangeSummary;
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+
+public class ChangeSummaryPropertyTestCase extends TestCase {
+    private final String TEST_MODEL = "/simpleWithChangeSummary.xsd";
+    private final String TEST_NAMESPACE = "http://www.example.com/simpleCS";
+
+    /**
+     * Simple ChangeSummary test.
+     */
+    public void testChangeSummary() throws Exception {
+        Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "RootQuote");
+        DataObject quote = DataFactory.INSTANCE.create(quoteType);
+        
+        ChangeSummary cs = quote.getChangeSummary();
+        ChangeSummary csp = (ChangeSummary)quote.get("changes");
+
+        assertSame(cs, csp);
+
+        quote.setString("symbol", "fbnt");
+        quote.setString("companyName", "FlyByNightTechnology");
+        quote.setBigDecimal("price", new BigDecimal("1000.0"));
+        DataObject child = quote.createDataObject("quotes");
+        child.setBigDecimal("price", new BigDecimal("1500.0"));
+        child = quote.createDataObject("quotes");
+        child.setBigDecimal("price", new BigDecimal("2000.0"));
+        child = quote.createDataObject("quotes");
+        child.setBigDecimal("price", new BigDecimal("2500.0"));
+
+        // Begin logging changes
+        //
+        cs.beginLogging();
+
+        // Modify the data graph in various ways
+        //
+        quote.setString("symbol", "FBNT");
+        quote.setBigDecimal("price", new BigDecimal("999.0"));
+        quote.setDouble("volume", 1000);
+
+        child = quote.createDataObject("quotes");
+        child.setBigDecimal("price", new BigDecimal("3000.0"));
+        child = quote.createDataObject("quotes");
+        child.setBigDecimal("price", new BigDecimal("4000.0"));
+
+        quote.getDataObject("quotes.1").delete();
+
+        // Stop logging changes and print the resulting data graph to stdout
+        //
+        cs.endLogging();
+
+        //XMLHelper.INSTANCE.save(quote, TEST_NAMESPACE, "rootQuote", System.out);
+               
+        cs.undoChanges();
+        
+        //System.out.println("\nAfter Undo Changes:");
+        //XMLHelper.INSTANCE.save(quote, TEST_NAMESPACE, "rootQuote", System.out);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // Populate the meta data for the test (Stock Quote) model
+        URL url = getClass().getResource(TEST_MODEL);
+        InputStream inputStream = url.openStream();
+        XSDHelper.INSTANCE.define(inputStream, url.toString());
+        inputStream.close();
+    }
+}

Modified: incubator/tuscany/java/sdo/impl/src/test/resources/simpleWithChangeSummary.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/test/resources/simpleWithChangeSummary.xsd?view=diff&rev=485768&r1=485767&r2=485768
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/test/resources/simpleWithChangeSummary.xsd (original)
+++ incubator/tuscany/java/sdo/impl/src/test/resources/simpleWithChangeSummary.xsd Mon Dec 11 09:36:27 2006
@@ -19,7 +19,7 @@
     		  
   <xsd:import namespace="commonj.sdo" schemaLocation="sdoModel.xsd"/>
   
-  <xsd:complexType name="QuoteBase">
+  <xsd:complexType name="RootQuote">
   	<xsd:complexContent>
   	  <xsd:extension base="simpleCS:Quote">
   	    <xsd:sequence>



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