Skip to content

Commit

Permalink
Testing ejb-ref in xml descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
ochaloup committed Nov 24, 2011
1 parent 78e7f23 commit f7ab8a1
Show file tree
Hide file tree
Showing 7 changed files with 284 additions and 0 deletions.
@@ -0,0 +1,74 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2006, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.ejb.interceptor.complex.a;

import javax.naming.InitialContext;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
* Injection test.
*/
@RunWith(Arquillian.class)
public class InterceptorUnitTestCaseB
{
private static final Logger log = Logger.getLogger(InterceptorUnitTestCaseB.class);

@ArquillianResource
InitialContext ctx;

@Deployment
public static Archive<?> deployment() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "interceptor-complexb-test.jar")
.addPackage(InterceptorUnitTestCaseB.class.getPackage())
.addAsManifestResource(InterceptorUnitTestCaseB.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml");
log.info(jar.toString(true));
return jar;
}
static boolean deployed = false;
static int test = 0;

@Test
public void testInjection() throws Exception
{
MySession2RemoteB test = (MySession2RemoteB) ctx.lookup("java:module/MySession2BeanB");
boolean a = test.doit();
Assert.assertEquals(false, a);
}

@Test
public void testInjection2() throws Exception
{
MyTestRemoteB test = (MyTestRemoteB) ctx.lookup("java:module/MyTestB");
boolean a = test.doit();
Assert.assertEquals(true, a);
}
}
@@ -0,0 +1,46 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2006, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.ejb.interceptor.complex.a;

import javax.ejb.Stateless;

import org.jboss.logging.Logger;

/**
* @author <a href="mailto:bill@jboss.org">Bill Burke</a>
*/
@Stateless
public class MySession2BeanB implements MySession2RemoteB
{
private static final Logger log = Logger.getLogger(MySession2BeanB.class);

public boolean doit()
{
log.info("Calling MySession2BeanB doit...");
return true;
}

public boolean doitSession() {
log.info("Calling MySession2BeanB doitSession...");
return true;
}
}
@@ -0,0 +1,35 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2006, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.ejb.interceptor.complex.a;

import javax.ejb.Remote;

/**
* @author <a href="mailto:bill@jboss.org">Bill Burke</a>
*/
@Remote
public interface MySession2RemoteB
{
boolean doit();

boolean doitSession();
}
@@ -0,0 +1,19 @@
package org.jboss.as.test.integration.ejb.interceptor.complex.a;

import javax.ejb.Stateless;

import org.jboss.logging.Logger;

@Stateless
public class MyTestB implements MyTestRemoteB {
private static final Logger log = Logger.getLogger(MyTestB.class);

MySession2RemoteB session23;

public boolean doit() {
log.info("Calling MyTest...");
session23.doitSession();
log.info("Calling MyTest - after doit");
return true;
}
}
@@ -0,0 +1,8 @@
package org.jboss.as.test.integration.ejb.interceptor.complex.a;

import javax.ejb.Remote;

@Remote
public interface MyTestRemoteB {
boolean doit();
}
@@ -0,0 +1,45 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2006, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.ejb.interceptor.complex.a;

import javax.interceptor.InvocationContext;

import org.jboss.logging.Logger;

/**
* @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
*/
public class XMLInterceptorB
{
private static final Logger log = Logger.getLogger(XMLInterceptorB.class);

MySession2RemoteB session2;

public Object intercept(InvocationContext ctx) throws Exception
{
log.info("Calling XMLInterceptorB...");
session2.doit();
log.info("Calling XMLInterceptorB - after doit");
return false;
}

}
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
version="3.0">
<display-name>InterceptorsTest</display-name>

<enterprise-beans>
<session>
<ejb-name>MyTestB</ejb-name>
<business-remote>org.jboss.as.test.integration.ejb.interceptor.complex.a.MyTestRemoteB</business-remote>
<ejb-class>org.jboss.as.test.integration.ejb.interceptor.complex.a.MyTestB</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<ejb-ref-name>ejb/Session23</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<remote>org.jboss.as.test.integration.ejb.interceptor.complex.a.MySession2RemoteB</remote>
<ejb-link>MySession2BeanB</ejb-link>
<injection-target>
<injection-target-class>org.jboss.as.test.integration.ejb.interceptor.complex.a.MyTestB</injection-target-class>
<injection-target-name>session23</injection-target-name>
</injection-target>
</ejb-ref>
</session>
</enterprise-beans>

<interceptors>
<interceptor>
<interceptor-class>org.jboss.as.test.integration.ejb.interceptor.complex.a.XMLInterceptorB</interceptor-class>
<around-invoke>
<method-name>intercept</method-name>
</around-invoke>
<ejb-ref>
<ejb-ref-name>ejb/Session2</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<remote>org.jboss.as.test.integration.ejb.interceptor.complex.a.MySession2RemoteB</remote>
<ejb-link>MySession2BeanB</ejb-link>
<injection-target>
<injection-target-class>org.jboss.as.test.integration.ejb.interceptor.complex.a.XMLInterceptorB</injection-target-class>
<injection-target-name>session2</injection-target-name>
</injection-target>
</ejb-ref>
</interceptor>
</interceptors>
<assembly-descriptor>
<interceptor-binding>
<ejb-name>MySession2BeanB</ejb-name>
<interceptor-class>org.jboss.as.test.integration.ejb.interceptor.complex.a.XMLInterceptorB</interceptor-class>
<method>
<method-name>doit</method-name>
</method>
</interceptor-binding>
</assembly-descriptor>


</ejb-jar>

0 comments on commit f7ab8a1

Please sign in to comment.