[jboss-svn-commits] JBoss Common SVN: r3456 - in declarchive/trunk/impl-base/src: main/java/org/jboss/declarchive/impl/base/asset and 3 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Aug 17 06:33:13 EDT 2009


Author: ALRubinger
Date: 2009-08-17 06:33:12 -0400 (Mon, 17 Aug 2009)
New Revision: 3456

Added:
   declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/Validate.java
   declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/
   declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/ByteArrayAsset.java
   declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/ClassAsset.java
   declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/ClassLoaderAsset.java
   declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/FileAsset.java
   declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/SecurityActions.java
   declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/UrlAsset.java
   declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/
   declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/ClassAssetTestCase.java
   declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/ClassLoaderAssetTestCase.java
   declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/FileAssetTestCase.java
   declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/UrlAssetTestCase.java
   declarchive/trunk/impl-base/src/test/resources/org/jboss/declarchive/impl/base/asset/
Removed:
   declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/resource/
   declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/ClassResourceTestCase.java
   declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/ClassloaderResourceTestCase.java
   declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/FileResourceTestCase.java
   declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/URLResourceTestCase.java
   declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/
   declarchive/trunk/impl-base/src/test/resources/org/jboss/declarchive/impl/base/resource/
Modified:
   declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/TestUtils.java
Log:
[TMPARCH-11] Refactor a bit the Asset types and tests

Added: declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/Validate.java
===================================================================
--- declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/Validate.java	                        (rev 0)
+++ declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/Validate.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.declarchive.impl.base;
+
+/**
+ * Validate
+ * 
+ * Validation utility
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class Validate
+{
+   private Validate()
+   {
+   }
+
+   /**
+    * Checks that object is not null, throws exception if it is.
+    * 
+    * @param obj The object to check
+    * @param message The exception message
+    * @throws IllegalArgumentException Thrown if obj is null 
+    */
+   public static void notNull(final Object obj, final String message) throws IllegalArgumentException
+   {
+      if (obj == null)
+      {
+         throw new IllegalArgumentException(message);
+      }
+   }
+
+   /**
+    * Checks that the specified String is not null or empty, 
+    * throws exception if it is.
+    * 
+    * @param string The object to check
+    * @param message The exception message
+    * @throws IllegalArgumentException Thrown if obj is null 
+    */
+   public static void notNullOrEmpty(final String string, final String message) throws IllegalArgumentException
+   {
+      if (string == null || string.length() == 0)
+      {
+         throw new IllegalArgumentException(message);
+      }
+   }
+}

Added: declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/ByteArrayAsset.java
===================================================================
--- declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/ByteArrayAsset.java	                        (rev 0)
+++ declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/ByteArrayAsset.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.declarchive.impl.base.asset;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.jboss.declarchive.api.Asset;
+import org.jboss.declarchive.impl.base.Validate;
+
+/**
+ * ByteArrayAsset
+ * 
+ * Implementation of a {@link Asset} backed by a byte array
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ByteArrayAsset implements Asset
+{
+
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(ByteArrayAsset.class.getName());
+
+   //-------------------------------------------------------------------------------------||
+   // Instance Members -------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Underlying content
+    */
+   private final byte[] content;
+
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Creates a new instance backed by the specified
+    * byte array
+    * 
+    * @param content
+    * @throws IllegalArgumentException If the contents were not specified
+    */
+   public ByteArrayAsset(final byte[] content) throws IllegalArgumentException
+   {
+      // Precondition check
+      Validate.notNull(content, "content must be specified");
+
+      // Set
+      this.content = content;
+      if (log.isLoggable(Level.FINER))
+      {
+         log.finer("Created " + this + " with backing byte array of size " + content.length + "b");
+      }
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Required Implementations -----------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * @see org.jboss.declarchive.api.Asset#getStream()
+    */
+   @Override
+   public InputStream getStream()
+   {
+      return new ByteArrayInputStream(this.content);
+   }
+}

