From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/tuscany/sdo/codegen/Bar1.java | 23 + .../java/org/apache/tuscany/sdo/codegen/Bar2.java | 23 + .../BytecodeInterfaceGeneratorTestCase.java | 164 ++++++ .../java/org/apache/tuscany/sdo/codegen/Foo.java | 23 + .../codegen/JavaInterfaceGeneratorTestCase.java | 126 ++++ .../apache/tuscany/sdo/codegen/MockProperty.java | 75 +++ .../org/apache/tuscany/sdo/codegen/MockType.java | 93 +++ .../tuscany/sdo/test/ChangeSummaryTestCase.java | 89 +++ .../tuscany/sdo/test/DataTypeBaseTypeTestCase.java | 65 +++ .../tuscany/sdo/test/DefineTypeTestCase.java | 632 +++++++++++++++++++++ .../apache/tuscany/sdo/test/MixedTypeTestCase.java | 86 +++ .../apache/tuscany/sdo/test/OpenTypeTestCase.java | 82 +++ .../tuscany/sdo/test/SimpleCopyTestCase.java | 68 +++ .../tuscany/sdo/test/SimpleDynamicTestCase.java | 78 +++ .../tuscany/sdo/test/SimpleEqualityTestCase.java | 60 ++ .../tuscany/sdo/test/SubstitutionValues.java | 24 + .../java/org/apache/tuscany/sdo/test/TestUtil.java | 282 +++++++++ .../apache/tuscany/sdo/test/TypeRoundTripTest.java | 161 ++++++ .../tuscany/sdo/test/XMLDocumentTestCase.java | 107 ++++ .../tuscany/sdo/test/XMLStreamHelperTestCase.java | 125 ++++ .../org/apache/tuscany/sdo/test/XPathTestCase.java | 125 ++++ .../apache/tuscany/sdo/test/XSDHelperTestCase.java | 61 ++ .../impl/src/test/resources/SubstitutionValues.xsd | 12 + .../XMLDocumentNoNamespaceSchemaLocation.xsd | 28 + .../test/resources/XMLDocumentSchemaLocation.xsd | 32 ++ .../src/test/resources/XMLDocumentTestCase.xml | 14 + .../sdo/impl/src/test/resources/customer1.xml | 8 + .../sdo/impl/src/test/resources/customer2.xml | 8 + .../sdo/impl/src/test/resources/datatype.xsd | 31 + .../sdo/impl/src/test/resources/foo-ext.xml | 9 + .../sdo/impl/src/test/resources/foo-ext.xsd | 41 ++ .../sdo/impl/src/test/resources/foo.xsd | 229 ++++++++ .../sdo/impl/src/test/resources/mixed.xml | 9 + .../sdo/impl/src/test/resources/mixed.xsd | 38 ++ .../sdo/impl/src/test/resources/mixed2.xml | 12 + .../sdo/impl/src/test/resources/mixedopen.xml | 13 + .../sdo/impl/src/test/resources/names.xsd | 30 + .../sdo/impl/src/test/resources/open.xml | 8 + .../sdo/impl/src/test/resources/open.xsd | 41 ++ .../sdo/impl/src/test/resources/open2.xml | 9 + .../sdo/impl/src/test/resources/quote.xml | 14 + .../sdo/impl/src/test/resources/sdoannotations.xsd | 57 ++ .../sdo/impl/src/test/resources/sdotypes.xsd | 68 +++ .../sdo/impl/src/test/resources/shallowquote.xml | 11 + .../sdo/impl/src/test/resources/simple.xsd | 38 ++ .../src/test/resources/simplechangesummary.xml | 36 ++ .../sdo/impl/src/test/resources/xpath.xml | 51 ++ .../sdo/impl/src/test/resources/xpath.xsd | 58 ++ 48 files changed, 3477 insertions(+) create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValues.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTest.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/SubstitutionValues.xsd create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/XMLDocumentSchemaLocation.xsd create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/XMLDocumentTestCase.xml create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/customer1.xml create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/customer2.xml create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/datatype.xsd create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/foo-ext.xml create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/foo-ext.xsd create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/foo.xsd create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/mixed.xml create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/mixed.xsd create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/mixed2.xml create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/mixedopen.xml create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/names.xsd create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/open.xml create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/open.xsd create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/open2.xml create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/quote.xml create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/sdoannotations.xsd create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/sdotypes.xsd create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/shallowquote.xml create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/simple.xsd create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/simplechangesummary.xml create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/xpath.xml create mode 100644 branches/java-post-M1/sdo/impl/src/test/resources/xpath.xsd (limited to 'branches/java-post-M1/sdo/impl/src/test') diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java new file mode 100644 index 0000000000..f862837715 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java @@ -0,0 +1,23 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * 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.codegen; + +/** + * @version $Rev$ $Date$ + */ +public interface Bar1 { +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java new file mode 100644 index 0000000000..35a878015f --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java @@ -0,0 +1,23 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * 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.codegen; + +/** + * @version $Rev$ $Date$ + */ +public interface Bar2 { +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java new file mode 100644 index 0000000000..7c64a42ab3 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java @@ -0,0 +1,164 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * 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.codegen; + +import java.lang.reflect.Method; +import java.util.List; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class BytecodeInterfaceGeneratorTestCase extends TestCase { + private MockType foo; + private BytecodeInterfaceGenerator gen; + private TestClassLoader cl; + + public void testHeaderNoBaseClass() { + gen.visitType(foo); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals("Foo", c.getName()); + assertTrue(c.isInterface()); + assertEquals(0, c.getInterfaces().length); + assertEquals(0, c.getMethods().length); + } + + public void testHeaderWithPackage() { + gen.visitType(new MockType("org.apache.Foo", null)); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals("org.apache.Foo", c.getName()); + assertEquals(0, c.getInterfaces().length); + assertEquals(0, c.getMethods().length); + } + + public void testHeaderOneBaseClass() throws NoJavaImplementationException { + foo.addBaseType(new MockType("bar1", Bar1.class)); + gen.visitType(foo); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals("Foo", c.getName()); + assertEquals(1, c.getInterfaces().length); + assertEquals(Bar1.class, c.getInterfaces()[0]); + assertEquals(0, c.getMethods().length); + } + + public void testHeaderMultipleBaseClass() throws NoJavaImplementationException { + foo.addBaseType(new MockType("bar1", Bar1.class)); + foo.addBaseType(new MockType("bar2", Bar2.class)); + gen.visitType(foo); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals("Foo", c.getName()); + assertEquals(2, c.getInterfaces().length); + assertEquals(Bar1.class, c.getInterfaces()[0]); + assertEquals(Bar2.class, c.getInterfaces()[1]); + assertEquals(0, c.getMethods().length); + } + + public void testBooleanProperty() throws NoJavaImplementationException, NoSuchMethodException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("true", Boolean.TYPE, false, false)); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals(2, c.getMethods().length); + Method getter = c.getMethod("isTrue", new Class[0]); + assertEquals(boolean.class, getter.getReturnType()); + Method setter = c.getMethod("setTrue", new Class[] {boolean.class}); + assertEquals(void.class, setter.getReturnType()); + } + + public void testByteArrayProperty() throws NoJavaImplementationException, NoSuchMethodException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("bytes", byte[].class, false, false)); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals(2, c.getMethods().length); + Method getter = c.getMethod("getBytes", new Class[0]); + assertEquals(byte[].class, getter.getReturnType()); + Method setter = c.getMethod("setBytes", new Class[] {byte[].class}); + assertEquals(void.class, setter.getReturnType()); + } + + public void testObjectProperty() throws NoJavaImplementationException, NoSuchMethodException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("bar", Bar1.class, false, false)); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals(2, c.getMethods().length); + Method getter = c.getMethod("getBar", new Class[0]); + assertEquals(Bar1.class, getter.getReturnType()); + Method setter = c.getMethod("setBar", new Class[] {Bar1.class}); + assertEquals(void.class, setter.getReturnType()); + } + + public void testReadOnlyProperty() throws NoJavaImplementationException, NoSuchMethodException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("int", Integer.TYPE, false, true)); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals(1, c.getMethods().length); + Method getter = c.getMethod("getInt", new Class[0]); + assertEquals(int.class, getter.getReturnType()); + } + + public void testManyProperty() throws NoJavaImplementationException, NoSuchMethodException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("list", Integer.TYPE, true, false)); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals(1, c.getMethods().length); + Method getter = c.getMethod("getList", new Class[0]); + assertEquals(List.class, getter.getReturnType()); + } + + public void testTwoProperties() throws NoJavaImplementationException, NoSuchMethodException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("true", Boolean.TYPE, false, false)); + gen.visitProperty(new MockProperty("int", Integer.TYPE, false, false)); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals(4, c.getMethods().length); + Method getter = c.getMethod("isTrue", new Class[0]); + assertEquals(boolean.class, getter.getReturnType()); + Method setter = c.getMethod("setTrue", new Class[] {boolean.class}); + assertEquals(void.class, setter.getReturnType()); + getter = c.getMethod("getInt", new Class[0]); + assertEquals(int.class, getter.getReturnType()); + setter = c.getMethod("setInt", new Class[] {int.class}); + assertEquals(void.class, setter.getReturnType()); + } + + protected void setUp() throws Exception { + super.setUp(); + foo = new MockType("foo", null); + gen = new BytecodeInterfaceGenerator(); + cl = new TestClassLoader(); + } + + private class TestClassLoader extends ClassLoader { + public TestClassLoader() { + super(TestClassLoader.class.getClassLoader()); + } + + Class addClass(byte[] bytes) { + return defineClass(null, bytes, 0, bytes.length); + } + } +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java new file mode 100644 index 0000000000..6a401d48bb --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java @@ -0,0 +1,23 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * 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.codegen; + +/** + * @version $Rev$ $Date$ + */ +public interface Foo { +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java new file mode 100644 index 0000000000..9d67b61317 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java @@ -0,0 +1,126 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * 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.codegen; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class JavaInterfaceGeneratorTestCase extends TestCase { + private static final String SEP = System.getProperty("line.separator"); + + private JavaInterfaceGenerator gen; + private StringWriter writer; + private MockType foo; + + public void testHeaderNoBaseClass() { + gen.visitType(foo); + gen.visitEnd(); + assertEquals(localize("public interface Foo {\n}\n"), writer.toString()); + } + + public void testHeaderWithPackage() { + gen.visitType(new MockType("org.apache.Foo", null)); + gen.visitEnd(); + assertEquals(localize("package org.apache;\n\npublic interface Foo {\n}\n"), writer.toString()); + } + + public void testHeaderOneBaseClass() throws NoJavaImplementationException { + foo.addBaseType(new MockType("bar1", Bar1.class)); + gen.visitType(foo); + gen.visitEnd(); + assertEquals(localize("public interface Foo extends org.apache.tuscany.sdo.codegen.Bar1 {\n}\n"), writer.toString()); + } + + public void testHeaderMultipleBaseClass() throws NoJavaImplementationException { + foo.addBaseType(new MockType("bar1", Bar1.class)); + foo.addBaseType(new MockType("bar2", Bar2.class)); + gen.visitType(foo); + gen.visitEnd(); + assertEquals(localize("public interface Foo extends org.apache.tuscany.sdo.codegen.Bar1, org.apache.tuscany.sdo.codegen.Bar2 {\n}\n"), writer.toString()); + } + + public void testBooleanProperty() throws NoJavaImplementationException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("true", Boolean.TYPE, false, false)); + gen.visitEnd(); + assertEquals(localize("public interface Foo {\n\tboolean isTrue();\n\tvoid setTrue(boolean value);\n}\n"), writer.toString()); + } + + public void testByteArrayProperty() throws NoJavaImplementationException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("bytes", byte[].class, false, false)); + gen.visitEnd(); + assertEquals(localize("public interface Foo {\n\tbyte[] getBytes();\n\tvoid setBytes(byte[] value);\n}\n"), writer.toString()); + } + + public void testObjectProperty() throws NoJavaImplementationException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("bar", Bar1.class, false, false)); + gen.visitEnd(); + assertEquals(localize("public interface Foo {\n\torg.apache.tuscany.sdo.codegen.Bar1 getBar();\n\tvoid setBar(org.apache.tuscany.sdo.codegen.Bar1 value);\n}\n"), writer.toString()); + } + + public void testReadOnlyProperty() throws NoJavaImplementationException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("int", Integer.TYPE, false, true)); + gen.visitEnd(); + assertEquals(localize("public interface Foo {\n\tint getInt();\n}\n"), writer.toString()); + } + + public void testManyProperty() throws NoJavaImplementationException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("list", Integer.TYPE, true, false)); + gen.visitEnd(); + assertEquals(localize("public interface Foo {\n\tjava.util.List getList();\n}\n"), writer.toString()); + } + + public void testTwoProperties() throws NoJavaImplementationException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("true", Boolean.TYPE, false, false)); + gen.visitProperty(new MockProperty("int", Integer.TYPE, false, false)); + gen.visitEnd(); + assertEquals(localize("public interface Foo {\n\tboolean isTrue();\n\tvoid setTrue(boolean value);\n\tint getInt();\n\tvoid setInt(int value);\n}\n"), writer.toString()); + } + + protected void setUp() throws Exception { + super.setUp(); + writer = new StringWriter(); + gen = new JavaInterfaceGenerator(new PrintWriter(writer)); + foo = new MockType("foo", null); + } + + private String localize(String s) { + StringBuffer b = new StringBuffer(s.length() + s.length()/10); + for (int i = 0; i < s.length(); i++) { + char ch = s.charAt(i); + if (ch == '\t') { + b.append(" "); + } else if (ch == '\n') { + b.append(SEP); + } else { + b.append(ch); + } + } + return b.toString(); + } + +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java new file mode 100644 index 0000000000..5cee856217 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java @@ -0,0 +1,75 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * 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.codegen; + +import java.util.List; + +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * @version $Rev$ $Date$ + */ +class MockProperty implements Property { + private final String name; + private final Type type; + private final boolean many; + private final boolean readOnly; + + public MockProperty(String name, Class type, boolean many, boolean readOnly) { + this.name = name; + this.type = new MockType(null, type); + this.many = many; + this.readOnly = readOnly; + } + + public String getName() { + return name; + } + + public Type getType() { + return type; + } + + public boolean isMany() { + return many; + } + + public boolean isContainment() { + throw new UnsupportedOperationException(); + } + + public Type getContainingType() { + throw new UnsupportedOperationException(); + } + + public Object getDefault() { + throw new UnsupportedOperationException(); + } + + public boolean isReadOnly() { + return readOnly; + } + + public Property getOpposite() { + throw new UnsupportedOperationException(); + } + + public List /*String*/ getAliasNames() { + throw new UnsupportedOperationException(); + } +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java new file mode 100644 index 0000000000..209d7021c0 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java @@ -0,0 +1,93 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * 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.codegen; + +import java.util.List; +import java.util.ArrayList; + +import commonj.sdo.Type; +import commonj.sdo.Property; + +/** + * @version $Rev$ $Date$ + */ +class MockType implements Type { + private final String name; + private final Class javaClass; + private final List baseTypes = new ArrayList(); + + public MockType(String name, Class javaClass) { + this.javaClass = javaClass; + this.name = name; + } + + public void addBaseType(Type baseType) { + baseTypes.add(baseType); + } + + public String getName() { + return name; + } + + public String getURI() { + throw new UnsupportedOperationException(); + } + + public Class getInstanceClass() { + return javaClass; + } + + public boolean isInstance(Object object) { + throw new UnsupportedOperationException(); + } + + public List /*Property*/ getProperties() { + throw new UnsupportedOperationException(); + } + + public Property getProperty(String propertyName) { + throw new UnsupportedOperationException(); + } + + public boolean isDataType() { + throw new UnsupportedOperationException(); + } + + public boolean isOpen() { + throw new UnsupportedOperationException(); + } + + public boolean isSequenced() { + throw new UnsupportedOperationException(); + } + + public boolean isAbstract() { + throw new UnsupportedOperationException(); + } + + public List /*Type*/ getBaseTypes() { + return baseTypes; + } + + public List /*Property*/ getDeclaredProperties() { + throw new UnsupportedOperationException(); + } + + public List /*String*/ getAliasNames() { + throw new UnsupportedOperationException(); + } +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java new file mode 100644 index 0000000000..4cc8c5e842 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java @@ -0,0 +1,89 @@ +/** + * + * Copyright 2005 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.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.net.URL; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.helper.XSDHelper; + + +public class ChangeSummaryTestCase extends TestCase { + private final String TEST_MODEL = "/simple.xsd"; + private final String TEST_DATA = "/simplechangesummary.xml"; + + /** + * Simple ChangeSummary test. + */ + public void testChangeSummary() throws IOException { + // Create an empty data graph and add a root object, an instance of type Quote + // + + DataGraph dataGraph = SDOUtil.createDataGraph(); + DataObject quote = dataGraph.createRootObject("http://www.example.com/simple", "Quote"); + + // Begin logging changes + // + ChangeSummary changeSummary = dataGraph.getChangeSummary(); + changeSummary.beginLogging(); + + // Modify the data graph in various fun and interesting ways + // + quote.setString("symbol", "fbnt"); + quote.setString("companyName", "FlyByNightTechnology"); + quote.setBigDecimal("price", new BigDecimal("1000.0")); + quote.setBigDecimal("open1", new BigDecimal("1000.0")); + quote.setBigDecimal("high", new BigDecimal("1000.0")); + quote.setBigDecimal("low", new BigDecimal("1000.0")); + quote.setDouble("volume", 1000); + quote.setDouble("change1", 1000); + + DataObject child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.0")); + + // Stop logging changes and print the resulting data graph to stdout + // + changeSummary.endLogging(); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SDOUtil.saveDataGraph(dataGraph, baos, null); + + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA))); + } + + 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(); + } +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java new file mode 100644 index 0000000000..faa8782a77 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java @@ -0,0 +1,65 @@ +/** + * + * Copyright 2005 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 java.util.List; + +import junit.framework.TestCase; + +import commonj.sdo.Type; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XSDHelper; + + +public class DataTypeBaseTypeTestCase extends TestCase { + private final String TEST_MODEL = "/datatype.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/datatype"; + + public void testSimpleSDOType() throws IOException + { + Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOType"); + List baseTypes = type.getBaseTypes(); + assertTrue(baseTypes.size() == 1); + } + + public void testSimpleSDOTypeInstanceClass() throws IOException + { + Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOTypeInstanceClass"); + List baseTypes = type.getBaseTypes(); + assertTrue(baseTypes.size() == 0); + } + + public void testSimpleSDOTypeExtendedInstanceClass() throws IOException + { + Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOTypeExtendedInstanceClass"); + List baseTypes = type.getBaseTypes(); + assertTrue(baseTypes.size() == 1); + } + + public void setUp() throws Exception + { + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + XSDHelper.INSTANCE.define(inputStream, url.toString()); + inputStream.close(); + } + +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java new file mode 100644 index 0000000000..b77b534be6 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java @@ -0,0 +1,632 @@ +/** + * + * Copyright 2005 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.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.math.BigDecimal; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; + +public class DefineTypeTestCase extends TestCase +{ + private static final String CUSTOMER1_XML = "/customer1.xml"; + private static final String CUSTOMER2_XML = "/customer2.xml"; + private static final String OPEN_XML = "/open2.xml"; + private static final String MIXED_XML = "/mixed2.xml"; + private static final String MIXEDOPEN_XML = "/mixedopen.xml"; + + public void testDefineTypeRoundTrip() throws Exception { + TypeHelper types = SDOUtil.createTypeHelper(); + DataFactory factory = SDOUtil.createDataFactory(types); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(types); + + Type intType = types.getType("commonj.sdo", "Int"); + Type stringType = types.getType("commonj.sdo", "String"); + + // create a new Type for Customers + DataObject customerType = factory.create("commonj.sdo", + "Type"); + customerType.set("uri", "http://example.com/customer"); + customerType.set("name", "Customer"); + + // create a customer number property + DataObject custNumProperty = customerType.createDataObject("property"); + custNumProperty.set("name", "custNum"); + custNumProperty.set("type", intType); + + // create a first name property + DataObject firstNameProperty = + customerType.createDataObject("property"); + firstNameProperty.set("name", "firstName"); + firstNameProperty.set("type", stringType); + + // create a last name property + DataObject lastNameProperty = customerType.createDataObject("property"); + lastNameProperty.set("name", "lastName"); + lastNameProperty.set("type", stringType); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save(customerType, "commonj.sdo", "type", baos); + + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + XMLDocument xdoc = xmlHelper.load(bais); + + customerType = xdoc.getRootObject(); + + // now define the Customer type so that customers can be made + types.define(customerType); + + DataObject customer1 = factory.create("http://example.com/customer", + "Customer"); + + customer1.setInt("custNum", 1); + customer1.set("firstName", "John"); + customer1.set("lastName", "Adams"); + DataObject customer2 = factory.create("http://example.com/customer", + "Customer"); + customer2.setInt("custNum", 2); + customer2.set("firstName", "Jeremy"); + customer2.set("lastName", "Pavick"); + + assertNotNull(customer1); + Type type = customer1.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertEquals(type.getProperty("custNum").getType(), intType); + assertEquals(type.getProperty("firstName").getType(), stringType); + assertEquals(type.getProperty("lastName").getType(), stringType); + + assertNotNull(customer2); + type = customer2.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertEquals(type.getProperty("custNum").getType(), intType); + assertEquals(type.getProperty("firstName").getType(), stringType); + assertEquals(type.getProperty("lastName").getType(), stringType); + + baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer1, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER1_XML))); + + baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer2, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER2_XML))); + } + + public void testDefineType() throws Exception + { + TypeHelper types = SDOUtil.createTypeHelper(); + DataFactory factory = SDOUtil.createDataFactory(types); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(types); + + Type intType = types.getType("commonj.sdo", "Int"); + Type stringType = types.getType("commonj.sdo", "String"); + + // create a new Type for Customers + DataObject customerType = factory.create("commonj.sdo", + "Type"); + customerType.set("uri", "http://example.com/customer"); + customerType.set("name", "Customer"); + + // create a customer number property + DataObject custNumProperty = customerType.createDataObject("property"); + custNumProperty.set("name", "custNum"); + custNumProperty.set("type", intType); + + // create a first name property + DataObject firstNameProperty = + customerType.createDataObject("property"); + firstNameProperty.set("name", "firstName"); + firstNameProperty.set("type", stringType); + + // create a last name property + DataObject lastNameProperty = customerType.createDataObject("property"); + lastNameProperty.set("name", "lastName"); + lastNameProperty.set("type", stringType); + + // now define the Customer type so that customers can be made + types.define(customerType); + + DataObject customer1 = factory.create("http://example.com/customer", + "Customer"); + customer1.setInt("custNum", 1); + customer1.set("firstName", "John"); + customer1.set("lastName", "Adams"); + DataObject customer2 = factory.create("http://example.com/customer", + "Customer"); + customer2.setInt("custNum", 2); + customer2.set("firstName", "Jeremy"); + customer2.set("lastName", "Pavick"); + + assertNotNull(customer1); + Type type = customer1.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertEquals(type.getProperty("custNum").getType(), intType); + assertEquals(type.getProperty("firstName").getType(), stringType); + assertEquals(type.getProperty("lastName").getType(), stringType); + + assertNotNull(customer2); + type = customer2.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertEquals(type.getProperty("custNum").getType(), intType); + assertEquals(type.getProperty("firstName").getType(), stringType); + assertEquals(type.getProperty("lastName").getType(), stringType); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer1, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER1_XML))); + + baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer2, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER2_XML))); + } + + public void testDefineDataType() throws Exception + { + TypeHelper types = SDOUtil.createTypeHelper(); + DataFactory factory = SDOUtil.createDataFactory(types); + XSDHelper xsdHelper = SDOUtil.createXSDHelper(types); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(types); + + Property javaClassProperty = xsdHelper.getGlobalProperty("commonj.sdo/java", "javaClass", false); + + // create a data types + DataObject intType = factory.create("commonj.sdo", "Type"); + intType.set("uri", "http://example.com/customer"); + intType.set("name", "MyIntType"); + intType.setBoolean("dataType", true); + intType.set(javaClassProperty, "int"); + + DataObject stringType = factory.create("commonj.sdo", "Type"); + stringType.set("uri", "http://example.com/customer"); + stringType.set("name", "MyStringType"); + stringType.setBoolean("dataType", true); + stringType.set(javaClassProperty, "java.lang.String"); + + // create a new Type for Customers + DataObject customerType = factory.create("commonj.sdo", + "Type"); + customerType.set("uri", "http://example.com/customer"); + customerType.set("name", "Customer"); + + // create a customer number property + DataObject custNumProperty = customerType.createDataObject("property"); + custNumProperty.set("name", "custNum"); + custNumProperty.set("type", intType); + + // create a first name property + DataObject firstNameProperty = + customerType.createDataObject("property"); + firstNameProperty.set("name", "firstName"); + firstNameProperty.set("type", stringType); + + // create a last name property + DataObject lastNameProperty = customerType.createDataObject("property"); + lastNameProperty.set("name", "lastName"); + lastNameProperty.set("type", stringType); + + // now define the Customer type so that customers can be made + types.define(customerType); + + DataObject customer1 = factory.create("http://example.com/customer", + "Customer"); + + customer1.setInt("custNum", 1); + customer1.set("firstName", "John"); + customer1.set("lastName", "Adams"); + DataObject customer2 = factory.create("http://example.com/customer", + "Customer"); + customer2.setInt("custNum", 2); + customer2.set("firstName", "Jeremy"); + customer2.set("lastName", "Pavick"); + + assertNotNull(customer1); + Type type = customer1.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + + type = type.getProperty("custNum").getType(); + assertEquals(type.getURI(), "http://example.com/customer"); + assertEquals(type.getName(), "MyIntType"); + assertTrue(type.isDataType()); + + assertNotNull(customer2); + type = customer2.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer1, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER1_XML))); + + baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer2, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER2_XML))); + } + + public void testFastDefineType() throws Exception + { + TypeHelper types = SDOUtil.createTypeHelper(); + DataFactory factory = SDOUtil.createDataFactory(types); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(types); + + Type intType = types.getType("commonj.sdo", "Int"); + Type stringType = types.getType("commonj.sdo", "String"); + + // create a new Type for Customers + Type customerType = SDOUtil.createType(types, "http://example.com/customer", "Customer", false); + + // create a customer number property + SDOUtil.createProperty(customerType, "custNum", intType); + + // create a first name property + SDOUtil.createProperty(customerType, "firstName", stringType); + + // create a last name property + SDOUtil.createProperty(customerType, "lastName", stringType); + + DataObject customer1 = factory.create("http://example.com/customer", + "Customer"); + customer1.setInt("custNum", 1); + customer1.set("firstName", "John"); + customer1.set("lastName", "Adams"); + DataObject customer2 = factory.create("http://example.com/customer", + "Customer"); + customer2.setInt("custNum", 2); + customer2.set("firstName", "Jeremy"); + customer2.set("lastName", "Pavick"); + + assertNotNull(customer1); + Type type = customer1.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertEquals(type.getProperty("custNum").getType(), intType); + assertEquals(type.getProperty("firstName").getType(), stringType); + assertEquals(type.getProperty("lastName").getType(), stringType); + + assertNotNull(customer2); + type = customer2.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertEquals(type.getProperty("custNum").getType(), intType); + assertEquals(type.getProperty("firstName").getType(), stringType); + assertEquals(type.getProperty("lastName").getType(), stringType); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer1, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER1_XML))); + + baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer2, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER2_XML))); + } + + public void testDefineSequencedType() throws Exception + { + + TypeHelper types = SDOUtil.createTypeHelper(); + DataFactory factory = SDOUtil.createDataFactory(types); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(types); + + Type stringType = types.getType("commonj.sdo", "String"); + Type decimalType = types.getType("commonj.sdo", "Decimal"); + + // Define a new mixed type - MixedQuote + DataObject mixedQuoteType = factory.create("commonj.sdo", "Type"); + mixedQuoteType.set("uri", "http://www.example.com/mixed"); + mixedQuoteType.set("name", "MixedQuote"); + mixedQuoteType.set("sequenced", Boolean.TRUE); + + DataObject symbolProperty = mixedQuoteType.createDataObject("property"); + symbolProperty.set("name", "symbol"); + symbolProperty.set("type", stringType); + + DataObject companyNameProperty = mixedQuoteType.createDataObject("property"); + companyNameProperty.set("name", "companyName"); + companyNameProperty.set("type", stringType); + + DataObject priceProperty = mixedQuoteType.createDataObject("property"); + priceProperty.set("name", "price"); + priceProperty.set("type", decimalType); + + DataObject quotesProperty = mixedQuoteType.createDataObject("property"); + quotesProperty.set("name", "quotes"); + quotesProperty.set("type", mixedQuoteType); + quotesProperty.set("many", Boolean.TRUE); + quotesProperty.set("containment", Boolean.TRUE); + + types.define(mixedQuoteType); + + DataObject quote = factory.create("http://www.example.com/mixed", "MixedQuote"); + + assertTrue(quote.getType().isSequenced()); + + Sequence sequence = quote.getSequence(); + + sequence.add("\n "); + + quote.setString("symbol", "fbnt"); + + sequence.add("\n "); + + quote.setString("companyName", "FlyByNightTechnology"); + + sequence.add("\n some text\n "); + + DataObject child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.0")); + + sequence.add("\n more text\n "); + + // quote.setBigDecimal("price", new BigDecimal("1000.0")); + sequence.add("price", new BigDecimal("1000.0")); + + sequence.add("\n"); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save(quote, "http://www.example.com/mixed", "mixedStockQuote", baos); + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MIXED_XML))); + } + + public void testDefineSequencedOpenType() throws Exception + { + + TypeHelper types = SDOUtil.createTypeHelper(); + DataFactory factory = SDOUtil.createDataFactory(types); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(types); + + Type stringType = types.getType("commonj.sdo", "String"); + Type decimalType = types.getType("commonj.sdo", "Decimal"); + + // Define a new mixed type - MixedQuote + DataObject mixedQuoteType = factory.create("commonj.sdo", "Type"); + mixedQuoteType.set("uri", "http://www.example.com/mixed"); + mixedQuoteType.set("name", "MixedOpenQuote"); + mixedQuoteType.set("sequenced", Boolean.TRUE); + mixedQuoteType.set("open", Boolean.TRUE); + +// DataObject symbolProperty = mixedQuoteType.createDataObject("property"); +// symbolProperty.set("name", "symbol"); +// symbolProperty.set("type", stringType); + + DataObject companyNameProperty = mixedQuoteType.createDataObject("property"); + companyNameProperty.set("name", "companyName"); + companyNameProperty.set("type", stringType); + + DataObject priceProperty = mixedQuoteType.createDataObject("property"); + priceProperty.set("name", "price"); + priceProperty.set("type", decimalType); + + DataObject quotesProperty = mixedQuoteType.createDataObject("property"); + quotesProperty.set("name", "quotes"); + quotesProperty.set("type", mixedQuoteType); + quotesProperty.set("many", Boolean.TRUE); + quotesProperty.set("containment", Boolean.TRUE); + + types.define(mixedQuoteType); + + // Define a global type + DataObject globalType = factory.create("commonj.sdo", "Type"); + globalType.set("uri", "http://www.example.com/open"); + // Don't set the type's name - null is used for types containing global properties. + + DataObject symbolProperty = globalType.createDataObject("property"); + symbolProperty.set("name", "symbol"); + symbolProperty.set("type", stringType); + symbolProperty.set("containment", Boolean.TRUE); + + types.define(globalType); + + DataObject quote = factory.create("http://www.example.com/mixed", "MixedOpenQuote"); + + assertTrue(quote.getType().isSequenced()); + + Sequence sequence = quote.getSequence(); + + sequence.add("\n "); + + Type definedGlobalType = types.getType("http://www.example.com/open", null); + + Property definedSymbolProperty = definedGlobalType.getProperty("symbol"); + quote.setString(definedSymbolProperty, "fbnt"); + + sequence.add("\n "); + + quote.setString("companyName", "FlyByNightTechnology"); + + sequence.add("\n some text\n "); + + DataObject child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.0")); + + sequence.add("\n more text\n "); + + // quote.setBigDecimal("price", new BigDecimal("1000.0")); + sequence.add("price", new BigDecimal("1000.0")); + + sequence.add("\n"); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save(quote, "http://www.example.com/mixed", "mixedOpenStockQuote", baos); + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MIXEDOPEN_XML))); + } + + + public void testDefineOpenType() throws Exception + { + TypeHelper types = SDOUtil.createTypeHelper(); + DataFactory factory = SDOUtil.createDataFactory(types); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(types); + + Type stringType = types.getType("commonj.sdo", "String"); + Type decimalType = types.getType("commonj.sdo", "Decimal"); + + // Define a new open type - OpenQuote + DataObject openQuoteType = factory.create("commonj.sdo", "Type"); + openQuoteType.set("uri", "http://www.example.com/open"); + openQuoteType.set("name", "OpenQuote"); + openQuoteType.set("open", Boolean.TRUE); + openQuoteType.setBoolean("open", true); + + types.define(openQuoteType); + + // Define new type - CompanyType + DataObject companyType = factory.create("commonj.sdo", "Type"); + companyType.set("uri", "http://www.example.com/open"); + companyType.set("name", "CompanyType"); + + // Create CompanyType property - "name" + DataObject nameProperty = companyType.createDataObject("property"); + nameProperty.set("name", "name"); + nameProperty.set("type", stringType); + nameProperty.set("containment", Boolean.TRUE); + + types.define(companyType); + + // Define a global type + DataObject globalType = factory.create("commonj.sdo", "Type"); + globalType.set("uri", "http://www.example.com/open"); + // Don't set the type's name - null is used for types containing global properties. + + DataObject symbolProperty = globalType.createDataObject("property"); + symbolProperty.set("name", "symbol"); + symbolProperty.set("type", stringType); + symbolProperty.set("containment", Boolean.TRUE); + + // Define a global property - company + DataObject companyProperty = globalType.createDataObject("property"); + companyProperty.set("name", "company"); + companyProperty.set("type", companyType); + companyProperty.set("containment", Boolean.TRUE); + + // Define a global property - price + DataObject priceProperty = globalType.createDataObject("property"); + priceProperty.set("name", "price"); + priceProperty.set("type", decimalType); + + types.define(globalType); + + // Create DataObject instances + DataObject openQuote = factory.create("http://www.example.com/open", "OpenQuote"); + + assertTrue(openQuote.getType().isOpen()); + + // Get global type + Type definedGlobalType = types.getType("http://www.example.com/open", null); + + Property definedSymbolProperty = definedGlobalType.getProperty("symbol"); + openQuote.set(definedSymbolProperty, "s1"); + + Property definedCompanyProperty = definedGlobalType.getProperty("company"); + + DataObject company = openQuote.createDataObject(definedCompanyProperty); + company.setString("name", "FlyByNightTechnology"); + + Property definedPriceProperty = definedGlobalType.getProperty("price"); + openQuote.setBigDecimal(definedPriceProperty, new BigDecimal("1000.0")); + + assertEquals(definedPriceProperty.getType(), decimalType); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save( + openQuote, + "http://www.example.com/open", + "openStockQuote", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(OPEN_XML))); + } + +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java new file mode 100644 index 0000000000..e46f9858e2 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java @@ -0,0 +1,86 @@ +/** + * + * Copyright 2005 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.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.net.URL; + +import commonj.sdo.DataObject; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; +import junit.framework.TestCase; + + +public class MixedTypeTestCase extends TestCase { + private final String TEST_MODEL = "/mixed.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/mixed"; + private final String TEST_DATA = "/mixed.xml"; + + /** + * Sequenced type SDO 2 test. + */ + public void testSequencedType() throws IOException { + Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "MixedQuote"); + DataObject quote = DataFactory.INSTANCE.create(quoteType); + + Sequence sequence = quote.getSequence(); + + sequence.add("\n "); + + quote.setString("symbol", "fbnt"); + + sequence.add("\n "); + + quote.setString("companyName", "FlyByNightTechnology"); + + sequence.add("\n some text\n "); + + DataObject child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.0")); + + sequence.add("\n more text\n "); + + // quote.setBigDecimal("price", new BigDecimal("1000.0")); + sequence.add("price", new BigDecimal("1000.0")); + + sequence.add("\n"); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + XMLHelper.INSTANCE.save(quote, TEST_NAMESPACE, "mixedStockQuote", baos); + + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA))); + } + + 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(); + } +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java new file mode 100644 index 0000000000..7e743e296a --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java @@ -0,0 +1,82 @@ +/** + * + * Copyright 2005 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.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.net.URL; +import java.util.Iterator; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; +import junit.framework.TestCase; + + +public class OpenTypeTestCase extends TestCase { + private final String TEST_MODEL = "/open.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/open"; + private final String TEST_DATA = "/open.xml"; + + /** + * Open content SDO 2 test. + */ + public void testOpenType() throws IOException { + Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "OpenQuote"); + DataObject quote = DataFactory.INSTANCE.create(quoteType); + + quote.setString("symbol", "s1"); + + for (Iterator iter = quote.getInstanceProperties().iterator(); iter.hasNext();) { + Property property = (Property) iter.next(); + } + + Property companyProperty = XSDHelper.INSTANCE.getGlobalProperty(TEST_NAMESPACE, "company", true); + DataObject company = quote.createDataObject(companyProperty); + company.setString("name", "FlyByNightTechnology"); + + Property priceProperty = XSDHelper.INSTANCE.getGlobalProperty(TEST_NAMESPACE, "price", true); + quote.getList(priceProperty).add(new BigDecimal("1000.0")); + + for (Iterator iter = quote.getInstanceProperties().iterator(); iter.hasNext();) { + Property property = (Property) iter.next(); + } + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + XMLHelper.INSTANCE.save(quote, TEST_NAMESPACE, "openStockQuote", baos); + + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA))); + } + + 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(); + } +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java new file mode 100644 index 0000000000..2e91a1a66f --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java @@ -0,0 +1,68 @@ +/** + * + * Copyright 2005 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.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.CopyHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; +import junit.framework.TestCase; + +public class SimpleCopyTestCase extends TestCase { + + private final String TEST_MODEL = "/simple.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/simple"; + private final String QUOTE_XML = "/quote.xml"; + private final String SHALLOW_QUOTE_XML = "/shallowquote.xml"; + + public void testSimpleCopy() throws IOException { + XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(QUOTE_XML)); + DataObject sdo = doc.getRootObject(); + + DataObject copiedSdo = CopyHelper.INSTANCE.copyShallow(sdo); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + XMLHelper.INSTANCE.save(copiedSdo, TEST_NAMESPACE, "stockQuote", baos); + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(SHALLOW_QUOTE_XML))); + assertFalse(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(QUOTE_XML))); + + copiedSdo = CopyHelper.INSTANCE.copy(sdo); + + baos.reset(); + XMLHelper.INSTANCE.save(copiedSdo, TEST_NAMESPACE, "stockQuote", baos); + assertFalse(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(SHALLOW_QUOTE_XML))); + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(QUOTE_XML))); + } + + 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(); + } + +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java new file mode 100644 index 0000000000..d86b793087 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java @@ -0,0 +1,78 @@ +/** + * + * Copyright 2005 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.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.net.URL; + +import junit.framework.TestCase; + +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 SimpleDynamicTestCase extends TestCase { + private final String TEST_MODEL = "/simple.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/simple"; + private final String QUOTE_XML = "/quote.xml"; + + /** + * Simple Dynamic SDO 2 test. + */ + public void testDynamic() throws IOException { + Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "Quote"); + DataObject quote = DataFactory.INSTANCE.create(quoteType); + + quote.setString("symbol", "fbnt"); + quote.setString("companyName", "FlyByNightTechnology"); + quote.setBigDecimal("price", new BigDecimal("1000.0")); + quote.setBigDecimal("open1", new BigDecimal("1000.0")); + quote.setBigDecimal("high", new BigDecimal("1000.0")); + quote.setBigDecimal("low", new BigDecimal("1000.0")); + quote.setDouble("volume", 1000); + quote.setDouble("change1", 1000); + + DataObject child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.0")); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + XMLHelper.INSTANCE.save(quote, TEST_NAMESPACE, "stockQuote", baos); + + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(QUOTE_XML))); + } + + + 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(); + } + +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java new file mode 100644 index 0000000000..ac05b362d9 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java @@ -0,0 +1,60 @@ +/** + * + * Copyright 2005 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 commonj.sdo.DataObject; +import commonj.sdo.helper.EqualityHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; +import junit.framework.TestCase; + +public class SimpleEqualityTestCase extends TestCase { + private static final String TEST_MODEL = "/simple.xsd"; + private static final String QUOTE_XML = "/quote.xml"; + private static final String SHALLOW_QUOTE_XML = "/shallowquote.xml"; + + public void testEquality() throws IOException { + + XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(QUOTE_XML)); + DataObject sdo = doc.getRootObject(); + + doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(SHALLOW_QUOTE_XML)); + DataObject shallowSdo = doc.getRootObject(); + + boolean result = EqualityHelper.INSTANCE.equalShallow(sdo, shallowSdo); + assertTrue(result); + + result = EqualityHelper.INSTANCE.equal(sdo, shallowSdo); + assertFalse(result); + } + + + 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(); + } +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValues.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValues.java new file mode 100644 index 0000000000..acc08c1056 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValues.java @@ -0,0 +1,24 @@ +package org.apache.tuscany.sdo.test; + +import java.net.URL; + +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.XSDHelper; +import commonj.sdo.helper.DataFactory; +import org.apache.tuscany.sdo.util.SDOUtil; + +public final class SubstitutionValues extends junit.framework.TestCase +{ + public void test() throws java.io.IOException + { + URL url = getClass().getResource("/SubstitutionValues.xsd"); + XSDHelper.INSTANCE.define(url.openStream(), url.toString()); + + final DataObject object = DataFactory.INSTANCE.create("http://www.apache.org/tuscany/SubstitutionValues", "TestObject"); + final Type type = object.getType(); + + assertNotNull( SDOUtil.getSubstitutionValues(object, type.getProperty("groupHead"))); + assertNull( SDOUtil.getSubstitutionValues(object, type.getProperty("nonGroupHead"))); + } +} \ No newline at end of file diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java new file mode 100644 index 0000000000..d2ac035e02 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java @@ -0,0 +1,282 @@ +/** + * + * Copyright 2005 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 java.util.ArrayList; +import java.util.List; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.FactoryConfigurationError; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.Document; +import org.w3c.dom.DocumentType; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +public class TestUtil +{ + private static void getAllNodes(NodeList nodeList, List nodes) + { + int length = nodeList.getLength(); + if (length == 0) + { + return; + } + + for (int i=0; i1Dummy2"; + + protected void setUp() throws Exception { + super.setUp(); + streamHelper = SDOUtil.createXMLStreamHelper(typeHelper); + URL url = getClass().getClassLoader().getResource(testName + ".xsd"); + xsdHelper.define(url.openStream(), url.toExternalForm()); + inputFactory = XMLInputFactory.newInstance(); + outputFactory = XMLOutputFactory.newInstance(); + url = getClass().getClassLoader().getResource(testName + ".xml"); + InputStreamReader reader = new InputStreamReader(url.openStream()); + StringBuffer stringBuffer = new StringBuffer(); + char buf[] = new char[1024]; + int size; + while ((size = reader.read(buf)) != -1) + stringBuffer.append(buf, 0, size); + xml = stringBuffer.toString(); + reader.close(); + } + + public void testLoadObject() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml)); + int event = reader.getEventType(); + while (!(event == XMLStreamConstants.START_ELEMENT && reader.getName().equals(name)) && reader.hasNext()) { + event = reader.next(); + } + DataObject dataObject = streamHelper.loadObject(reader); + Assert.assertNotNull(dataObject); + Assert.assertTrue(dataObject.getString("myAttr").equals("helloworld.HelloWorldImpl")); + } + + public void testLoad() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml)); + XMLDocument document = streamHelper.load(reader); + Assert.assertNotNull(document); + Assert.assertEquals(document.getRootElementURI(), module.getNamespaceURI()); + Assert.assertEquals(document.getRootElementName(), module.getLocalPart()); + DataObject moduleObject = document.getRootObject(); + List components = moduleObject.getList("component"); + DataObject componentObject = (DataObject) components.get(0); + // componentObject.getDataObject("implementation.mock"); + DataObject implObject = (DataObject) componentObject.getSequence(0).getValue(0); + Assert.assertTrue(implObject.getString("myAttr").equals("helloworld.HelloWorldImpl")); + } + + public void testSave() throws XMLStreamException { + XMLDocument document = XMLHelper.INSTANCE.load(xml); + StringWriter writer = new StringWriter(); + XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer); + streamHelper.save(document, streamWriter); + streamWriter.flush(); + String xmlStr = writer.toString(); + // System.out.println(xmlStr); + Assert.assertTrue(xmlStr.contains("myAttr=\"helloworld.HelloWorldImpl\"")); + } + + public void testSaveObject() throws XMLStreamException { + XMLDocument document = XMLHelper.INSTANCE.load(xml); + DataObject moduleObject = document.getRootObject(); + List components = moduleObject.getList("component"); + DataObject componentObject = (DataObject) components.get(0); + StringWriter writer = new StringWriter(); + XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer); + streamHelper.saveObject(componentObject, streamWriter); + streamWriter.flush(); + Assert.assertTrue(writer.toString().contains("myAttr=\"helloworld.HelloWorldImpl\"")); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java new file mode 100644 index 0000000000..7940663290 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java @@ -0,0 +1,125 @@ +/** + * + * 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"); + } + + public void testListIndexing() throws Exception { + 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 root = doc.getRootObject(); + DataObject folder1 = root.getDataObject("Folder[1]"); + assertNotNull(folder1); + DataObject folder1a = root.getDataObject("Folder.0"); + assertEquals(folder1, folder1a); + folder1a = root.getDataObject("Folder[FolderName=Folder00000000000]"); + assertEquals(folder1, folder1a); + + DataObject noFolder = null; + + try { + noFolder = root.getDataObject("Folder[3]"); + assertFalse("bad indexing passed", true); + } catch (IndexOutOfBoundsException iobe) { + // as expected + } catch (Exception e) { + assertFalse("bad indexing generated wrong exception" + e, true); + } + + try { + noFolder = root.getDataObject("Folder[0]"); + assertFalse("bad indexing passed", true); + } catch (IndexOutOfBoundsException iobe) { + // as expected + } catch (Exception e) { + assertFalse("bad indexing generated wrong exception" + e, true); + } + + try { + noFolder = root.getDataObject("Folder.2"); + assertFalse("bad indexing passed", true); + } catch (IndexOutOfBoundsException iobe) { + // as expected + } catch (Exception e) { + assertFalse("bad indexing generated wrong exception" + e, true); + } + + try { + noFolder = root.getDataObject("Folder.-1"); + assertFalse("bad indexing passed", true); + } catch (IndexOutOfBoundsException iobe) { + // as expected + } catch (Exception e) { + assertFalse("bad indexing generated wrong exception" + e, true); + } + + noFolder = root.getDataObject("Folder[FolderName=foo]"); + assertNull(noFolder); + } +} diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java new file mode 100644 index 0000000000..16a2cbd195 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java @@ -0,0 +1,61 @@ +/** + * + * Copyright 2005 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.net.URL; +import java.util.List; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import junit.framework.TestCase; + +import commonj.sdo.helper.XSDHelper; + +/** + * @version $Rev$ $Date$ + */ +public class XSDHelperTestCase extends TestCase { + private static final String TEST_MODEL = "/simple.xsd"; + private URL modelURL; + + public void testDefineWithLocation() throws IOException { + XSDHelper xsdHelper = SDOUtil.createXSDHelper(SDOUtil.createTypeHelper()); + List types = xsdHelper.define(modelURL.openStream(), modelURL.toString()); + assertEquals(2, types.size()); + } + + public void testDefineWithNoLocation() { + XSDHelper xsdHelper = SDOUtil.createXSDHelper(SDOUtil.createTypeHelper()); + List types = xsdHelper.define(getClass().getResourceAsStream(TEST_MODEL), null); + assertEquals(2, types.size()); + } + + public void testDuplicateDefineWithLocation() throws IOException { + XSDHelper xsdHelper = SDOUtil.createXSDHelper(SDOUtil.createTypeHelper()); + List types = xsdHelper.define(modelURL.openStream(), modelURL.toString()); + assertEquals(2, types.size()); + + List types2 = xsdHelper.define(modelURL.openStream(), modelURL.toString()); + assertEquals(0, types2.size()); + } + + protected void setUp() throws Exception { + super.setUp(); + modelURL = getClass().getResource(TEST_MODEL); + } +} diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/SubstitutionValues.xsd b/branches/java-post-M1/sdo/impl/src/test/resources/SubstitutionValues.xsd new file mode 100644 index 0000000000..ec4a25740f --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/SubstitutionValues.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd b/branches/java-post-M1/sdo/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd new file mode 100644 index 0000000000..42f9555d44 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/XMLDocumentSchemaLocation.xsd b/branches/java-post-M1/sdo/impl/src/test/resources/XMLDocumentSchemaLocation.xsd new file mode 100644 index 0000000000..268ea375f0 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/XMLDocumentSchemaLocation.xsd @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/XMLDocumentTestCase.xml b/branches/java-post-M1/sdo/impl/src/test/resources/XMLDocumentTestCase.xml new file mode 100644 index 0000000000..34e1648429 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/XMLDocumentTestCase.xml @@ -0,0 +1,14 @@ + + some string + + another string + + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/customer1.xml b/branches/java-post-M1/sdo/impl/src/test/resources/customer1.xml new file mode 100644 index 0000000000..0c18fa47fa --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/customer1.xml @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/customer2.xml b/branches/java-post-M1/sdo/impl/src/test/resources/customer2.xml new file mode 100644 index 0000000000..5b74c06c73 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/customer2.xml @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/datatype.xsd b/branches/java-post-M1/sdo/impl/src/test/resources/datatype.xsd new file mode 100644 index 0000000000..032f026137 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/datatype.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/foo-ext.xml b/branches/java-post-M1/sdo/impl/src/test/resources/foo-ext.xml new file mode 100644 index 0000000000..000909a52e --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/foo-ext.xml @@ -0,0 +1,9 @@ + + + 1Dummy2 + + + \ No newline at end of file diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/foo-ext.xsd b/branches/java-post-M1/sdo/impl/src/test/resources/foo-ext.xsd new file mode 100644 index 0000000000..cb74df8fa3 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/foo-ext.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/foo.xsd b/branches/java-post-M1/sdo/impl/src/test/resources/foo.xsd new file mode 100644 index 0000000000..fec090de71 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/foo.xsd @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/mixed.xml b/branches/java-post-M1/sdo/impl/src/test/resources/mixed.xml new file mode 100644 index 0000000000..42ff3a3a5b --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/mixed.xml @@ -0,0 +1,9 @@ + + + fbnt + FlyByNightTechnology + some text + 2000.0 + more text + 1000.0 + \ No newline at end of file diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/mixed.xsd b/branches/java-post-M1/sdo/impl/src/test/resources/mixed.xsd new file mode 100644 index 0000000000..c45fc87de2 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/mixed.xsd @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/mixed2.xml b/branches/java-post-M1/sdo/impl/src/test/resources/mixed2.xml new file mode 100644 index 0000000000..723d7bb891 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/mixed2.xml @@ -0,0 +1,12 @@ + + + fbnt + FlyByNightTechnology + some text + 2000.0 + more text + 1000.0 + \ No newline at end of file diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/mixedopen.xml b/branches/java-post-M1/sdo/impl/src/test/resources/mixedopen.xml new file mode 100644 index 0000000000..2409ce85a6 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/mixedopen.xml @@ -0,0 +1,13 @@ + + + fbnt + FlyByNightTechnology + some text + 2000.0 + more text + 1000.0 + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/names.xsd b/branches/java-post-M1/sdo/impl/src/test/resources/names.xsd new file mode 100644 index 0000000000..601ecc5f6a --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/names.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/open.xml b/branches/java-post-M1/sdo/impl/src/test/resources/open.xml new file mode 100644 index 0000000000..d4a5b92e0c --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/open.xml @@ -0,0 +1,8 @@ + + + s1 + + FlyByNightTechnology + + 1000.0 + \ No newline at end of file diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/open.xsd b/branches/java-post-M1/sdo/impl/src/test/resources/open.xsd new file mode 100644 index 0000000000..06881e3f05 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/open.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/open2.xml b/branches/java-post-M1/sdo/impl/src/test/resources/open2.xml new file mode 100644 index 0000000000..5bd70af711 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/open2.xml @@ -0,0 +1,9 @@ + + + s1 + + 1000.0 + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/quote.xml b/branches/java-post-M1/sdo/impl/src/test/resources/quote.xml new file mode 100644 index 0000000000..d7b5969e23 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/quote.xml @@ -0,0 +1,14 @@ + + + fbnt + FlyByNightTechnology + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + + 2000.0 + + \ No newline at end of file diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/sdoannotations.xsd b/branches/java-post-M1/sdo/impl/src/test/resources/sdoannotations.xsd new file mode 100644 index 0000000000..355e9e2ba3 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/sdoannotations.xsd @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/sdotypes.xsd b/branches/java-post-M1/sdo/impl/src/test/resources/sdotypes.xsd new file mode 100644 index 0000000000..aa0def2be6 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/sdotypes.xsd @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/shallowquote.xml b/branches/java-post-M1/sdo/impl/src/test/resources/shallowquote.xml new file mode 100644 index 0000000000..a56f2fe2b7 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/shallowquote.xml @@ -0,0 +1,11 @@ + + + fbnt + FlyByNightTechnology + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + \ No newline at end of file diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/simple.xsd b/branches/java-post-M1/sdo/impl/src/test/resources/simple.xsd new file mode 100644 index 0000000000..5310f7e1f3 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/simple.xsd @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/simplechangesummary.xml b/branches/java-post-M1/sdo/impl/src/test/resources/simplechangesummary.xml new file mode 100644 index 0000000000..1a34e0bf80 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/simplechangesummary.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + fbnt + FlyByNightTechnology + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + + 2000.0 + + + diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/xpath.xml b/branches/java-post-M1/sdo/impl/src/test/resources/xpath.xml new file mode 100644 index 0000000000..b1972b7260 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/xpath.xml @@ -0,0 +1,51 @@ + + + + Folder00000000000 + marries inflamed apprehended beseeming bustle + + + + Brian + rw + + + Fuhwei + r + + + + + Hasan + + + Frank + + + + + + Folder00000000011 + Mumbling Jumblin Pink Panther goofs it up + + + + Imad + x + + + Robbie + rwx + + + + + Yang + + + Art + + + + + \ No newline at end of file diff --git a/branches/java-post-M1/sdo/impl/src/test/resources/xpath.xsd b/branches/java-post-M1/sdo/impl/src/test/resources/xpath.xsd new file mode 100644 index 0000000000..258d1b40e6 --- /dev/null +++ b/branches/java-post-M1/sdo/impl/src/test/resources/xpath.xsd @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3