-
1. Re: JUnitSeamTest Initialization Components from xml
manarh Oct 9, 2014 4:08 AM (in response to vata2999)Do you mean you added this class jboss-seam/JUnitSeamTest.java at Seam_2_3 · seam2/jboss-seam · GitHub or different source?
Basically Arquillian usage in Seam 2.3 uses components.xml from src/test/resources/WEB-INF directory which is added to test archive prepared by Shrinkwrap API calls.
Look at jboss-seam/seam-integration-tests/src/test/resources/WEB-INF at Seam_2_3 · seam2/jboss-seam · GitHub and jboss-seam/Deployments.java at Seam_2_3 · seam2/jboss-seam · GitHub
If you use Maven that is what you should do.
-
2. Re: Re: JUnitSeamTest Initialization Components from xml
vata2999 Oct 10, 2014 4:10 AM (in response to manarh)I exactly added the class you mentioned from Seam 2.3 to Seam 2.2 and yes I'm using Maven.
unlike the sample you pointed I'm trying to deploy an EAR file as following in Arquillian
@Deployment(testable = false) public static Archive<?> createDeployment() { //TODO : get from System.getProperties(testDeployment) String testDeployment = "/home/omidbiz/blog-ear/target/blog.ear";//can not deploy exploded archive String deploymentName = testDeployment.substring(testDeployment.lastIndexOf("/") + 1); Class<? extends Archive<?>> deploymentClass = EnterpriseArchive.class; return ShrinkWrap.create(ZipImporter.class, deploymentName).importFrom(new File(testDeployment)).as(deploymentClass); //there is no addAsWebInfResource for EnterpriseArchive }
which I took from https://github.com/seam2/jboss-seam/blob/Seam_2_3/functional-tests/src/main/java/org/jboss/seam/example/common/test/DeploymentResolver.java
can I deploy a Seam EAR file into Arquillian ? (the EAR file successfully runs in JBoss AS 7)
-
3. Re: Re: JUnitSeamTest Initialization Components from xml
manarh Oct 10, 2014 5:01 AM (in response to vata2999)1 of 1 people found this helpfulOmid,
you can use EAR in Arquillian.
Try to debug the content of your test EAR, like is described here http://arquillian.org/guides/getting_started_rinse_and_repeat/#export_the_deployment Seam 2.3 tests are using this option to have prepared a test archive in case of a deployment failure and that is not clear why it happens.
Btw you are not trying to import exploded directory by
ShrinkWrap.create(ZipImporter.class, deploymentName).importFrom(File) ? that is designed for already existing archive not directory I think.
-
4. Re: Re: Re: JUnitSeamTest Initialization Components from xml
vata2999 Oct 10, 2014 1:37 PM (in response to manarh)I managed to solve the previous error now I get the following exception
java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI : java:/myseamEntityManagerFactory at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:261) Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344) at javax.naming.InitialContext.lookup(InitialContext.java:411) at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:257) ... 103 more
I don't understand the Arquillian if it's using the jboss that I define in arquillian.xml then everything should be ok
arquillian.xml
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.org/schema/arquillian" xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> <defaultProtocol type="Servlet 3.0" /> <engine> <property name="deploymentExportPath">target</property> </engine> <container qualifier="jboss7" default="true"> <configuration> <property name="jbossHome">/home/omidbiz/jboss-eap-6.2/</property> <property name="javaVmArguments">-Xms512m -Xmx512m -XX:MaxPermSize=512m -Djava.net.preferIPv4Stack=true -XX:-UseSplitVerifier</property> </configuration> </container> </arquillian>
TestCase.java
@Test public void simpleEntryTest() throws Exception { String id = "simpleBlogEntry"; String title = "Simple blog entry"; String excerpt = "This is an excerpt"; String body = "This is a simple blog entry posted for testing purposes."; System.out.println(id); new ComponentTest() { @Override protected void testComponents() throws Exception { DBUtil du = (DBUtil) getValue("#{dbUtil}"); System.out.println(du.getEntityManager()); // this line throw the exception } }.run(); }
I also realize that seam-integration-tests module is using Arquillian differently with packaging a war file after I changed my test module I get this exception
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS014395: Could not load component class org.jboss.seam.mock.MockSeamListener"}}
-
5. Re: Re: Re: JUnitSeamTest Initialization Components from xml
manarh Oct 13, 2014 3:15 AM (in response to vata2999)You very probably use Seam 2.2 or 2.3.0.ALPHA which doesn't have the org.jboss.seam.mock.MockSeamListener class - it was added in 2.3.0.Beta2 - implementation of MockSeamListener · 3b57cc1 · seam2/jboss-seam · GitHub
I also realize that seam-integration-tests module is using Arquillian differently with packaging a war file after I changed my test module I get this exception
- Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS014395: Could not load component class org.jboss.seam.mock.MockSeamListener"}}
We use everywhere it is possible the easiest packaging - WAR - to not depend on building of whole EAR packagement. So almost all EJB tests are done in WAR only packagement.
-
6. Re: Re: Re: JUnitSeamTest Initialization Components from xml
manarh Oct 13, 2014 3:14 AM (in response to vata2999)Not sure with the error, but I would think that something is wrong with your configuration. Just try to deploy the test deployment as standard deployment manually into server and you will see if that persists. How do you launch your tests?
- java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI : java:/myseamEntityManagerFactory
- at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:261)
- Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
- at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
- at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
- at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:344)
- at javax.naming.InitialContext.lookup(InitialContext.java:411)
- at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:257)
- ... 103 more