KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.net.URL JavaDoc;
25
26 import javax.management.MBeanServerConnection JavaDoc;
27 import javax.management.ObjectName JavaDoc;
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 /**
36  * Sample client for the jboss container.
37  *
38  * @author <a HREF="mailto:bill@burkecentral.com">Kabir Khan</a>
39  * @version $Id$
40  */

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 JavaDoc name)
51    {
52       super(name);
53    }
54
55    public void testExpectedValues1() throws Exception JavaDoc
56    {
57       MBeanServerConnection JavaDoc server = getServer();
58       ObjectName JavaDoc testerName = new ObjectName JavaDoc("jboss.aop:name=ScopedTester1");
59       Integer JavaDoc iv = (Integer JavaDoc)server.getAttribute(testerName, "ExpectedInterceptorValue");
60       Integer JavaDoc ia = (Integer JavaDoc)server.getAttribute(testerName, "ExpectedAspectValue");
61       assertEquals(11, iv.intValue());
62       assertEquals(21, ia.intValue());
63    }
64    
65    public void testExpectedValues2() throws Exception JavaDoc
66    {
67       MBeanServerConnection JavaDoc server = getServer();
68       ObjectName JavaDoc testerName = new ObjectName JavaDoc("jboss.aop:name=ScopedTester2");
69       Integer JavaDoc iv = (Integer JavaDoc)server.getAttribute(testerName, "ExpectedInterceptorValue");
70       Integer JavaDoc ia = (Integer JavaDoc)server.getAttribute(testerName, "ExpectedAspectValue");
71       assertEquals(12, iv.intValue());
72       assertEquals(22, ia.intValue());
73    }
74    
75    public void testScoped1() throws Exception JavaDoc
76    {
77       MBeanServerConnection JavaDoc server = getServer();
78       ObjectName JavaDoc testerName = new ObjectName JavaDoc("jboss.aop:name=ScopedTester1");
79       Object JavaDoc[] params = {};
80       String JavaDoc[] sig = {};
81       server.invoke(testerName, "testScoped", params, sig);
82    }
83
84    public void testScoped2() throws Exception JavaDoc
85    {
86       MBeanServerConnection JavaDoc server = getServer();
87       ObjectName JavaDoc testerName = new ObjectName JavaDoc("jboss.aop:name=ScopedTester2");
88       Object JavaDoc[] params = {};
89       String JavaDoc[] sig = {};
90       server.invoke(testerName, "testScoped", params, sig);
91    }
92    
93    public void testAnnotations1() throws Exception JavaDoc
94    {
95       MBeanServerConnection JavaDoc server = getServer();
96       ObjectName JavaDoc testerName = new ObjectName JavaDoc("jboss.aop:name=ScopedTester1");
97       Object JavaDoc[] params = {};
98       String JavaDoc[] sig = {};
99       server.invoke(testerName, "testAnnotatedScopedAnnotationsDeployed", params, sig);
100    }
101    
102    public void testAnnotations2() throws Exception JavaDoc
103    {
104       MBeanServerConnection JavaDoc server = getServer();
105       ObjectName JavaDoc testerName = new ObjectName JavaDoc("jboss.aop:name=ScopedTester2");
106       Object JavaDoc[] params = {};
107       String JavaDoc[] sig = {};
108       server.invoke(testerName, "testAnnotatedScopedAnnotationsNotDeployed", params, sig);
109    }
110    
111    public void testIntroduction1() throws Exception JavaDoc
112    {
113       MBeanServerConnection JavaDoc server = getServer();
114       ObjectName JavaDoc testerName = new ObjectName JavaDoc("jboss.aop:name=ScopedTester1");
115       Object JavaDoc[] params = {};
116       String JavaDoc[] sig = {};
117       server.invoke(testerName, "testIntroduction1", params, sig);
118    }
119    
120    public void testIntroduction2() throws Exception JavaDoc
121    {
122       MBeanServerConnection JavaDoc server = getServer();
123       ObjectName JavaDoc testerName = new ObjectName JavaDoc("jboss.aop:name=ScopedTester2");
124       Object JavaDoc[] params = {};
125       String JavaDoc[] sig = {};
126       server.invoke(testerName, "testIntroduction2", params, sig);
127    }
128
129    public void testEar1() throws Exception JavaDoc
130    {
131       URL JavaDoc url = new URL JavaDoc(HttpUtils.getBaseURL() + "ear1/srv");
132       HttpUtils.accessURL(url);
133    }
134
135    public void testEar2() throws Exception JavaDoc
136    {
137       URL JavaDoc url = new URL JavaDoc(HttpUtils.getBaseURL() + "ear2/srv");
138       HttpUtils.accessURL(url);
139    }
140
141    public static Test suite() throws Exception JavaDoc
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