Added: declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/ClassAsset.java
===================================================================
--- declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/ClassAsset.java	                        (rev 0)
+++ declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/ClassAsset.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.declarchive.impl.base.asset;
+
+import java.io.InputStream;
+
+import org.jboss.declarchive.api.Asset;
+import org.jboss.declarchive.impl.base.Validate;
+
+/**
+ * ClassAsset
+ * 
+ * Implementation of a {@link Asset} backed by a loaded {@link Class}
+ * 
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ *
+ */
+public class ClassAsset implements Asset
+{
+   /**
+    * Delimiter for paths while looking for resources 
+    */
+   private static final char DELIMITER_RESOURCE_PATH = '/';
+
+   /**
+    * Delimiter for paths in fully-qualified class names 
+    */
+   private static final char DELIMITER_CLASS_NAME_PATH = '.';
+
+   /**
+    * The filename extension appended to classes
+    */
+   private static final String EXTENSION_CLASS = ".class";
+
+   private Class<?> clazz;
+
+   /**
+    * Load any class as a resource.
+    * 
+    * @param clazz The class to load
+    * @throws IllegalArgumentException Class can not be null
+    */
+   public ClassAsset(final Class<?> clazz)
+   {
+      // Precondition check
+      Validate.notNull(clazz, "Class must be specified");
+      this.clazz = clazz;
+   }
+
+   /**
+    * Converts the Class name into a Resource URL and uses the 
+    * ClassloaderResource for loading the Class.
+    */
+   @Override
+   public InputStream getStream()
+   {
+      return new ClassLoaderAsset(getResourceNameOfClass(clazz), clazz.getClassLoader()).getStream();
+   }
+
+   /**
+    * Returns the name of the class such that it may be accessed via ClassLoader.getResource()
+    * 
+    * @param clazz The class
+    * @throws IllegalArgumentException If the class was not specified
+    */
+   private String getResourceNameOfClass(final Class<?> clazz) throws IllegalArgumentException
+   {
+      // Build the name
+      final String fqn = clazz.getName();
+      final String nameAsResourcePath = fqn.replace(DELIMITER_CLASS_NAME_PATH, DELIMITER_RESOURCE_PATH);
+      final String resourceName = nameAsResourcePath + EXTENSION_CLASS;
+
+      // Return 
+      return resourceName;
+   }
+}

Added: declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/ClassLoaderAsset.java
===================================================================
--- declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/ClassLoaderAsset.java	                        (rev 0)
+++ declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/ClassLoaderAsset.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.declarchive.impl.base.asset;
+
+import java.io.InputStream;
+
+import org.jboss.declarchive.api.Asset;
+import org.jboss.declarchive.impl.base.Validate;
+
+/**
+ * ClassloaderAsset
+ * 
+ * Implementation of a {@link Asset} backed by a 
+ * resource located in the Classloader.
+ * 
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ */
+public class ClassLoaderAsset implements Asset
+{
+   private String resourceName;
+
+   private ClassLoader classLoader;
+
+   /**
+    * Load a named resource using the current threads context classloader.
+    * 
+    * @param resourceName The name of the resource to load
+    * @throws IllegalArgumentException resourceName can not be null
+    * @throws IllegalArgumentException resourceName must be found in given classloader
+    */
+   public ClassLoaderAsset(String resourceName)
+   {
+      this(resourceName, SecurityActions.getThreadContextClassLoader());
+   }
+
+   /**
+    * Load a named resource using the given classloader.
+    * 
+    * @param resourceName The name of the resource to load
+    * @param classLoader The ClassLoader to use
+    * @throws IllegalArgumentException resourceName can not be null
+    * @throws IllegalArgumentException classloader can not be null
+    * @throws IllegalArgumentException resourceName must be found in given classloader
+    */
+   public ClassLoaderAsset(String resourceName, ClassLoader classLoader)
+   {
+      Validate.notNull(resourceName, "ResourceName must be specified");
+      Validate.notNull(classLoader, "ClassLoader must be specified");
+      Validate
+            .notNull(classLoader.getResource(resourceName), resourceName + " not found in classloader " + classLoader);
+
+      this.resourceName = resourceName;
+      this.classLoader = classLoader;
+   }
+
+   /**
+    * Opens up the given resource as a stream.
+    * 
+    */
+   @Override
+   public InputStream getStream()
+   {
+      return classLoader.getResourceAsStream(resourceName);
+   }
+
+}

