summaryrefslogtreecommitdiffstats
path: root/tags/java-stable-20060304/sdo/impl/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java-stable-20060304/sdo/impl/src/test/java')
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java23
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java23
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java164
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java23
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java126
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java75
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java93
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java90
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java65
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java86
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java82
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java68
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java81
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java60
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java168
-rw-r--r--tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java57
16 files changed, 0 insertions, 1284 deletions
diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java
deleted file mode 100644
index f862837715..0000000000
--- a/tags/java-stable-20060304/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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java
deleted file mode 100644
index 35a878015f..0000000000
--- a/tags/java-stable-20060304/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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java
deleted file mode 100644
index 61f0ebd4fe..0000000000
--- a/tags/java-stable-20060304/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");
- assertEquals(boolean.class, getter.getReturnType());
- Method setter = c.getMethod("setTrue", 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");
- assertEquals(byte[].class, getter.getReturnType());
- Method setter = c.getMethod("setBytes", 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");
- assertEquals(Bar1.class, getter.getReturnType());
- Method setter = c.getMethod("setBar", 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");
- 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");
- 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");
- assertEquals(boolean.class, getter.getReturnType());
- Method setter = c.getMethod("setTrue", boolean.class);
- assertEquals(void.class, setter.getReturnType());
- getter = c.getMethod("getInt");
- assertEquals(int.class, getter.getReturnType());
- setter = c.getMethod("setInt", 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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java
deleted file mode 100644
index 6a401d48bb..0000000000
--- a/tags/java-stable-20060304/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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java
deleted file mode 100644
index ada15e151d..0000000000
--- a/tags/java-stable-20060304/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) {
- StringBuilder b = new StringBuilder(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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java
deleted file mode 100644
index 5cee856217..0000000000
--- a/tags/java-stable-20060304/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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java
deleted file mode 100644
index 7aa880b1e9..0000000000
--- a/tags/java-stable-20060304/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<Type> baseTypes = new ArrayList<Type>();
-
- 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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java
deleted file mode 100644
index dbb6b7af46..0000000000
--- a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java
+++ /dev/null
@@ -1,90 +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.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.net.URL;
-
-import commonj.sdo.ChangeSummary;
-import commonj.sdo.DataGraph;
-import commonj.sdo.DataObject;
-import commonj.sdo.helper.XSDHelper;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.util.SDOUtil;
-
-
-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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java
deleted file mode 100644
index faa8782a77..0000000000
--- a/tags/java-stable-20060304/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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java
deleted file mode 100644
index e46f9858e2..0000000000
--- a/tags/java-stable-20060304/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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java
deleted file mode 100644
index 7e743e296a..0000000000
--- a/tags/java-stable-20060304/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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java
deleted file mode 100644
index 2e91a1a66f..0000000000
--- a/tags/java-stable-20060304/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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java
deleted file mode 100644
index d4f425457f..0000000000
--- a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java
+++ /dev/null
@@ -1,81 +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.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.math.BigDecimal;
-import java.net.URL;
-
-import commonj.sdo.DataObject;
-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;
-import junit.framework.TestCase;
-
-
-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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java
deleted file mode 100644
index ac05b362d9..0000000000
--- a/tags/java-stable-20060304/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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java
deleted file mode 100644
index a377281622..0000000000
--- a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java
+++ /dev/null
@@ -1,168 +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.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-public class TestUtil
-{
- private static void getAllNodes(NodeList nodeList, List<Node> 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 equalNodes(NodeList sourceNodeList, NodeList targetNodeList)
- {
- ArrayList<Node> sourceNodes = new ArrayList<Node>();
- ArrayList<Node> targetNodes = new ArrayList<Node>();
-
- 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 = sourceNodes.get(i);
- Node targetNode = targetNodes.get(i);
-
- if (!sourceNode.isEqualNode(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.normalizeDocument();
- targetDocument.normalizeDocument();
-
- 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/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java
deleted file mode 100644
index db66034928..0000000000
--- a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- *
- * Copyright 2005 BEA Systems Inc.
- * Copyright 2005 International Business Machines Corporation
- *
- * 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.util.List;
-import java.net.URL;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-import commonj.sdo.helper.XSDHelper;
-import commonj.sdo.Type;
-
-/**
- * @version $Rev$ $Date$
- */
-public class XSDHelperTestCase extends TestCase {
- private static final String TEST_MODEL = "/simple.xsd";
- private URL modelURL;
-
- public void testDefineWithLocation() throws IOException {
- List<Type> types = XSDHelper.INSTANCE.define(modelURL.openStream(), modelURL.toString());
- assertEquals(2, types.size());
- }
-
- public void testDefineWithNoLocation() {
- List<Type> types = XSDHelper.INSTANCE.define(getClass().getResourceAsStream(TEST_MODEL), null);
- assertEquals(2, types.size());
- }
-
- public void testDuplicateDefineWithLocation() throws IOException {
- List<Type> types = XSDHelper.INSTANCE.define(modelURL.openStream(), modelURL.toString());
- assertEquals(2, types.size());
-
- List<Type> types2 = XSDHelper.INSTANCE.define(modelURL.openStream(), modelURL.toString());
- assertEquals(types, types2);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- modelURL = getClass().getResource(TEST_MODEL);
- }
-}