[jboss-svn-commits] JBoss Common SVN: r3594 - in shrinkwrap/trunk: impl-base/src/main/java/org/jboss/shrinkwrap/impl/base and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Oct 13 23:58:14 EDT 2009


Author: ALRubinger
Date: 2009-10-13 23:58:14 -0400 (Tue, 13 Oct 2009)
New Revision: 3594

Modified:
   shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/EnterpriseContainer.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ContainerBase.java
   shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/EnterpriseContainerBase.java
   shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicContainerTestBase.java
   shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicEnterpriseContainerTestBase.java
   shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicWebContainerTestBase.java
Log:
[SHRINKWRAP-51] Fix erring tests by specifying targetPath for URLs and correcting some bugs/missing features

Modified: shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/EnterpriseContainer.java
===================================================================
--- shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/EnterpriseContainer.java	2009-10-13 07:00:52 UTC (rev 3593)
+++ shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/EnterpriseContainer.java	2009-10-14 03:58:14 UTC (rev 3594)
@@ -237,4 +237,64 @@
     * @throws IllegalArgumentException if resource is null
     */
    T addModule(URL resource) throws IllegalArgumentException;
+
+   /**
+    * Adds a resource to this {@link Archive}s module context.
+    * <br/><br/>
+    * The resource name is used as path.
+    * 
+    * @param targetPath The target path within the archive in which to add the resource
+    * @param resourceName Name of the {@link ClassLoader} resource to add
+    * @return This virtual archive
+    * @throws IllegalArgumentException if resourceName is null
+    */
+   T addModule(String targetPath, String resourceName) throws IllegalArgumentException;
+
+   /**
+    * 
+    * @param targetPath The target path within the archive in which to add the resource
+    * @param resource {@link File} resource to add
+    * @return This virtual archive
+    * @throws IllegalArgumentException if resource is null
+    */
+   T addModule(String targetPath, File resource) throws IllegalArgumentException;
+
+   /**
+    * 
+    * @param targetPath The target path within the archive in which to add the resource
+    * @param resource {@link URL} resource to add
+    * @return This virtual archive
+    * @throws IllegalArgumentException if resource is null
+    */
+   T addModule(String targetPath, URL resource) throws IllegalArgumentException;
+
+   /**
+    * Adds a resource to this {@link Archive}s module context.
+    * <br/><br/>
+    * The resource name is used as path.
+    * 
+    * @param targetPath The target path within the archive in which to add the resource
+    * @param resourceName Name of the {@link ClassLoader} resource to add
+    * @return This virtual archive
+    * @throws IllegalArgumentException if resourceName is null
+    */
+   T addModule(Path targetPath, String resourceName) throws IllegalArgumentException;
+
+   /**
+    * 
+    * @param targetPath The target path within the archive in which to add the resource
+    * @param resource {@link File} resource to add
+    * @return This virtual archive
+    * @throws IllegalArgumentException if resource is null
+    */
+   T addModule(Path targetPath, File resource) throws IllegalArgumentException;
+
+   /**
+    * 
+    * @param targetPath The target path within the archive in which to add the resource
+    * @param resource {@link URL} resource to add
+    * @return This virtual archive
+    * @throws IllegalArgumentException if resource is null
+    */
+   T addModule(Path targetPath, URL resource) throws IllegalArgumentException;
 }

Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ContainerBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ContainerBase.java	2009-10-13 07:00:52 UTC (rev 3593)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ContainerBase.java	2009-10-14 03:58:14 UTC (rev 3594)
@@ -458,7 +458,7 @@
       Validate.notNull(target, "Target should be specified");
       Validate.notNull(resource, "Resource should be specified");
       