Added: declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/FileAsset.java
===================================================================
--- declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/FileAsset.java	                        (rev 0)
+++ declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/FileAsset.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.declarchive.impl.base.asset;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+import org.jboss.declarchive.api.Asset;
+import org.jboss.declarchive.impl.base.Validate;
+
+/**
+ * FileAsset
+ * 
+ * Implementation of a {@link Asset} backed by a {@link File}
+ * 
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ */
+public class FileAsset implements Asset
+{
+   private File file;
+
+   /**
+    * Load the specified File. 
+    * 
+    * @param file The file to load
+    * @throws IllegalArgumentException File can not be null
+    * @throws IllegalArgumentException File must exist
+    */
+   public FileAsset(File file)
+   {
+      // Precondition check
+      Validate.notNull(file, "File must be specified");
+      if (!file.exists())
+      {
+         throw new IllegalArgumentException("File must exist: " + file.getAbsolutePath());
+      }
+      this.file = file;
+   }
+
+   /**
+    * Opens a new FileInputStream for the given File.
+    * 
+    * Can throw a Runtime exception if the file has been deleted inbetween 
+    * the FileResource was created and the stream is opened. 
+    * 
+    * @throws RuntimeException If the file is not found.
+    */
+   @Override
+   public InputStream getStream()
+   {
+      try
+      {
+         return new FileInputStream(file);
+      }
+      catch (FileNotFoundException e)
+      {
+         throw new RuntimeException("Could not open file " + file, e);
+      }
+   }
+}

Added: declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/SecurityActions.java
===================================================================
--- declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/SecurityActions.java	                        (rev 0)
+++ declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/SecurityActions.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.declarchive.impl.base.asset;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * SecurityActions
+ * 
+ * A set of privileged actions that are not to leak out
+ * of this package 
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+class SecurityActions
+{
+
+   //-------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------||
+
+   /**
+    * No external instantiation
+    */
+   private SecurityActions()
+   {
+
+   }
+
+   //-------------------------------------------------------------------------------||
+   // Utility Methods --------------------------------------------------------------||
+   //-------------------------------------------------------------------------------||
+
+   /**
+    * Obtains the Thread Context ClassLoader
+    */
+   static ClassLoader getThreadContextClassLoader()
+   {
+      return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+      {
+         public ClassLoader run()
+         {
+            return Thread.currentThread().getContextClassLoader();
+         }
+      });
+   }
+}

Added: declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/UrlAsset.java
===================================================================
--- declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/UrlAsset.java	                        (rev 0)
+++ declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/asset/UrlAsset.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.declarchive.impl.base.asset;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import org.jboss.declarchive.api.Asset;
+import org.jboss.declarchive.impl.base.Validate;
+
+/**
+ * UrlAsset
+ * 
+ * Implementation of a {@link Asset} backed by a {@link URL}.  
+ * The URL may be of any backing protocol supported by the runtime
+ * (ie. has a handler registered).
+ * 
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ *
+ */
+public class UrlAsset implements Asset
+{
+   private URL url;
+
+   /**
+    * Create a new resource with a <code>URL</code> source.
+    * 
+    * @param url A valid URL
+    * @throws IllegalArgumentException <Code>URL</code> can not be null
+    */
+   public UrlAsset(URL url)
+   {
+      // Precondition check
+      Validate.notNull(url, "URL must be specified");
+      this.url = url;
+   }
+
+   /**
+    * Open the <code>URL</code> stream.
+    * 
+    * @return A open stream with the content of the URL
+    */
+   @Override
+   public InputStream getStream()
+   {
+      try
+      {
+         return url.openStream();
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Could not open stream for url " + url.toExternalForm(), e);
+      }
+   }
+}

Copied: declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset (from rev 3455, declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/resource)

