commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r674372 [6/6] - in /commons/sandbox/compress/branches/redesign: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/commons/ src/main/java/org/apache/commons/compress/ src/main/java/org/apa...
Date Mon, 07 Jul 2008 00:28:49 GMT
Added: commons/sandbox/compress/branches/redesign/src/site/xdoc/issue-tracking.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/site/xdoc/issue-tracking.xml?rev=674372&view=auto
==============================================================================
--- commons/sandbox/compress/branches/redesign/src/site/xdoc/issue-tracking.xml (added)
+++ commons/sandbox/compress/branches/redesign/src/site/xdoc/issue-tracking.xml Sun Jul  6
17:28:46 2008
@@ -0,0 +1,100 @@
+<?xml version="1.0"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+-->
+<!--
+ +======================================================================+
+ |****                                                              ****|
+ |****      THIS FILE IS GENERATED BY THE COMMONS BUILD PLUGIN      ****|
+ |****                    DO NOT EDIT DIRECTLY                      ****|
+ |****                                                              ****|
+ +======================================================================+
+ | TEMPLATE FILE: sandbox-issue-tracking-template.xml                   |
+ | commons-build-plugin/trunk/src/main/resources/commons-xdoc-templates |
+ +======================================================================+
+ |                                                                      |
+ | 1) Re-generate using: mvn commons:jira-page                          |
+ |                                                                      |
+ | 2) Set the following properties in the component's pom:              |
+ |    - commons.jira.componentid (required, numeric)                    |
+ |                                                                      |
+ | 3) Example Properties                                                |
+ |                                                                      |
+ |  <properties>                                                        |
+ |    <commons.jira.componentid>12311182</commons.jira.componentid>     |
+ |  </properties>                                                       |
+ |                                                                      |
+ +======================================================================+
+-->
+<document>
+  <properties>
+    <title>Commons Compress (Sandbox) Issue tracking</title>
+    <author email="dev@commons.apache.org">Commons Documentation Team</author>
+  </properties>
+  <body>
+
+    <section name="Commons Compress (Sandbox) Issue tracking">
+      <p>
+      Commons Compress (Sandbox) uses <a href="http://issues.apache.org/jira/">ASF
JIRA</a> for tracking issues.
+      See the <a href="http://issues.apache.org/jira/browse/SANDBOX">Sandbox JIRA project
page</a>.
+      </p>
+
+      <p>
+      To use JIRA you may need to <a href="http://issues.apache.org/jira/secure/Signup!default.jspa">create
an account</a>
+      (if you have previously created/updated Commons issues using Bugzilla an account will
have been automatically
+      created and you can use the <a href="http://issues.apache.org/jira/secure/ForgotPassword!default.jspa">Forgot
Password</a>
+      page to get a new password).
+      </p>
+
+      <p>
+      If you would like to report a bug, or raise an enhancement request with
+      Commons Compress (Sandbox) please do the following:
+      <ol>
+        <li><a href="http://issues.apache.org/jira/secure/IssueNavigator.jspa?reset=true&amp;pid=12310491&amp;component=12311183&amp;sorter/field=issuekey&amp;sorter/order=DESC&amp;status=1&amp;status=3&amp;status=4">Search
existing open bugs</a>.
+            If you find your issue listed then please add a comment with your details.</li>
+        <li><a href="mail-lists.html">Search the mailing list archive(s)</a>.
+            You may find your issue or idea has already been discussed.</li>
+        <li>Decide if your issue is a bug or an enhancement.</li>
+        <li>Submit either a <a href="http://issues.apache.org/jira/secure/CreateIssueDetails!init.jspa?pid=12310491&amp;components=12311183&amp;issuetype=1&amp;priority=4&amp;assignee=-1">bug
report</a>
+            or <a href="http://issues.apache.org/jira/secure/CreateIssueDetails!init.jspa?pid=12310491&amp;components=12311183&amp;issuetype=4&amp;priority=4&amp;assignee=-1">enhancement
request</a>.</li>
+      </ol>
+      </p>
+
+      <p>
+      Please also remember these points:
+      <ul>
+        <li>the more information you provide, the better we can help you</li>
+        <li>test cases are vital, particularly for any proposed enhancements</li>
+        <li>the developers of Commons Compress (Sandbox) are all unpaid volunteers</li>
+      </ul>
+      </p>
+
+      <p>
+      For more information on subversion and creating patches see the
+      <a href="http://www.apache.org/dev/contributors.html">Apache Contributors Guide</a>.
+      </p>
+
+      <p>
+      You may also find these links useful:
+      <ul>
+        <li><a href="http://issues.apache.org/jira/secure/IssueNavigator.jspa?reset=true&amp;pid=12310491&amp;component=12311183&amp;sorter/field=issuekey&amp;sorter/order=DESC&amp;status=1&amp;status=3&amp;status=4">All
Open Commons Compress (Sandbox) bugs</a></li>
+        <li><a href="http://issues.apache.org/jira/secure/IssueNavigator.jspa?reset=true&amp;pid=12310491&amp;component=12311183&amp;sorter/field=issuekey&amp;sorter/order=DESC&amp;status=5&amp;status=6">All
Resolved Commons Compress (Sandbox) bugs</a></li>
+        <li><a href="http://issues.apache.org/jira/secure/IssueNavigator.jspa?reset=true&amp;pid=12310491&amp;component=12311183&amp;sorter/field=issuekey&amp;sorter/order=DESC">All
Commons Compress (Sandbox) bugs</a></li>
+      </ul>
+      </p>
+    </section>
+  </body>
+</document>

