1 22 package org.jboss.ejb3.test; 23 24 import java.util.StringTokenizer ; 25 26 import junit.framework.Test; 27 import junit.framework.TestSuite; 28 29 import org.jboss.test.AbstractTestDelegate; 30 import org.jboss.test.JBossTestCase; 31 32 38 public class CustomJNDIJBossTestCase extends JBossTestCase 39 { 40 41 public CustomJNDIJBossTestCase(String name) 42 { 43 super(name); 44 } 45 46 49 public static AbstractTestDelegate getDelegate(Class clazz) throws Exception 50 { 51 AbstractTestDelegate delegate = new CustomJNDIJBossTestServices(clazz); 52 return delegate; 53 } 54 55 61 public static Test getDeploySetup(final Test test, final String jarNames) 62 throws Exception 63 { 64 CustomJNDIJBossTestSetup wrapper = new CustomJNDIJBossTestSetup(test) 65 { 66 protected void setUp() throws Exception 67 { 68 deploymentException = null; 69 try 70 { 71 this.delegate.init(); 72 73 if (this.getDelegate().isSecureTest()) 74 this.delegate.login(); 75 76 if (jarNames == null) return; 77 78 StringTokenizer st = new StringTokenizer (jarNames, ", "); 80 while (st != null && st.hasMoreTokens()) 81 { 82 String jarName = st.nextToken(); 83 this.redeploy(jarName); 84 this.getLog().debug("deployed package: " + jarName); 85 } 86 } 87 catch (Exception ex) 88 { 89 deploymentException = ex; 91 } 92 } 93 94 protected void tearDown() throws Exception 95 { 96 if (jarNames == null) return; 98 StringTokenizer st = new StringTokenizer (jarNames, ", "); 100 String [] depoyments = new String [st.countTokens()]; 101 for (int i = depoyments.length - 1; i >= 0; i--) 102 depoyments[i] = st.nextToken(); 103 for (int i = 0; i < depoyments.length; i++) 104 { 105 String jarName = depoyments[i]; 106 this.undeploy(jarName); 107 this.getLog().debug("undeployed package: " + jarName); 108 } 109 110 if (this.getDelegate().isSecureTest()) 111 this.delegate.logout(); 112 } 113 }; 114 return wrapper; 115 } 116 117 public static Test getDeploySetup(final Class clazz, final String jarName) 118 throws Exception 119 { 120 TestSuite suite = new TestSuite(); 121 suite.addTest(new TestSuite(clazz)); 122 return getDeploySetup(suite, jarName); 123 } 124 } 125 | Popular Tags |