From 195774c489a1a671aca514b0afa88332bf9c6ee3 Mon Sep 17 00:00:00 2001 From: lresende Date: Tue, 10 Nov 2009 19:20:12 +0000 Subject: Moving SDO tags git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@834617 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tuscany/sdo/codegen/AllTests.java | 47 ++++++ .../java/org/apache/tuscany/sdo/codegen/Bar1.java | 26 ++++ .../java/org/apache/tuscany/sdo/codegen/Bar2.java | 26 ++++ .../BytecodeInterfaceGeneratorTestCase.java | 167 +++++++++++++++++++++ .../java/org/apache/tuscany/sdo/codegen/Foo.java | 26 ++++ .../codegen/JavaInterfaceGeneratorTestCase.java | 129 ++++++++++++++++ .../apache/tuscany/sdo/codegen/MockProperty.java | 94 ++++++++++++ .../org/apache/tuscany/sdo/codegen/MockType.java | 104 +++++++++++++ 8 files changed, 619 insertions(+) create mode 100644 sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java create mode 100644 sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java create mode 100644 sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java create mode 100644 sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java create mode 100644 sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java create mode 100644 sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java create mode 100644 sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java create mode 100644 sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java (limited to 'sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen') diff --git a/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java new file mode 100644 index 0000000000..d67b53fb7c --- /dev/null +++ b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java @@ -0,0 +1,47 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTests { + + + public static TestSuite suite() { + + TestSuite suite = new TestSuite(); + + suite.addTestSuite(BytecodeInterfaceGeneratorTestCase.class); + suite.addTestSuite(JavaInterfaceGeneratorTestCase.class); + + + return suite; + } + + + /** + * Runs the test suite using the textual runner. + */ + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } +} + diff --git a/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java new file mode 100644 index 0000000000..4a51310cd0 --- /dev/null +++ b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java @@ -0,0 +1,26 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java new file mode 100644 index 0000000000..e9151b9d46 --- /dev/null +++ b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java @@ -0,0 +1,26 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java new file mode 100644 index 0000000000..218a725226 --- /dev/null +++ b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java @@ -0,0 +1,167 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java new file mode 100644 index 0000000000..56bf6af9b4 --- /dev/null +++ b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java @@ -0,0 +1,26 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java new file mode 100644 index 0000000000..6cc0529c5f --- /dev/null +++ b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java @@ -0,0 +1,129 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java new file mode 100644 index 0000000000..3e3e87e47b --- /dev/null +++ b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java @@ -0,0 +1,94 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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(); + } + + public boolean isNullable() { + throw new UnsupportedOperationException(); + } + + public boolean isOpenContent() { + throw new UnsupportedOperationException(); + } + + public List getInstanceProperties() { + throw new UnsupportedOperationException(); + } + + public Object get(Property property) { + throw new UnsupportedOperationException(); + } +} diff --git a/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java new file mode 100644 index 0000000000..ec848de4fa --- /dev/null +++ b/sdo-java/tags/1.1.1-RC2a/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java @@ -0,0 +1,104 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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(); + } + + public List getInstanceProperties() { + throw new UnsupportedOperationException(); + } + + public Object get(Property property) { + throw new UnsupportedOperationException(); + } +} -- cgit v1.2.3