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/05/24 16:59:16 UTC

svn commit: r409180 - in /incubator/tuscany/java/sdo/impl/src: main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java test/java/org/apache/tuscany/sdo/test/XPathTestCase.java test/resources/xpath.xml test/resources/xpath.xsd

Author: frankb
Date: Wed May 24 07:59:15 2006
New Revision: 409180

URL: http://svn.apache.org/viewvc?rev=409180&view=rev
Log:
Fix for TUSCANY-425

Added:
    incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java
    incubator/tuscany/java/sdo/impl/src/test/resources/xpath.xml
    incubator/tuscany/java/sdo/impl/src/test/resources/xpath.xsd
Modified:
    incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java

Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java?rev=409180&r1=409179&r2=409180&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java (original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java Wed May 24 07:59:15 2006
@@ -2085,7 +2085,7 @@
         }
         else if ('@' == c)
         {
-          x++; // skip @
+          // skip @
         }
         else
         {

Added: incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java?rev=409180&view=auto
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java (added)
+++ incubator/tuscany/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java Wed May 24 07:59:15 2006
@@ -0,0 +1,62 @@
+/**
+ *
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import junit.framework.TestCase;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+
+public class XPathTestCase extends TestCase {
+
+    private final String TEST_MODEL = "/xpath.xsd";
+    private final String XPATH_XML = "/xpath.xml";
+
+    /**
+     * The presence or absence of the @ sign in a path has no meaning.
+     * Properties are always matched by name independent of their XML representation.
+     * @throws IOException
+     */
+    public void testAtSignProperty() throws IOException {
+        TypeHelper typeHelper = SDOUtil.createTypeHelper();
+        XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper);
+        XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
+        
+        URL url = getClass().getResource(TEST_MODEL);
+        InputStream inputStream = url.openStream();
+        xsdHelper.define(inputStream, url.toString());
+        
+        inputStream.close();
+        
+        XMLDocument doc = xmlHelper.load(getClass().getResourceAsStream(XPATH_XML));
+          
+        DataObject drive = doc.getRootObject();
+        DataObject folder1 = (DataObject) drive.get("Folder.1");
+        String value = folder1.getString("@creation_date");
+         
+        assertEquals(value, "2000-03-23");
+    }
+}

Added: incubator/tuscany/java/sdo/impl/src/test/resources/xpath.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/test/resources/xpath.xml?rev=409180&view=auto
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/test/resources/xpath.xml (added)
+++ incubator/tuscany/java/sdo/impl/src/test/resources/xpath.xml Wed May 24 07:59:15 2006
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="ASCII"?>
+<xpath:drive xmlns:xpath="http://www.example.com/xpath" id="0">
+  <Folder creation_date="1999-10-20" creator="Hasan" type="FolderType">
+    <FolderName>Folder00000000000</FolderName>
+    <description>marries inflamed apprehended beseeming bustle</description>
+    <SecurityObject name="secure1">
+      <Allows>
+        <Allow>
+          <User>Brian</User>
+          <Permissions>rw</Permissions>
+        </Allow>
+        <Allow>
+          <User>Fuhwei</User>
+          <Permissions>r</Permissions>
+        </Allow>
+      </Allows>
+      <Denies>
+        <Deny>
+          <User>Hasan</User>
+        </Deny>
+        <Deny>
+          <User>Frank</User>
+        </Deny>
+      </Denies>
+    </SecurityObject>
+  </Folder>
+  <Folder creation_date="2000-03-23" creator="Kapil" type="FileType">
+    <FolderName>Folder00000000011</FolderName>
+    <description>Mumbling Jumblin Pink Panther goofs it up</description>
+    <SecurityObject name="secure2">
+      <Allows>
+        <Allow>
+          <User>Imad</User>
+          <Permissions>x</Permissions>
+        </Allow>
+        <Allow>
+          <User>Robbie</User>
+          <Permissions>rwx</Permissions>
+        </Allow>
+      </Allows>
+      <Denies>
+        <Deny>
+          <User>Yang</User>
+        </Deny>
+        <Deny>
+          <User>Art</User>
+        </Deny>
+      </Denies>
+    </SecurityObject>
+  </Folder>
+</xpath:drive>
\ No newline at end of file

Added: incubator/tuscany/java/sdo/impl/src/test/resources/xpath.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/test/resources/xpath.xsd?rev=409180&view=auto
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/test/resources/xpath.xsd (added)
+++ incubator/tuscany/java/sdo/impl/src/test/resources/xpath.xsd Wed May 24 07:59:15 2006
@@ -0,0 +1,58 @@
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns="http://www.example.com/xpath" targetNamespace="http://www.example.com/xpath"> 
+  
+   <xsd:element name="drive" type="DriveType"/>
+
+   <xsd:complexType name="DriveType">
+   	<xsd:sequence>
+		<xsd:element name="Folder" type="FolderType" minOccurs="0" maxOccurs="unbounded"/>
+	</xsd:sequence>
+	<xsd:attribute name="id" type="xsd:int"/>
+   </xsd:complexType>
+   
+   <xsd:complexType name="FolderType">
+        <xsd:sequence>
+            <xsd:element name="FolderName"   type="xsd:string"/>
+            <xsd:element name="description" type="xsd:string"/>
+            <xsd:element name="SecurityObject"   type="SecurityObjectType"/>
+        </xsd:sequence>
+        <xsd:attribute name="creation_date" type="xsd:date" minOccurs="0"/>
+        <xsd:attribute name="creator" type="xsd:string" minOccurs="0"/>
+        <xsd:attribute name="type" type="xsd:string" minOccurs="0"/>
+
+    </xsd:complexType>
+    
+    <xsd:complexType name="AllowsObjectType">
+    	<xsd:sequence>
+    		<xsd:element name="Allow" minOccurs="0" maxOccurs="unbounded">
+                <xsd:complexType>
+                    <xsd:sequence>
+                        <xsd:element name="User" type="xsd:string"/>
+                        <xsd:element name="Permissions"  type="xsd:string"/>
+                    </xsd:sequence>
+                </xsd:complexType>
+    		</xsd:element>
+        </xsd:sequence>
+     </xsd:complexType>
+     
+     <xsd:complexType name="DeniesObjectType">
+    	<xsd:sequence>
+    		<xsd:element name="Deny" minOccurs="0" maxOccurs="unbounded">
+                <xsd:complexType>
+                    <xsd:sequence>
+                        <xsd:element name="User" type="xsd:string"/>
+                    </xsd:sequence>
+                </xsd:complexType>
+    		</xsd:element>
+        </xsd:sequence>
+     </xsd:complexType>
+    
+    <xsd:complexType name="SecurityObjectType">
+        <xsd:sequence>
+            <xsd:element name="Allows" type="AllowsObjectType"/>
+        	<xsd:element name="Denies" type="DeniesObjectType"/>
+        </xsd:sequence>
+        <xsd:attribute name="name" type="xsd:string"/>
+    </xsd:complexType>
+
+</xsd:schema>



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