If you are using Maven simply add the folling dependency entry:
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1</version>
<scope>test</scope>
</dependency>
I read about former issues and additional configurations when using Maven, but I did not run into any problems and just used the following code for my test:
import javax.ejb.embeddable.EJBContainer;
public class SomeEJBTest {
private EJBContainer ejbContainer;
private Context context;
@Before
public void setup() throws Exception{
ejbContainer = EJBContainer.createEJBContainer();
context = ejbContainer.getContext();
}
public class SomeEJBTest {
private EJBContainer ejbContainer;
private Context context;
@Before
public void setup() throws Exception{
ejbContainer = EJBContainer.createEJBContainer();
context = ejbContainer.getContext();
}
@After
public void teardown(){
ejbContainer.close();
}
@Test
public void getsInterceptedCorrectly() throws Exception {
SomeEjbLocal someEjb =
public void teardown(){
ejbContainer.close();
}
@Test
public void getsInterceptedCorrectly() throws Exception {
SomeEjbLocal someEjb =
(SomeEjbLocal) context.lookup(
"java:global/classes/SomeEJB!at.rt.ejbs.SomeEjbLocal");
assertEquals(MyInterceptor.NUM, someEjb.getNum());
}
assertEquals(MyInterceptor.NUM, someEjb.getNum());
}
}
The test ran through using either the IDE (Eclipse) and Maven and the container started within ~6 seconds. No remote interface was needed and it worked with implementation view and local interface. By specification the container supports just the Web Profile, which should be sufficient in most cases. However, here you can also download the full profile for the Glassfish v3 container. More Glassfish specific information can be found here.
No comments:
Post a Comment