01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.test.aop.bean;
23:
24: import org.jboss.logging.Logger;
25: import org.jboss.security.SecurityAssociation;
26: import org.jboss.security.SimplePrincipal;
27: import org.jboss.system.ServiceMBeanSupport;
28: import org.jboss.test.aop.simpleejb.SimpleHome;
29: import org.jboss.test.aop.simpleejb.Simple;
30:
31: import javax.management.MBeanRegistration;
32: import javax.management.MBeanServer;
33: import javax.management.ObjectName;
34: import javax.naming.InitialContext;
35:
36: /**
37: *
38: * @see Monitorable
39: * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
40: * @version $Revision: 57211 $
41: */
42: public class SimpleBeanTester extends ServiceMBeanSupport implements
43: MBeanRegistration, SimpleBeanTesterMBean {
44: // Constants ----------------------------------------------------
45: // Attributes ---------------------------------------------------
46: static Logger log = Logger.getLogger(SimpleBeanTester.class);
47: MBeanServer m_mbeanServer;
48:
49: // Static -------------------------------------------------------
50:
51: // Constructors -------------------------------------------------
52: public SimpleBeanTester() {
53: }
54:
55: // Public -------------------------------------------------------
56:
57: // MBeanRegistration implementation -----------------------------------
58: public ObjectName preRegister(MBeanServer server, ObjectName name)
59: throws Exception {
60: m_mbeanServer = server;
61: return name;
62: }
63:
64: public void postRegister(Boolean registrationDone) {
65: }
66:
67: public void preDeregister() throws Exception {
68: }
69:
70: public void postDeregister() {
71: }
72:
73: protected void startService() throws Exception {
74: }
75:
76: protected void stopService() {
77: }
78:
79: public void testEJBCallside() throws Exception {
80: SimpleHome home = (SimpleHome) new InitialContext()
81: .lookup("ejb/test/Simple");
82: Simple bean = home.create();
83: SimpleBeanCallerInterceptor.wasCalled = false;
84: String value = bean.getTest();
85: if (!SimpleBeanCallerInterceptor.wasCalled)
86: throw new Exception("Caller interceptor wasn't called");
87: if (!value.equals(SimpleBeanInterceptor.RETURN_VALUE))
88: throw new Exception("bean interceptor failed");
89:
90: }
91:
92: }
|