package org.jfox.ejb.meta;
import java.net.URL;
import java.io.File;
import junit.framework.TestCase;
import org.w3c.dom.Element;
public class EjbJarMetaTest extends TestCase {
private Element element;
private URL jarUrl;
protected void setUp() throws Exception {
jarUrl = new File("./apps/jfox-ejb-test.jar").toURL();
element = EjbJarDocumentBuilder.getEjbJarDocument(jarUrl);
}
protected void tearDown() throws Exception {
super.tearDown();
}
public void testParse() throws Exception {
assertEquals("ejb-jar",element.getNodeName());
}
public void testEjbs() throws Exception {
EJBBundle bundle = new EJBBundle(jarUrl);
assertEquals(1,bundle.getEjbs().size());
}
public void testEJBBase() throws Exception {
EJBBundle bundle = new EJBBundle(jarUrl);
EJBDescriptor ejbDesc = (EJBDescriptor)bundle.getEjbs().get(0);
System.out.println(ejbDesc.getJndiName());
assertEquals("EJBTestRunnerEJB",ejbDesc.getEjbName());
assertEquals("Container",((SessionBeanDescriptor)ejbDesc).getTransactionType());
}
public void testContainerTransaction() throws Exception {
EJBBundle bundle = new EJBBundle(jarUrl);
EJBDescriptor ejbDesc = (EJBDescriptor)bundle.getEjbs().get(0);
assertFalse(ejbDesc.isBeanManagedTransaction());
assertEquals(1,ejbDesc.getContainerTransactions().size());
assertEquals(TransactionAttribute.TX_REQUIRED,ejbDesc.getMethodTransactionAttribute(this.getClass().getMethod("testParse",null)));
}
public static void main(String[] args) {
}
}