2 Replies Latest reply on Aug 13, 2013 3:33 PM by Euber Almeida

    PersistContext and Websphere Remote 8

    Euber Almeida Newbie

      In reference guide show the WAS V8.0 - Remote dont support @PersistContext:

       

      https://docs.jboss.org/author/display/ARQ/WAS+V8.0+-+Remote#

       

       

      Is there another way or workarround to test class with @PersistContext?

       

       

       

      Thanks.

        • 1. Re: PersistContext and Websphere Remote 8
          Bartosz Majsak Master

          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
            Euber Almeida Newbie

            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));

             

            }

             

            }