felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1240032 - in /felix/trunk/deploymentadmin/deploymentadmin/src/test: ./ java/ java/org/ java/org/apache/ java/org/apache/felix/ java/org/apache/felix/deploymentadmin/
Date Fri, 03 Feb 2012 08:54:57 GMT
Author: marrs
Date: Fri Feb  3 08:54:56 2012
New Revision: 1240032

URL: http://svn.apache.org/viewvc?rev=1240032&view=rev
Log:
FELIX-3336 Added a test case while trying to hunt down a potential bug.

Added:
    felix/trunk/deploymentadmin/deploymentadmin/src/test/
    felix/trunk/deploymentadmin/deploymentadmin/src/test/java/
    felix/trunk/deploymentadmin/deploymentadmin/src/test/java/org/
    felix/trunk/deploymentadmin/deploymentadmin/src/test/java/org/apache/
    felix/trunk/deploymentadmin/deploymentadmin/src/test/java/org/apache/felix/
    felix/trunk/deploymentadmin/deploymentadmin/src/test/java/org/apache/felix/deploymentadmin/
    felix/trunk/deploymentadmin/deploymentadmin/src/test/java/org/apache/felix/deploymentadmin/ExplodingOutputtingInputStreamTest.java
  (with props)

Added: felix/trunk/deploymentadmin/deploymentadmin/src/test/java/org/apache/felix/deploymentadmin/ExplodingOutputtingInputStreamTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/deploymentadmin/src/test/java/org/apache/felix/deploymentadmin/ExplodingOutputtingInputStreamTest.java?rev=1240032&view=auto
==============================================================================
--- felix/trunk/deploymentadmin/deploymentadmin/src/test/java/org/apache/felix/deploymentadmin/ExplodingOutputtingInputStreamTest.java
(added)
+++ felix/trunk/deploymentadmin/deploymentadmin/src/test/java/org/apache/felix/deploymentadmin/ExplodingOutputtingInputStreamTest.java
Fri Feb  3 08:54:56 2012
@@ -0,0 +1,63 @@
+package org.apache.felix.deploymentadmin;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import junit.framework.TestCase;
+
+public class ExplodingOutputtingInputStreamTest extends TestCase {
+    public void testStream() throws Exception {
+        // fill up a stringbuffer with some test data
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < 1000; i++) {
+            sb.append("DATAdataDATAdata");
+        }
+        String data = sb.toString();
+        
+        // create a temporary folder
+        File tempDir = File.createTempFile("temp", "dir");
+        tempDir.delete();
+        tempDir.mkdirs();
+        System.out.println("Dir: " + tempDir);
+        
+        // create a zip file with two entries in it
+        File zipfile = new File(tempDir, "zipfile");
+        ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipfile));
+        String dummy1 = "dummy";
+        zos.putNextEntry(new ZipEntry(dummy1));
+        zos.write(data.getBytes());
+        zos.closeEntry();
+        String dummy2 = "dummy2";
+        zos.putNextEntry(new ZipEntry(dummy2));
+        zos.write(data.getBytes());
+        zos.closeEntry();
+        zos.close();
+        
+        // create another temporary folder
+        File dir = new File(tempDir, "dir");
+        dir.mkdirs();
+        File index = new File(tempDir, "list");
+        ExplodingOutputtingInputStream stream = new ExplodingOutputtingInputStream(new FileInputStream(zipfile),
index, dir);
+        byte[] buffer = new byte[2];
+        int read = stream.read(buffer);
+        while (read != -1) {
+            read = stream.read(buffer);
+        }
+        stream.close();
+        
+        // create references to the unpacked dummy files
+        File d1 = new File(dir, dummy1);
+        File d2 = new File(dir, dummy2);
+        
+        // cleanup
+        zipfile.delete();
+        index.delete();
+        d1.delete();
+        d2.delete();
+        dir.delete();
+        tempDir.delete();
+    }
+}

Propchange: felix/trunk/deploymentadmin/deploymentadmin/src/test/java/org/apache/felix/deploymentadmin/ExplodingOutputtingInputStreamTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message