Package org.omg.CORBA

Examples of org.omg.CORBA.Any


        }
    }

    static void testUnion3(ORB orb, DynAnyFactory factory) {
        try {
            Any any = orb.create_any();
            Any av;
            DynAny d1, d2, copy, disc, member;
            String str;
            DynUnion u1, u2;
            DynEnum e;
            TypeCode type, discType, tc;
View Full Code Here


        }
    }

    static void testUnion4(ORB orb, DynAnyFactory factory) {
        try {
            Any any = orb.create_any();
            ;
            Any av;
            DynAny d1, d2, copy, disc, member;
            String str;
            DynUnion u1, u2;
            TypeCode type, discType, tc;
            test.types.DynAnyTypes.TestUnion4 tu4 = new test.types.DynAnyTypes.TestUnion4();
View Full Code Here

    }

    static void testShortSeq(ORB orb, DynAnyFactory factory) {
        try {
            int i;
            Any any = orb.create_any();
            Any av;
            DynAny d1, d2, comp, copy;
            String str;
            DynSequence s1, s2;
            TypeCode type, tc;
            short[] seq;
View Full Code Here

    }

    static void testBoundedString10Seq(ORB orb, DynAnyFactory factory) {
        try {
            int i;
            Any any = orb.create_any();
            Any av;
            DynAny d1, d2, comp, copy;
            String str;
            DynSequence s1, s2;
            TypeCode type, tc;
            String[] seq;
View Full Code Here

    static void testAnySeq(ORB orb, DynAnyFactory factory) {
        try {
            int i;
            short s;
            Any any = orb.create_any();
            Any av;
            DynAny d1, d2, comp, copy;
            String str;
            DynSequence s1, s2;
            TypeCode type, tc;
            Any[] seq;
            Any[] pseq;

            //
            // Test: initialization
            //
            type = TestAnySeqHelper.type();
            d1 = factory.create_dyn_any_from_type_code(type);
            s1 = DynSequenceHelper.narrow(d1);
            TEST(s1.get_length() == 0);
            TEST(s1.component_count() == 0);

            //
            // Test: set_length() - increase length - position should be 0
            //
            s1.set_length(5);
            TEST(s1.get_length() == 5);
            TEST(s1.component_count() == 5);
            for (i = 0; i < 5; i++) {
                any.insert_short((short) i);
                s1.insert_any(any);
                s1.next();
            }
            s1.rewind();
            for (i = 0; i < 5; i++) {
                av = s1.get_any();
                s = av.extract_short();
                TEST(s == (short) i);
                s1.next();
            }

            //
            // Test: set_length() - decrease length - position should not
            // change
            //
            s1.seek(1);
            s1.set_length(3);
            av = s1.get_any();
            s = av.extract_short();
            TEST(s == (short) 1);
            TEST(s1.get_length() == 3);
            TEST(s1.component_count() == 3);
            s1.rewind();
            for (i = 0; i < 3; i++) {
                av = s1.get_any();
                s = av.extract_short();
                TEST(s == (short) i);
                s1.next();
            }

            //
            // Test: to_any
            //
            av = s1.to_any();
            pseq = TestAnySeqHelper.extract(av);
            TEST(pseq.length == 3);
            for (i = 0; i < 3; i++) {
                s = pseq[i].extract_short();
                TEST(s == (short) i);
            }

            //
            // Test: copy
            //
            copy = s1.copy();
            TEST(s1.equal(copy));
            copy.destroy();

            //
            // Test: equal
            //
            copy = s1.copy();
            copy.seek(1);
            any.insert_short((short) -33);
            copy.insert_any(any);
            TEST(!s1.equal(copy));
            copy.destroy();

            //
            // Test: from_any
            //
            seq = new Any[8];
            for (i = 0; i < 8; i++) {
                seq[i] = orb.create_any();
                seq[i].insert_short((short) (8 - i));
            }
            TestAnySeqHelper.insert(any, seq);
            s1.from_any(any);
            s1.rewind();
            for (i = 0; i < 8; i++) {
                av = s1.get_any();
                s = av.extract_short();
                TEST(s == (short) (8 - i));
                s1.next();
            }

            //
            // Test: components - ensure that the sequence and its components
            // are synchronized
            //
            s1.rewind();
            for (i = 0; i < 8; i++) {
                comp = s1.current_component();
                av = comp.get_any();
                s = av.extract_short();
                TEST(s == (short) (8 - i));
                any.insert_short((short) i);
                comp.insert_any(any);
                av = s1.get_any();
                s = av.extract_short();
                TEST(s == (short) i);
                s1.next();
            }

            //
            // Test: get_elements()
            //
            Any[] anySeq = s1.get_elements();
            TEST(anySeq.length == 8);
            for (i = 0; i < 8; i++) {
                Any p = anySeq[i].extract_any();
                s = p.extract_short();
                TEST(s == (short) i);
            }

            //
            // Test: set_elements()
            //
            anySeq = new Any[3]; // decrease sequence length
            for (i = 0; i < 3; i++) {
                Any anyVal = orb.create_any();
                anyVal.insert_short((short) (i + 10));
                anySeq[i] = orb.create_any();
                anySeq[i].insert_any(anyVal);
            }
            s1.set_elements(anySeq);
            s1.rewind();
            for (i = 0; i < 3; i++) {
                av = s1.get_any();
                s = av.extract_short();
                TEST(s == (short) (i + 10));
                s1.next();
            }

            //
            // Test: get_elements_as_dyn_any()
            //
            DynAny[] dynAnySeq = s1.get_elements_as_dyn_any();
            TEST(dynAnySeq.length == 3);
            for (i = 0; i < 3; i++) {
                av = dynAnySeq[i].get_any();
                s = av.extract_short();
                TEST(s == (short) (i + 10));
            }

            //
            // Test: set_elements_as_dyn_any
            //
            dynAnySeq = new DynAny[4]; // increase sequence length
            for (i = 0; i < 4; i++) {
                Any anyVal = orb.create_any();
                anyVal.insert_short((short) (i + 100));
                any.insert_any(anyVal);
                dynAnySeq[i] = factory.create_dyn_any(any);
            }
            s1.set_elements_as_dyn_any(dynAnySeq);
            s1.rewind();
View Full Code Here

    }

    static void testStringArray(ORB orb, DynAnyFactory factory) {
        try {
            int i;
            Any any = orb.create_any();
            Any av;
            DynAny d1, d2, comp, copy;
            String str;
            DynArray a1, a2;
            String[] arr;
            TypeCode type;
View Full Code Here

        }
    }

    static void testStructBox(ORB orb, DynAnyFactory factory) {
        try {
            Any any = orb.create_any();
            Any av;
            DynAny d1, d2, comp, copy;
            String str;
            DynValueBox v1, v2;
            DynStruct ds;
            TestStruct ts = new TestStruct();
View Full Code Here

        }
    }

    static void testStringBox(ORB orb, DynAnyFactory factory) {
        try {
            Any any = orb.create_any();
            Any av;
            DynAny d1, d2, comp, copy;
            String str;
            String cp;
            DynValueBox v1, v2;
            String ptsb;
            TypeCode type;

            //
            // Test: initialization
            //
            type = TestStringBoxHelper.type();
            d1 = factory.create_dyn_any_from_type_code(type);
            v1 = DynValueBoxHelper.narrow(d1);
            TEST(v1.is_null());
            TEST(v1.component_count() == 0);
            TEST(v1.current_component() == null);

            //
            // Test: to_any (null)
            //
            av = d1.to_any();
            str = TestStringBoxHelper.extract(av);
            TEST(str == null);

            //
            // Test: copy (null)
            //
            copy = d1.copy();
            TEST(d1.equal(copy));
            copy.destroy();

            //
            // Test: equal (null)
            //
            TestStringBoxHelper.insert(any, null);
            d2 = factory.create_dyn_any(any);
            TEST(d1.equal(d2));
            d2.destroy();

            //
            // Test: assign (null)
            //
            TestStringBoxHelper.insert(any, null);
            d2 = factory.create_dyn_any(any);
            d1.assign(d2);
            TEST(d1.equal(d2));
            d2.destroy();
            TEST(v1.is_null());

            //
            // Test: get_boxed_value (null)
            //
            try {
                v1.get_boxed_value();
                TEST(false);
            } catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue ex) {
                // expected
            }

            //
            // Test: get_boxed_value_as_dyn_any (null)
            //
            try {
                v1.get_boxed_value_as_dyn_any();
                TEST(false);
            } catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue ex) {
                // expected
            }

            //
            // Test: set_boxed_value (TypeMismatch)
            //
            try {
                any.insert_boolean(false);
                v1.set_boxed_value(any);
                TEST(false);
            } catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch ex) {
                // expected
            }

            //
            // Test: set_boxed_value (InvalidValue)
            //
            try {
                any.type(orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_string));
                v1.set_boxed_value(any);
                TEST(false);
            } catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue ex) {
                // expected
            }

            //
            // Test: set_boxed_value_as_dyn_any (TypeMismatch)
            //
            try {
                any.insert_long(123);
                d2 = factory.create_dyn_any(any);
                v1.set_boxed_value_as_dyn_any(d2);
                TEST(false);
            } catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch ex) {
                // expected
                d2.destroy();
            }

            //
            // Test: set_to_value
            //
            TEST(v1.is_null());
            v1.set_to_value();
            TEST(!v1.is_null());
            TEST(v1.component_count() == 1);

            //
            // Test: component
            //
            comp = v1.current_component();
            str = comp.get_string();
            TEST(str.length() == 0);
            any.insert_string("hi");
            comp.from_any(any);

            //
            // Test: to_any
            //
            av = d1.to_any();
            str = TestStringBoxHelper.extract(av);
            TEST(str.equals("hi"));

            //
            // Test: copy
            //
            copy = d1.copy();
            TEST(d1.equal(copy));
            copy.destroy();

            //
            // Test: equal
            //
            TestStringBoxHelper.insert(any, "hi");
            d2 = factory.create_dyn_any(any);
            TEST(d1.equal(d2));
            d2.destroy();

            //
            // Test: get_boxed_value
            //
            av = v1.get_boxed_value();
            TEST(av.extract_string().equals("hi"));

            //
            // Test: set_boxed_value
            //
            any.insert_string("bye");
View Full Code Here

        }
    }

    static void testValue1(ORB orb, DynAnyFactory factory) {
        try {
            Any any = orb.create_any();
            Any av;
            DynAny d1, d2, comp, copy;
            String str;
            DynValue v1, v2;
            TestValue1 ptv1;
            TypeCode type;
View Full Code Here

        }
    }

    static void testValue2(ORB orb, DynAnyFactory factory) {
        try {
            Any any = orb.create_any();
            Any av;
            DynAny d1, d2, comp, copy;
            String str;
            String cp;
            DynValue v1, v2;
            TestValue2 ptv2;
View Full Code Here

TOP

Related Classes of org.omg.CORBA.Any

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.