[jboss-svn-commits] JBoss Common SVN: r4571 - arquillian/trunk/containers/jetty-embedded-6_1/src/test/java/org/jboss/arquillian/container/jetty/embedded6_1.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jun 28 00:56:13 EDT 2010


Author: dan.j.allen
Date: 2010-06-28 00:56:13 -0400 (Mon, 28 Jun 2010)
New Revision: 4571

Added:
   arquillian/trunk/containers/jetty-embedded-6_1/src/test/java/org/jboss/arquillian/container/jetty/embedded6_1/MavenArtifactResolver.java
Modified:
   arquillian/trunk/containers/jetty-embedded-6_1/src/test/java/org/jboss/arquillian/container/jetty/embedded6_1/JettyEmbeddedInContainerTestCase.java
Log:
simplify test using MavenArtifactResolver


Modified: arquillian/trunk/containers/jetty-embedded-6_1/src/test/java/org/jboss/arquillian/container/jetty/embedded6_1/JettyEmbeddedInContainerTestCase.java
===================================================================
--- arquillian/trunk/containers/jetty-embedded-6_1/src/test/java/org/jboss/arquillian/container/jetty/embedded6_1/JettyEmbeddedInContainerTestCase.java	2010-06-28 04:49:19 UTC (rev 4570)
+++ arquillian/trunk/containers/jetty-embedded-6_1/src/test/java/org/jboss/arquillian/container/jetty/embedded6_1/JettyEmbeddedInContainerTestCase.java	2010-06-28 04:56:13 UTC (rev 4571)
@@ -53,7 +53,7 @@
          .addClass(TestBean.class)
          // adding the configuration class silences the logged exception when building the configuration on the server-side, but shouldn't be necessary
          //.addClass(JettyEmbeddedConfiguration.class)
-         .addLibrary(new File(System.getProperty("user.home") + "/.m2/repository/org/jboss/weld/servlet/weld-servlet/1.0.1-Final/weld-servlet-1.0.1-Final.jar"))
+         .addLibrary(MavenArtifactResolver.resolve("org.jboss.weld.servlet:weld-servlet:1.0.1-Final"))
          .addWebResource("jetty-env.xml")
          .addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml")
          .setWebXML("in-container-web.xml");

Added: arquillian/trunk/containers/jetty-embedded-6_1/src/test/java/org/jboss/arquillian/container/jetty/embedded6_1/MavenArtifactResolver.java
===================================================================
--- arquillian/trunk/containers/jetty-embedded-6_1/src/test/java/org/jboss/arquillian/container/jetty/embedded6_1/MavenArtifactResolver.java	                        (rev 0)
+++ arquillian/trunk/containers/jetty-embedded-6_1/src/test/java/org/jboss/arquillian/container/jetty/embedded6_1/MavenArtifactResolver.java	2010-06-28 04:56:13 UTC (rev 4571)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.container.jetty.embedded6_1;
+
+import java.io.File;
+
+/**
+ * A crude 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]);
+   }
+}



More information about the jboss-svn-commits mailing list