summaryrefslogtreecommitdiffstats
path: root/branches/java-post-M1/sdo/impl/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'branches/java-post-M1/sdo/impl/src/test/java')
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java23
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java23
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java164
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java23
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java126
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java75
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java93
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java89
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java65
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java632
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java86
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java82
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java68
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java78
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java60
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValues.java24
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java282
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTest.java161
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java107
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java125
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java125
-rw-r--r--branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java61
22 files changed, 0 insertions, 2572 deletions
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
deleted file mode 100644
index f862837715..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index 35a878015f..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index 7c64a42ab3..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index 6a401d48bb..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index 9d67b61317..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index 5cee856217..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index 209d7021c0..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index 4cc8c5e842..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index faa8782a77..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index b77b534be6..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java
+++ /dev/null
@@ -1,632 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index e46f9858e2..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index 7e743e296a..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index 2e91a1a66f..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index d86b793087..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index ac05b362d9..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index acc08c1056..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValues.java
+++ /dev/null
@@ -1,24 +0,0 @@
-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
deleted file mode 100644
index d2ac035e02..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/**
- *
- * 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; i<length; i++)
- {
- Node node = nodeList.item(i);
- nodes.add(node);
- getAllNodes(node.getChildNodes(), nodes);
- } // for
- }
-
- private static boolean equalNamedNodeMap(NamedNodeMap mapA, NamedNodeMap mapB) {
- if (mapA == null) {
- if (mapB == null) {
- return true;
- }
- return false;
- }
- if (mapA.getLength() != mapB.getLength()) {
- return false;
- }
- for (int i = 0; i < mapA.getLength(); i++) {
- Node trialNode = mapA.item(i);
- if (trialNode == null) {
- return false;
- }
- Node checkNode = mapB.getNamedItem(trialNode.getNodeName());
- if (checkNode == null) {
- return false;
- }
- if (!equalNode(trialNode, checkNode)) {
- return false;
- }
- }
- return true;
- }
-
- private static boolean equalNode(Node nodeA, Node nodeB) {
- if (nodeA == null) {
- if (nodeB == null) {
- return true;
- }
- return false;
- }
- // following is intended to provide same function as 1.5 isEqualNode()
- if (nodeA.getNodeType() != nodeB.getNodeType()) {
- return false;
- }
- if (!equalString(nodeA.getNodeName(), nodeB.getNodeName())) {
- return false;
- }
- if (!equalString(nodeA.getLocalName(), nodeB.getLocalName())) {
- return false;
- }
- if (!equalString(nodeA.getNamespaceURI(), nodeB.getNamespaceURI())) {
- return false;
- }
- if (!equalString(nodeA.getNamespaceURI(), nodeB.getNamespaceURI())) {
- return false;
- }
- if (!equalString(nodeA.getPrefix(), nodeB.getPrefix())) {
- return false;
- }
- if (!equalString(nodeA.getNodeValue(), nodeB.getNodeValue())) {
- return false;
- }
- if (!equalNamedNodeMap(nodeA.getAttributes(), nodeB.getAttributes())) {
- return false;
- }
- if (!equalNodeList(nodeA.getChildNodes(), nodeB.getChildNodes())) {
- return false;
- }
- if (nodeA.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
- DocumentType documentTypeA = (DocumentType) nodeA;
- DocumentType documentTypeB = (DocumentType) nodeB;
- if (!equalString(documentTypeA.getPublicId(), documentTypeB.getPublicId())) {
- return false;
- }
- if (!equalString(documentTypeA.getSystemId(), documentTypeB.getSystemId())) {
- return false;
- }
- if (!equalString(documentTypeA.getInternalSubset(), documentTypeB.getInternalSubset())) {
- return false;
- }
- if (!equalNamedNodeMap(documentTypeA.getEntities(), documentTypeB.getEntities())) {
- return false;
- }
- if (!equalNamedNodeMap(documentTypeA.getNotations(), documentTypeB.getNotations())) {
- return false;
- }
- }
- return true;
- }
-
- private static boolean equalNodeList(NodeList nodeListA, NodeList nodeListB) {
- if (nodeListA == null) {
- if (nodeListB == null) {
- return true;
- }
- return false;
- }
- return equalNodes(nodeListA, nodeListB);
- }
-
- private static boolean equalString(String stringA, String stringB) {
- if (stringA == null) {
- if (stringB == null) {
- return true;
- }
- return false;
- }
- return stringA.equals(stringB);
- }
-
- private static boolean equalNodes(NodeList sourceNodeList, NodeList targetNodeList)
- {
- ArrayList sourceNodes = new ArrayList();
- ArrayList targetNodes = new ArrayList();
-
- getAllNodes(sourceNodeList, sourceNodes);
- getAllNodes(targetNodeList, targetNodes);
-
- int sourceLength = sourceNodes.size();
- int targetLength = targetNodes.size();
-
- if (sourceLength != targetLength)
- {
- return false;
- }
-
- for (int i=0; i<sourceLength; i++)
- {
- Node sourceNode = (Node)sourceNodes.get(i);
- Node targetNode = (Node)targetNodes.get(i);
-
- /* remove comment when migrated to Java 1.5
- if (!sourceNode.isEqualNode(targetNode))
- {
- return false;
- }
- */
- // following is intended as 1.4 equivalent of isEqualNode()
- if (!equalNode(sourceNode, targetNode))
- {
- return false;
- }
- } // for
-
- return true;
- }
-
- public static boolean equalXmlFiles(URL source, URL target)
- {
- try {
- return equalXmlFiles(source.openStream(), target.openStream());
- }
- catch (IOException e)
- {
- return false;
- }
- }
-
- public static boolean equalXmlFiles(InputStream sourceStream, URL target)
- {
- try {
- return equalXmlFiles(sourceStream, target.openStream());
- }
- catch (IOException e)
- {
- return false;
- }
- }
-
- public static boolean equalXmlFiles(URL source, InputStream targetStream)
- {
- try {
- return equalXmlFiles(source.openStream(), targetStream);
- }
- catch (IOException e)
- {
- return false;
- }
- }
-
- public static boolean equalXmlFiles(InputStream sourceStream, InputStream targetStream)
- {
- DocumentBuilder builder;
- Document sourceDocument;
- Document targetDocument;
-
- try {
- builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- sourceDocument = builder.parse(sourceStream);
- targetDocument = builder.parse(targetStream);
- }
- catch (FactoryConfigurationError fce) {
- return false;
- }
- catch (ParserConfigurationException ce) {
- return false;
- }
- catch (SAXException se)
- {
- return false;
- }
- catch (IOException ie)
- {
- return false;
- }
-
- sourceDocument.normalize();
- targetDocument.normalize();
-
- /* remove comment when migrated to Java 1.5
- if (!sourceDocument.getXmlVersion().equals(targetDocument.getXmlVersion()))
- {
- return false;
- }
-
- String sourceXmlEncoding = sourceDocument.getXmlEncoding();
- String targetXmlEncoding = targetDocument.getXmlEncoding();
-
- if (sourceXmlEncoding != null && targetXmlEncoding != null &&
- sourceXmlEncoding.equalsIgnoreCase(targetXmlEncoding))
- {
- // continue
- }
- else
- {
- return false;
- }
- */
-
- NodeList sourceNodes = sourceDocument.getChildNodes();
- NodeList targetNodes = targetDocument.getChildNodes();
-
- return equalNodes(sourceNodes, targetNodes);
- }
-}
diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTest.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTest.java
deleted file mode 100644
index b14ae165dc..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- *
- * 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 junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.util.SDOUtil;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-
-import commonj.sdo.Type;
-import commonj.sdo.helper.TypeHelper;
-
-public class TypeRoundTripTest extends TestCase {
-
- private static class Test {
- Type type;
- String value;
- Object obj;
- Comparator comp;
-
- Test(Type type, String value, Object obj) {
- this.type = type;
- this.value = value;
- this.obj = obj;
- }
-
- Test(Type type, String value, Object obj, Comparator comp) {
- this.type = type;
- this.value = value;
- this.obj = obj;
- this.comp = comp;
- }
- }
-
- private static class ListComparator implements Comparator {
- public int compare(Object list1, Object list2) {
- int answer = 1;
- if (list1 instanceof List && list2 instanceof List) {
- List l1 = (List) list1;
- List l2 = (List) list2;
- if (l1.size() == l2.size()) {
- for (int n = 0; n < l1.size(); n++) {
- if (!l1.get(n).equals(l2.get(n))) {
- answer = 0;
- break;
- }
- }
- } else {
- answer = 0;
- }
- } else {
- answer = 0;
- }
- return answer;
- }
- }
-
- private static class BytesComparator implements Comparator {
- public int compare(Object o1, Object o2) {
- o2 = new String((byte[])o2);
- if (o1.equals(o2)) return 1;
- else return 0;
- }
- }
-
- private static class DateComparator implements Comparator {
- public int compare(Object o1, Object o2) {
- int answer = 1;
- try {
- if (o1 instanceof String && o2 instanceof Date) {
- SimpleDateFormat sdf =
- new SimpleDateFormat("yyyy-MM-dd'Z'");
- o1 = sdf.parse((String)o1);
- if (!o1.equals(o2)) answer = 0;
- } else {
- answer = 0;
- }
- } catch (Exception e) {}
- return answer;
- }
- }
-
- public void testTypeRoundTrips() throws Exception {
- String URI = "commonj.sdo";
- TypeHelper types = TypeHelper.INSTANCE;
- List list = new ArrayList();
- list.add("foo");
- list.add("bar");
- list.add("test");
- Test[] tests = {
- new Test(types.getType(URI, "Boolean"), "true", new Boolean(true)),
- new Test(types.getType(URI, "Byte"), "49", new Byte((byte)49)),
- new Test(types.getType(URI, "Bytes"), "Zm9v", "foo", new BytesComparator()),
- new Test(types.getType(URI, "Character"), "a", new Character('a')),
- new Test(types.getType(URI, "Date"), "2005-12-12Z", "2005-12-12Z", new DateComparator()),
- new Test(types.getType(URI, "DateTime"), "2005-12-12T12:12:12Z", "2005-12-12T12:12:12Z"),
- new Test(types.getType(URI, "Day"), "---12", "---12"),
- new Test(types.getType(URI, "Decimal"), "12.12", new BigDecimal("12.12")),
- new Test(types.getType(URI, "Double"), "12.12", new Double(12.12)),
- new Test(types.getType(URI, "Duration"), "P5Y2M10D", "P5Y2M10D"),
- new Test(types.getType(URI, "Float"), "12.12", new Float(12.12f)),
- new Test(types.getType(URI, "Int"), "12", new Integer(12)),
- new Test(types.getType(URI, "Integer"), "12", new BigInteger("12")),
- new Test(types.getType(URI, "Long"), "12", new Long(12l)),
- new Test(types.getType(URI, "Month"), "--12", "--12"),
- new Test(types.getType(URI, "MonthDay"), "--12-12", "--12-12"),
- new Test(types.getType(URI, "Object"), "test", "test"),
- new Test(types.getType(URI, "Short"), "12", new Short((short)12)),
- new Test(types.getType(URI, "String"), "test", "test"),
- new Test(types.getType(URI, "Strings"), "foo bar test", list, new ListComparator()),
- new Test(types.getType(URI, "Time"), "12:12:12.12", "12:12:12.12"),
- new Test(types.getType(URI, "URI"), "http://example.org", "http://example.org"),
- new Test(types.getType(URI, "Year"), "2005", "2005"),
- new Test(types.getType(URI, "YearMonth"), "2005-12", "2005-12"),
- new Test(types.getType(URI, "YearMonthDay"), "2005-12-12", "2005-12-12")
- };
-
- for (int n = 0; n < tests.length; n++) {
- assertEquals(
- SDOUtil.convertToString(tests[n].type, SDOUtil.createFromString(tests[n].type, tests[n].value)),
- tests[n].value
- );
-
- //System.out.print(".");
-
- if (tests[n].comp == null) {
- assertEquals(
- SDOUtil.createFromString(tests[n].type, SDOUtil.convertToString(tests[n].type, tests[n].obj)),
- tests[n].obj
- );
- } else {
- String o1 = SDOUtil.convertToString(tests[n].type, tests[n].obj);
- Object o2 = SDOUtil.createFromString(tests[n].type, o1);
- assertEquals(tests[n].comp.compare(tests[n].obj, o2), 1);
- }
- }
-
- }
-
-}
diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java
deleted file mode 100644
index c4f2cc4586..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- *
- * 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 junit.framework.TestCase;
-
-import commonj.sdo.helper.XMLDocument;
-import commonj.sdo.helper.XMLHelper;
-
-
-public class XMLDocumentTestCase extends TestCase
-{
- private final String TEST_XML_DOCUMENT = "/XMLDocumentTestCase.xml";
-
- // remember that NS1... and NS2... items are expected in sorted order by name
- private final String NS1_SCHEMA_NAME = "http://www.example.com/open";
-
- private final String NS1_SCHEMA_LOCATION = "/open.xsd";
-
- private final String NS2_SCHEMA_NAME = "http://www.example.com/xmlDocumentSchemaLocation";
-
- private final String NS2_SCHEMA_LOCATION = "/XMLDocumentSchemaLocation.xsd";
-
- private final String NS_SET_NAME_LOCATION = "namespace schemaLocation";
-
- //private final String NNS_SCHEMA_LOCATION = "http://www.example.com/XMLDocumentNoNamespaceSchemaLocation.xsd";
- private final String NNS_SCHEMA_LOCATION = "/XMLDocumentNoNamespaceSchemaLocation.xsd";
-
- private final String NNS_SET_LOCATION = "noNamespaceSchemaLocation";
-
- /**
- * This method will load an xml document consisting of a xsi:schemaLocation and
- * xsi:noNamespaceSchemaLocation defined. It will then use the XMLDocument API to get and
- * set the schemaLocation property.
- *
- * @throws IOException
- */
- public void testSchemaLocation() throws IOException
- {
- // load the xml document which has xsi:noNamespaceSchemaLocation and xsi:schemaLocation defined
- XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT));
-
- // get the schemaLocation
- assertEquals(NS1_SCHEMA_NAME + " " + NS1_SCHEMA_LOCATION + " " + NS2_SCHEMA_NAME + " " + NS2_SCHEMA_LOCATION, doc.getSchemaLocation());
-
- // set the schemaLocation to another value and test to see if the value was set
- doc.setSchemaLocation(NS_SET_NAME_LOCATION);
- assertEquals(NS_SET_NAME_LOCATION, doc.getSchemaLocation());
-
- // remove the schemaLocation and ensure it returns null
- doc.setSchemaLocation(null);
- assertNull(doc.getSchemaLocation());
-
- // ensure changes to schemaLocation have not changed noNamespaceSchemaLocation
- assertEquals(NNS_SCHEMA_LOCATION, doc.getNoNamespaceSchemaLocation());
- }
-
- /**
- * This method will load an xml document consisting of a xsi:schemaLocation and
- * xsi:noNamespaceSchemaLocation defined. It will then use the XMLDocument API to get and
- * set the noNamespaceSchemaLocation property.
- *
- * @throws IOException
- */
- public void testNoNamespaceSchemaLocation() throws IOException
- {
- // load the xml document which has xsi:noNamespaceSchemaLocation and xsi:schemaLocation defined
- XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT));
-
- // get the noNamespaceSchemaLocation
- assertEquals(NNS_SCHEMA_LOCATION, doc.getNoNamespaceSchemaLocation());
-
- // set the noNameSpaceSchemaLocation to another value and test to see if the value was set
- doc.setNoNamespaceSchemaLocation(NNS_SET_LOCATION);
- assertEquals(NNS_SET_LOCATION, doc.getNoNamespaceSchemaLocation());
-
- // remove the noNameSpaceSchemaLocation and ensure it returns null
- doc.setNoNamespaceSchemaLocation(null);
- assertNull(doc.getNoNamespaceSchemaLocation());
-
- // ensure changes to noNameSpaceSchemaLocation have not changed schemaLocation
- assertEquals(NS1_SCHEMA_NAME + " " + NS1_SCHEMA_LOCATION + " " + NS2_SCHEMA_NAME + " " + NS2_SCHEMA_LOCATION, doc.getSchemaLocation());
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
- }
-
-}
diff --git a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java b/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java
deleted file mode 100644
index d318f4ba73..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.apache.tuscany.sdo.test;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.net.URL;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.helper.XMLStreamHelper;
-import org.apache.tuscany.sdo.util.SDOUtil;
-
-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 XMLStreamHelperTestCase extends TestCase {
-
- private XSDHelper xsdHelper = XSDHelper.INSTANCE;
-
- private TypeHelper typeHelper = TypeHelper.INSTANCE;
-
- private XMLStreamHelper streamHelper;
-
- private XMLInputFactory inputFactory;
-
- private XMLOutputFactory outputFactory;
-
- private QName module = new QName("http://foo", "module");
-
- private QName name = new QName("http://bar", "implementation.mock");
-
- private String testName = "foo-ext";
- // private String testName = "complex";
-
- private String xml;
-
- // = "<module name=\"m\" xmlns=\"http://foo\" xmlns:bar=\"http://bar\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
- // xsi:schemaLocation=\"http://bar foo-ext.xsd http://foo foo.xsd \"><component name=\"c\"><bar:implementation.mock
- // myAttr=\"helloworld.HelloWorldImpl\" listAttr=\"1 2\">1<bar:myElement>Dummy</bar:myElement>2</bar:implementation.mock></component></module>";
-
- 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
deleted file mode 100644
index 7940663290..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- *
- * 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
deleted file mode 100644
index 16a2cbd195..0000000000
--- a/branches/java-post-M1/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- *
- * 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);
- }
-}