KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > aop > test > ScopedExtenderBaseTest


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * 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.test;
23
24 import javax.management.ObjectName JavaDoc;
25
26 import org.jboss.test.JBossTestCase;
27
28 /**
29  *
30  * @author <a HREF="kabir.khan@jboss.com">Kabir Khan</a>
31  * @version $Revision: 1.1 $
32  */

33 public abstract class ScopedExtenderBaseTest extends JBossTestCase
34 {
35    final static String JavaDoc BASE_NAME= "jboss.aop:name=BaseTester";
36    final static String JavaDoc CHILD_NAME= "jboss.aop:name=ChildTester";
37    final static Object JavaDoc[] PARAMS = new Object JavaDoc[0];
38    final static String JavaDoc[] SIG = new String JavaDoc[0];
39    
40    public ScopedExtenderBaseTest(String JavaDoc name)
41    {
42       super(name);
43    }
44
45    public void testCorrectBaseDeployed() throws Exception JavaDoc
46    {
47       String JavaDoc name = invokeReadName(BASE_NAME);
48       assertEquals(getExpectedBaseName(), name);
49    }
50    
51    public void testCorrectChildDeployed() throws Exception JavaDoc
52    {
53       String JavaDoc name = invokeReadName(CHILD_NAME);
54       assertEquals(getExpectedChildName(), name);
55    }
56    
57    public void testLoaders() throws Exception JavaDoc
58    {
59       invokeTestClassLoaders(BASE_NAME);
60       invokeTestClassLoaders(CHILD_NAME);
61    }
62    
63    public void testMethod() throws Exception JavaDoc
64    {
65       invokeMethodTest(BASE_NAME);
66       invokeMethodTest(CHILD_NAME);
67    }
68    
69    public void testField() throws Exception JavaDoc
70    {
71       invokeFieldTest(BASE_NAME);
72       invokeFieldTest(CHILD_NAME);
73    }
74    
75    public void testConstructor() throws Exception JavaDoc
76    {
77       invokeConstructorTest(BASE_NAME);
78       invokeConstructorTest(CHILD_NAME);
79    }
80    
81    public void testDifferentScopes() throws Exception JavaDoc
82    {
83       invokeOverriddenInterceptorsTest(BASE_NAME);
84       invokeOverriddenInterceptorsTest(CHILD_NAME);
85    }
86    
87    private void invokeMethodTest(String JavaDoc objName) throws Exception JavaDoc
88    {
89       invoke(objName, "testMethod");
90    }
91
92    private void invokeFieldTest(String JavaDoc objName) throws Exception JavaDoc
93    {
94       invoke(objName, "testField");
95    }
96    
97    private void invokeConstructorTest(String JavaDoc objName) throws Exception JavaDoc
98    {
99       invoke(objName, "testConstructor");
100    }
101    
102    private String JavaDoc invokeReadName(String JavaDoc objName) throws Exception JavaDoc
103    {
104       return (String JavaDoc)invoke(objName, "readName");
105    }
106    
107    private void invokeTestClassLoaders(String JavaDoc objName) throws Exception JavaDoc
108    {
109       invoke(objName, "testLoaders");
110    }
111    
112    private void invokeOverriddenInterceptorsTest(String JavaDoc objName) throws Exception JavaDoc
113    {
114       invoke(objName, "testOverriddenInterceptors");
115    }
116    
117    private Object JavaDoc invoke(String JavaDoc objName, String JavaDoc method) throws Exception JavaDoc
118    {
119       ObjectName JavaDoc testerName = new ObjectName JavaDoc(objName);
120       return getServer().invoke(testerName, method, PARAMS, SIG);
121    }
122    
123    protected abstract String JavaDoc getExpectedBaseName();
124
125    protected abstract String JavaDoc getExpectedChildName();
126
127 }
128
Popular Tags