Added: commons/sandbox/compress/branches/redesign/src/site/xdoc/style/project.css
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/site/xdoc/style/project.css?rev=674372&view=auto
==============================================================================
--- commons/sandbox/compress/branches/redesign/src/site/xdoc/style/project.css (added)
+++ commons/sandbox/compress/branches/redesign/src/site/xdoc/style/project.css Sun Jul  6
17:28:46 2008
@@ -0,0 +1 @@
+@import url("http://jakarta.apache.org/style/jakarta-maven.css");

Added: commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/CompressTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/CompressTestCase.java?rev=674372&view=auto
==============================================================================
--- commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/CompressTestCase.java
(added)
+++ commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/CompressTestCase.java
Sun Jul  6 17:28:46 2008
@@ -0,0 +1,338 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.commons.compress.archivers;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.compress.archivers.ar.ArArchiveEntry;
+import org.apache.commons.compress.archivers.ar.ArArchiveInputStream;
+import org.apache.commons.compress.archivers.jar.JarArchiveInputStream;
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
+import org.apache.commons.compress.compressors.CompressorInputStream;
+import org.apache.commons.compress.compressors.CompressorOutputStream;
+import org.apache.commons.compress.compressors.CompressorStreamFactory;
+import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
+import org.apache.commons.compress.utils.IOUtils;
+
+public final class CompressTestCase extends TestCase {
+
+	private File dir;
+	
+	protected void setUp() throws Exception {
+		dir = File.createTempFile("dir", "");
+		dir.delete();
+		dir.mkdir();
+	}
+
+	protected void tearDown() throws Exception {
+		dir.delete();
+		dir = null;
+	}
+
+
+	public void testGzipCreation()  throws Exception {
+		final File output = new File(dir, "bla.gz");
+		final File file1 = new File(getClass().getClassLoader().getResource("test1.xml").getFile());
+		final OutputStream out = new FileOutputStream(output);
+		CompressorOutputStream cos = new CompressorStreamFactory().createCompressorOutputStream("gz",
out);
+		IOUtils.copy(new FileInputStream(file1), cos);
+		cos.close();
+	}
+	
+	public void testGzipUnarchive() throws Exception {
+		final File output = new File(dir, "bla-entpackt.tar");
+		final File input = new File(getClass().getClassLoader().getResource("bla.tgz").getFile());
+        final InputStream is = new FileInputStream(input);
+        final CompressorInputStream in = new CompressorStreamFactory().createCompressorInputStream("gz",
is);
+        IOUtils.copy(in, new FileOutputStream(output));
+		in.close();
+    }
+	
+	public void testBzipCreation()  throws Exception {
+		final File output = new File(dir, "bla.txt.bz2");
+		System.out.println(dir);
+		final File file1 = new File(getClass().getClassLoader().getResource("test.txt").getFile());
+		final OutputStream out = new FileOutputStream(output);
+		CompressorOutputStream cos = new CompressorStreamFactory().createCompressorOutputStream("bzip2",
out);
+		IOUtils.copy(new FileInputStream(file1), cos);
+		cos.close();
+	}
+	
+	public void testBzip2Unarchive() throws Exception {
+		final File output = new File(dir, "test-entpackt.txt");
+		System.out.println(dir);
+		final File input = new File(getClass().getClassLoader().getResource("bla.txt.bz2").getFile());
+        final InputStream is = new FileInputStream(input);
+        //final CompressorInputStream in = new CompressorStreamFactory().createCompressorInputStream("bzip2",
is);
+        final CompressorInputStream in = new BZip2CompressorInputStream(is);
+        IOUtils.copy(in, new FileOutputStream(output));
+		in.close();
+    }
+	
+	public void testJarArchiveCreation() throws Exception {
+		final File output = new File(dir, "bla.jar");
+
+		final File file1 = new File(getClass().getClassLoader().getResource("test1.xml").getFile());
+		final File file2 = new File(getClass().getClassLoader().getResource("test2.xml").getFile());
+		
+        final OutputStream out = new FileOutputStream(output);
+        
+        final ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream("jar",
out);
+
+        os.putArchiveEntry(new ZipArchiveEntry("testdata/test1.xml"));
+        IOUtils.copy(new FileInputStream(file1), os);
+        os.closeArchiveEntry();
+        
+        os.putArchiveEntry(new ZipArchiveEntry("testdata/test2.xml"));
+        IOUtils.copy(new FileInputStream(file2), os);
+        os.closeArchiveEntry();
+
+        os.close();
+    }
+	
+	public void testJarUnarchive() throws Exception {
+		final File input = new File(getClass().getClassLoader().getResource("bla.jar").getFile());
+        final InputStream is = new FileInputStream(input);
+        final ArchiveInputStream in = new ArchiveStreamFactory().createArchiveInputStream("jar",
is);
+        
+        ZipArchiveEntry entry = (ZipArchiveEntry)in.getNextEntry();
+        File o = new File(dir, entry.getName());
+        o.getParentFile().mkdirs();
+        OutputStream out = new FileOutputStream(o);
+        IOUtils.copy(in, out);
+        out.close();
+        
+        entry = (ZipArchiveEntry)in.getNextEntry();
+        o = new File(dir, entry.getName());
+        o.getParentFile().mkdirs();
+        out = new FileOutputStream(o);
+        IOUtils.copy(in, out);
+        out.close();
+        
+        entry = (ZipArchiveEntry)in.getNextEntry();
+        o = new File(dir, entry.getName());
+        o.getParentFile().mkdirs();
+        out = new FileOutputStream(o);
+        IOUtils.copy(in, out);
+        out.close();
+        
+        in.close();
+    }
+	
+	
+	public void testDetection() throws Exception {
+		final ArchiveStreamFactory factory = new ArchiveStreamFactory();
+
+		final ArchiveInputStream ar = factory.createArchiveInputStream(
+				new BufferedInputStream(new FileInputStream(
+						new File(getClass().getClassLoader().getResource("bla.ar").getFile())))); 
+		assertTrue(ar instanceof ArArchiveInputStream);
+
+		final ArchiveInputStream tar = factory.createArchiveInputStream(
+				new BufferedInputStream(new FileInputStream(
+						new File(getClass().getClassLoader().getResource("bla.tar").getFile()))));
+		assertTrue(tar instanceof TarArchiveInputStream);
+
+		final ArchiveInputStream zip = factory.createArchiveInputStream(
+				new BufferedInputStream(new FileInputStream(
+						new File(getClass().getClassLoader().getResource("bla.zip").getFile()))));
+		assertTrue(zip instanceof ZipArchiveInputStream);
+
+		final ArchiveInputStream jar = factory.createArchiveInputStream(
+				new BufferedInputStream(new FileInputStream(
+						new File(getClass().getClassLoader().getResource("bla.jar").getFile()))));
+		assertTrue(jar instanceof JarArchiveInputStream);
+
+//		final ArchiveInputStream tgz = factory.createArchiveInputStream(
+//				new BufferedInputStream(new FileInputStream(
+//						new File(getClass().getClassLoader().getResource("bla.tgz").getFile()))));
+//		assertTrue(tgz instanceof TarArchiveInputStream);
+		
+	}
+	
+	public void testArArchiveCreation() throws Exception {
+		final File output = new File(dir, "bla.ar");
+		
+		final File file1 = new File(getClass().getClassLoader().getResource("test1.xml").getFile());
+		final File file2 = new File(getClass().getClassLoader().getResource("test2.xml").getFile());
+		
+		final OutputStream out = new FileOutputStream(output);
+        final ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream("ar",
out);
+		os.putArchiveEntry(new ArArchiveEntry("test1.xml", file1.length()));
+		IOUtils.copy(new FileInputStream(file1), os);
+		os.closeArchiveEntry();
+		
+		os.putArchiveEntry(new ArArchiveEntry("test2.xml", file2.length()));
+		IOUtils.copy(new FileInputStream(file2), os);
+		os.closeArchiveEntry();
+		
+		os.close();
+	}
+	
+	public void testArUnarchive() throws Exception {
+		final File output = new File(dir, "bla.ar");
+		{
+			final File file1 = new File(getClass().getClassLoader().getResource("test1.xml").getFile());
+			final File file2 = new File(getClass().getClassLoader().getResource("test2.xml").getFile());
+			
+			final OutputStream out = new FileOutputStream(output);
+	        final ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream("ar",
out);
+			os.putArchiveEntry(new ArArchiveEntry("test1.xml", file1.length()));
+			IOUtils.copy(new FileInputStream(file1), os);
+			os.closeArchiveEntry();
+			
+			os.putArchiveEntry(new ArArchiveEntry("test2.xml", file2.length()));
+			IOUtils.copy(new FileInputStream(file2), os);
+			os.closeArchiveEntry();
+			os.close();
+		}
+		
+		// UnArArchive Operation
+		final File input = output;
+		final InputStream is = new FileInputStream(input);
+		final ArchiveInputStream in = new ArchiveStreamFactory().createArchiveInputStream("ar",
is);
+		final ArArchiveEntry entry = (ArArchiveEntry)in.getNextEntry();
+		
+		File target = new File(dir, entry.getName());
+        final OutputStream out = new FileOutputStream(target);
+        
+        IOUtils.copy(in, out);
+    
+        out.close();
+        in.close();
+	}
+	
+	public void testZipArchiveCreation() throws Exception {
+		
+		final File output = new File(dir, "bla.zip");
+		
+		final File file1 = new File(getClass().getClassLoader().getResource("test1.xml").getFile());
+		final File file2 = new File(getClass().getClassLoader().getResource("test2.xml").getFile());
+		
+        final OutputStream out = new FileOutputStream(output);
+        
+        final ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream("zip",
out);
+
+        os.putArchiveEntry(new ZipArchiveEntry("testdata/test1.xml"));
+        IOUtils.copy(new FileInputStream(file1), os);
+        os.closeArchiveEntry();
+        
+        os.putArchiveEntry(new ZipArchiveEntry("testdata/test2.xml"));
+        IOUtils.copy(new FileInputStream(file2), os);
+        os.closeArchiveEntry();
+        
+        os.close();
+    }
+    
+    public void testTarArchiveCreation() throws Exception {
+
+		final File output = new File(dir, "bla.tar");
+
+		final File file1 = new File(getClass().getClassLoader().getResource("test1.xml").getFile());
+
+    	final OutputStream out = new FileOutputStream(output);
+        
+        final ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream("tar",
out);
+        
+        final TarArchiveEntry entry = new TarArchiveEntry("testdata/test1.xml");
+        entry.setModTime(0);
+        entry.setSize(file1.length());
+        entry.setUserID(0);
+        entry.setGroupID(0);
+        entry.setUserName("avalon");
+        entry.setGroupName("excalibur");
+        entry.setMode(0100000);
+        
+        os.putArchiveEntry(entry);
+        IOUtils.copy(new FileInputStream(file1), os);
+
+        os.closeArchiveEntry();
+        os.close();
+    }
+    
+    public void testZipUnarchive() throws Exception {
+
+		final File input = new File(getClass().getClassLoader().getResource("bla.zip").getFile());
+    	
+        final InputStream is = new FileInputStream(input);
+        final ArchiveInputStream in = new ArchiveStreamFactory().createArchiveInputStream("zip",
is);
+ 
+        final ZipArchiveEntry entry = (ZipArchiveEntry)in.getNextEntry();
+        final OutputStream out = new FileOutputStream(new File(dir, entry.getName()));
+        
+        IOUtils.copy(in, out);
+    
+        out.close();
+        in.close();
+    }
+        
+    public void testTarUnarchive() throws Exception {
+		final File input = new File(getClass().getClassLoader().getResource("bla.tar").getFile());
+		final InputStream is = new FileInputStream(input);
+        final ArchiveInputStream in = new ArchiveStreamFactory().createArchiveInputStream("tar",
is);
+        final TarArchiveEntry entry = (TarArchiveEntry)in.getNextEntry();
+        final OutputStream out = new FileOutputStream(new File(dir, entry.getName()));
+        IOUtils.copy(in, out);
+        out.close();
+        in.close();
+    }
+    
+//  public void testZipUnarchive() throws Exception {
+//        ZipInputStream zip = 
+//            new ZipInputStream(new FileInputStream("C:\\dev\\sources\\compress\\testdata\\bla.zip"));
+//        Iterator iterator = zip.getEntryIterator();
+//        while (iterator.hasNext()) {
+//            ArchiveEntry entry = (ArchiveEntry) iterator.next();
+//            OutputStream output = new FileOutputStream("testdata\\blub\\" + entry.getName());
+//            IOUtils.copy(zip, output);
+//        }
+//        zip.close();
+//    }
+
+    
+//	public void xtestFactoryUnarchive() throws Exception {
+//		CompressUtils.unpack(new FileInputStream("bla.tgz"), new File("output"));
+//	}
+//
+//	
+//	public void xtestArUnarchive() throws Exception {
+//		ArchiveInputStream ar = new ArArchiveInputStream(new FileInputStream("bla.tgz"));
+//		Iterator iterator = ar.getEntryIterator();
+//		while(iterator.hasNext()) {
+//			ArchiveEntry entry = (ArchiveEntry) iterator.next();
+//			OutputStream output = new FileOutputStream(entry.getName());
+//			IOUtils.copy(ar, output);
+//		}
+//		ar.close();
+//	}
+//
+
+//
+
+}