Added: declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/ClassAssetTestCase.java
===================================================================
--- declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/ClassAssetTestCase.java	                        (rev 0)
+++ declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/ClassAssetTestCase.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.declarchive.impl.base.asset;
+
+import java.io.InputStream;
+
+import org.jboss.declarchive.api.Asset;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test to ensure that we are able to use Classes as Resources.
+ *
+ * https://jira.jboss.org/jira/browse/TMPARCH-5
+ * 
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ *
+ */
+public class ClassAssetTestCase
+{
+
+   @Test
+   public void shouldBeAbleToReadThisClass() throws Exception
+   {
+      Asset asset = new ClassAsset(ClassAssetTestCase.class);
+      InputStream io = asset.getStream();
+
+      Assert.assertNotNull(io);
+   }
+
+   @Test
+   public void shouldThrowExceptionOnNullClass() throws Exception
+   {
+      try
+      {
+         new ClassAsset(null);
+         Assert.fail("Should have thrown IllegalArgumentException");
+      }
+      catch (Exception e)
+      {
+         Assert.assertEquals("A null clazz argument should result in a IllegalArgumentException",
+               IllegalArgumentException.class, e.getClass());
+      }
+   }
+}

Added: declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/ClassLoaderAssetTestCase.java
===================================================================
--- declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/ClassLoaderAssetTestCase.java	                        (rev 0)
+++ declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/ClassLoaderAssetTestCase.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.declarchive.impl.base.asset;
+
+import java.io.InputStream;
+
+import junit.framework.Assert;
+
+import org.jboss.declarchive.api.Asset;
+import org.junit.Test;
+
+/**
+ * Test to ensure that we are can use a ClassLoader Resource as a resource.
+ * 
+ * https://jira.jboss.org/jira/browse/TMPARCH-5
+ * 
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ *
+ */
+public class ClassLoaderAssetTestCase
+{
+   private static final String EXISTING_RESOURCE = "org/jboss/declarchive/impl/base/asset/Test.properties";
+
+   private static final String NON_EXISTING_RESOURCE = "org/jboss/declarchive/impl/base/asset/NoFileShouldBePlacedHere.properties";
+
+   @Test
+   public void shouldBeAbleToReadResource() throws Exception
+   {
+      Asset asset = new ClassLoaderAsset(EXISTING_RESOURCE);
+      InputStream io = asset.getStream();
+
+      Assert.assertNotNull(io);
+      Assert.assertEquals("Should be able to read the content of the resource", "declarch=true", TestUtils
+            .convertToString(io));
+   }
+
+   @Test
+   public void shouldThrowExceptionOnNullName()
+   {
+      try
+      {
+         new ClassLoaderAsset(null);
+         Assert.fail("Should have thrown IllegalArgumentException");
+      }
+      catch (Exception e)
+      {
+         Assert.assertEquals("A null resourceName argument should result in a IllegalArgumentException",
+               IllegalArgumentException.class, e.getClass());
+      }
+   }
+
+   @Test
+   public void shouldThrowExceptionOnNullClassloader()
+   {
+      try
+      {
+         new ClassLoaderAsset(EXISTING_RESOURCE, null);
+         Assert.fail("Should have thrown IllegalArgumentException");
+      }
+      catch (Exception e)
+      {
+         Assert.assertEquals("A null classLoader argument should result in a IllegalArgumentException",
+               IllegalArgumentException.class, e.getClass());
+      }
+   }
+
+   @Test
+   public void shouldThrowExceptionOnMissingResource()
+   {
+      try
+      {
+         new ClassLoaderAsset(NON_EXISTING_RESOURCE);
+         Assert.fail("Should have thrown IllegalArgumentException");
+      }
+      catch (Exception e)
+      {
+         Assert.assertEquals(
+               "A resource that is not found in the classLoader should result in a IllegalArgumentException",
+               IllegalArgumentException.class, e.getClass());
+      }
+   }
+}

Deleted: declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/ClassResourceTestCase.java
===================================================================
--- declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/ClassResourceTestCase.java	2009-08-17 10:20:09 UTC (rev 3455)
+++ declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/ClassResourceTestCase.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.declarchive.impl.base.resource;
-
-import java.io.InputStream;
-
-import org.jboss.declarchive.spi.Resource;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Test to ensure that we are able to use Classes as Resources.
- *
- * https://jira.jboss.org/jira/browse/TMPARCH-5
- * 
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- *
- */
-public class ClassResourceTestCase
-{
-
-   @Test
-   public void shouldBeAbleToReadThisClass() throws Exception
-   {
-      Resource resource = new ClassResource(ClassResourceTestCase.class);
-      InputStream io = resource.getStream();
-
-      Assert.assertNotNull(io);
-   }
-
-   // TODO: add test to byte compare expected result?
-
-   @Test
-   public void shouldBeAbleToReadDefaultName() throws Exception
-   {
-      Resource resource = new ClassResource(ClassResourceTestCase.class);
-      Assert.assertEquals("A Class resource should use class name + '.class' as default name",
-            "org/jboss/declarchive/impl/base/resource/ClassResourceTestCase.class", resource.getDefaultName());
-   }
-
-   @Test
-   public void shouldThrowExceptionOnNullClass() throws Exception
-   {
-      try
-      {
-         new ClassResource(null);
-         Assert.fail("Should have thrown IllegalArgumentException");
-      }
-      catch (Exception e)
-      {
-         Assert.assertEquals("A null clazz argument should result in a IllegalArgumentException",
-               IllegalArgumentException.class, e.getClass());
-      }
-   }
-}

