File: Twoways.java

package info (click to toggle)
zeroc-ice 3.3.1-12
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 40,720 kB
  • ctags: 46,971
  • sloc: cpp: 241,481; java: 104,729; cs: 66,568; python: 18,996; makefile: 5,797; xml: 5,397; ruby: 4,788; php: 3,172; yacc: 3,113; lex: 2,223; ansic: 1,249; perl: 1,200; sh: 182; sql: 73
file content (132 lines) | stat: -rw-r--r-- 3,881 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// **********************************************************************
//
// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

class Twoways
{
    private static void
    test(boolean b)
    {
        if(!b)
        {
            throw new RuntimeException();
        }
    }

    static void
    twoways(Ice.Communicator communicator, Test.MyClassPrx p)
    {
        {
            Serialize.Small i = null;
            Ice.Holder<Serialize.Small> o = new Ice.Holder<Serialize.Small>();
            Serialize.Small r;

            r = p.opSerialSmallJava(i, o);

            test(o.value == null);
            test(r == null);
        }

        {
            Serialize.Small i = new Serialize.Small();
            i.i = 99;
            Ice.Holder<Serialize.Small> o = new Ice.Holder<Serialize.Small>();
            Serialize.Small r;

            try
            {
                r = p.opSerialSmallJava(i, o);

                test(o.value.i == 99);
                test(r.i == 99);
            }
            catch(Ice.OperationNotExistException ex)
            {
                // OK, talking to non-Java server.
            }
        }

        {
            Serialize.Large i = new Serialize.Large();
            i.d1 = 1.0;
            i.d2 = 2.0;
            i.d3 = 3.0;
            i.d4 = 4.0;
            i.d5 = 5.0;
            i.d6 = 6.0;
            i.d7 = 7.0;
            i.d8 = 8.0;
            i.d9 = 9.0;
            i.d10 = 10.0;
            Ice.Holder<Serialize.Large> o = new Ice.Holder<Serialize.Large>();
            Serialize.Large r;

            try
            {
                r = p.opSerialLargeJava(i, o);

                test(o.value.d1 == 1.0);
                test(o.value.d2 == 2.0);
                test(o.value.d3 == 3.0);
                test(o.value.d4 == 4.0);
                test(o.value.d5 == 5.0);
                test(o.value.d6 == 6.0);
                test(o.value.d7 == 7.0);
                test(o.value.d8 == 8.0);
                test(o.value.d9 == 9.0);
                test(o.value.d10 == 10.0);
                test(r.d1 == 1.0);
                test(r.d2 == 2.0);
                test(r.d3 == 3.0);
                test(r.d4 == 4.0);
                test(r.d5 == 5.0);
                test(r.d6 == 6.0);
                test(r.d7 == 7.0);
                test(r.d8 == 8.0);
                test(r.d9 == 9.0);
                test(r.d10 == 10.0);
            }
            catch(Ice.OperationNotExistException ex)
            {
                // OK, talking to non-Java server.
            }
        }

        {
            Serialize.Struct i = new Serialize.Struct();
            i.o = null;
            i.o2 = i;
            i.s = null;
            i.s2 = "Hello";
            Ice.Holder<Serialize.Struct> o = new Ice.Holder<Serialize.Struct>();
            Serialize.Struct r;

            try
            {
                r = p.opSerialStructJava(i, o);

                test(o.value.o == null);
                test(o.value.o2 != null);
                test(((Serialize.Struct)(o.value.o2)).o == null);
                test(((Serialize.Struct)(o.value.o2)).o2 == o.value.o2);
                test(o.value.s == null);
                test(o.value.s2.equals("Hello"));
                test(r.o == null);
                test(r.o2 != null);
                test(((Serialize.Struct)(r.o2)).o == null);
                test(((Serialize.Struct)(r.o2)).o2 == r.o2);
                test(r.s == null);
                test(r.s2.equals("Hello"));
            }
            catch(Ice.OperationNotExistException ex)
            {
                // OK, talking to non-Java server.
            }
        }
    }
}