[weld-commits] Weld SVN: r6694 - in archetypes/javaee6-webapp/trunk/src/test: resources and 1 other directory.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Sat Jul 17 12:56:13 EDT 2010


Author: dan.j.allen
Date: 2010-07-17 12:56:12 -0400 (Sat, 17 Jul 2010)
New Revision: 6694

Added:
   archetypes/javaee6-webapp/trunk/src/test/java/com/mycompany/MavenArtifactResolver.java
Modified:
   archetypes/javaee6-webapp/trunk/src/test/java/com/mycompany/MemberRegistrationTest.java
   archetypes/javaee6-webapp/trunk/src/test/resources/arquillian.xml
Log:
fix Arquillian test in JBoss AS


Added: archetypes/javaee6-webapp/trunk/src/test/java/com/mycompany/MavenArtifactResolver.java
===================================================================
--- archetypes/javaee6-webapp/trunk/src/test/java/com/mycompany/MavenArtifactResolver.java	                        (rev 0)
+++ archetypes/javaee6-webapp/trunk/src/test/java/com/mycompany/MavenArtifactResolver.java	2010-07-17 16:56:12 UTC (rev 6694)
@@ -0,0 +1,47 @@
+package com.mycompany;
+
+import java.io.File;
+
+/**
+ * A temporary resolver that converts a Maven artifact reference
+ * into a {@link java.io.File} object.
+ * 
+ * <p>This approach is an interim solution for Maven projects
+ * until the open feature request to add formally add artifacts
+ * to a test (ARQ-66) is implementated.</p>
+ *
+ * <p>The testCompile goal will resolve any test dependencies and
+ * put them in your local Maven repository. By the time the test
+ * executes, you can be sure that the JAR files you need will be
+ * in your local repository.</p>
+ *
+ * <p>Example usage:</p>
+ * 
+ * <pre>
+ * WebArchive war = ShrinkWrap.create("test.war", WebArchive.class)
+ *     .addLibrary(MavenArtifactResolver.resolve("commons-lang:commons-lang:2.5"));
+ * </pre>
+ *
+ * @author Dan Allen
+ */
+public class MavenArtifactResolver
+{
+   private static final String LOCAL_MAVEN_REPO =
+         System.getProperty("user.home") + File.separatorChar +
+         ".m2" + File.separatorChar + "repository";
+
+   public static File resolve(String groupId, String artifactId, String version)
+   {
+      return new File(LOCAL_MAVEN_REPO + File.separatorChar +
+            groupId.replace(".", File.separator) + File.separatorChar +
+            artifactId + File.separatorChar +
+            version + File.separatorChar +
+            artifactId + "-" + version + ".jar");
+   }
+
+   public static File resolve(String qualifiedArtifactId)
+   {
+      String[] segments = qualifiedArtifactId.split(":");
+      return resolve(segments[0], segments[1], segments[2]);
+   }
+}

Modified: archetypes/javaee6-webapp/trunk/src/test/java/com/mycompany/MemberRegistrationTest.java
===================================================================
--- archetypes/javaee6-webapp/trunk/src/test/java/com/mycompany/MemberRegistrationTest.java	2010-07-17 16:52:44 UTC (rev 6693)
+++ archetypes/javaee6-webapp/trunk/src/test/java/com/mycompany/MemberRegistrationTest.java	2010-07-17 16:56:12 UTC (rev 6694)
@@ -22,7 +22,10 @@
    public static Archive<?> createTestArchive() {
       return ShrinkWrap.create(WebArchive.class, "test.war")
          .addClasses(Member.class, MemberRegistration.class, MemberRepository.class, MemberRepositoryProducer.class)
-         .addPackage(Logger.class.getPackage())
+         .addLibraries(
+               MavenArtifactResolver.resolve("org.slf4j:slf4j-api:1.5.10"),
+               MavenArtifactResolver.resolve("org.slf4j:slf4j-simple:1.5.10")
+         )
          .addWebResource("test-persistence.xml", "classes/META-INF/persistence.xml")
          .addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
    }

Modified: archetypes/javaee6-webapp/trunk/src/test/resources/arquillian.xml
===================================================================
--- archetypes/javaee6-webapp/trunk/src/test/resources/arquillian.xml	2010-07-17 16:52:44 UTC (rev 6693)
+++ archetypes/javaee6-webapp/trunk/src/test/resources/arquillian.xml	2010-07-17 16:56:12 UTC (rev 6694)
@@ -1,18 +1,25 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <arquillian xmlns="http://jboss.com/arquillian"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xmlns:jbossas-remote="urn:arq:org.jboss.arquillian.container.jbossas.remote_6"
    xmlns:glassfish-embedded="urn:arq:org.jboss.arquillian.container.glassfish.embedded_3">
 
    <!-- Uncomment to have test archives exported to the file system for inspection -->
    <!--
    <engine>
-      <deploymentExportPath>/tmp/</deploymentExportPath>
+      <deploymentExportPath>target/</deploymentExportPath>
    </engine>
    -->
 
+   <!-- Required configuration for an embedded GlassFish instance -->
    <glassfish-embedded:container>
       <glassfish-embedded:bindHttpPort>7070</glassfish-embedded:bindHttpPort>
       <glassfish-embedded:sunResourcesXml>src/test/resources-glassfish-embedded/sun-resources.xml</glassfish-embedded:sunResourcesXml>
-   </glassfish-embedded:container>  
+   </glassfish-embedded:container>
 
+   <!-- Example configuration for a remote JBoss AS instance -->
+   <jbossas-remote:container>
+      <jbossas-remote:remoteServerHttpPort>8080</jbossas-remote:remoteServerHttpPort>
+   </jbossas-remote:container>
+
 </arquillian>



More information about the weld-commits mailing list