KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > bugs > bug387 > TestCase


1 package org.jacorb.test.bugs.bug387;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2003 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import junit.framework.*;
24
25 import org.jacorb.test.common.*;
26
27 /**
28  * Tests marshaling of value box instances within structs within anys.
29  *
30  * @author <a HREF="mailto:spiegel@gnu.org">Andre Spiegel</a>
31  * @version $Id: TestCase.java,v 1.2 2003/11/11 23:25:15 andre.spiegel Exp $
32  */

33 public class TestCase extends ClientServerTestCase
34 {
35     private TestInterface server = null;
36     
37     public TestCase (String JavaDoc name, ClientServerSetup setup)
38     {
39         super (name, setup);
40     }
41     
42     public void setUp()
43     {
44         server = (TestInterface)TestInterfaceHelper.narrow(setup.getServerObject());
45     }
46     
47     public static Test suite()
48     {
49         TestSuite suite = new TestSuite("bug 387 value box in struct in any");
50         ClientServerSetup setup =
51             new ClientServerSetup(suite,
52                                   "org.jacorb.test.bugs.bug387.TestInterfaceImpl");
53
54         suite.addTest(new TestCase("test_return_value", setup));
55         suite.addTest(new TestCase("test_return_null", setup));
56         suite.addTest(new TestCase("test_pass_value", setup));
57         suite.addTest(new TestCase("test_pass_null", setup));
58         suite.addTest(new TestCase("test_pass_unshared", setup));
59         suite.addTest(new TestCase("test_pass_shared", setup));
60         
61         return setup;
62     }
63     
64     public void test_return_value()
65     {
66         org.omg.CORBA.Any JavaDoc a = server.test_return_value();
67         TestStruct t = TestStructHelper.extract(a);
68         assertEquals("STRINGTEST", t.name);
69     }
70     
71     public void test_return_null()
72     {
73         org.omg.CORBA.Any JavaDoc a = server.test_return_null();
74         TestStruct t = TestStructHelper.extract(a);
75         assertEquals(null, t.name);
76     }
77     
78     public void test_pass_value()
79     {
80         org.omg.CORBA.Any JavaDoc a = setup.getClientOrb().create_any();
81         TestStruct t = new TestStruct("STRINGTEST", null, 1);
82         TestStructHelper.insert(a, t);
83         boolean result = server.test_pass_value(a, "STRINGTEST");
84         assertTrue(result);
85     }
86
87     public void test_pass_null()
88     {
89         org.omg.CORBA.Any JavaDoc a = setup.getClientOrb().create_any();
90         TestStruct t = new TestStruct(null, null, 1);
91         TestStructHelper.insert(a, t);
92         boolean result = server.test_pass_null(a);
93         assertTrue(result);
94     }
95     
96     public void test_pass_unshared()
97     {
98         org.omg.CORBA.Any JavaDoc a = setup.getClientOrb().create_any();
99         String JavaDoc s1 = "hello";
100         String JavaDoc s2 = new String JavaDoc(s1);
101         TestStruct t = new TestStruct(s1, s2, 1);
102         TestStructHelper.insert(a, t);
103         boolean result = server.test_pass_shared(a);
104         assertFalse(result);
105     }
106
107     public void test_pass_shared()
108     {
109         org.omg.CORBA.Any JavaDoc a = setup.getClientOrb().create_any();
110         String JavaDoc s1 = "hello";
111         String JavaDoc s2 = s1;
112         TestStruct t = new TestStruct(s1, s2, 1);
113         TestStructHelper.insert(a, t);
114         boolean result = server.test_pass_shared(a);
115         assertTrue(result);
116     }
117 }
118
Popular Tags