KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > interop > InteropGBeanTest


1 /**
2  *
3  * Copyright 2004-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * 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  */

17 package org.apache.geronimo.interop;
18
19 import javax.management.ObjectName JavaDoc;
20
21 import junit.framework.TestCase;
22
23 import org.apache.geronimo.gbean.GBeanInfo;
24 import org.apache.geronimo.kernel.KernelFactory;
25 import org.apache.geronimo.kernel.Kernel;
26
27
28 /**
29  * @version $Rev: $ $Date: $
30  */

31 public class InteropGBeanTest extends TestCase {
32
33     private Kernel kernel;
34     private ObjectName JavaDoc objName;
35     private static final String JavaDoc KERNEL_NAME = "testKernel";
36
37     public void testFoo() throws Exception JavaDoc {
38         log("testFoo():");
39     }
40
41     public void testProperties() throws Exception JavaDoc {
42         try {
43             log("testProperties():");
44
45             GBeanInfo gbi = InteropGBean.getGBeanInfo();
46             log("testProperties(): gbi = " + gbi);
47
48 // GBeanMBean cmf = new GBeanMBean(gbi);
49
// log("testProperties(): cmf = " + cmf);
50

51             /*
52             cmf.setAttribute("strprop", "strvalue");
53             log( "testProperties(): strprop set" );
54
55             objName = ObjectName.getInstance("interop: name=default");
56             log( "testProperties(): objName = " + objName );
57
58             kernel.loadGBean(objName, cmf);
59             kernel.startGBean(objName);
60
61             Object proxy = kernel.invoke(objName, "$getResource");
62
63             log( "proxy = " + proxy );
64
65             kernel.stopGBean(objName);
66             */

67         } catch (Error JavaDoc er) {
68             // JUnit did not print out the stack trace for this messsage.
69
log("er = " + er);
70             er.printStackTrace(System.out);
71             throw new Exception JavaDoc(er.toString());
72         } catch (Exception JavaDoc ex) {
73             // JUnit did not print out the stack trace for this messsage.
74
log("ex = " + ex);
75             ex.printStackTrace(System.out);
76             throw new Exception JavaDoc(ex.toString());
77         }
78     }
79
80     /*
81      * Hum, testError and testException will result in a test failure, but
82      * no information about which test or why it failed is sent to the console
83      * even with maven -X.
84      */

85     public void testError() {
86         log("testError()");
87         //throw new java.lang.ExceptionInInitializerError( "Error: Unable to find constructor" );
88
}
89
90     public void testException()
91             throws Exception JavaDoc {
92         log("testException()");
93         //throw new java.lang.Exception( "Exception: Something went wrong." );
94
}
95
96     protected void setUp() throws Exception JavaDoc {
97         log("setUp():");
98         kernel = KernelFactory.newInstance().createKernel(KERNEL_NAME);
99
100         log("setUp(): kernel = " + kernel);
101
102         kernel.boot();
103     }
104
105     protected void tearDown() throws Exception JavaDoc {
106         log("tearDown():");
107         kernel.shutdown();
108     }
109
110     protected void log(String JavaDoc msg) {
111         System.out.println(msg);
112     }
113 }
114
Popular Tags