-      return addResource(AssetUtil.getFullPathForURLResource(resource), new UrlAsset(resource));
+      return addResource(target, new UrlAsset(resource));
    }
    
    /* (non-Javadoc)

Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/EnterpriseContainerBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/EnterpriseContainerBase.java	2009-10-13 07:00:52 UTC (rev 3593)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/EnterpriseContainerBase.java	2009-10-14 03:58:14 UTC (rev 3594)
@@ -271,10 +271,9 @@
    public T addModule(String resourceName)
    {
       Validate.notNull(resourceName, "ResourceName must be specified");
-      
-      Asset asset = new ClassLoaderAsset(resourceName);
-      Path location = new BasicPath(getModulePath(), AssetUtil.getNameForClassloaderResource(resourceName));
-      return add(location, asset);
+      ;
+      Path location = new BasicPath(AssetUtil.getNameForClassloaderResource(resourceName));
+      return addModule(location, resourceName);
    }
    
    /* (non-Javadoc)
@@ -285,9 +284,8 @@
    {
       Validate.notNull(resource, "Resource must be specified");
       
-      Asset asset = new FileAsset(resource);
-      Path location = new BasicPath(getModulePath(), resource.getName());
-      return add(location, asset);
+      Path location = new BasicPath(resource.getName());
+      return addModule(location, resource);
    }
    
    /* (non-Javadoc)
@@ -298,8 +296,76 @@
    {
       Validate.notNull(resource, "Resource must be specified");
       
+      final Path location = AssetUtil.getFullPathForURLResource(resource);
+      return addModule(location, resource);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(org.jboss.shrinkwrap.api.Path, java.io.File)
+    */
+   @Override
+   public T addModule(final Path targetPath, final File resource) throws IllegalArgumentException
+   {
+      Validate.notNull(targetPath, "Target Path must be specified");
+      Validate.notNull(resource, "Resource must be specified");
+      
+      final Asset asset = new FileAsset(resource);
+      final Path location = new BasicPath(getModulePath(), targetPath);
+      return add(location, asset);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(org.jboss.shrinkwrap.api.Path, java.lang.String)
+    */
+   @Override
+   public T addModule(final Path targetPath, final String resourceName) throws IllegalArgumentException
+   {
+      Validate.notNull(targetPath, "Target Path must be specified");
+      Validate.notNull(resourceName, "ResourceName must be specified");
+      
+      final Asset asset = new ClassLoaderAsset(resourceName);
+      final Path location = new BasicPath(getModulePath(), targetPath);
+      return add(location, asset);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(org.jboss.shrinkwrap.api.Path, java.net.URL)
+    */
+   @Override
+   public T addModule(final Path targetPath, final URL resource) throws IllegalArgumentException
+   {
+      Validate.notNull(targetPath, "Target Path must be specified");
+      Validate.notNull(resource, "Resource must be specified");
+      
       Asset asset = new UrlAsset(resource);
-      Path location = new BasicPath(getModulePath(), AssetUtil.getFullPathForURLResource(resource));
+      Path location = new BasicPath(getModulePath(),targetPath);
       return add(location, asset);
    }
+
+   /* (non-Javadoc)
+    * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(java.lang.String, java.io.File)
+    */
+   @Override
+   public T addModule(final String targetPath, final File resource) throws IllegalArgumentException
+   {
+      return addModule(new BasicPath(targetPath), resource);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(java.lang.String, java.lang.String)
+    */
+   @Override
+   public T addModule(final String targetPath, final String resourceName) throws IllegalArgumentException
+   {
+      return addModule(new BasicPath(targetPath), resourceName);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(java.lang.String, java.net.URL)
+    */
+   @Override
+   public T addModule(final String targetPath, final URL resource) throws IllegalArgumentException
+   {
+      return addModule(new BasicPath(targetPath), resource);
+   }
 }

Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicContainerTestBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicContainerTestBase.java	2009-10-13 07:00:52 UTC (rev 3593)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicContainerTestBase.java	2009-10-14 03:58:14 UTC (rev 3594)
@@ -140,12 +140,10 @@
    @Test
    @ArchiveType(ManifestContainer.class)
    public void testAddManifestURL() throws Exception {
-      getManifestContainer().addManifestResource(getURLForClassResource(NAME_TEST_PROPERTIES));
-      
-      Path testPath = new BasicPath(getManifestPath(), "Test.properties");
-      Assert.assertTrue(
-            "Archive should contain " + testPath,
-            getArchive().contains(testPath));
+      Path targetPath = new BasicPath("Test.properties");
+      getManifestContainer().addManifestResource(targetPath, getURLForClassResource(NAME_TEST_PROPERTIES));
+      Path testPath = new BasicPath(getManifestPath(), targetPath);
+      Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath));
    }
 
    @Test
@@ -265,12 +263,10 @@
    @Test
    @ArchiveType(ResourceContainer.class)
    public void testAddResourceURL() throws Exception {
-      getResourceContainer().addResource(getURLForClassResource(NAME_TEST_PROPERTIES));
-      
-      Path testPath = new BasicPath(getResourcePath(), "Test.properties");
-      Assert.assertTrue(
-            "Archive should contain " + testPath,
-            getArchive().contains(testPath));
+      Path targetPath = new BasicPath("Test.properties");
+      getResourceContainer().addResource(targetPath, getURLForClassResource(NAME_TEST_PROPERTIES));
+      Path testPath = new BasicPath(getResourcePath(), targetPath);
+      Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath));
    }
 
    @Test
