Search in sources :

Example 11 with ContainerTransaction$JAXB.writeContainerTransaction

use of org.apache.openejb.jee.ContainerTransaction$JAXB.writeContainerTransaction in project tomee by apache.

the class CheckInvalidContainerTransactionTest method test.

@Keys({ @Key("containerTransaction.ejbNameRequired"), @Key("containerTransaction.noSuchEjbName") })
public EjbJar test() throws Exception {
    final EjbJar ejbJar = new EjbJar();
    final ContainerTransaction tx = new ContainerTransaction(TransAttribute.REQUIRED, new Method((String) null, (String) null));
    ejbJar.getAssemblyDescriptor().getContainerTransaction().add(tx);
    final ContainerTransaction tx1 = new ContainerTransaction(TransAttribute.REQUIRED, new Method("wrongEjbName", "wrongMethodName"));
    ejbJar.getAssemblyDescriptor().getContainerTransaction().add(tx1);
    return ejbJar;
}
Also used : ContainerTransaction(org.apache.openejb.jee.ContainerTransaction) Method(org.apache.openejb.jee.Method) EjbJar(org.apache.openejb.jee.EjbJar)

Example 12 with ContainerTransaction$JAXB.writeContainerTransaction

use of org.apache.openejb.jee.ContainerTransaction$JAXB.writeContainerTransaction in project tomee by apache.

the class TransactionAttributesTest method test.

public void test() throws Exception {
    final Assembler assembler = new Assembler();
    final ConfigurationFactory config = new ConfigurationFactory();
    assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(Color.class));
    ejbJar.addEnterpriseBean(new StatelessBean(Red.class));
    ejbJar.addEnterpriseBean(new StatelessBean(Crimson.class));
    ejbJar.addEnterpriseBean(new StatelessBean(Scarlet.class));
    final List<ContainerTransaction> declared = ejbJar.getAssemblyDescriptor().getContainerTransaction();
    declared.add(new ContainerTransaction(TransAttribute.REQUIRED, "*", "*", "*"));
    declared.add(new ContainerTransaction(TransAttribute.SUPPORTS, "*", "Crimson", "*"));
    declared.add(new ContainerTransaction(TransAttribute.SUPPORTS, Color.class.getName(), "Scarlet", "*"));
    declared.add(new ContainerTransaction(TransAttribute.NEVER, Red.class.getName(), "Scarlet", "red"));
    declared.add(new ContainerTransaction(TransAttribute.REQUIRED, "Scarlet", Scarlet.class.getMethod("scarlet")));
    ejbJar.getAssemblyDescriptor().addInterceptorBinding(new InterceptorBinding("*", AttributeInterceptor.class.getName()));
    final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
    assembler.createApplication(ejbJarInfo);
    loadAttributes(ejbJarInfo, "Color");
    assertAttribute("Never", Color.class.getMethod("color"));
    assertAttribute("RequiresNew", Color.class.getMethod("color", Object.class));
    assertAttribute("Mandatory", Color.class.getMethod("color", String.class));
    assertAttribute("Mandatory", Color.class.getMethod("color", Boolean.class));
    assertAttribute("Mandatory", Color.class.getMethod("color", Integer.class));
    loadAttributes(ejbJarInfo, "Red");
    assertAttribute("Never", Red.class.getMethod("color"));
    assertAttribute("Required", Red.class.getMethod("color", Object.class));
    assertAttribute("Mandatory", Red.class.getMethod("color", String.class));
    assertAttribute("Mandatory", Red.class.getMethod("color", Boolean.class));
    assertAttribute("Mandatory", Red.class.getMethod("color", Integer.class));
    assertAttribute("RequiresNew", Red.class.getMethod("red"));
    assertAttribute("Required", Red.class.getMethod("red", Object.class));
    assertAttribute("Required", Red.class.getMethod("red", String.class));
    loadAttributes(ejbJarInfo, "Crimson");
    assertAttribute("Supports", Crimson.class.getMethod("color"));
    assertAttribute("Supports", Crimson.class.getMethod("color", Object.class));
    assertAttribute("Supports", Crimson.class.getMethod("color", String.class));
    assertAttribute("Supports", Crimson.class.getMethod("color", Boolean.class));
    assertAttribute("Supports", Crimson.class.getMethod("color", Integer.class));
    assertAttribute("RequiresNew", Crimson.class.getMethod("red"));
    assertAttribute("Supports", Crimson.class.getMethod("red", Object.class));
    assertAttribute("Supports", Crimson.class.getMethod("red", String.class));
    assertAttribute("RequiresNew", Crimson.class.getMethod("crimson"));
    assertAttribute("Supports", Crimson.class.getMethod("crimson", String.class));
    loadAttributes(ejbJarInfo, "Scarlet");
    assertAttribute("Never", Scarlet.class.getMethod("color"));
    assertAttribute("Required", Scarlet.class.getMethod("color", Object.class));
    assertAttribute("Supports", Scarlet.class.getMethod("color", String.class));
    assertAttribute("Supports", Scarlet.class.getMethod("color", Boolean.class));
    assertAttribute("Supports", Scarlet.class.getMethod("color", Integer.class));
    assertAttribute("RequiresNew", Scarlet.class.getMethod("red"));
    assertAttribute("Never", Scarlet.class.getMethod("red", Object.class));
    assertAttribute("Never", Scarlet.class.getMethod("red", String.class));
    assertAttribute("Required", Scarlet.class.getMethod("scarlet"));
    assertAttribute("NotSupported", Scarlet.class.getMethod("scarlet", String.class));
}
Also used : InterceptorBinding(org.apache.openejb.jee.InterceptorBinding) StatelessBean(org.apache.openejb.jee.StatelessBean) ContainerTransaction(org.apache.openejb.jee.ContainerTransaction) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

ContainerTransaction (org.apache.openejb.jee.ContainerTransaction)10 EjbJar (org.apache.openejb.jee.EjbJar)8 Method (org.apache.openejb.jee.Method)6 InterceptorBinding (org.apache.openejb.jee.InterceptorBinding)4 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)3 AssemblyDescriptor (org.apache.openejb.jee.AssemblyDescriptor)3 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)3 MethodPermission (org.apache.openejb.jee.MethodPermission)3 ArrayList (java.util.ArrayList)2 Assembler (org.apache.openejb.assembler.classic.Assembler)2 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)2 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)2 ApplicationException$JAXB.readApplicationException (org.apache.openejb.jee.ApplicationException$JAXB.readApplicationException)2 ApplicationException$JAXB.writeApplicationException (org.apache.openejb.jee.ApplicationException$JAXB.writeApplicationException)2 ContainerConcurrency$JAXB.readContainerConcurrency (org.apache.openejb.jee.ContainerConcurrency$JAXB.readContainerConcurrency)2 ContainerConcurrency$JAXB.writeContainerConcurrency (org.apache.openejb.jee.ContainerConcurrency$JAXB.writeContainerConcurrency)2 ContainerTransaction$JAXB.readContainerTransaction (org.apache.openejb.jee.ContainerTransaction$JAXB.readContainerTransaction)2 ContainerTransaction$JAXB.writeContainerTransaction (org.apache.openejb.jee.ContainerTransaction$JAXB.writeContainerTransaction)2 EntityBean (org.apache.openejb.jee.EntityBean)2 ExcludeList$JAXB.readExcludeList (org.apache.openejb.jee.ExcludeList$JAXB.readExcludeList)2