[jboss-svn-commits] JBoss Common SVN: r3760 - shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Nov 19 06:28:31 EST 2009


Author: aslak
Date: 2009-11-19 06:28:31 -0500 (Thu, 19 Nov 2009)
New Revision: 3760

Modified:
   shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ExplodedExporterTestCase.java
Log:
SHRINKWRAP-86 TestCase to expose bug

Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ExplodedExporterTestCase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ExplodedExporterTestCase.java	2009-11-19 11:02:56 UTC (rev 3759)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/exporter/ExplodedExporterTestCase.java	2009-11-19 11:28:31 UTC (rev 3760)
@@ -16,9 +16,11 @@
  */
 package org.jboss.shrinkwrap.impl.base.exporter;
 
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.logging.Logger;
@@ -232,6 +234,26 @@
             new File(existingParentFolder, archive.getName()).exists());
    }
    
+   /**
+    * Ensure an ArchiveExportException is thrown when output directory is a file
+    */
+   @Test(expected = IllegalArgumentException.class)
+   public void testExportExplodedOutpuDirIsAFile() throws Exception
+   {
+      log.info("testExportExplodedOutpuDirIsAFile");
+      final File directory = createTempDirectory("testExportExplodedOutpuDirIsAFile");
+      // Will cause the creation of Archive directory to fail
+      final File existingFile = new File(directory, NAME_ARCHIVE);
+      final boolean created = existingFile.createNewFile();
+      
+      IOUtil.copyWithClose(new ByteArrayInputStream("test-test".getBytes()), new FileOutputStream(existingFile));
+      
+      Assert.assertEquals("Could not create test file",true, created);
+      
+      createArchiveWithAssets().as(ExplodedExporter.class).exportExploded(directory);
+   }
+
+   
    //-------------------------------------------------------------------------------------||
    // Internal Helper Methods ------------------------------------------------------------||
    //-------------------------------------------------------------------------------------||



More information about the jboss-svn-commits mailing list