From 80c2130923497ebb90a51e8c7839e9ac39c1febf Mon Sep 17 00:00:00 2001 From: rfeng Date: Fri, 20 Jun 2008 17:57:47 +0000 Subject: Apply the patch from Wojtek for TUSCANY-2357. Thanks. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@670012 13f79535-47bb-0310-9956-ffa450edef68 --- .../exceptions/RequestConfigurationException.java | 4 + .../corba/impl/reference/DynaCorbaRequest.java | 12 +- .../sca/binding/corba/impl/types/NodeType.java | 2 +- .../binding/corba/impl/types/TypeTreeCreator.java | 158 +++++++++++++++++- .../corba/impl/types/util/EnumTypeHelper.java | 42 +++++ .../corba/impl/types/util/TypeHelpersProxy.java | 2 + .../binding/corba/testing/CorbaTypesTestCase.java | 181 ++++++++++++++++----- .../sca/binding/corba/testing/enums/Color.java | 61 +++++++ .../binding/corba/testing/enums/ColorHelper.java | 72 ++++++++ .../binding/corba/testing/enums/ColorHolder.java | 57 +++++++ .../binding/corba/testing/enums/EnumManager.java | 32 ++++ .../corba/testing/enums/EnumManagerHelper.java | 104 ++++++++++++ .../corba/testing/enums/EnumManagerHolder.java | 57 +++++++ .../corba/testing/enums/EnumManagerOperations.java | 34 ++++ .../corba/testing/enums/_EnumManagerImplBase.java | 83 ++++++++++ .../corba/testing/enums/_EnumManagerStub.java | 79 +++++++++ .../corba/testing/hierarchy/InvalidEnum1.java | 36 ++++ .../corba/testing/hierarchy/InvalidEnum2.java | 33 ++++ .../corba/testing/hierarchy/InvalidEnum3.java | 33 ++++ .../corba/testing/hierarchy/InvalidStruct1.java | 28 ++++ .../corba/testing/hierarchy/InvalidStruct2.java | 31 ++++ .../corba/testing/hierarchy/InvalidStruct3.java | 36 ++++ .../corba/testing/servants/EnumManagerServant.java | 33 ++++ .../src/test/resources/enums.idl | 132 +++++++++++++++ 24 files changed, 1291 insertions(+), 51 deletions(-) create mode 100644 java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/EnumTypeHelper.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/Color.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHelper.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHolder.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHelper.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHolder.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerOperations.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerImplBase.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerStub.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum1.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum2.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum3.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct1.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct2.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct3.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/EnumManagerServant.java create mode 100644 java/sca/modules/binding-corba-runtime/src/test/resources/enums.idl (limited to 'java') diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/exceptions/RequestConfigurationException.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/exceptions/RequestConfigurationException.java index c4d78a5027..61de0496e3 100644 --- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/exceptions/RequestConfigurationException.java +++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/exceptions/RequestConfigurationException.java @@ -32,6 +32,10 @@ public class RequestConfigurationException extends Exception { this.objectId = objectId; } + public RequestConfigurationException(String message) { + super(message); + } + public String getType() { return objectId; } diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaRequest.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaRequest.java index 759f9756b6..dc2224d7a8 100644 --- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaRequest.java +++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/reference/DynaCorbaRequest.java @@ -19,9 +19,7 @@ package org.apache.tuscany.sca.binding.corba.impl.reference; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; import org.apache.tuscany.sca.binding.corba.impl.exceptions.CorbaException; @@ -43,7 +41,6 @@ import org.omg.CORBA.portable.OutputStream; public class DynaCorbaRequest { private TypeTree returnTree; - private List arguments = new ArrayList(); private Map exceptions = new HashMap(); private OutputStream outputStream; private ObjectImpl remoteObject; @@ -69,7 +66,8 @@ public class DynaCorbaRequest { * * @param argument */ - public void addArgument(java.lang.Object argument) { + public void addArgument(java.lang.Object argument) + throws RequestConfigurationException { TypeTree tree = TypeTreeCreator.createTypeTree(argument.getClass()); TypeHelpersProxy.write(tree.getRootNode(), outputStream, argument); } @@ -79,7 +77,8 @@ public class DynaCorbaRequest { * * @param forClass */ - public void setOutputType(Class forClass) { + public void setOutputType(Class forClass) + throws RequestConfigurationException { returnTree = TypeTreeCreator.createTypeTree(forClass); } @@ -99,7 +98,8 @@ public class DynaCorbaRequest { * * @param forClass */ - public void addExceptionType(Class forClass) { + public void addExceptionType(Class forClass) + throws RequestConfigurationException { TypeTree tree = TypeTreeCreator.createTypeTree(forClass); String exceptionId = getExceptionId(forClass); exceptions.put(exceptionId, tree); diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/NodeType.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/NodeType.java index 155bfb5444..cb1987cb4b 100644 --- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/NodeType.java +++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/NodeType.java @@ -24,5 +24,5 @@ package org.apache.tuscany.sca.binding.corba.impl.types; * Types of CORBA objects. */ public enum NodeType { - primitive, struct, union, array, sequence, reference + primitive, struct, union, array, sequence, reference, idl_enum, exception } diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/TypeTreeCreator.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/TypeTreeCreator.java index d370c5cd7e..24bd8dcbe7 100644 --- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/TypeTreeCreator.java +++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/TypeTreeCreator.java @@ -19,9 +19,17 @@ package org.apache.tuscany.sca.binding.corba.impl.types; +import java.lang.reflect.Constructor; import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Set; + +import org.apache.tuscany.sca.binding.corba.impl.exceptions.RequestConfigurationException; /** * @version $Rev$ $Date$ @@ -134,7 +142,8 @@ public class TypeTreeCreator { * @param forClass * @return type tree */ - public static TypeTree createTypeTree(Class forClass) { + public static TypeTree createTypeTree(Class forClass) + throws RequestConfigurationException { TypeTree tree = new TypeTree(); TypeTreeNode rootNode = null; rootNode = inspectClassHierarchy(forClass, tree); @@ -151,7 +160,7 @@ public class TypeTreeCreator { * @return */ private static TypeTreeNode inspectClassHierarchy(Class forClass, - TypeTree tree) { + TypeTree tree) throws RequestConfigurationException { // //remains of type tree caching // TypeTreeNode existingNode = tree.getNodeForType(forClass); // if (existingNode != null) { @@ -175,7 +184,8 @@ public class TypeTreeCreator { Class reduced = reduceArrayDimension(node.getJavaClass()); children = new TypeTreeNode[1]; children[0] = inspectClassHierarchy(reduced, tree); - } else if (nodeType.equals(NodeType.struct)) { + } else if (nodeType.equals(NodeType.struct) + || nodeType.equals(NodeType.exception)) { // inspect types for every structure member Field[] fields = node.getJavaClass().getFields(); children = new TypeTreeNode[fields.length]; @@ -185,6 +195,8 @@ public class TypeTreeCreator { child.setName(fields[i].getName()); children[i] = child; } + } else if (nodeType.equals(NodeType.idl_enum)) { + } else if (nodeType.equals(NodeType.union)) { // TODO: unions } else if (nodeType.equals(NodeType.reference)) { @@ -201,8 +213,10 @@ public class TypeTreeCreator { * @param forClass * class * @return node + * @throws RequestConfigurationException */ - private static TypeTreeNode createTypeNode(Class forClass) { + private static TypeTreeNode createTypeNode(Class forClass) + throws RequestConfigurationException { TypeTreeNode node = new TypeTreeNode(); if (forClass.isArray()) { node.setNodeType(NodeType.sequence); @@ -215,10 +229,144 @@ public class TypeTreeCreator { node.setNodeType(NodeType.reference); node.setJavaClass(forClass); node.setChildren(null); - } else { + } else if (isStructType(forClass)) { node.setNodeType(NodeType.struct); node.setJavaClass(forClass); + } else if (isEnumType(forClass)) { + node.setNodeType(NodeType.idl_enum); + node.setJavaClass(forClass); + } else if (isUserException(forClass)) { + node.setNodeType(NodeType.exception); + node.setJavaClass(forClass); + } else { + RequestConfigurationException e = new RequestConfigurationException( + "User defined type which cannot be handler: " + + forClass.getCanonicalName()); + throw e; } return node; } + + /** + * Tells whether given class is structure + * + * @param forClass + * @return + */ + private static boolean isStructType(Class forClass) { + int classMods = forClass.getModifiers(); + if (!Modifier.isFinal(classMods)) { + return false; + } + boolean areCtorsValid = false; + Class[] fieldsTypes = null; + Constructor[] ctors = forClass.getConstructors(); + /* + * Do we have 2 ctors and one of them is null ctor? + */ + if (ctors.length != 2) { + return false; + } + for (int i = 0; i < ctors.length; i++) { + Class[] params = ctors[i].getParameterTypes(); + if (params.length == 0) { + areCtorsValid = true; + } else { + fieldsTypes = params; + } + } + if (!areCtorsValid) { + return false; + } + /* + * Are constructor args declared as class fields? + */ + Field[] fields = forClass.getFields(); + Set> fieldsSet = new HashSet>(Arrays + .asList(fieldsTypes)); + for (int i = 0; i < fields.length && !fieldsSet.isEmpty(); i++) { + int mods = fields[i].getModifiers(); + if (Modifier.isPublic(mods) && !Modifier.isStatic(mods) + && !Modifier.isFinal(mods)) { + fieldsSet.remove(fields[i].getType()); + } + + } + return fieldsSet.isEmpty(); + } + + /** + * Tells whether given class is enum + * + * @param forClass + * @return + */ + private static boolean isEnumType(Class forClass) { + boolean isValueMethod = false; + boolean isFromIntMethod = false; + /* + * enum type should have value and from_int methods + */ + try { + Method valueMet = forClass.getMethod("value", new Class[] {}); + int modValueMet = valueMet.getModifiers(); + if (valueMet.getReturnType().equals(int.class) + && Modifier.isPublic(modValueMet)) { + isValueMethod = true; + } + Method fromIntMet = forClass.getMethod("from_int", + new Class[] { int.class }); + int modFromIntMet = fromIntMet.getModifiers(); + if ((fromIntMet.getReturnType().equals(forClass) + && Modifier.isPublic(modFromIntMet) && Modifier + .isStatic(modFromIntMet))) { + isFromIntMethod = true; + } + } catch (NoSuchMethodException e) { + } + if (!isFromIntMethod && !isValueMethod) { + return false; + } + /* + * enum type should also contain minimum one pair of fields: EnumType + * field and int _field + */ + int enumCount = 0; + Field[] fields = forClass.getFields(); + for (int i = 0; i < fields.length; i++) { + if (fields[i].getType().equals(forClass)) { + int modifiers = fields[i].getModifiers(); + if (Modifier.isStatic(modifiers) + && Modifier.isPublic(modifiers) + && Modifier.isFinal(modifiers)) { + try { + Field field = forClass.getField("_" + + fields[i].getName()); + if (field.getType().equals(int.class)) { + enumCount++; + } + } catch (NoSuchFieldException e) { + } + + } + } + } + return enumCount > 0; + } + + /** + * Tells whether given class is corba user exception + * @param forClass + * @return + */ + private static boolean isUserException(Class forClass) { + do { + if (forClass.equals(Exception.class)) { + return true; + } else { + forClass = forClass.getSuperclass(); + } + } while (!forClass.equals(Object.class)); + return false; + } } diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/EnumTypeHelper.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/EnumTypeHelper.java new file mode 100644 index 0000000000..5cb68433a2 --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/EnumTypeHelper.java @@ -0,0 +1,42 @@ +package org.apache.tuscany.sca.binding.corba.impl.types.util; + +import java.lang.reflect.Method; + +import org.apache.tuscany.sca.binding.corba.impl.types.TypeTreeNode; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +public class EnumTypeHelper implements TypeHelper { + + public TypeCode getType(TypeTreeNode node) { + // TODO Auto-generated method stub + return null; + } + + public Object read(TypeTreeNode node, InputStream is) { + int value = is.read_long(); + Object result = null; + try { + Method method = node.getJavaClass().getMethod("from_int", + new Class[] { int.class }); + result = method.invoke(null, new Object[] { value }); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return result; + } + + public void write(TypeTreeNode node, OutputStream os, Object data) { + int value = 0; + try { + Method method = data.getClass().getMethod("value", new Class[] {}); + value = (Integer) method.invoke(data, new Object[] {}); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + os.write_long(value); + } +} diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelpersProxy.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelpersProxy.java index 467287382e..77dff7bab9 100644 --- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelpersProxy.java +++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/types/util/TypeHelpersProxy.java @@ -71,6 +71,8 @@ public class TypeHelpersProxy { complexTypes.put(NodeType.struct, new StructTypeHelper()); complexTypes.put(NodeType.reference, new ReferenceTypeHelper()); complexTypes.put(NodeType.sequence, new SequenceTypeHelper()); + complexTypes.put(NodeType.idl_enum, new EnumTypeHelper()); + complexTypes.put(NodeType.exception, new StructTypeHelper()); } /** diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java index ed9d6dfc29..9bfcdaa5d1 100644 --- a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java @@ -27,13 +27,21 @@ import org.apache.tuscany.sca.binding.corba.impl.exceptions.CorbaException; import org.apache.tuscany.sca.binding.corba.impl.exceptions.RequestConfigurationException; import org.apache.tuscany.sca.binding.corba.impl.reference.DynaCorbaRequest; import org.apache.tuscany.sca.binding.corba.impl.reference.DynaCorbaResponse; +import org.apache.tuscany.sca.binding.corba.testing.enums.Color; import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.DivByZero; import org.apache.tuscany.sca.binding.corba.testing.exceptions.CalcPackage.NotSupported; +import org.apache.tuscany.sca.binding.corba.testing.generated.SimpleStruct; +import org.apache.tuscany.sca.binding.corba.testing.generated.SomeStruct; import org.apache.tuscany.sca.binding.corba.testing.hierarchy.DummyObject; -import org.apache.tuscany.sca.binding.corba.testing.hierarchy.SimpleStruct; -import org.apache.tuscany.sca.binding.corba.testing.hierarchy.SomeStruct; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidEnum1; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidEnum2; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidEnum3; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidStruct1; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidStruct2; +import org.apache.tuscany.sca.binding.corba.testing.hierarchy.InvalidStruct3; import org.apache.tuscany.sca.binding.corba.testing.servants.ArraysSetterServant; import org.apache.tuscany.sca.binding.corba.testing.servants.CalcServant; +import org.apache.tuscany.sca.binding.corba.testing.servants.EnumManagerServant; import org.apache.tuscany.sca.binding.corba.testing.servants.ObjectManagerServant; import org.apache.tuscany.sca.binding.corba.testing.servants.PrimitivesSetterServant; import org.apache.tuscany.sca.binding.corba.testing.servants.TestObjectServant; @@ -56,6 +64,7 @@ public class CorbaTypesTestCase extends TestCase { private Object refTestObject; private Object refCalcObject; private Object refObjectManager; + private Object refEnumManager; /** * Spawns tnameserv process (must be in PATH). Initializes test servants and @@ -85,6 +94,7 @@ public class CorbaTypesTestCase extends TestCase { TestObjectServant complexObject = new TestObjectServant(); CalcServant calcObject = new CalcServant(); ObjectManagerServant objectManager = new ObjectManagerServant(); + EnumManagerServant enumManager = new EnumManagerServant(); orb.connect(singleSetter); orb.connect(arraysSetter); @@ -107,11 +117,15 @@ public class CorbaTypesTestCase extends TestCase { nc = new NameComponent("CalcObject", ""); path = new NameComponent[] { nc }; namingContext.rebind(path, calcObject); - + nc = new NameComponent("ObjectManager", ""); path = new NameComponent[] { nc }; namingContext.rebind(path, objectManager); + nc = new NameComponent("EnumManager", ""); + path = new NameComponent[] { nc }; + namingContext.rebind(path, enumManager); + NamingContextExt nce = NamingContextExtHelper.narrow(orb .resolve_initial_references("NameService")); @@ -120,6 +134,7 @@ public class CorbaTypesTestCase extends TestCase { refTestObject = nce.resolve(nce.to_name("TestObject")); refCalcObject = nce.resolve(nce.to_name("CalcObject")); refObjectManager = nce.resolve(nce.to_name("ObjectManager")); + refEnumManager = nce.resolve(nce.to_name("EnumManager")); } catch (Exception e) { e.printStackTrace(); @@ -270,10 +285,9 @@ public class CorbaTypesTestCase extends TestCase { struct.threeDimSeq = TestConstants.INT_ARRAY_3_DIM; struct.str = TestConstants.STR_1; - request.addArgument(struct); - request.setOutputType(SomeStruct.class); - try { + request.addArgument(struct); + request.setOutputType(SomeStruct.class); DynaCorbaResponse response = request.invoke(); SomeStruct result = (SomeStruct) response.getContent(); int sum = 0; @@ -314,9 +328,9 @@ public class CorbaTypesTestCase extends TestCase { struct.field2 = TestConstants.INT_1; DynaCorbaRequest request = new DynaCorbaRequest(refTestObject, "setSimpleStruct"); - request.setOutputType(SimpleStruct.class); - request.addArgument(struct); try { + request.setOutputType(SimpleStruct.class); + request.addArgument(struct); DynaCorbaResponse response = request.invoke(); SimpleStruct retStruct = (SimpleStruct) response.getContent(); assertTrue(retStruct.field1.equals(struct.field1) @@ -339,9 +353,9 @@ public class CorbaTypesTestCase extends TestCase { } DynaCorbaRequest request = new DynaCorbaRequest(refTestObject, "setLongSeq2"); - request.setOutputType(arr1.getClass()); - request.addArgument(arr1); try { + request.setOutputType(arr1.getClass()); + request.addArgument(arr1); DynaCorbaResponse response = request.invoke(); int[][] arr2 = (int[][]) response.getContent(); for (int i = 0; i < 2; i++) { @@ -389,13 +403,13 @@ public class CorbaTypesTestCase extends TestCase { DynaCorbaRequest request = new DynaCorbaRequest(refTestObject, "pickStructFromArgs"); - request.setOutputType(SomeStruct.class); - request.addArgument(arg1); - request.addArgument(arg2); - request.addArgument(arg3); - request.addArgument(1); try { + request.setOutputType(SomeStruct.class); + request.addArgument(arg1); + request.addArgument(arg2); + request.addArgument(arg3); + request.addArgument(1); DynaCorbaResponse response = request.invoke(); SomeStruct result = (SomeStruct) response.getContent(); @@ -413,27 +427,28 @@ public class CorbaTypesTestCase extends TestCase { */ public void test_singleException() { DynaCorbaRequest request1 = new DynaCorbaRequest(refCalcObject, "div"); - request1.addArgument(2d); - request1.addArgument(2d); - request1.setOutputType(Double.class); - request1.addExceptionType(DivByZero.class); try { + request1.addArgument(2d); + request1.addArgument(2d); + request1.setOutputType(Double.class); + request1.addExceptionType(DivByZero.class); request1.invoke(); } catch (Exception e) { fail(); } DynaCorbaRequest request2 = new DynaCorbaRequest(refCalcObject, "div"); - request2.addArgument(2d); - request2.addArgument(0d); - request2.setOutputType(Double.class); - request2.addExceptionType(DivByZero.class); try { + request2.addArgument(2d); + request2.addArgument(0d); + request2.setOutputType(Double.class); + request2.addExceptionType(DivByZero.class); request2.invoke(); } catch (DivByZero e) { assertTrue(e.info != null && e.arguments != null && e.arguments.arg1 == 2 && e.arguments.arg2 == 0); } catch (Exception exc) { + exc.printStackTrace(); fail(); } } @@ -444,12 +459,12 @@ public class CorbaTypesTestCase extends TestCase { public void test_multipleExceptions() { DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "divForSmallArgs"); - request.addArgument(101d); - request.addArgument(101d); - request.setOutputType(Double.class); - request.addExceptionType(DivByZero.class); - request.addExceptionType(NotSupported.class); try { + request.addArgument(101d); + request.addArgument(101d); + request.setOutputType(Double.class); + request.addExceptionType(DivByZero.class); + request.addExceptionType(NotSupported.class); request.invoke(); } catch (Exception e) { assertTrue(e instanceof NotSupported); @@ -461,10 +476,10 @@ public class CorbaTypesTestCase extends TestCase { */ public void test_noExceptionsDeclared() { DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "div"); - request.addArgument(1d); - request.addArgument(0d); - request.setOutputType(Double.class); try { + request.addArgument(1d); + request.addArgument(0d); + request.setOutputType(Double.class); request.invoke(); fail(); } catch (Exception e) { @@ -477,18 +492,18 @@ public class CorbaTypesTestCase extends TestCase { */ public void test_noSuchExceptionDeclared() { DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "div"); - request.addArgument(1d); - request.addArgument(0d); - request.addExceptionType(NotSupported.class); - request.setOutputType(Double.class); try { + request.addArgument(1d); + request.addArgument(0d); + request.addExceptionType(NotSupported.class); + request.setOutputType(Double.class); request.invoke(); fail(); } catch (Exception e) { assertTrue(e instanceof RequestConfigurationException); } } - + /** * Tests handling non existing operation situation */ @@ -502,18 +517,106 @@ public class CorbaTypesTestCase extends TestCase { assertTrue(e instanceof CorbaException); } } - + /** - * Tests obtaining references to other objects and using them with specified user interface + * Tests obtaining references to other objects and using them with specified + * user interface */ public void test_enchancedReferences() { try { - DynaCorbaRequest request = new DynaCorbaRequest(refObjectManager, "getDummyObject"); + DynaCorbaRequest request = new DynaCorbaRequest(refObjectManager, + "getDummyObject"); request.setOutputType(DummyObject.class); DynaCorbaResponse response = request.invoke(); DummyObject dummy = (DummyObject) response.getContent(); DummyObject dummy2 = dummy.cloneObject(); assertNotSame(dummy.getLong(), dummy2.getLong()); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Test passing enums as arguments and retrieving them as a result + */ + public void test_enums() { + try { + DynaCorbaRequest request = new DynaCorbaRequest(refEnumManager, + "getColor"); + Color color = Color.green; + request.addArgument(color); + request.setOutputType(Color.class); + DynaCorbaResponse response = request.invoke(); + Color result = (Color) response.getContent(); + assertEquals(color.value(), result.value()); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests recognizing structures + */ + public void test_structValidation() { + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(InvalidStruct1.class); + fail(); + } catch (Exception e) { + assertTrue(e instanceof RequestConfigurationException); + } + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(InvalidStruct2.class); + fail(); + } catch (Exception e) { + assertTrue(e instanceof RequestConfigurationException); + } + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(InvalidStruct3.class); + fail(); + } catch (Exception e) { + assertTrue(e instanceof RequestConfigurationException); + } + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(SomeStruct.class); + } catch (Exception e) { + fail(); + } + } + + /** + * Tests recognizing enums + */ + public void test_enumValidation() { + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(InvalidEnum1.class); + fail(); + } catch (Exception e) { + assertTrue(e instanceof RequestConfigurationException); + } + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(InvalidEnum2.class); + fail(); + } catch (Exception e) { + assertTrue(e instanceof RequestConfigurationException); + } + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(InvalidEnum3.class); + fail(); + } catch (Exception e) { + assertTrue(e instanceof RequestConfigurationException); + } + try { + DynaCorbaRequest request = new DynaCorbaRequest(refArraysSetter, "whatever"); + request.setOutputType(Color.class); } catch (Exception e) { fail(); } diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/Color.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/Color.java new file mode 100644 index 0000000000..71f307be26 --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/Color.java @@ -0,0 +1,61 @@ +/* + * 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.sca.binding.corba.testing.enums; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/Color.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +public class Color implements org.omg.CORBA.portable.IDLEntity +{ + private int __value; + private static int __size = 3; + private static org.apache.tuscany.sca.binding.corba.testing.enums.Color[] __array = new org.apache.tuscany.sca.binding.corba.testing.enums.Color [__size]; + + public static final int _red = 0; + public static final org.apache.tuscany.sca.binding.corba.testing.enums.Color red = new org.apache.tuscany.sca.binding.corba.testing.enums.Color(_red); + public static final int _yellow = 1; + public static final org.apache.tuscany.sca.binding.corba.testing.enums.Color yellow = new org.apache.tuscany.sca.binding.corba.testing.enums.Color(_yellow); + public static final int _green = 2; + public static final org.apache.tuscany.sca.binding.corba.testing.enums.Color green = new org.apache.tuscany.sca.binding.corba.testing.enums.Color(_green); + + public int value () + { + return __value; + } + + public static org.apache.tuscany.sca.binding.corba.testing.enums.Color from_int (int value) + { + if (value >= 0 && value < __size) + return __array[value]; + else + throw new org.omg.CORBA.BAD_PARAM (); + } + + protected Color (int value) + { + __value = value; + __array[__value] = this; + } +} // class Color diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHelper.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHelper.java new file mode 100644 index 0000000000..55409a1d92 --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHelper.java @@ -0,0 +1,72 @@ +/* + * 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.sca.binding.corba.testing.enums; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/ColorHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +abstract public class ColorHelper +{ + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/enums/Color:1.0"; + + public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.enums.Color that) + { + org.omg.CORBA.portable.OutputStream out = a.create_output_stream (); + a.type (type ()); + write (out, that); + a.read_value (out.create_input_stream (), type ()); + } + + public static org.apache.tuscany.sca.binding.corba.testing.enums.Color extract (org.omg.CORBA.Any a) + { + return read (a.create_input_stream ()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + synchronized public static org.omg.CORBA.TypeCode type () + { + if (__typeCode == null) + { + __typeCode = org.omg.CORBA.ORB.init ().create_enum_tc (org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.id (), "Color", new String[] { "red", "yellow", "green"} ); + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.enums.Color read (org.omg.CORBA.portable.InputStream istream) + { + return org.apache.tuscany.sca.binding.corba.testing.enums.Color.from_int (istream.read_long ()); + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.binding.corba.testing.enums.Color value) + { + ostream.write_long (value.value ()); + } + +} diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHolder.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHolder.java new file mode 100644 index 0000000000..3290d26397 --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/ColorHolder.java @@ -0,0 +1,57 @@ +/* + * 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.sca.binding.corba.testing.enums; + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/ColorHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +public final class ColorHolder implements org.omg.CORBA.portable.Streamable +{ + public org.apache.tuscany.sca.binding.corba.testing.enums.Color value = null; + + public ColorHolder () + { + } + + public ColorHolder (org.apache.tuscany.sca.binding.corba.testing.enums.Color initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.type (); + } + +} diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager.java new file mode 100644 index 0000000000..5e2df26961 --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager.java @@ -0,0 +1,32 @@ +/* + * 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.sca.binding.corba.testing.enums; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +public interface EnumManager extends EnumManagerOperations, org.omg.CORBA.Object, org.omg.CORBA.portable.IDLEntity +{ +} // interface EnumManager diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHelper.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHelper.java new file mode 100644 index 0000000000..8ba4dc0729 --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHelper.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.sca.binding.corba.testing.enums; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +abstract public class EnumManagerHelper +{ + private static String _id = "IDL:org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager:1.0"; + + public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager that) + { + org.omg.CORBA.portable.OutputStream out = a.create_output_stream (); + a.type (type ()); + write (out, that); + a.read_value (out.create_input_stream (), type ()); + } + + public static org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager extract (org.omg.CORBA.Any a) + { + return read (a.create_input_stream ()); + } + + private static org.omg.CORBA.TypeCode __typeCode = null; + synchronized public static org.omg.CORBA.TypeCode type () + { + if (__typeCode == null) + { + __typeCode = org.omg.CORBA.ORB.init ().create_interface_tc (org.apache.tuscany.sca.binding.corba.testing.enums.EnumManagerHelper.id (), "EnumManager"); + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager read (org.omg.CORBA.portable.InputStream istream) + { + return narrow (istream.read_Object (_EnumManagerStub.class)); + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager value) + { + ostream.write_Object ((org.omg.CORBA.Object) value); + } + + public static org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager narrow (org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager) + return (org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager)obj; + else if (!obj._is_a (id ())) + throw new org.omg.CORBA.BAD_PARAM (); + else + { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); + org.apache.tuscany.sca.binding.corba.testing.enums._EnumManagerStub stub = new org.apache.tuscany.sca.binding.corba.testing.enums._EnumManagerStub (); + stub._set_delegate(delegate); + return stub; + } + } + + public static org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager unchecked_narrow (org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager) + return (org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager)obj; + else + { + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate (); + org.apache.tuscany.sca.binding.corba.testing.enums._EnumManagerStub stub = new org.apache.tuscany.sca.binding.corba.testing.enums._EnumManagerStub (); + stub._set_delegate(delegate); + return stub; + } + } + +} diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHolder.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHolder.java new file mode 100644 index 0000000000..065287d547 --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHolder.java @@ -0,0 +1,57 @@ +/* + * 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.sca.binding.corba.testing.enums; + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +public final class EnumManagerHolder implements org.omg.CORBA.portable.Streamable +{ + public org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager value = null; + + public EnumManagerHolder () + { + } + + public EnumManagerHolder (org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = org.apache.tuscany.sca.binding.corba.testing.enums.EnumManagerHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + org.apache.tuscany.sca.binding.corba.testing.enums.EnumManagerHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return org.apache.tuscany.sca.binding.corba.testing.enums.EnumManagerHelper.type (); + } + +} diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerOperations.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerOperations.java new file mode 100644 index 0000000000..6452d55db7 --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerOperations.java @@ -0,0 +1,34 @@ +/* + * 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.sca.binding.corba.testing.enums; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/EnumManagerOperations.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +public interface EnumManagerOperations +{ + + org.apache.tuscany.sca.binding.corba.testing.enums.Color getColor (org.apache.tuscany.sca.binding.corba.testing.enums.Color color); +} // interface EnumManagerOperations diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerImplBase.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerImplBase.java new file mode 100644 index 0000000000..6975a4d4f0 --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerImplBase.java @@ -0,0 +1,83 @@ +/* + * 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.sca.binding.corba.testing.enums; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerImplBase.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +public abstract class _EnumManagerImplBase extends org.omg.CORBA.portable.ObjectImpl + implements org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager, org.omg.CORBA.portable.InvokeHandler +{ + + // Constructors + public _EnumManagerImplBase () + { + } + + private static java.util.Hashtable _methods = new java.util.Hashtable (); + static + { + _methods.put ("getColor", new java.lang.Integer (0)); + } + + public org.omg.CORBA.portable.OutputStream _invoke (String $method, + org.omg.CORBA.portable.InputStream in, + org.omg.CORBA.portable.ResponseHandler $rh) + { + org.omg.CORBA.portable.OutputStream out = null; + java.lang.Integer __method = (java.lang.Integer)_methods.get ($method); + if (__method == null) + throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + + switch (__method.intValue ()) + { + case 0: // org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager/getColor + { + org.apache.tuscany.sca.binding.corba.testing.enums.Color color = org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.read (in); + org.apache.tuscany.sca.binding.corba.testing.enums.Color $result = null; + $result = this.getColor (color); + out = $rh.createReply(); + org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.write (out, $result); + break; + } + + default: + throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); + } + + return out; + } // _invoke + + // Type-specific CORBA::Object operations + private static String[] __ids = { + "IDL:org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager:1.0"}; + + public String[] _ids () + { + return (String[])__ids.clone (); + } + + +} // class _EnumManagerImplBase diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerStub.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerStub.java new file mode 100644 index 0000000000..77bfa7c6e9 --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerStub.java @@ -0,0 +1,79 @@ +/* + * 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.sca.binding.corba.testing.enums; + + +/** +* org/apache/tuscany/sca/binding/corba/testing/enums/_EnumManagerStub.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from enums.idl +* czwartek, 19 czerwiec 2008 15:46:10 CEST +*/ + +public class _EnumManagerStub extends org.omg.CORBA.portable.ObjectImpl implements org.apache.tuscany.sca.binding.corba.testing.enums.EnumManager +{ + + public org.apache.tuscany.sca.binding.corba.testing.enums.Color getColor (org.apache.tuscany.sca.binding.corba.testing.enums.Color color) + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("getColor", true); + org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.write ($out, color); + $in = _invoke ($out); + org.apache.tuscany.sca.binding.corba.testing.enums.Color $result = org.apache.tuscany.sca.binding.corba.testing.enums.ColorHelper.read ($in); + return $result; + } catch (org.omg.CORBA.portable.ApplicationException $ex) { + $in = $ex.getInputStream (); + String _id = $ex.getId (); + throw new org.omg.CORBA.MARSHAL (_id); + } catch (org.omg.CORBA.portable.RemarshalException $rm) { + return getColor (color ); + } finally { + _releaseReply ($in); + } + } // getColor + + // Type-specific CORBA::Object operations + private static String[] __ids = { + "IDL:org/apache/tuscany/sca/binding/corba/testing/enums/EnumManager:1.0"}; + + public String[] _ids () + { + return (String[])__ids.clone (); + } + + private void readObject (java.io.ObjectInputStream s) throws java.io.IOException + { + String str = s.readUTF (); + String[] args = null; + java.util.Properties props = null; + org.omg.CORBA.Object obj = org.omg.CORBA.ORB.init (args, props).string_to_object (str); + org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate (); + _set_delegate (delegate); + } + + private void writeObject (java.io.ObjectOutputStream s) throws java.io.IOException + { + String[] args = null; + java.util.Properties props = null; + String str = org.omg.CORBA.ORB.init (args, props).object_to_string (this); + s.writeUTF (str); + } +} // class _EnumManagerStub diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum1.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum1.java new file mode 100644 index 0000000000..0fb8a3ffab --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum1.java @@ -0,0 +1,36 @@ +/* + * 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.sca.binding.corba.testing.hierarchy; + +public class InvalidEnum1 { + + public static final InvalidEnum1 red = new InvalidEnum1(0); + + public int value() { + return 0; + } + + public static InvalidEnum1 from_int(int value) { + return null; + } + + protected InvalidEnum1(int value) { + } +} diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum2.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum2.java new file mode 100644 index 0000000000..6c8f568bb4 --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum2.java @@ -0,0 +1,33 @@ +/* + * 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.sca.binding.corba.testing.hierarchy; + +public class InvalidEnum2 { + + public static final int _red = 0; + public static final InvalidEnum2 red = new InvalidEnum2(_red); + + public static InvalidEnum2 from_int(int value) { + return null; + } + + protected InvalidEnum2(int value) { + } +} diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum3.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum3.java new file mode 100644 index 0000000000..ca630e361e --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidEnum3.java @@ -0,0 +1,33 @@ +/* + * 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.sca.binding.corba.testing.hierarchy; + +public class InvalidEnum3 { + + public static final int _red = 0; + public static final InvalidEnum2 red = new InvalidEnum2(_red); + + public int value() { + return 0; + } + + protected InvalidEnum3(int value) { + } +} diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct1.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct1.java new file mode 100644 index 0000000000..180211ecdc --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct1.java @@ -0,0 +1,28 @@ +/* + * 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.sca.binding.corba.testing.hierarchy; + +public final class InvalidStruct1 { + + public InvalidStruct1() { + + } + +} diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct2.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct2.java new file mode 100644 index 0000000000..34699111eb --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct2.java @@ -0,0 +1,31 @@ +/* + * 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.sca.binding.corba.testing.hierarchy; + +public final class InvalidStruct2 { + + public int f1; + public String f2; + + public InvalidStruct2(int f1, String f2) { + + } + +} diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct3.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct3.java new file mode 100644 index 0000000000..59c8c2d39c --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/hierarchy/InvalidStruct3.java @@ -0,0 +1,36 @@ +/* + * 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.sca.binding.corba.testing.hierarchy; + +public final class InvalidStruct3 { + + public int f1; + public String f2; + public static byte f3; + + public InvalidStruct3() { + + } + + public InvalidStruct3(int f1, String f2, byte f3) { + + } + +} diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/EnumManagerServant.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/EnumManagerServant.java new file mode 100644 index 0000000000..58cc370f10 --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/servants/EnumManagerServant.java @@ -0,0 +1,33 @@ +/* + * 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.sca.binding.corba.testing.servants; + +import org.apache.tuscany.sca.binding.corba.testing.enums.Color; +import org.apache.tuscany.sca.binding.corba.testing.enums._EnumManagerImplBase; + +public class EnumManagerServant extends _EnumManagerImplBase { + + private static final long serialVersionUID = 1L; + + public Color getColor(Color color) { + return color; + } + +} diff --git a/java/sca/modules/binding-corba-runtime/src/test/resources/enums.idl b/java/sca/modules/binding-corba-runtime/src/test/resources/enums.idl new file mode 100644 index 0000000000..053185e88f --- /dev/null +++ b/java/sca/modules/binding-corba-runtime/src/test/resources/enums.idl @@ -0,0 +1,132 @@ +/* + * 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. + */ + +/* + * compile by + * idlj -fall -oldImplBase enums.idl + */ + +module org { + module apache { + module tuscany { + module sca { + module binding { + module corba { + module testing { + module enums { + enum Color {red, yellow, green}; + interface EnumManager { + Color getColor(in Color color); + }; + }; + }; + }; + }; + }; + }; + }; +}; +/* + * 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. + */ + +/* + * compile by + * idlj -fall -oldImplBase enums.idl + */ + +module org { + module apache { + module tuscany { + module sca { + module binding { + module corba { + module testing { + module enums { + enum Color {red, yellow, green}; + interface EnumManager { + Color getColor(in Color color); + }; + }; + }; + }; + }; + }; + }; + }; +}; +/* + * 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. + */ + +/* + * compile by + * idlj -fall -oldImplBase enums.idl + */ + +module org { + module apache { + module tuscany { + module sca { + module binding { + module corba { + module testing { + module enums { + enum Color {red, yellow, green}; + interface EnumManager { + Color getColor(in Color color); + }; + }; + }; + }; + }; + }; + }; + }; +}; -- cgit v1.2.3