01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.corba.util;
17:
18: import java.util.Arrays;
19: import java.util.List;
20: import javax.rmi.CORBA.Stub;
21:
22: import junit.framework.TestCase;
23:
24: /**
25: * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
26: */
27: public class DynamicStubClassLoaderTest extends TestCase {
28: public void testGeneration() throws Exception {
29: DynamicStubClassLoader dynamicStubClassLoader = new DynamicStubClassLoader();
30: dynamicStubClassLoader.doStart();
31: Class c = dynamicStubClassLoader
32: .loadClass("org.omg.stub.org.apache.geronimo.corba.compiler._Simple_Stub");
33: verifyStub(c);
34: verifyStub(c);
35: verifyStub(c);
36: verifyStub(c);
37:
38: }
39:
40: private void verifyStub(final Class c) throws Exception {
41: final Exception[] exception = new Exception[1];
42: Runnable verify = new Runnable() {
43: public void run() {
44: try {
45: Stub stub = (Stub) c.newInstance();
46: String[] strings = stub._ids();
47: assertNotNull(strings);
48: assertEquals(2, strings.length);
49: List ids = Arrays.asList(strings);
50: assertTrue(ids
51: .contains("RMI:org.apache.geronimo.corba.compiler.Simple:0000000000000000"));
52: assertTrue(ids
53: .contains("RMI:org.apache.geronimo.corba.compiler.Special:0000000000000000"));
54: } catch (Exception e) {
55: exception[0] = e;
56: }
57: }
58: };
59: Thread thread = new Thread(verify);
60: thread.start();
61: thread.join();
62: if (exception[0] != null) {
63: throw exception[0];
64: }
65: }
66: }
|