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