1 22 package org.jboss.test.aop.test; 23 24 import java.net.URL ; 25 26 import javax.management.MBeanServerConnection ; 27 import javax.management.ObjectName ; 28 29 import junit.framework.Test; 30 import junit.framework.TestSuite; 31 32 import org.jboss.test.JBossTestCase; 33 import org.jboss.test.util.web.HttpUtils; 34 35 41 public class ScopedUnitTestCase 42 extends JBossTestCase 43 { 44 org.jboss.logging.Logger log = getLog(); 45 46 static boolean deployed = false; 47 static int test = 0; 48 static AOPClassLoaderHookTestSetup setup; 49 50 public ScopedUnitTestCase(String name) 51 { 52 super(name); 53 } 54 55 public void testExpectedValues1() throws Exception 56 { 57 MBeanServerConnection server = getServer(); 58 ObjectName testerName = new ObjectName ("jboss.aop:name=ScopedTester1"); 59 Integer iv = (Integer )server.getAttribute(testerName, "ExpectedInterceptorValue"); 60 Integer ia = (Integer )server.getAttribute(testerName, "ExpectedAspectValue"); 61 assertEquals(11, iv.intValue()); 62 assertEquals(21, ia.intValue()); 63 } 64 65 public void testExpectedValues2() throws Exception 66 { 67 MBeanServerConnection server = getServer(); 68 ObjectName testerName = new ObjectName ("jboss.aop:name=ScopedTester2"); 69 Integer iv = (Integer )server.getAttribute(testerName, "ExpectedInterceptorValue"); 70 Integer ia = (Integer )server.getAttribute(testerName, "ExpectedAspectValue"); 71 assertEquals(12, iv.intValue()); 72 assertEquals(22, ia.intValue()); 73 } 74 75 public void testScoped1() throws Exception 76 { 77 MBeanServerConnection server = getServer(); 78 ObjectName testerName = new ObjectName ("jboss.aop:name=ScopedTester1"); 79 Object [] params = {}; 80 String [] sig = {}; 81 server.invoke(testerName, "testScoped", params, sig); 82 } 83 84 public void testScoped2() throws Exception 85 { 86 MBeanServerConnection server = getServer(); 87 ObjectName testerName = new ObjectName ("jboss.aop:name=ScopedTester2"); 88 Object [] params = {}; 89 String [] sig = {}; 90 server.invoke(testerName, "testScoped", params, sig); 91 } 92 93 public void testAnnotations1() throws Exception 94 { 95 MBeanServerConnection server = getServer(); 96 ObjectName testerName = new ObjectName ("jboss.aop:name=ScopedTester1"); 97 Object [] params = {}; 98 String [] sig = {}; 99 server.invoke(testerName, "testAnnotatedScopedAnnotationsDeployed", params, sig); 100 } 101 102 public void testAnnotations2() throws Exception 103 { 104 MBeanServerConnection server = getServer(); 105 ObjectName testerName = new ObjectName ("jboss.aop:name=ScopedTester2"); 106 Object [] params = {}; 107 String [] sig = {}; 108 server.invoke(testerName, "testAnnotatedScopedAnnotationsNotDeployed", params, sig); 109 } 110 111 public void testIntroduction1() throws Exception 112 { 113 MBeanServerConnection server = getServer(); 114 ObjectName testerName = new ObjectName ("jboss.aop:name=ScopedTester1"); 115 Object [] params = {}; 116 String [] sig = {}; 117 server.invoke(testerName, "testIntroduction1", params, sig); 118 } 119 120 public void testIntroduction2() throws Exception 121 { 122 MBeanServerConnection server = getServer(); 123 ObjectName testerName = new ObjectName ("jboss.aop:name=ScopedTester2"); 124 Object [] params = {}; 125 String [] sig = {}; 126 server.invoke(testerName, "testIntroduction2", params, sig); 127 } 128 129 public void testEar1() throws Exception 130 { 131 URL url = new URL (HttpUtils.getBaseURL() + "ear1/srv"); 132 HttpUtils.accessURL(url); 133 } 134 135 public void testEar2() throws Exception 136 { 137 URL url = new URL (HttpUtils.getBaseURL() + "ear2/srv"); 138 HttpUtils.accessURL(url); 139 } 140 141 public static Test suite() throws Exception 142 { 143 TestSuite suite = new TestSuite(); 144 suite.addTest(new TestSuite(ScopedUnitTestCase.class)); 145 146 setup = new AOPClassLoaderHookTestSetup(suite, "aop-scopedtest1.sar,aop-scopedtest2.sar,aop-scopedear1.ear,aop-scopedear2.ear"); 147 return setup; 148 } 149 150 } 151 | Popular Tags |