Added: commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveEntry.java?rev=674372&view=auto
==============================================================================
--- commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveEntry.java
(added)
+++ commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveEntry.java
Sun Jul  6 17:28:46 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.commons.compress.archivers.memory;
+
+import org.apache.commons.compress.archivers.ArchiveEntry;
+
+public final class MemoryArchiveEntry implements ArchiveEntry {
+
+	private final String name;
+	
+	public MemoryArchiveEntry( final String pName ) {
+		name = pName;
+	}
+	
+	public String getName() {
+		return name;
+	}
+
+	public long getSize() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+}

Added: commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveInputStream.java?rev=674372&view=auto
==============================================================================
--- commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveInputStream.java
(added)
+++ commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveInputStream.java
Sun Jul  6 17:28:46 2008
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.commons.compress.archivers.memory;
+
+import java.io.IOException;
+
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.ArchiveInputStream;
+
+public final class MemoryArchiveInputStream extends ArchiveInputStream {
+
+	private final String[] filenames;
+	private final String[] content;
+	private int p;
+	
+	public MemoryArchiveInputStream( final String[][] pFiles ) {
+		filenames = new String[pFiles.length];
+		content = new String[pFiles.length];
+		
+		for (int i = 0; i < pFiles.length; i++) {
+			String[] nameAndContent = pFiles[i];
+			filenames[i] = nameAndContent[0];
+			content[i] = nameAndContent[1];
+		}
+		p = 0;
+	}
+	
+	public ArchiveEntry getNextEntry() throws IOException {
+		if (p >= filenames.length) {
+			return null;
+		}
+
+		return new MemoryArchiveEntry(filenames[p]);
+	}
+
+	public String readString() {
+		return content[p++];
+	}
+	
+	public int read() throws IOException {
+		return 0;
+	}
+
+}

