-
1. Re: PersistContext and Websphere Remote 8
bmajsak Aug 8, 2013 4:45 PM (in response to malk182)Hi Euber,
it only means that you can't directly inject @PersistenceContext into Arquillian test. If you inject EJB which contains it that should work without any issues. I'm currenlty involved in the projects when run Arq tests agains Websfear 8.0 and 8.5 without major issues (they are just slow... as all on WAS).
Cheers,
Bartosz
-
2. Re: PersistContext and Websphere Remote 8
malk182 Aug 13, 2013 3:33 PM (in response to bmajsak)EDIT: WORKS, MISSING THE CREATION OF DATASOURCE IN WAS (LOL). THANKS.
I create a eclipse project using the Websphere sample called Plants. The project run OK, but with the arquillian test the persist context are null.
The error occurs in this line -> Assert.assertNotNull("Entity Manager is null", customerMgr.em);
Arquillian Test Code
package com.ibm.websphere.samples.pbw.ejb;
import javax.ejb.EJB;
import junit.framework.Assert;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.ibm.websphere.samples.pbw.jpa.Customer;
import com.ibm.websphere.samples.pbw.utils.ListProperties;
@RunWith(Arquillian.class)
public class WebsphereIntegrationTestCase {
@Deployment
public static EnterpriseArchive createDeployment() {
WebArchive webArc = ShrinkWrap
.create(WebArchive.class, "PlantsTest.war")
.addClass(CustomerMgr.class).addClass(Customer.class)
.addClass(WebsphereIntegrationClientTestCase.class)
.addAsResource("META-INF/persistence.xml")
.addAsResource("META-INF/application.xml");
JavaArchive jarLib = ShrinkWrap
.create(JavaArchive.class, "PlantsLib.jar")
.addPackage(ListProperties.class.getPackage());
return ShrinkWrap.create(EnterpriseArchive.class, "PlantsTest.ear")
.addAsLibrary(jarLib)
.addAsModule(webArc);
}
@EJB
private CustomerMgr customerMgr;
@Test
public void customerVerify() throws Exception {
Assert.assertNotNull("CustomerMgr is null", customerMgr);
Assert.assertNotNull("Entity Manager is null", customerMgr.em);
String usuario = "plants@plantsbywebsphere.ibm.com";
String senha = "plants";
System.out.println(customerMgr.verifyUserAndPassword(usuario, senha));
}
}