Deleted: declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/ClassloaderResourceTestCase.java
===================================================================
--- declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/ClassloaderResourceTestCase.java	2009-08-17 10:20:09 UTC (rev 3455)
+++ declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/ClassloaderResourceTestCase.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.declarchive.impl.base.resource;
-
-import java.io.InputStream;
-
-import junit.framework.Assert;
-
-import org.jboss.declarchive.spi.Resource;
-import org.junit.Test;
-
-/**
- * Test to ensure that we are can use a ClassLoader Resource as a resource.
- * 
- * https://jira.jboss.org/jira/browse/TMPARCH-5
- * 
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- *
- */
-public class ClassloaderResourceTestCase
-{
-   private static final String EXISTING_RESOURCE = "org/jboss/declarchive/impl/base/resource/Test.properties";
-
-   private static final String NON_EXISTING_RESOURCE = "org/jboss/declarchive/impl/base/resource/NoFileShouldBePlacedHere.properties";
-
-   @Test
-   public void shouldBeAbleToReadResource() throws Exception
-   {
-      Resource resource = new ClassloaderResource(EXISTING_RESOURCE);
-      InputStream io = resource.getStream();
-
-      Assert.assertNotNull(io);
-      Assert.assertEquals("Should be able to read the content of the resource", "declarch=true", TestUtils
-            .convertToString(io));
-   }
-
-   @Test
-   public void shouldBeAbleToReadDefaultName() throws Exception
-   {
-      Resource resource = new ClassloaderResource(EXISTING_RESOURCE);
-      Assert.assertEquals("A Classloader resource should use file name as default name, not absolute path",
-            "Test.properties", resource.getDefaultName());
-   }
-
-   @Test
-   public void shouldThrowExceptionOnNullName()
-   {
-      try
-      {
-         new ClassloaderResource(null);
-         Assert.fail("Should have thrown IllegalArgumentException");
-      }
-      catch (Exception e)
-      {
-         Assert.assertEquals("A null resourceName argument should result in a IllegalArgumentException",
-               IllegalArgumentException.class, e.getClass());
-      }
-   }
-
-   @Test
-   public void shouldThrowExceptionOnNullClassloader()
-   {
-      try
-      {
-         new ClassloaderResource(EXISTING_RESOURCE, null);
-         Assert.fail("Should have thrown IllegalArgumentException");
-      }
-      catch (Exception e)
-      {
-         Assert.assertEquals("A null classLoader argument should result in a IllegalArgumentException",
-               IllegalArgumentException.class, e.getClass());
-      }
-   }
-
-   @Test
-   public void shouldThrowExceptionOnMissingResource()
-   {
-      try
-      {
-         new ClassloaderResource(NON_EXISTING_RESOURCE);
-         Assert.fail("Should have thrown IllegalArgumentException");
-      }
-      catch (Exception e)
-      {
-         Assert.assertEquals(
-               "A resource that is not found in the classLoader should result in a IllegalArgumentException",
-               IllegalArgumentException.class, e.getClass());
-      }
-   }
-}

