summaryrefslogtreecommitdiffstats
path: root/tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen')
-rw-r--r--tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java23
-rw-r--r--tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java23
-rw-r--r--tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java164
-rw-r--r--tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java23
-rw-r--r--tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java126
-rw-r--r--tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java75
-rw-r--r--tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java93
7 files changed, 0 insertions, 527 deletions
diff --git a/tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java b/tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java
deleted file mode 100644
index f862837715..0000000000
--- a/tags/java-M1-20060522/java/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-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java b/tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java
deleted file mode 100644
index 35a878015f..0000000000
--- a/tags/java-M1-20060522/java/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-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java b/tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java
deleted file mode 100644
index 7c64a42ab3..0000000000
--- a/tags/java-M1-20060522/java/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/tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java b/tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java
deleted file mode 100644
index 6a401d48bb..0000000000
--- a/tags/java-M1-20060522/java/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-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java b/tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java
deleted file mode 100644
index 9d67b61317..0000000000
--- a/tags/java-M1-20060522/java/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/tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java b/tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java
deleted file mode 100644
index 5cee856217..0000000000
--- a/tags/java-M1-20060522/java/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-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java b/tags/java-M1-20060522/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java
deleted file mode 100644
index 209d7021c0..0000000000
--- a/tags/java-M1-20060522/java/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();
- }
-}