diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-10 19:20:03 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-10 19:20:03 +0000 |
commit | 836328ea2ca7c6780307abf258503201c91e5a96 (patch) | |
tree | 1bb1b4a3af18e95389780d65ece875ba5ae93aff /branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen | |
parent | 2a444004802173fa97afbc389fc4a6600b6d3f88 (diff) |
moving SDO branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@834615 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen')
8 files changed, 0 insertions, 619 deletions
diff --git a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java deleted file mode 100644 index d67b53fb7c..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java deleted file mode 100644 index 4a51310cd0..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java deleted file mode 100644 index e9151b9d46..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java deleted file mode 100644 index 218a725226..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java deleted file mode 100644 index 56bf6af9b4..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java deleted file mode 100644 index 6cc0529c5f..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java deleted file mode 100644 index 3e3e87e47b..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * - * 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/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java b/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java deleted file mode 100644 index ec848de4fa..0000000000 --- a/branches/sdo-1.1.1-incubating/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * - * 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(); - } -} |