Added: declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/FileAssetTestCase.java
===================================================================
--- declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/FileAssetTestCase.java	                        (rev 0)
+++ declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/FileAssetTestCase.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.declarchive.impl.base.asset;
+
+import java.io.File;
+import java.io.InputStream;
+
+import junit.framework.Assert;
+
+import org.jboss.declarchive.api.Asset;
+import org.junit.Test;
+
+/**
+ * Test to ensure that we can use a File as a resource.
+ * 
+ * https://jira.jboss.org/jira/browse/TMPARCH-5
+ * 
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ *
+ */
+public class FileAssetTestCase
+{
+   private static final String BASE_PATH = "src/test/resources/org/jboss/declarchive/impl/base/asset/";
+
+   private static final String EXISTING_FILE = BASE_PATH + "Test.properties";
+
+   private static final String NON_EXISTING_FILE = BASE_PATH + "NoFileShouldBePlacedHere.properties";
+
+   @Test
+   public void shouldBeAbleToReadFile() throws Exception
+   {
+      Asset asset = new FileAsset(new File(EXISTING_FILE));
+      InputStream io = asset.getStream();
+
+      Assert.assertNotNull(io);
+      Assert.assertEquals("Should be able to read the content of the resource", "declarch=true", TestUtils
+            .convertToString(io));
+   }
+
+   @Test
+   public void shouldThrowExceptionOnNullFile() throws Exception
+   {
+      try
+      {
+         new FileAsset(null);
+         Assert.fail("Should have thrown IllegalArgumentException");
+      }
+      catch (Exception e)
+      {
+         Assert.assertEquals("A null file argument should result in a IllegalArgumentException",
+               IllegalArgumentException.class, e.getClass());
+      }
+   }
+
+   @Test
+   public void shouldThrowExceptionOnMissingFile() throws Exception
+   {
+      try
+      {
+         new FileAsset(new File(NON_EXISTING_FILE));
+         Assert.fail("Should have thrown IllegalArgumentException");
+      }
+      catch (Exception e)
+      {
+         Assert.assertEquals("A non existing file should result in a IllegalArgumentException",
+               IllegalArgumentException.class, e.getClass());
+      }
+   }
+}

Deleted: declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/FileResourceTestCase.java
===================================================================
--- declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/FileResourceTestCase.java	2009-08-17 10:20:09 UTC (rev 3455)
+++ declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/FileResourceTestCase.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.declarchive.impl.base.resource;
-
-import java.io.File;
-import java.io.InputStream;
-
-import junit.framework.Assert;
-
-import org.jboss.declarchive.spi.Resource;
-import org.junit.Test;
-
-/**
- * Test to ensure that we can use a File as a resource.
- * 
- * https://jira.jboss.org/jira/browse/TMPARCH-5
- * 
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- *
- */
-public class FileResourceTestCase
-{
-   private static final String BASE_PATH = "src/test/resources/org/jboss/declarchive/impl/base/resource/";
-
-   private static final String EXISTING_FILE = BASE_PATH + "Test.properties";
-
-   private static final String NON_EXISTING_FILE = BASE_PATH + "NoFileShouldBePlacedHere.properties";
-
-   @Test
-   public void shouldBeAbleToReadFile() throws Exception
-   {
-      Resource resource = new FileResource(new File(EXISTING_FILE));
-      InputStream io = resource.getStream();
-
-      Assert.assertNotNull(io);
-      Assert.assertEquals("Should be able to read the content of the resource", "declarch=true", TestUtils
-            .convertToString(io));
-   }
-
-   @Test
-   public void shouldBeAbleToReadDefaultName() throws Exception
-   {
-      Resource resource = new FileResource(new File(EXISTING_FILE));
-      Assert.assertEquals("A File resource should use the file name as default name, not absolute path",
-            "Test.properties", resource.getDefaultName());
-   }
-
-   @Test
-   public void shouldThrowExceptionOnNullFile() throws Exception
-   {
-      try
-      {
-         new FileResource(null);
-         Assert.fail("Should have thrown IllegalArgumentException");
-      }
-      catch (Exception e)
-      {
-         Assert.assertEquals("A null file argument should result in a IllegalArgumentException",
-               IllegalArgumentException.class, e.getClass());
-      }
-   }
-
-   @Test
-   public void shouldThrowExceptionOnMissingFile() throws Exception
-   {
-      try
-      {
-         new FileResource(new File(NON_EXISTING_FILE));
-         Assert.fail("Should have thrown IllegalArgumentException");
-      }
-      catch (Exception e)
-      {
-         Assert.assertEquals("A non existing file should result in a IllegalArgumentException",
-               IllegalArgumentException.class, e.getClass());
-      }
-   }
-}