Added: commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveTestCase.java?rev=674372&view=auto
==============================================================================
--- commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveTestCase.java
(added)
+++ commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveTestCase.java
Sun Jul  6 17:28:46 2008
@@ -0,0 +1,35 @@
+package org.apache.commons.compress.archivers.memory;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.compress.archivers.ArchiveEntry;
+
+public final class MemoryArchiveTestCase extends TestCase {
+
+	public void testReading() throws IOException {
+		
+		final MemoryArchiveInputStream is = new MemoryArchiveInputStream(new String[][] {
+				{ "test1",     "content1" },
+				{ "test2",     "content2" },
+				});
+
+		final ArchiveEntry entry1 = is.getNextEntry();
+		assertNotNull(entry1);
+		assertEquals("test1", entry1.getName());
+		final String content1 = is.readString();
+		assertEquals("content1", content1);
+		
+		final ArchiveEntry entry2 = is.getNextEntry();
+		assertNotNull(entry2);
+		assertEquals("test2", entry2.getName());
+		final String content2 = is.readString();
+		assertEquals("content2", content2);
+		
+		final ArchiveEntry entry3 = is.getNextEntry();
+		assertNull(entry3);
+		
+	}
+
+}

Added: commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java?rev=674372&view=auto
==============================================================================
--- commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java
(added)
+++ commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java
Sun Jul  6 17:28:46 2008
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.commons.compress.changes;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.compress.archivers.memory.MemoryArchiveInputStream;
+
+public final class ChangeSetTestCase extends TestCase {
+
+	private void apply( final ChangeSet cs ) throws IOException {
+		
+		final ArchiveInputStream is = new MemoryArchiveInputStream(new String[][] {
+				{ "test1",      "" },
+				{ "test2",      "" },
+				{ "dir1/test1", "" },
+				{ "dir1/test2", "" },
+				{ "dir2/test1", "" },
+				{ "dir2/test2", "" }
+				});
+		
+		while(true) {
+			final ArchiveEntry entry = is.getNextEntry();
+			
+			if (entry == null) {
+				break;
+			}
+			
+			// delete, new name, new content
+		}
+	}
+	
+}

