1   /***
2    * @(#)MBeanServerInterceptorTest.java
3    * 
4    * JFoxSOAF, Service-Oriented Application Framework
5    * 
6    * Copyright(c) JFoxSOAF Team
7    * 
8    * Licensed under the GNU LGPL, Version 2.1 (the "License"); 
9    * you may not use this file except in compliance with the License. 
10   * You may obtain a copy of the License at  
11   * 
12   * http://www.gnu.org/copyleft/lesser.html
13   * 
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, 
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
17   * See the License for the specific language governing permissions and 
18   * limitations under the License. 
19   * 
20   * For more information, please visit:
21   * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
22   * http://www.huihoo.org/jfox/jfoxsoaf
23   */
24  
25  package org.huihoo.jfox.soaf.container;
26  
27  import junit.framework.TestCase;
28  
29  /***
30   * JUnit test case for the
31   * {@link org.huihoo.jfox.soaf.container.MBeanServerInceptor).
32   * 
33   * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
34   * @version $Revision: 1.6 $ $Date: 2005/01/17 14:10:49 $
35   * @version Revision: 1.0
36   */
37  
38  public class MBeanServerInterceptorTest extends TestCase {
39  
40      private ManageableServiceContainer mServiceContainer = ManageableServiceContainer
41              .getInstance();
42  
43      private ServiceInterceptor serviceInterceptor = new MBeanServerInterceptor();
44  
45      private ServiceEntry simpleStandardWithID = new MockServiceEntry();
46  
47      private ServiceEntry simpleStandardWithoutID = new MockServiceEntry();
48  
49      private ServiceFactory serviceFactory = ServiceFactory.getInstance();
50  
51      /***
52       * @see TestCase#setUp()
53       */
54      protected void setUp() throws Exception {
55          super.setUp();
56          simpleStandardWithoutID
57                  .setImplementation("org.huihoo.jfox.soaf.container.SimpleStandard");
58          simpleStandardWithoutID.setManageable("true");
59  
60          simpleStandardWithID.setId("SimpleStandard");
61          simpleStandardWithID
62                  .setImplementation("org.huihoo.jfox.soaf.container.SimpleStandard");
63          simpleStandardWithID.setManageable("true");
64      }
65  
66      /***
67       * @see TestCase#tearDown()
68       */
69      protected void tearDown() throws Exception {
70          super.tearDown();
71      }
72  
73      public void testInvokeWihoutID() {
74  
75          try {
76              serviceInterceptor.invoke(simpleStandardWithoutID);
77              mServiceContainer.getMBeanServer().invoke(
78                      mServiceContainer.objectName(simpleStandardWithoutID),
79                      "reset", null, null);
80          } catch (Throwable e1) {
81              e1.printStackTrace();
82          }
83  
84          assertNotNull(serviceFactory.getService(SimpleStandardMBean.class));
85          assertNotNull(serviceFactory.getService(SimpleStandard.class));
86      }
87  
88      //    public void testInvoke() {
89      //        try {
90      //            serviceInterceptor.invoke(simpleStandardWithID, cl);
91      //            mServiceContainer.getMBeanServer().invoke(
92      //                    mServiceContainer.objectName(simpleStandardWithID),
93      //                    "reset", null, null);
94      //        } catch (Throwable e1) {
95      //            e1.printStackTrace();
96      //        }
97      //
98      //        //assertNotNull(serviceFactory.getService("SimpleStandard"));
99      //        //assertNotNull(serviceFactory.getService(SimpleStandard.class));
100     //    }
101 
102 }