Modified: declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/TestUtils.java
===================================================================
--- declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/TestUtils.java	2009-08-17 10:20:09 UTC (rev 3455)
+++ declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/TestUtils.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jboss.declarchive.impl.base.resource;
+package org.jboss.declarchive.impl.base.asset;
 
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;

Deleted: declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/URLResourceTestCase.java
===================================================================
--- declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/URLResourceTestCase.java	2009-08-17 10:20:09 UTC (rev 3455)
+++ declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/URLResourceTestCase.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.declarchive.impl.base.resource;
-
-import java.io.InputStream;
-
-import junit.framework.Assert;
-
-import org.jboss.declarchive.spi.Resource;
-import org.junit.Test;
-
-/**
- * Test to ensure that we can use a URL as a resource.
- * 
- * https://jira.jboss.org/jira/browse/TMPARCH-5
- * 
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- *
- */
-public class URLResourceTestCase
-{
-   private static final String EXISTING_RESOURCE = "org/jboss/declarchive/impl/base/resource/Test.properties";
-
-   @Test
-   public void shouldBeAbleToReadURL() throws Exception
-   {
-      Resource resource = new URLResource(Thread.currentThread().getContextClassLoader().getResource(EXISTING_RESOURCE));
-
-      InputStream io = resource.getStream();
-
-      Assert.assertNotNull(io);
-      Assert.assertEquals("Should be able to read the content of the resource", "declarch=true", TestUtils
-            .convertToString(io));
-   }
-
-   @Test
-   public void shouldBeAbleToReadDefaultName() throws Exception
-   {
-      Resource resource = new URLResource(Thread.currentThread().getContextClassLoader().getResource(EXISTING_RESOURCE));
-
-      Assert.assertEquals("A URL resource should use the file name as default name, not absolute path",
-            "Test.properties", resource.getDefaultName());
-   }
-
-   @Test
-   public void shouldThrowExceptionOnNullURL() throws Exception
-   {
-      try
-      {
-         new URLResource(null);
-         Assert.fail("Should have thrown IllegalArgumentException");
-      }
-      catch (Exception e)
-      {
-         Assert.assertEquals("A null url argument should result in a IllegalArgumentException",
-               IllegalArgumentException.class, e.getClass());
-      }
-   }
-}

Added: declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/UrlAssetTestCase.java
===================================================================
--- declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/UrlAssetTestCase.java	                        (rev 0)
+++ declarchive/trunk/impl-base/src/test/java/org/jboss/declarchive/impl/base/asset/UrlAssetTestCase.java	2009-08-17 10:33:12 UTC (rev 3456)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.declarchive.impl.base.asset;
+
+import java.io.InputStream;
+
+import junit.framework.Assert;
+
+import org.jboss.declarchive.api.Asset;
+import org.junit.Test;
+
+/**
+ * Test to ensure that we can use a URL as a resource.
+ * 
+ * https://jira.jboss.org/jira/browse/TMPARCH-5
+ * 
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ *
+ */
+public class UrlAssetTestCase
+{
+   private static final String EXISTING_RESOURCE = "org/jboss/declarchive/impl/base/asset/Test.properties";
+
+   @Test
+   public void shouldBeAbleToReadURL() throws Exception
+   {
+      Asset asset = new UrlAsset(Thread.currentThread().getContextClassLoader().getResource(EXISTING_RESOURCE));
+
+      InputStream io = asset.getStream();
+
+      Assert.assertNotNull(io);
+      Assert.assertEquals("Should be able to read the content of the resource", "declarch=true", TestUtils
+            .convertToString(io));
+   }
+
+   @Test
+   public void shouldThrowExceptionOnNullURL() throws Exception
+   {
+      try
+      {
+         new UrlAsset(null);
+         Assert.fail("Should have thrown IllegalArgumentException");
+      }
+      catch (Exception e)
+      {
+         Assert.assertEquals("A null url argument should result in a IllegalArgumentException",
+               IllegalArgumentException.class, e.getClass());
+      }
+   }
+}

Copied: declarchive/trunk/impl-base/src/test/resources/org/jboss/declarchive/impl/base/asset (from rev 3455, declarchive/trunk/impl-base/src/test/resources/org/jboss/declarchive/impl/base/resource)



More information about the jboss-svn-commits mailing list