001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.classloader.test;
023:
024: import javax.management.MBeanServerConnection;
025: import javax.management.ObjectName;
026:
027: import junit.extensions.TestSetup;
028: import junit.framework.Test;
029: import junit.framework.TestSuite;
030:
031: import org.jboss.test.JBossTestCase;
032: import org.jboss.test.JBossTestSetup;
033:
034: /** Unit tests for the org.jboss.mx.loading.UnifiedLoaderRepository
035: * @author Scott.Stark@jboss.org
036: * @version $Revision: 60355 $
037: */
038: public class CircularityUnitTestCase extends JBossTestCase {
039: private static String JMX_NAME = "jboss.test:name=CircularityError";
040: private ObjectName testObjectName;
041: private Object[] args = {};
042: private String[] sig = {};
043: MBeanServerConnection server;
044:
045: public CircularityUnitTestCase(String name) throws Exception {
046: super (name);
047: testObjectName = new ObjectName(JMX_NAME);
048: server = getServer();
049: }
050:
051: /** Test the UnifiedLoaderRepository for ClassCircularityError
052: */
053: public void testDuplicateClass() throws Exception {
054: server.invoke(testObjectName, "testDuplicateClass", args, sig);
055: }
056:
057: public void testUCLOwner() throws Exception {
058: server.invoke(testObjectName, "testUCLOwner", args, sig);
059: }
060:
061: public void testMissingSuperClass() throws Exception {
062: server.invoke(testObjectName, "testMissingSuperClass", args,
063: sig);
064: }
065:
066: public void testLoading() throws Exception {
067: server.invoke(testObjectName, "testLoading", args, sig);
068: }
069:
070: public void testPackageProtected() throws Exception {
071: server
072: .invoke(testObjectName, "testPackageProtected", args,
073: sig);
074: }
075:
076: public void testDeadlockCase1() throws Exception {
077: server.invoke(testObjectName, "testDeadlockCase1", args, sig);
078: }
079:
080: public void testRecursiveLoadMT() throws Exception {
081: server.invoke(testObjectName, "testRecursiveLoadMT", args, sig);
082: }
083:
084: /**
085: * Setup the test suite by deploying the sar with the
086: * {@link org.jboss.test.classloader.circularity.Starter} mbean
087: */
088: public static Test suite() throws Exception {
089: TestSuite suite = new TestSuite();
090: suite.addTest(new TestSuite(CircularityUnitTestCase.class));
091:
092: // Create an initializer for the test suite
093: TestSetup wrapper = new JBossTestSetup(suite) {
094: protected void setUp() throws Exception {
095: super .setUp();
096: deploy("circularity.sar");
097: }
098:
099: protected void tearDown() throws Exception {
100: undeploy("circularity.sar");
101: super.tearDown();
102: }
103: };
104: return wrapper;
105: }
106:
107: }
|