Author: brett
Date: Wed Dec  7 10:40:43 2011
New Revision: 1211381

URL: http://svn.apache.org/viewvc?rev=1211381&view=rev
Log:
enhance IT to check contents of the ZIP

Modified:
    
incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AbstractNPandayIntegrationTestCase.java
    
incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/NPandayIT0012VBWebAppTest.java

Modified: 
incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AbstractNPandayIntegrationTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AbstractNPandayIntegrationTestCase.java?rev=1211381&r1=1211380&r2=1211381&view=diff
==============================================================================
--- 
incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AbstractNPandayIntegrationTestCase.java
 (original)
+++ 
incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/AbstractNPandayIntegrationTestCase.java
 Wed Dec  7 10:40:43 2011
@@ -202,6 +202,23 @@ public abstract class AbstractNPandayInt
         return versionRange;
     }
 
+    protected static void assertZipEntries( File zipFile, List<String> 
expectedEntries )
+        throws IOException
+    {
+        ZipFile zip = new ZipFile( zipFile );
+        try
+        {
+            for ( String name : expectedEntries )
+            {
+                assertNotNull( zip.getEntry( name ) );
+            }
+        }
+        finally
+        {
+            zip.close();
+        }
+    }
+
     protected void runTest()
         throws Throwable
     {
@@ -541,56 +558,6 @@ public abstract class AbstractNPandayInt
         return checkNPandayVersion( createVersionRange( versionRangeStr ), 
version ) || forceVersion;
     }
 
-    protected File unzipResources( String resourcePath )
-        throws IOException
-    {
-        String tempDirPath = System.getProperty( "maven.test.tmpdir", 
System.getProperty( "java.io.tmpdir" ) );
-        File tempDir = new File( tempDirPath );
-
-        File testDir = new File( tempDir, resourcePath.substring( 0, 
resourcePath.length() - 4 ) );
-
-        FileUtils.deleteDirectory( testDir );
-
-        File f = ResourceExtractor.extractResourcePath( getClass(), 
resourcePath, tempDir, true );
-
-        ZipFile zipFile = new ZipFile( f );
-        try
-        {
-            for ( Enumeration entries = zipFile.entries(); 
entries.hasMoreElements(); )
-            {
-                ZipEntry entry = (ZipEntry) entries.nextElement();
-
-                File file = new File( testDir.getParentFile(), entry.getName() 
);
-                file.getParentFile().mkdirs();
-                if ( entry.isDirectory() )
-                {
-                    file.mkdir();
-                    continue;
-                }
-
-                InputStream inputStream = null;
-                FileOutputStream outputStream = null;
-                try
-                {
-                    inputStream = zipFile.getInputStream( entry );
-                    outputStream = new FileOutputStream( file );
-                    IOUtil.copy( inputStream, outputStream );
-                }
-                finally
-                {
-                    IOUtil.close( inputStream );
-                    IOUtil.close( outputStream );
-                }
-            }
-        }
-        finally
-        {
-            zipFile.close();
-        }
-
-        return testDir;
-    }
-
     protected NPandayIntegrationTestContext createDefaultTestContext()
         throws IOException, VerificationException
     {

Modified: 
incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/NPandayIT0012VBWebAppTest.java
URL: 
http://svn.apache.org/viewvc/incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/NPandayIT0012VBWebAppTest.java?rev=1211381&r1=1211380&r2=1211381&view=diff
==============================================================================
--- 
incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/NPandayIT0012VBWebAppTest.java
 (original)
+++ 
incubator/npanday/npanday-its/trunk/src/test/java/npanday/its/NPandayIT0012VBWebAppTest.java
 Wed Dec  7 10:40:43 2011
@@ -24,6 +24,10 @@ import org.apache.maven.it.Verifier;
 import org.apache.maven.it.util.ResourceExtractor;
 
 import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.zip.ZipFile;
 
 public class NPandayIT0012VBWebAppTest
     extends AbstractNPandayIntegrationTestCase
@@ -39,8 +43,19 @@ public class NPandayIT0012VBWebAppTest
         File testDir = ResourceExtractor.simpleExtractResources( getClass(), 
"/NPandayIT0012VBWebAppTest" );
         Verifier verifier = getVerifier( testDir );
         verifier.executeGoal( "install" );
-        verifier.assertFilePresent( new File( testDir, getAssemblyFile( 
"VBWebAppTest", "1.0.0", "zip" ) ).getAbsolutePath() );
+        File zipFile = new File( testDir, getAssemblyFile( "VBWebAppTest", 
"1.0.0", "zip" ) );
+        verifier.assertFilePresent( zipFile.getAbsolutePath() );
         verifier.verifyErrorFreeLog();
         verifier.resetStreams();
+
+        List<String> expectedEntries = Arrays.asList( "bin/VBWebAppTest.dll", 
"Default.aspx",
+                                                      "My 
Project/Application.myapp", "My Project/Resources.resx",
+                                                      "My 
Project/Settings.settings", "Web.config" );
+
+        assertZipEntries( zipFile, expectedEntries );
+
+        String assembly = new File( testDir, "target/bin/VBWebAppTest.dll" 
).getAbsolutePath();
+        assertResourcePresent( assembly, "VBWebAppTest.Resources.resources" );
+        assertClassPresent( assembly, "VBWebAppTest._Default" );
     }
 }


Reply via email to