Added: commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/changes/ChangeWorkerTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/changes/ChangeWorkerTest.java?rev=674372&view=auto
==============================================================================
--- commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/changes/ChangeWorkerTest.java
(added)
+++ commons/sandbox/compress/branches/redesign/src/test/java/org/apache/commons/compress/changes/ChangeWorkerTest.java
Sun Jul  6 17:28:46 2008
@@ -0,0 +1,64 @@
+/**
+ * 
+ */
+package org.apache.commons.compress.changes;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.compress.archivers.memory.MemoryArchiveInputStream;
+import org.apache.commons.compress.archivers.*;
+/**
+ * @author Cy
+ *
+ */
+public class ChangeWorkerTest extends TestCase {
+
+	final ArchiveInputStream is = null;
+	
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		final ArchiveInputStream is = new MemoryArchiveInputStream(new String[][] {
+				{ "test1",      "" },
+				{ "test2",      "" },
+				{ "dir1/test1", "" },
+				{ "dir1/test2", "" },
+				{ "dir2/test1", "" },
+				{ "dir2/test2", "" }
+				});
+	}
+
+	/* (non-Javadoc)
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+	}
+
+	/**
+	 * Test method for {@link org.apache.commons.compress.changes.ChangeWorker#perform(org.apache.commons.compress.changes.ChangeSet,
java.io.InputStream, java.io.OutputStream)}.
+	 */
+	public void testPerform() throws Exception {
+		ChangeSet changes = new ChangeSet();
+		changes.delete("test2.xml");
+		
+		final File input = new File(getClass().getClassLoader().getResource("bla.zip").getFile());
+		final InputStream is = new FileInputStream(input);
+		ArchiveInputStream ais = new ArchiveStreamFactory().createArchiveInputStream("zip", is);
+		
+		File temp = File.createTempFile("test", ".zip");
+		ArchiveOutputStream out = new ArchiveStreamFactory().createArchiveOutputStream("zip", new
FileOutputStream(temp));
+		
+		System.out.println(temp.getAbsolutePath());
+		ChangeWorker.perform(changes, ais, out);
+	}
+
+}

