Author: kelvingoodson
Date: Fri Mar 14 03:27:01 2008
New Revision: 637039

URL: http://svn.apache.org/viewvc?rev=637039&view=rev
Log:
added test for TUSCANY-2080

Added:
    incubator/tuscany/java/sdo/tools-test/src/test/resources/stockquote.xml   
(with props)
Modified:
    
incubator/tuscany/java/sdo/tools-test/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java

Modified: 
incubator/tuscany/java/sdo/tools-test/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools-test/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java?rev=637039&r1=637038&r2=637039&view=diff
==============================================================================
--- 
incubator/tuscany/java/sdo/tools-test/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java
 (original)
+++ 
incubator/tuscany/java/sdo/tools-test/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java
 Fri Mar 14 03:27:01 2008
@@ -19,15 +19,24 @@
  */
 package org.apache.tuscany.sdo.test;
 
+import java.io.InputStream;
 import java.math.BigDecimal;
 
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.dom.DOMSource;
+
 import junit.framework.TestCase;
 
 import org.apache.tuscany.sdo.api.SDOUtil;
 
 import com.example.simple.Quote;
 import com.example.simple.SimpleFactory;
+
+import commonj.sdo.DataObject;
 import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.impl.HelperProvider;
 
 
 public class SimpleStaticTestCase extends TestCase
@@ -41,10 +50,6 @@
   {
     try
     {
-      SimpleFactory.INSTANCE.register(scope);
-      // System.out.println(SimpleFactoryImpl.PATTERN_VERSION);
-      
-      //Quote quote = (Quote)DataFactory.INSTANCE.create(Quote.class);
       Quote quote = SimpleFactory.INSTANCE.createQuote();
       
       quote.setSymbol("fbnt");
@@ -68,9 +73,32 @@
       e.printStackTrace();
     }
   }
+  
+  public void testSimpleStaticViaDomSource() throws Exception {
+    // created for TUSCANY-2080
+
+    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+    factory.setNamespaceAware(true);
+
+    DocumentBuilder builder = factory.newDocumentBuilder();
+
+    java.net.URL url = getClass().getResource("/stockquote.xml");
+    InputStream inputStream = url.openStream();
+    org.w3c.dom.Document dom = builder.parse(inputStream);
+
+    // Now load from dom to object
+    DOMSource source = new DOMSource(dom);
+
+    XMLDocument xml = scope.getXMLHelper().load(source, null, null);
+    assertTrue("Root element is not an instance of the generated class", xml
+        .getRootObject() instanceof Quote);
+
+  }
 
   protected void setUp() throws Exception {
     scope = SDOUtil.createHelperContext();
+    SimpleFactory.INSTANCE.register(scope);
+    
     super.setUp();
   }
   

Added: incubator/tuscany/java/sdo/tools-test/src/test/resources/stockquote.xml
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools-test/src/test/resources/stockquote.xml?rev=637039&view=auto
==============================================================================
--- incubator/tuscany/java/sdo/tools-test/src/test/resources/stockquote.xml 
(added)
+++ incubator/tuscany/java/sdo/tools-test/src/test/resources/stockquote.xml Fri 
Mar 14 03:27:01 2008
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.    
+ -->
+<simple:stockQuote xmlns:simple="http://www.example.com/simple";>
+  <symbol>fbnt</symbol>
+  <companyName>FlyByNightTechnology</companyName>
+  <price>1000.0</price>
+  <open1>1000.0</open1>
+  <high>1000.0</high>
+  <low>1000.0</low>
+  <volume>1000.0</volume>
+  <change1>1000.0</change1>
+  <quotes>
+    <price>2000.0</price>
+  </quotes>
+</simple:stockQuote>
\ No newline at end of file

Propchange: 
incubator/tuscany/java/sdo/tools-test/src/test/resources/stockquote.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sdo/tools-test/src/test/resources/stockquote.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: 
incubator/tuscany/java/sdo/tools-test/src/test/resources/stockquote.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to