@@ -298,6 +294,7 @@
    @Test
    @ArchiveType(ResourceContainer.class)
    public void testAddResourceStringTargetURL() throws Exception {
+      
       getResourceContainer().addResource("Test.txt", getURLForClassResource(NAME_TEST_PROPERTIES));
       
       Path testPath = new BasicPath(getResourcePath(), "Test.txt");
@@ -470,12 +467,10 @@
    @Test
    @ArchiveType(LibraryContainer.class)
    public void testAddLibraryURL() throws Exception {
-      getLibraryContainer().addLibrary(getURLForClassResource(NAME_TEST_PROPERTIES));
-      
-      Path testPath = new BasicPath(getLibraryPath(), "Test.properties");
-      Assert.assertTrue(
-            "Archive should contain " + testPath,
-            getArchive().contains(testPath));
+      final Path targetPath = new BasicPath("Test.properties");
+      getLibraryContainer().addLibrary(targetPath, getURLForClassResource(NAME_TEST_PROPERTIES));
+      Path testPath = new BasicPath(getLibraryPath(), targetPath);
+      Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath));
    }
    
    @Test

Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicEnterpriseContainerTestBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicEnterpriseContainerTestBase.java	2009-10-13 07:00:52 UTC (rev 3593)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicEnterpriseContainerTestBase.java	2009-10-14 03:58:14 UTC (rev 3594)
@@ -111,12 +111,10 @@
    @Test
    @ArchiveType(EnterpriseContainer.class)
    public void testAddApplicationURL() throws Exception {
-      getEnterpriseContainer().addApplicationResource(getURLForClassResource(NAME_TEST_PROPERTIES));
-      
-      Path expectedPath = new BasicPath(getApplicationPath(), "Test.properties");
-      Assert.assertTrue(
-            "Archive should contain " + expectedPath,
-            getArchive().contains(expectedPath));
+      final Path targetPath = new BasicPath("Test.properties");;
+      getEnterpriseContainer().addApplicationResource(targetPath, getURLForClassResource(NAME_TEST_PROPERTIES));
+      Path expectedPath = new BasicPath(getApplicationPath(), targetPath);
+      Assert.assertTrue("Archive should contain " + expectedPath, getArchive().contains(expectedPath));
    }
 
    @Test
@@ -232,12 +230,10 @@
    @Test
    @ArchiveType(EnterpriseContainer.class)
    public void testAddModuleURL() throws Exception {
-      getEnterpriseContainer().addModule(getURLForClassResource(NAME_TEST_PROPERTIES));
-      
-      Path expectedPath = new BasicPath(getModulePath(), "Test.properties");
-      Assert.assertTrue(
-            "Archive should contain " + expectedPath,
-            getArchive().contains(expectedPath));
+      final Path targetPath = new BasicPath("Test.properties");
+      getEnterpriseContainer().addModule(targetPath, getURLForClassResource(NAME_TEST_PROPERTIES));
+      Path expectedPath = new BasicPath(getModulePath(), targetPath);
+      Assert.assertTrue("Archive should contain " + expectedPath, getArchive().contains(expectedPath));
    }
    
    @Test

Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicWebContainerTestBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicWebContainerTestBase.java	2009-10-13 07:00:52 UTC (rev 3593)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicWebContainerTestBase.java	2009-10-14 03:58:14 UTC (rev 3594)
@@ -109,12 +109,10 @@
    @Test
    @ArchiveType(WebContainer.class)
    public void testAddWebResourceURL() throws Exception {
-      getWebContainer().addWebResource(getURLForClassResource(NAME_TEST_PROPERTIES));
-      
-      Path testPath = new BasicPath(getWebPath(), "Test.properties");
-      Assert.assertTrue(
-            "Archive should contain " + testPath,
-            getArchive().contains(testPath));
+      Path targetPath = new BasicPath("Test.properties");
+      getWebContainer().addWebResource(targetPath, getURLForClassResource(NAME_TEST_PROPERTIES));
+      Path testPath = new BasicPath(getWebPath(), targetPath);
+      Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath));
    }
 
    @Test



More information about the jboss-svn-commits mailing list