Added: commons/sandbox/compress/branches/redesign/src/test/resources/bla.ar
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/resources/bla.ar?rev=674372&view=auto
==============================================================================
--- commons/sandbox/compress/branches/redesign/src/test/resources/bla.ar (added)
+++ commons/sandbox/compress/branches/redesign/src/test/resources/bla.ar Sun Jul  6 17:28:46
2008
@@ -0,0 +1,27 @@
+!<arch>
+test1.xml       1201445869  501   501   100644  610       `
+<?xml version = '1.0'?>
+<!DOCTYPE connections>
+<connections>
+<<<<<<< HEAD:testdata/test.xml
+=======
+    as
+>>>>>>> 75cb63ff7005344589b57d17338b64783f8f430c:testdata/test.xml
+   <connection>
+      <JDBC_PORT>1521</JDBC_PORT>
+      <HOSTNAME>10.248.40.111</HOSTNAME>
+      <ConnectionType>JDBC</ConnectionType>
+      <DeployPassword>false</DeployPassword>
+      <user>appsrv</user>
+      <ConnectionName>Dev-DB</ConnectionName>
+      <SID>O10gIN1</SID>
+      <JdbcDriver>oracle.jdbc.driver.OracleDriver</JdbcDriver>
+      <ORACLE_JDBC_TYPE>thin</ORACLE_JDBC_TYPE>
+   </connection>
+</connections>
+test2.xml       1201445869  501   501   100644  82        `
+<?xml version = '1.0'?>
+<!DOCTYPE connections>
+<meinxml>
+	<leer />
+</meinxml>

