diff options
author | wjaniszewski <wjaniszewski@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-17 21:43:38 +0000 |
---|---|---|
committer | wjaniszewski <wjaniszewski@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-17 21:43:38 +0000 |
commit | b11978062889d7e20a742547ba844dbaf21d1a6e (patch) | |
tree | ea80368e54d00f63b85569091d116412c4eaee26 /java/sca/itest/corba | |
parent | 7d05fe8fd909c342fe796afcc811639d4aaab55c (diff) |
itest/corba tests update for CORBA unions
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@686645 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/itest/corba')
16 files changed, 914 insertions, 8 deletions
diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioSixTestCase.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioSixTestCase.java index 17acd29b26..3c12bf1b8c 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioSixTestCase.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioSixTestCase.java @@ -19,6 +19,7 @@ package org.apache.tuscany.sca.test.corba; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import junit.framework.Assert; @@ -28,10 +29,14 @@ import org.apache.tuscany.sca.host.corba.naming.TransientNameServer; import org.apache.tuscany.sca.host.corba.naming.TransientNameService; import org.apache.tuscany.sca.host.embedded.SCADomain; import org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct; +import org.apache.tuscany.sca.test.corba.generated.InnerUnion; +import org.apache.tuscany.sca.test.corba.generated.RichUnion; import org.apache.tuscany.sca.test.corba.generated.ScenarioSix; import org.apache.tuscany.sca.test.corba.generated.ScenarioSixHelper; import org.apache.tuscany.sca.test.corba.types.ScenarioSixServant; import org.apache.tuscany.sca.test.corba.types.TAnnotatedStruct; +import org.apache.tuscany.sca.test.corba.types.TInnerUnion; +import org.apache.tuscany.sca.test.corba.types.TRichUnion; import org.apache.tuscany.sca.test.corba.types.TScenarioSix; import org.apache.tuscany.sca.test.corba.types.TScenarioSixComponent; import org.junit.AfterClass; @@ -44,6 +49,7 @@ import org.omg.CosNaming.NamingContextHelper; /** * Tests using enhanced Java interfaces (annotations) + * * @version $Rev$ $Date$ */ public class ScenarioSixTestCase { @@ -114,15 +120,16 @@ public class ScenarioSixTestCase { String[][] result = { {"Hello", "World"}, {"Hi", "Again"}}; return result; } - + /** - * Tests passing arrays. Tuscany acts as a client, servant object is served in a traditional way + * Tests passing arrays. Tuscany acts as a client, servant object is served + * in a traditional way */ @Test public void test_arraysPassing_tuscanyAsClient() { try { TScenarioSix ref = domain.getService(TScenarioSixComponent.class, "ScenarioSix").getScenarioSix(); - String[][] arrayArg = getStringArray(); + String[][] arrayArg = getStringArray(); String[][] arrayRes = ref.passStringArray(arrayArg); assertTrue(areArraysEqual(arrayArg, arrayRes)); TAnnotatedStruct structArg = new TAnnotatedStruct(); @@ -134,9 +141,10 @@ public class ScenarioSixTestCase { fail(); } } - + /** - * Tests passing arrays. Servant object is served by Tuscany and it is accessed by traditional Corba client + * Tests passing arrays. Servant object is served by Tuscany and it is + * accessed by traditional Corba client */ @Test public void test_arraysPassing_tuscanyAsService() { @@ -159,4 +167,62 @@ public class ScenarioSixTestCase { } } + /** + * Tests passing unions. Tuscany acts as a client, servant object is served + * in a traditional way + */ + @Test + public void test_unionsPassing_tuscanyAsClient() { + try { + TScenarioSix ref = domain.getService(TScenarioSixComponent.class, "ScenarioSix").getScenarioSix(); + TRichUnion arg = new TRichUnion(); + TInnerUnion inner = new TInnerUnion(); + inner.setY(10f); + arg.setIu(inner); + TRichUnion result = ref.passRichUnion(arg); + assertEquals(arg.getIu().getY(), result.getIu().getY()); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + try { + TScenarioSix ref = domain.getService(TScenarioSixComponent.class, "ScenarioSix").getScenarioSix(); + TRichUnion arg = new TRichUnion(); + arg.setY(15f); + TRichUnion result = ref.passRichUnion(arg); + assertEquals(arg.getY(), result.getY()); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + /** + * Tests passing unions. Servant object is served by Tuscany and it is + * accessed by traditional Corba client + */ + @Test + public void test_unionsPassing_tuscanyAsService() { + try { + org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); + NamingContext ncRef = NamingContextHelper.narrow(objRef); + NameComponent nc = new NameComponent(TUSCANY_SERVICE_NAME, ""); + NameComponent path[] = {nc}; + ScenarioSix ref = ScenarioSixHelper.narrow(ncRef.resolve(path)); + RichUnion arg = new RichUnion(); + InnerUnion inner = new InnerUnion(); + inner.y(20f); + arg.iu(inner); + RichUnion result = ref.passRichUnion(arg); + assertEquals(arg.iu().y(), result.iu().y()); + arg = new RichUnion(); + arg.y(15f); + result = ref.passRichUnion(arg); + assertEquals(arg.y(), result.y()); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + } diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnion.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnion.java new file mode 100644 index 0000000000..40c017dd29 --- /dev/null +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnion.java @@ -0,0 +1,112 @@ +package org.apache.tuscany.sca.test.corba.generated; + + +/** +* org/apache/tuscany/sca/test/corba/generated/InnerUnion.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from itest_scenario.idl +* niedziela, 17 sierpień 2008 19:07:14 CEST +*/ + +public final class InnerUnion implements org.omg.CORBA.portable.IDLEntity +{ + private int ___x; + private float ___y; + private int __discriminator; + private boolean __uninitialized = true; + + public InnerUnion () + { + } + + public int discriminator () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + return __discriminator; + } + + public int x () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + verifyx (__discriminator); + return ___x; + } + + public void x (int value) + { + __discriminator = 1; + ___x = value; + __uninitialized = false; + } + + public void x (int discriminator, int value) + { + verifyx (discriminator); + __discriminator = discriminator; + ___x = value; + __uninitialized = false; + } + + private void verifyx (int discriminator) + { + if (discriminator != 1) + throw new org.omg.CORBA.BAD_OPERATION (); + } + + public float y () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + verifyy (__discriminator); + return ___y; + } + + public void y (float value) + { + __discriminator = 2; + ___y = value; + __uninitialized = false; + } + + public void y (int discriminator, float value) + { + verifyy (discriminator); + __discriminator = discriminator; + ___y = value; + __uninitialized = false; + } + + private void verifyy (int discriminator) + { + if (discriminator != 2) + throw new org.omg.CORBA.BAD_OPERATION (); + } + + public void _default () + { + __discriminator = -2147483648; + __uninitialized = false; + } + + public void _default (int discriminator) + { + verifyDefault( discriminator ) ; + __discriminator = discriminator ; + __uninitialized = false; + } + + private void verifyDefault( int value ) + { + switch (value) { + case 1: + case 2: + throw new org.omg.CORBA.BAD_OPERATION() ; + + default: + return; + } + } + +} // class InnerUnion diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnionHelper.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnionHelper.java new file mode 100644 index 0000000000..6ec067521e --- /dev/null +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnionHelper.java @@ -0,0 +1,106 @@ +package org.apache.tuscany.sca.test.corba.generated; + + +/** +* org/apache/tuscany/sca/test/corba/generated/InnerUnionHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from itest_scenario.idl +* niedziela, 17 sierpień 2008 19:07:14 CEST +*/ + +abstract public class InnerUnionHelper +{ + private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/InnerUnion/InnerUnion:1.0"; + + public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.test.corba.generated.InnerUnion 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.test.corba.generated.InnerUnion 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) + { + org.omg.CORBA.TypeCode _disTypeCode0; + _disTypeCode0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long); + org.omg.CORBA.UnionMember[] _members0 = new org.omg.CORBA.UnionMember [2]; + org.omg.CORBA.TypeCode _tcOf_members0; + org.omg.CORBA.Any _anyOf_members0; + + // Branch for x (case label 1) + _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any (); + _anyOf_members0.insert_long ((int)1); + _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long); + _members0[0] = new org.omg.CORBA.UnionMember ( + "x", + _anyOf_members0, + _tcOf_members0, + null); + + // Branch for y (case label 2) + _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any (); + _anyOf_members0.insert_long ((int)2); + _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_float); + _members0[1] = new org.omg.CORBA.UnionMember ( + "y", + _anyOf_members0, + _tcOf_members0, + null); + __typeCode = org.omg.CORBA.ORB.init ().create_union_tc (org.apache.tuscany.sca.test.corba.generated.InnerUnionHelper.id (), "InnerUnion", _disTypeCode0, _members0); + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static org.apache.tuscany.sca.test.corba.generated.InnerUnion read (org.omg.CORBA.portable.InputStream istream) + { + org.apache.tuscany.sca.test.corba.generated.InnerUnion value = new org.apache.tuscany.sca.test.corba.generated.InnerUnion (); + int _dis0 = (int)0; + _dis0 = istream.read_long (); + switch (_dis0) + { + case 1: + int _x = (int)0; + _x = istream.read_long (); + value.x (_x); + break; + case 2: + float _y = (float)0; + _y = istream.read_float (); + value.y (_y); + break; + default: + value._default( _dis0 ) ; + break; + } + return value; + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.test.corba.generated.InnerUnion value) + { + ostream.write_long (value.discriminator ()); + switch (value.discriminator ()) + { + case 1: + ostream.write_long (value.x ()); + break; + case 2: + ostream.write_float (value.y ()); + break; + } + } + +} diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnionHolder.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnionHolder.java new file mode 100644 index 0000000000..8955f81694 --- /dev/null +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/InnerUnionHolder.java @@ -0,0 +1,38 @@ +package org.apache.tuscany.sca.test.corba.generated; + +/** +* org/apache/tuscany/sca/test/corba/generated/InnerUnionHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from itest_scenario.idl +* niedziela, 17 sierpień 2008 19:07:14 CEST +*/ + +public final class InnerUnionHolder implements org.omg.CORBA.portable.Streamable +{ + public org.apache.tuscany.sca.test.corba.generated.InnerUnion value = null; + + public InnerUnionHolder () + { + } + + public InnerUnionHolder (org.apache.tuscany.sca.test.corba.generated.InnerUnion initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = org.apache.tuscany.sca.test.corba.generated.InnerUnionHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + org.apache.tuscany.sca.test.corba.generated.InnerUnionHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return org.apache.tuscany.sca.test.corba.generated.InnerUnionHelper.type (); + } + +} diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnion.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnion.java new file mode 100644 index 0000000000..4a3376c476 --- /dev/null +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnion.java @@ -0,0 +1,177 @@ +package org.apache.tuscany.sca.test.corba.generated; + + +/** +* org/apache/tuscany/sca/test/corba/generated/RichUnion.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from itest_scenario.idl +* niedziela, 17 sierpień 2008 19:07:14 CEST +*/ + +public final class RichUnion implements org.omg.CORBA.portable.IDLEntity +{ + private int ___x; + private float ___y; + private String ___z; + private org.apache.tuscany.sca.test.corba.generated.InnerUnion ___iu; + private boolean ___a; + private int __discriminator; + private boolean __uninitialized = true; + + public RichUnion () + { + } + + public int discriminator () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + return __discriminator; + } + + public int x () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + verifyx (__discriminator); + return ___x; + } + + public void x (int value) + { + __discriminator = 1; + ___x = value; + __uninitialized = false; + } + + public void x (int discriminator, int value) + { + verifyx (discriminator); + __discriminator = discriminator; + ___x = value; + __uninitialized = false; + } + + private void verifyx (int discriminator) + { + if (discriminator != 1) + throw new org.omg.CORBA.BAD_OPERATION (); + } + + public float y () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + verifyy (__discriminator); + return ___y; + } + + public void y (float value) + { + __discriminator = 2; + ___y = value; + __uninitialized = false; + } + + public void y (int discriminator, float value) + { + verifyy (discriminator); + __discriminator = discriminator; + ___y = value; + __uninitialized = false; + } + + private void verifyy (int discriminator) + { + if (discriminator != 2) + throw new org.omg.CORBA.BAD_OPERATION (); + } + + public String z () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + verifyz (__discriminator); + return ___z; + } + + public void z (String value) + { + __discriminator = 3; + ___z = value; + __uninitialized = false; + } + + public void z (int discriminator, String value) + { + verifyz (discriminator); + __discriminator = discriminator; + ___z = value; + __uninitialized = false; + } + + private void verifyz (int discriminator) + { + if (discriminator != 3) + throw new org.omg.CORBA.BAD_OPERATION (); + } + + public org.apache.tuscany.sca.test.corba.generated.InnerUnion iu () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + verifyiu (__discriminator); + return ___iu; + } + + public void iu (org.apache.tuscany.sca.test.corba.generated.InnerUnion value) + { + __discriminator = 4; + ___iu = value; + __uninitialized = false; + } + + public void iu (int discriminator, org.apache.tuscany.sca.test.corba.generated.InnerUnion value) + { + verifyiu (discriminator); + __discriminator = discriminator; + ___iu = value; + __uninitialized = false; + } + + private void verifyiu (int discriminator) + { + if (discriminator != 4) + throw new org.omg.CORBA.BAD_OPERATION (); + } + + public boolean a () + { + if (__uninitialized) + throw new org.omg.CORBA.BAD_OPERATION (); + verifya (__discriminator); + return ___a; + } + + public void a (boolean value) + { + __discriminator = -2147483648; + ___a = value; + __uninitialized = false; + } + + public void a (int discriminator, boolean value) + { + verifya (discriminator); + __discriminator = discriminator; + ___a = value; + __uninitialized = false; + } + + private void verifya (int discriminator) + { + if (discriminator == 1 || discriminator == 2 || discriminator == 3 || discriminator == 4) + throw new org.omg.CORBA.BAD_OPERATION (); + } + +} // class RichUnion diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnionHelper.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnionHelper.java new file mode 100644 index 0000000000..9b89d7f98a --- /dev/null +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnionHelper.java @@ -0,0 +1,157 @@ +package org.apache.tuscany.sca.test.corba.generated; + + +/** +* org/apache/tuscany/sca/test/corba/generated/RichUnionHelper.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from itest_scenario.idl +* niedziela, 17 sierpień 2008 19:07:14 CEST +*/ + +abstract public class RichUnionHelper +{ + private static String _id = "IDL:org/apache/tuscany/sca/test/corba/generated/RichUnion/RichUnion:1.0"; + + public static void insert (org.omg.CORBA.Any a, org.apache.tuscany.sca.test.corba.generated.RichUnion 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.test.corba.generated.RichUnion 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) + { + org.omg.CORBA.TypeCode _disTypeCode0; + _disTypeCode0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long); + org.omg.CORBA.UnionMember[] _members0 = new org.omg.CORBA.UnionMember [5]; + org.omg.CORBA.TypeCode _tcOf_members0; + org.omg.CORBA.Any _anyOf_members0; + + // Branch for x (case label 1) + _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any (); + _anyOf_members0.insert_long ((int)1); + _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_long); + _members0[0] = new org.omg.CORBA.UnionMember ( + "x", + _anyOf_members0, + _tcOf_members0, + null); + + // Branch for y (case label 2) + _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any (); + _anyOf_members0.insert_long ((int)2); + _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_float); + _members0[1] = new org.omg.CORBA.UnionMember ( + "y", + _anyOf_members0, + _tcOf_members0, + null); + + // Branch for z (case label 3) + _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any (); + _anyOf_members0.insert_long ((int)3); + _tcOf_members0 = org.omg.CORBA.ORB.init ().create_string_tc (0); + _members0[2] = new org.omg.CORBA.UnionMember ( + "z", + _anyOf_members0, + _tcOf_members0, + null); + + // Branch for iu (case label 4) + _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any (); + _anyOf_members0.insert_long ((int)4); + _tcOf_members0 = org.apache.tuscany.sca.test.corba.generated.InnerUnionHelper.type (); + _members0[3] = new org.omg.CORBA.UnionMember ( + "iu", + _anyOf_members0, + _tcOf_members0, + null); + + // Branch for a (Default case) + _anyOf_members0 = org.omg.CORBA.ORB.init ().create_any (); + _anyOf_members0.insert_octet ((byte)0); // default member label + _tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_boolean); + _members0[4] = new org.omg.CORBA.UnionMember ( + "a", + _anyOf_members0, + _tcOf_members0, + null); + __typeCode = org.omg.CORBA.ORB.init ().create_union_tc (org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.id (), "RichUnion", _disTypeCode0, _members0); + } + return __typeCode; + } + + public static String id () + { + return _id; + } + + public static org.apache.tuscany.sca.test.corba.generated.RichUnion read (org.omg.CORBA.portable.InputStream istream) + { + org.apache.tuscany.sca.test.corba.generated.RichUnion value = new org.apache.tuscany.sca.test.corba.generated.RichUnion (); + int _dis0 = (int)0; + _dis0 = istream.read_long (); + switch (_dis0) + { + case 1: + int _x = (int)0; + _x = istream.read_long (); + value.x (_x); + break; + case 2: + float _y = (float)0; + _y = istream.read_float (); + value.y (_y); + break; + case 3: + String _z = null; + _z = istream.read_string (); + value.z (_z); + break; + case 4: + org.apache.tuscany.sca.test.corba.generated.InnerUnion _iu = null; + _iu = org.apache.tuscany.sca.test.corba.generated.InnerUnionHelper.read (istream); + value.iu (_iu); + break; + default: + boolean _a = false; + _a = istream.read_boolean (); + value.a (_dis0, _a); + break; + } + return value; + } + + public static void write (org.omg.CORBA.portable.OutputStream ostream, org.apache.tuscany.sca.test.corba.generated.RichUnion value) + { + ostream.write_long (value.discriminator ()); + switch (value.discriminator ()) + { + case 1: + ostream.write_long (value.x ()); + break; + case 2: + ostream.write_float (value.y ()); + break; + case 3: + ostream.write_string (value.z ()); + break; + case 4: + org.apache.tuscany.sca.test.corba.generated.InnerUnionHelper.write (ostream, value.iu ()); + break; + default: + ostream.write_boolean (value.a ()); + break; + } + } + +} diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnionHolder.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnionHolder.java new file mode 100644 index 0000000000..3c1a1c9a83 --- /dev/null +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/RichUnionHolder.java @@ -0,0 +1,38 @@ +package org.apache.tuscany.sca.test.corba.generated; + +/** +* org/apache/tuscany/sca/test/corba/generated/RichUnionHolder.java . +* Generated by the IDL-to-Java compiler (portable), version "3.2" +* from itest_scenario.idl +* niedziela, 17 sierpień 2008 19:07:14 CEST +*/ + +public final class RichUnionHolder implements org.omg.CORBA.portable.Streamable +{ + public org.apache.tuscany.sca.test.corba.generated.RichUnion value = null; + + public RichUnionHolder () + { + } + + public RichUnionHolder (org.apache.tuscany.sca.test.corba.generated.RichUnion initialValue) + { + value = initialValue; + } + + public void _read (org.omg.CORBA.portable.InputStream i) + { + value = org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.read (i); + } + + public void _write (org.omg.CORBA.portable.OutputStream o) + { + org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.write (o, value); + } + + public org.omg.CORBA.TypeCode _type () + { + return org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.type (); + } + +} diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixOperations.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixOperations.java index 4e7485a8ce..648144299c 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixOperations.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/ScenarioSixOperations.java @@ -24,11 +24,12 @@ package org.apache.tuscany.sca.test.corba.generated; * org/apache/tuscany/sca/test/corba/generated/ScenarioSixOperations.java . * Generated by the IDL-to-Java compiler (portable), version "3.2" * from itest_scenario.idl -* sobota, 16 sierpień 2008 15:31:35 CEST +* niedziela, 17 sierpień 2008 19:07:14 CEST */ public interface ScenarioSixOperations { String[][] passStringArray (String[][] arg); org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct passAnnotatedStruct (org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct arg); + org.apache.tuscany.sca.test.corba.generated.RichUnion passRichUnion (org.apache.tuscany.sca.test.corba.generated.RichUnion arg); } // interface ScenarioSixOperations diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixImplBase.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixImplBase.java index 2b67d1bffa..78464fe40d 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixImplBase.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixImplBase.java @@ -24,7 +24,7 @@ package org.apache.tuscany.sca.test.corba.generated; * org/apache/tuscany/sca/test/corba/generated/_ScenarioSixImplBase.java . * Generated by the IDL-to-Java compiler (portable), version "3.2" * from itest_scenario.idl -* sobota, 16 sierpień 2008 15:31:35 CEST +* niedziela, 17 sierpień 2008 23:35:36 CEST */ public abstract class _ScenarioSixImplBase extends org.omg.CORBA.portable.ObjectImpl @@ -41,6 +41,7 @@ public abstract class _ScenarioSixImplBase extends org.omg.CORBA.portable.Object { _methods.put ("passStringArray", new java.lang.Integer (0)); _methods.put ("passAnnotatedStruct", new java.lang.Integer (1)); + _methods.put ("passRichUnion", new java.lang.Integer (2)); } public org.omg.CORBA.portable.OutputStream _invoke (String $method, @@ -74,6 +75,16 @@ public abstract class _ScenarioSixImplBase extends org.omg.CORBA.portable.Object break; } + case 2: // org/apache/tuscany/sca/test/corba/generated/ScenarioSix/passRichUnion + { + org.apache.tuscany.sca.test.corba.generated.RichUnion arg = org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.read (in); + org.apache.tuscany.sca.test.corba.generated.RichUnion $result = null; + $result = this.passRichUnion (arg); + out = $rh.createReply(); + org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.write (out, $result); + break; + } + default: throw new org.omg.CORBA.BAD_OPERATION (0, org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE); } diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixStub.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixStub.java index 4f64b9b4d4..faff36c2a4 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixStub.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/generated/_ScenarioSixStub.java @@ -24,7 +24,7 @@ package org.apache.tuscany.sca.test.corba.generated; * org/apache/tuscany/sca/test/corba/generated/_ScenarioSixStub.java . * Generated by the IDL-to-Java compiler (portable), version "3.2" * from itest_scenario.idl -* sobota, 16 sierpień 2008 15:31:35 CEST +* niedziela, 17 sierpień 2008 19:07:14 CEST */ public class _ScenarioSixStub extends org.omg.CORBA.portable.ObjectImpl implements org.apache.tuscany.sca.test.corba.generated.ScenarioSix @@ -70,6 +70,26 @@ public class _ScenarioSixStub extends org.omg.CORBA.portable.ObjectImpl implemen } } // passAnnotatedStruct + public org.apache.tuscany.sca.test.corba.generated.RichUnion passRichUnion (org.apache.tuscany.sca.test.corba.generated.RichUnion arg) + { + org.omg.CORBA.portable.InputStream $in = null; + try { + org.omg.CORBA.portable.OutputStream $out = _request ("passRichUnion", true); + org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.write ($out, arg); + $in = _invoke ($out); + org.apache.tuscany.sca.test.corba.generated.RichUnion $result = org.apache.tuscany.sca.test.corba.generated.RichUnionHelper.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 passRichUnion (arg ); + } finally { + _releaseReply ($in); + } + } // passRichUnion + // Type-specific CORBA::Object operations private static String[] __ids = { "IDL:org/apache/tuscany/sca/test/corba/generated/ScenarioSix:1.0"}; diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioSixServant.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioSixServant.java index 35185cdf8b..7889a80bf1 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioSixServant.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioSixServant.java @@ -20,6 +20,7 @@ package org.apache.tuscany.sca.test.corba.types; import org.apache.tuscany.sca.test.corba.generated.AnnotatedStruct; +import org.apache.tuscany.sca.test.corba.generated.RichUnion; import org.apache.tuscany.sca.test.corba.generated._ScenarioSixImplBase; /** @@ -37,5 +38,9 @@ public class ScenarioSixServant extends _ScenarioSixImplBase { public AnnotatedStruct passAnnotatedStruct(AnnotatedStruct arg) { return arg; } + + public RichUnion passRichUnion(RichUnion arg) { + return arg; + } } diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TInnerUnion.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TInnerUnion.java new file mode 100644 index 0000000000..d7734c48a3 --- /dev/null +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TInnerUnion.java @@ -0,0 +1,59 @@ +/* + * 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.test.corba.types; + +import org.apache.tuscany.sca.binding.corba.meta.CorbaUnionElement; +import org.apache.tuscany.sca.binding.corba.meta.CorbaUnionElementType; + +/** + * @version $Rev$ $Date$ + * User provided interface representation for CORBA InnerUnion type. + */ +public final class TInnerUnion { + + @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 1) + private int x; + + @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 2) + private float y; + + @CorbaUnionElement(type = CorbaUnionElementType.discriminator) + @SuppressWarnings("unused") + private int discriminator; + + public int getX() { + return x; + } + + public void setX(int x) { + discriminator = 1; + this.x = x; + } + + public float getY() { + return y; + } + + public void setY(float y) { + discriminator = 2; + this.y = y; + } + +} diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TRichUnion.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TRichUnion.java new file mode 100644 index 0000000000..eb76c94643 --- /dev/null +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TRichUnion.java @@ -0,0 +1,95 @@ +/* + * 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.test.corba.types; + +import org.apache.tuscany.sca.binding.corba.meta.CorbaUnionElement; +import org.apache.tuscany.sca.binding.corba.meta.CorbaUnionElementType; + +/** + * @version $Rev$ $Date$ + * User provided interface representation for CORBA RichUnion type. + */ +public final class TRichUnion { + + @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 1) + private int x; + + @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 2) + private float y; + + @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 3) + private String z; + + @CorbaUnionElement(type = CorbaUnionElementType.option, optionNumber = 4) + private TInnerUnion iu; + + @CorbaUnionElement(type = CorbaUnionElementType.defaultOption) + private boolean def; + + @CorbaUnionElement(type = CorbaUnionElementType.discriminator) + @SuppressWarnings("unused") + private int discriminator = -1; + + public int getX() { + return x; + } + + public void setX(int x) { + this.discriminator = 1; + this.x = x; + } + + public float getY() { + return y; + } + + public void setY(float y) { + this.discriminator = 2; + this.y = y; + } + + public String getZ() { + return z; + } + + public void setZ(String z) { + this.discriminator = 3; + this.z = z; + } + + public boolean isDef() { + return def; + } + + public void setDef(boolean def) { + this.discriminator = -1; + this.def = def; + } + + public TInnerUnion getIu() { + return iu; + } + + public void setIu(TInnerUnion iu) { + this.discriminator = 4; + this.iu = iu; + } + +} diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSix.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSix.java index 8c8f2bb219..3b4943a43d 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSix.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSix.java @@ -31,5 +31,7 @@ public interface TScenarioSix { public String[][] passStringArray(@CorbaArray( {2, 2})String[][] arg); public TAnnotatedStruct passAnnotatedStruct(TAnnotatedStruct arg); + + public TRichUnion passRichUnion(TRichUnion arg); } diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSixServant.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSixServant.java index aeda9bed52..8e76958e31 100644 --- a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSixServant.java +++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/TScenarioSixServant.java @@ -34,5 +34,9 @@ public class TScenarioSixServant implements TScenarioSix { public TAnnotatedStruct passAnnotatedStruct(TAnnotatedStruct arg) { return arg; } + + public TRichUnion passRichUnion(TRichUnion arg) { + return arg; + } } diff --git a/java/sca/itest/corba/src/test/resources/itest_scenario.idl b/java/sca/itest/corba/src/test/resources/itest_scenario.idl index fb7697ce77..41489a4565 100644 --- a/java/sca/itest/corba/src/test/resources/itest_scenario.idl +++ b/java/sca/itest/corba/src/test/resources/itest_scenario.idl @@ -79,12 +79,27 @@ module org { StringArray stringArray;
};
+ union InnerUnion switch (long) {
+ case 1: long x;
+ case 2: float y;
+ };
+
+ union RichUnion switch (long) {
+ case 1: long x;
+ case 2: float y;
+ case 3: string z;
+ case 4: InnerUnion iu;
+ default: boolean a;
+ };
+
interface ScenarioSix {
StringArray passStringArray(in StringArray arg);
AnnotatedStruct passAnnotatedStruct(in AnnotatedStruct arg);
+ RichUnion passRichUnion(in RichUnion arg);
+
};
};
};
|