Added: commons/sandbox/compress/branches/redesign/src/test/resources/bla.jar
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/resources/bla.jar?rev=674372&view=auto
==============================================================================
Files commons/sandbox/compress/branches/redesign/src/test/resources/bla.jar (added) and commons/sandbox/compress/branches/redesign/src/test/resources/bla.jar
Sun Jul  6 17:28:46 2008 differ

Added: commons/sandbox/compress/branches/redesign/src/test/resources/bla.tar
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/resources/bla.tar?rev=674372&view=auto
==============================================================================
Files commons/sandbox/compress/branches/redesign/src/test/resources/bla.tar (added) and commons/sandbox/compress/branches/redesign/src/test/resources/bla.tar
Sun Jul  6 17:28:46 2008 differ

Added: commons/sandbox/compress/branches/redesign/src/test/resources/bla.tgz
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/resources/bla.tgz?rev=674372&view=auto
==============================================================================
Files commons/sandbox/compress/branches/redesign/src/test/resources/bla.tgz (added) and commons/sandbox/compress/branches/redesign/src/test/resources/bla.tgz
Sun Jul  6 17:28:46 2008 differ

Added: commons/sandbox/compress/branches/redesign/src/test/resources/bla.txt.bz2
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/resources/bla.txt.bz2?rev=674372&view=auto
==============================================================================
Files commons/sandbox/compress/branches/redesign/src/test/resources/bla.txt.bz2 (added) and
commons/sandbox/compress/branches/redesign/src/test/resources/bla.txt.bz2 Sun Jul  6 17:28:46
2008 differ

Added: commons/sandbox/compress/branches/redesign/src/test/resources/bla.xml.bz2
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/resources/bla.xml.bz2?rev=674372&view=auto
==============================================================================
Files commons/sandbox/compress/branches/redesign/src/test/resources/bla.xml.bz2 (added) and
commons/sandbox/compress/branches/redesign/src/test/resources/bla.xml.bz2 Sun Jul  6 17:28:46
2008 differ

Added: commons/sandbox/compress/branches/redesign/src/test/resources/bla.zip
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/resources/bla.zip?rev=674372&view=auto
==============================================================================
Files commons/sandbox/compress/branches/redesign/src/test/resources/bla.zip (added) and commons/sandbox/compress/branches/redesign/src/test/resources/bla.zip
Sun Jul  6 17:28:46 2008 differ

Added: commons/sandbox/compress/branches/redesign/src/test/resources/test.txt
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/resources/test.txt?rev=674372&view=auto
==============================================================================
--- commons/sandbox/compress/branches/redesign/src/test/resources/test.txt (added)
+++ commons/sandbox/compress/branches/redesign/src/test/resources/test.txt Sun Jul  6 17:28:46
2008
@@ -0,0 +1,10 @@
+111111111111111111111111111000101011
+111111111111111111111111111000101011
+111111111111111111111111111000101011
+111111111111111111111111111000101011
+111111111111111111111111111000101011
+111111111111111111111111111000101011
+111111111111111111111111111000101011
+111111111111111111111111111000101011
+111111111111111111111111111000101011
+111111111111111111111111111000101011
\ No newline at end of file

Added: commons/sandbox/compress/branches/redesign/src/test/resources/test1.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/resources/test1.xml?rev=674372&view=auto
==============================================================================
--- commons/sandbox/compress/branches/redesign/src/test/resources/test1.xml (added)
+++ commons/sandbox/compress/branches/redesign/src/test/resources/test1.xml Sun Jul  6 17:28:46
2008
@@ -0,0 +1,19 @@
+<?xml version = '1.0'?>
+<!DOCTYPE connections>
+<connections>
+<<<<<<< HEAD:testdata/test.xml
+=======
+    as
+>>>>>>> 75cb63ff7005344589b57d17338b64783f8f430c:testdata/test.xml
+   <connection>
+      <JDBC_PORT>1521</JDBC_PORT>
+      <HOSTNAME>10.248.40.111</HOSTNAME>
+      <ConnectionType>JDBC</ConnectionType>
+      <DeployPassword>false</DeployPassword>
+      <user>appsrv</user>
+      <ConnectionName>Dev-DB</ConnectionName>
+      <SID>O10gIN1</SID>
+      <JdbcDriver>oracle.jdbc.driver.OracleDriver</JdbcDriver>
+      <ORACLE_JDBC_TYPE>thin</ORACLE_JDBC_TYPE>
+   </connection>
+</connections>

Added: commons/sandbox/compress/branches/redesign/src/test/resources/test2.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/branches/redesign/src/test/resources/test2.xml?rev=674372&view=auto
==============================================================================
--- commons/sandbox/compress/branches/redesign/src/test/resources/test2.xml (added)
+++ commons/sandbox/compress/branches/redesign/src/test/resources/test2.xml Sun Jul  6 17:28:46
2008
@@ -0,0 +1,5 @@
+<?xml version = '1.0'?>
+<!DOCTYPE connections>
+<meinxml>
+	<leer />
+</meinxml>



Mime
View raw message