Author: bodewig Date: Mon Feb 16 14:19:43 2009 New Revision: 744922 URL: http://svn.apache.org/viewvc?rev=744922&view=rev Log: new testcases by Christian Grobmeier - SANDBOX-183
Added: commons/sandbox/compress/trunk/src/test/resources/test with spaces.txt (with props) commons/sandbox/compress/trunk/src/test/resources/test3.xml (with props) commons/sandbox/compress/trunk/src/test/resources/test4.xml (with props) Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java Modified: commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java?rev=744922&r1=744921&r2=744922&view=diff ============================================================================== --- commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java (original) +++ commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java Mon Feb 16 14:19:43 2009 @@ -66,7 +66,6 @@ if( change.type() == Change.TYPE_DELETE && entry.getName() != null && entry.getName().equals(change.targetFile())) { - System.out.println("Delete: " + entry.getName()); copy = false; it.remove(); break; @@ -83,7 +82,5 @@ out.putArchiveEntry(entry); IOUtils.copy(in, out); out.closeArchiveEntry(); - System.out.println("Copy: " + entry.getName()); } - } Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java?rev=744922&r1=744921&r2=744922&view=diff ============================================================================== --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java Mon Feb 16 14:19:43 2009 @@ -18,10 +18,26 @@ */ package org.apache.commons.compress; +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 java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.List; import junit.framework.TestCase; +import org.apache.commons.compress.archivers.ArchiveEntry; +import org.apache.commons.compress.archivers.ArchiveInputStream; +import org.apache.commons.compress.archivers.ArchiveOutputStream; +import org.apache.commons.compress.archivers.ArchiveStreamFactory; +import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; +import org.apache.commons.compress.utils.IOUtils; + public abstract class AbstractTestCase extends TestCase { protected File dir; @@ -30,6 +46,8 @@ dir = File.createTempFile("dir", ""); dir.delete(); dir.mkdir(); + + addURL(new File("src/test/resources").toURL()); } protected File getFile( String path ) { @@ -41,5 +59,126 @@ dir = null; } + /** + * Adds a URL to the classpath. This method is necessary when running + * junit tests from within eclipse. + * @param url the url to add + * @throws Exception if an error occurs + */ + public void addURL(URL url) throws Exception { + URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); + Class clazz = URLClassLoader.class; + + Method method= clazz.getDeclaredMethod("addURL", new Class[] { URL.class }); + method.setAccessible(true); + method.invoke(classLoader, new Object[] { url }); + } + /** + * Creates an archive of 5 textbased files in several directories. + * The archivername is the factory identifier for the archiver, for example + * zip, tar, cpio, jar, ar. + * The archive is created as a temp file. + * + * The archive contains the following files: + * <ul> + * <li>testdata/test1.xml</li> + * <li>testdata/test2.xml</li> + * <li>test/test3.xml</li> + * <li>bla/test4.xml</li> + * <li>test.txt</li> + * <li>something/bla</li> + * <li>test with spaces.txt</li> + * </ul> + * + * @param archivename the identifier of this archive + * @return the newly created file + * @throws Exception in case something goes wrong + */ + protected File createArchive(String archivename) throws Exception { + ArchiveOutputStream out = null; + ArchiveInputStream ais = null; + try { + File temp = File.createTempFile("test", "." + archivename); + + final OutputStream stream = new FileOutputStream(temp); + out = new ArchiveStreamFactory().createArchiveOutputStream(archivename, stream); + + final File file1 = getFile("test1.xml"); + final File file2 = getFile("test2.xml"); + final File file3 = getFile("test3.xml"); + final File file4 = getFile("test4.xml"); + final File file5 = getFile("test.txt"); + final File file6 = getFile("test with spaces.txt"); + + ZipArchiveEntry entry = new ZipArchiveEntry("testdata/test1.xml"); + entry.setSize(file1.length()); + out.putArchiveEntry(entry); + IOUtils.copy(new FileInputStream(file1), out); + out.closeArchiveEntry(); + + out.putArchiveEntry(new ZipArchiveEntry("testdata/test2.xml")); + IOUtils.copy(new FileInputStream(file2), out); + out.closeArchiveEntry(); + + out.putArchiveEntry(new ZipArchiveEntry("test/test3.xml")); + IOUtils.copy(new FileInputStream(file3), out); + out.closeArchiveEntry(); + + out.putArchiveEntry(new ZipArchiveEntry("bla/test4.xml")); + IOUtils.copy(new FileInputStream(file4), out); + out.closeArchiveEntry(); + + out.putArchiveEntry(new ZipArchiveEntry("test.txt")); + IOUtils.copy(new FileInputStream(file5), out); + out.closeArchiveEntry(); + + out.putArchiveEntry(new ZipArchiveEntry("something/bla")); + IOUtils.copy(new FileInputStream(file6), out); + out.closeArchiveEntry(); + + out.putArchiveEntry(new ZipArchiveEntry("test with spaces.txt")); + IOUtils.copy(new FileInputStream(file6), out); + out.closeArchiveEntry(); + + return temp; + } finally { + if(out != null) out.close(); + if(ais != null) ais.close(); + } + } + + /** + * Checks if an archive contains all expected files. + * + * @param archive + * the archive to check + * @param expected + * a list with expected string filenames + * @throws Exception + */ + protected void checkArchiveContent(File archive, List expected) + throws Exception { + final InputStream is = new FileInputStream(archive); + final BufferedInputStream buf = new BufferedInputStream(is); + final ArchiveInputStream in = new ArchiveStreamFactory().createArchiveInputStream(buf); + + File result = File.createTempFile("dir-result", ""); + result.delete(); + result.mkdir(); + + ArchiveEntry entry = null; + while((entry = (ArchiveEntry)in.getNextEntry()) != null) { + File outfile = new File(result.getCanonicalPath() + "/result/" + entry.getName()); + outfile.getParentFile().mkdirs(); + OutputStream out = new FileOutputStream(outfile); + if(!expected.remove(entry.getName())) { + fail("unexpected entry: " + entry.getName()); + } + IOUtils.copy(in, out); + out.close(); + } + in.close(); + assertEquals(expected.size(), 0); + } } Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java?rev=744922&r1=744921&r2=744922&view=diff ============================================================================== --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java Mon Feb 16 14:19:43 2009 @@ -32,7 +32,7 @@ import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; -public final class DetectArchiverTestCase extends TestCase { +public final class DetectArchiverTestCase extends AbstractTestCase { public void testDetection() throws Exception { final ArchiveStreamFactory factory = new ArchiveStreamFactory(); Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java?rev=744922&r1=744921&r2=744922&view=diff ============================================================================== --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java Mon Feb 16 14:19:43 2009 @@ -23,48 +23,81 @@ import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; +import org.apache.commons.compress.AbstractTestCase; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.utils.IOUtils; -import org.apache.commons.compress.AbstractTestCase; - public final class ZipTestCase extends AbstractTestCase { + /** + * Archives 2 files and unarchives it again. If the file length of result + * and source is the same, it looks like the operations have worked + * @throws Exception + */ public void testZipArchiveCreation() throws Exception { - + // Archive final File output = new File(dir, "bla.zip"); - final File file1 = getFile("test1.xml"); final File file2 = getFile("test2.xml"); - - 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(); + { + 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(); + } + + // Unarchive the same + List results = new ArrayList(); + + { + final InputStream is = new FileInputStream(output); + final ArchiveInputStream in = new ArchiveStreamFactory().createArchiveInputStream("zip", is); + + File result = File.createTempFile("dir-result", ""); + result.delete(); + result.mkdir(); + + ZipArchiveEntry entry = null; + while((entry = (ZipArchiveEntry)in.getNextEntry()) != null) { + File outfile = new File(result.getCanonicalPath() + "/result/" + entry.getName()); + outfile.getParentFile().mkdirs(); + OutputStream out = new FileOutputStream(outfile); + IOUtils.copy(in, out); + out.close(); + results.add(outfile); + } + in.close(); + } - os.close(); + assertEquals(results.size(), 2); + File result = (File)results.get(0); + assertEquals(file1.length(), result.length()); + result = (File)results.get(1); + assertEquals(file2.length(), result.length()); } + + /** + * Simple unarchive test. Asserts nothing. + * @throws Exception + */ public void testZipUnarchive() throws Exception { - final File input = getFile("bla.zip"); - 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(); } - } Modified: commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java?rev=744922&r1=744921&r2=744922&view=diff ============================================================================== --- commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java (original) +++ commons/sandbox/compress/trunk/src/test/java/org/apache/commons/compress/changes/ChangeSetTestCase.java Mon Feb 16 14:19:43 2009 @@ -22,8 +22,11 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; import org.apache.commons.compress.AbstractTestCase; +import org.apache.commons.compress.archivers.ArchiveEntry; import org.apache.commons.compress.archivers.ArchiveInputStream; import org.apache.commons.compress.archivers.ArchiveOutputStream; import org.apache.commons.compress.archivers.ArchiveStreamFactory; @@ -32,8 +35,237 @@ import org.apache.commons.compress.archivers.tar.TarArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; +/** + * Checks several ChangeSet business logics. + */ public final class ChangeSetTestCase extends AbstractTestCase { + /** + * Tries to delete the folder "bla" from a zip file. + * This should result in the deletion of bla/*, which + * actually means bla/test4.xml should be removed from this zipfile. + * The file something/bla (without ending, named like the folder) should + * not be deleted. + * + * @throws Exception + */ + public void XtestDeleteDir() throws Exception { + File input = this.createArchive("zip"); + + ArchiveOutputStream out = null; + ArchiveInputStream ais = null; + File result = File.createTempFile("test", ".zip"); + try { + + final InputStream is = new FileInputStream(input); + ais = new ArchiveStreamFactory().createArchiveInputStream("zip", is); + + out = new ArchiveStreamFactory().createArchiveOutputStream("zip", new FileOutputStream(result)); + + ChangeSet changes = new ChangeSet(); + changes.delete("bla"); + changes.perform(ais, out); + + } finally { + if(out != null) out.close(); + if(ais != null) ais.close(); + } + + List expected = new ArrayList(); + expected.add("testdata/test1.xml"); + expected.add("testdata/test2.xml"); + expected.add("test/test3.xml"); + expected.add("test.txt"); + expected.add("something/bla"); + expected.add("test with spaces.txt"); + + this.checkArchiveContent(result, expected); + } + + /** + * Tries to delete a directory with a file and adds + * a new directory with a new file and with the same name. + * Should delete dir1/* and add dir1/test.txt at the end + * + * @throws Exception + */ + public void XtestDeletePlusAdd() throws Exception { + File input = this.createArchive("zip"); + + ArchiveOutputStream out = null; + ArchiveInputStream ais = null; + File result = File.createTempFile("test", ".zip"); + try { + + final InputStream is = new FileInputStream(input); + ais = new ArchiveStreamFactory().createArchiveInputStream("zip", is); + out = new ArchiveStreamFactory().createArchiveOutputStream("zip", new FileOutputStream(result)); + + ChangeSet changes = new ChangeSet(); + changes.delete("bla"); + + // Add a file + final File file1 = getFile("test.txt"); + ArchiveEntry entry = new ZipArchiveEntry("bla/test.txt"); + changes.add(entry, new FileInputStream(file1)); + + changes.perform(ais, out); + + } finally { + if(out != null) out.close(); + if(ais != null) ais.close(); + } + + List expected = new ArrayList(); + expected.add("testdata/test1.xml"); + expected.add("testdata/test2.xml"); + expected.add("test/test3.xml"); + expected.add("test.txt"); + expected.add("something/bla"); + expected.add("bla/test.txt"); + expected.add("test with spaces.txt"); + + this.checkArchiveContent(result, expected); + } + + /** + * Adds a file to a zip archive. Deletes an other file. + * @throws Exception + */ + public void testDeleteFromAndAddToZip() throws Exception { + File input = this.createArchive("zip"); + + ArchiveOutputStream out = null; + ArchiveInputStream ais = null; + File result = File.createTempFile("test", ".zip"); + try { + + final InputStream is = new FileInputStream(input); + ais = new ArchiveStreamFactory().createArchiveInputStream("zip", is); + out = new ArchiveStreamFactory().createArchiveOutputStream("zip", new FileOutputStream(result)); + ChangeSet changes = new ChangeSet(); + + final File file1 = getFile("test.txt"); + ArchiveEntry entry = new ZipArchiveEntry("blub/test.txt"); + changes.add(entry, new FileInputStream(file1)); + + changes.delete("testdata/test1.xml"); + + changes.perform(ais, out); + + } finally { + if(out != null) out.close(); + if(ais != null) ais.close(); + } + + List expected = new ArrayList(); + expected.add("testdata/test2.xml"); + expected.add("test/test3.xml"); + expected.add("blub/test.txt"); + expected.add("test.txt"); + expected.add("something/bla"); + expected.add("bla/test4.xml"); + expected.add("test with spaces.txt"); + + this.checkArchiveContent(result, expected); + } + + /** + * add blub/test.txt + delete blub + * Should add dir1/test.txt and delete it afterwards. In this example, + * the zip archive should stay untouched. + * @throws Exception + */ + public void XtestAddDeleteAdd() throws Exception { + File input = this.createArchive("zip"); + + ArchiveOutputStream out = null; + ArchiveInputStream ais = null; + File result = File.createTempFile("test", ".zip"); + try { + + final InputStream is = new FileInputStream(input); + ais = new ArchiveStreamFactory().createArchiveInputStream("zip", is); + out = new ArchiveStreamFactory().createArchiveOutputStream("zip", new FileOutputStream(result)); + + ChangeSet changes = new ChangeSet(); + + final File file1 = getFile("test.txt"); + ArchiveEntry entry = new ZipArchiveEntry("blub/test.txt"); + changes.add(entry, new FileInputStream(file1)); + + changes.delete("blub"); + + changes.perform(ais, out); + + } finally { + if(out != null) out.close(); + if(ais != null) ais.close(); + } + + List expected = new ArrayList(); + expected.add("testdata/test1.xml"); + expected.add("testdata/test2.xml"); + expected.add("test/test3.xml"); + expected.add("test.txt"); + expected.add("something/bla"); + expected.add("bla/test4.xml"); + expected.add("test with spaces.txt"); + + this.checkArchiveContent(result, expected); + } + + + /** + * delete bla + add bla/test.txt + delete bla + * Deletes dir1/* first, then surpresses the add of bla.txt cause there + * is a delete operation later. + * @throws Exception + */ + public void XtestDeleteAddDelete() throws Exception { + File input = this.createArchive("zip"); + + ArchiveOutputStream out = null; + ArchiveInputStream ais = null; + File result = File.createTempFile("test", ".zip"); + try { + + final InputStream is = new FileInputStream(input); + ais = new ArchiveStreamFactory().createArchiveInputStream("zip", is); + out = new ArchiveStreamFactory().createArchiveOutputStream("zip", new FileOutputStream(result)); + + ChangeSet changes = new ChangeSet(); + + changes.delete("bla"); + + final File file1 = getFile("test.txt"); + ArchiveEntry entry = new ZipArchiveEntry("bla/test.txt"); + changes.add(entry, new FileInputStream(file1)); + + changes.delete("bla"); + + changes.perform(ais, out); + + } finally { + if(out != null) out.close(); + if(ais != null) ais.close(); + } + + List expected = new ArrayList(); + expected.add("testdata/test1.xml"); + expected.add("testdata/test2.xml"); + expected.add("test/test3.xml"); + expected.add("test.txt"); + expected.add("something/bla"); + expected.add("test with spaces.txt"); + + this.checkArchiveContent(result, expected); + } + + /** + * Simple Delete from a zip file. + * @throws Exception + */ public void testDeleteFromZip() throws Exception { ArchiveOutputStream out = null; ArchiveInputStream ais = null; @@ -47,15 +279,19 @@ File temp = File.createTempFile("test", ".zip"); out = new ArchiveStreamFactory().createArchiveOutputStream("zip", new FileOutputStream(temp)); - - System.out.println(temp.getAbsolutePath()); + changes.perform(ais, out); } finally { if(out != null) out.close(); if(ais != null) ais.close(); } + // TODO add asserts } - + + /** + * Simple delete from a tar file + * @throws Exception + */ public void testDeleteFromTar() throws Exception { ArchiveOutputStream out = null; ArchiveInputStream ais = null; @@ -69,15 +305,19 @@ File temp = new File(dir, "bla.tar"); out = new ArchiveStreamFactory().createArchiveOutputStream("tar", new FileOutputStream(temp)); - - System.out.println(temp.getAbsolutePath()); + changes.perform(ais, out); } finally { if(out != null) out.close(); if(ais != null) ais.close(); } + // TODO add asserts } + /** + * Simple delete from a jar file + * @throws Exception + */ public void testDeleteFromJar() throws Exception { ArchiveOutputStream out = null; ArchiveInputStream ais = null; @@ -92,15 +332,19 @@ File temp = new File(dir, "bla.jar"); out = new ArchiveStreamFactory().createArchiveOutputStream("jar", new FileOutputStream(temp)); - - System.out.println(temp.getAbsolutePath()); + changes.perform(ais, out); } finally { if(out != null) out.close(); if(ais != null) ais.close(); } + // TODO add asserts } - + + /** + * Simple delete from an ar file + * @throws Exception + */ public void testDeleteFromAr() throws Exception { ArchiveOutputStream out = null; ArchiveInputStream ais = null; @@ -114,40 +358,13 @@ File temp = new File(dir, "bla.ar"); out = new ArchiveStreamFactory().createArchiveOutputStream("ar", new FileOutputStream(temp)); - - System.out.println(temp.getAbsolutePath()); - changes.perform(ais, out); - } finally { - if(out != null) out.close(); - if(ais != null) ais.close(); - } - } - - public void testDeleteFromAndAddToZip() throws Exception { - ArchiveOutputStream out = null; - ArchiveInputStream ais = null; - try { - ChangeSet changes = new ChangeSet(); - changes.delete("test2.xml"); - - - final File file1 = getFile("test.txt"); - ZipArchiveEntry entry = new ZipArchiveEntry("testdata/test.txt"); - changes.add(entry, new FileInputStream(file1)); - - final File input = getFile("bla.zip"); - final InputStream is = new FileInputStream(input); - ais = new ArchiveStreamFactory().createArchiveInputStream("zip", is); - - File temp = new File(dir, "bla.zip"); - out = new ArchiveStreamFactory().createArchiveOutputStream("zip", new FileOutputStream(temp)); - - System.out.println(temp.getAbsolutePath()); + changes.perform(ais, out); } finally { if(out != null) out.close(); if(ais != null) ais.close(); } + // TODO add asserts } public void testDeleteFromAndAddToTar() throws Exception { @@ -157,7 +374,6 @@ ChangeSet changes = new ChangeSet(); changes.delete("test2.xml"); - final File file1 = getFile("test.txt"); final TarArchiveEntry entry = new TarArchiveEntry("testdata/test.txt"); @@ -177,15 +393,19 @@ File temp = new File(dir, "bla.tar"); out = new ArchiveStreamFactory().createArchiveOutputStream("tar", new FileOutputStream(temp)); - - System.out.println(temp.getAbsolutePath()); + changes.perform(ais, out); } finally { if(out != null) out.close(); if(ais != null) ais.close(); } + // TODO add asserts } + /** + * Delete from a jar file and add another file + * @throws Exception + */ public void testDeleteFromAndAddToJar() throws Exception { ArchiveOutputStream out = null; ArchiveInputStream ais = null; @@ -203,15 +423,19 @@ File temp = new File(dir, "bla.jar"); out = new ArchiveStreamFactory().createArchiveOutputStream("jar", new FileOutputStream(temp)); - - System.out.println(temp.getAbsolutePath()); + changes.perform(ais, out); } finally { if(out != null) out.close(); if(ais != null) ais.close(); } + // TODO add asserts } - + + /** + * Deletes a file from an AR-archive and adds another + * @throws Exception + */ public void testDeleteFromAndAddToAr() throws Exception { ArchiveOutputStream out = null; ArchiveInputStream ais = null; @@ -231,12 +455,35 @@ File temp = new File(dir, "bla.ar"); out = new ArchiveStreamFactory().createArchiveOutputStream("ar", new FileOutputStream(temp)); - - System.out.println(temp.getAbsolutePath()); + changes.perform(ais, out); } finally { if(out != null) out.close(); if(ais != null) ais.close(); } + // TODO add asserts + } + + /** + * TODO: Move operations are not supported currently + * + * mv dir1/test.text dir2/test.txt + delete dir1 + * Moves the file to dir2 and deletes everything in dir1 + * @throws Exception + */ + public void testRenameAndDelete() throws Exception { + } + + /** + * TODO: Move operations are not supported currently + * + * add dir1/bla.txt + mv dir1/test.text dir2/test.txt + delete dir1 + * + * Add dir1/bla.txt should be surpressed. All other dir1 files will be + * deleted, except dir1/test.text will be moved + * + * @throws Exception + */ + public void testAddMoveDelete() throws Exception { } } Added: commons/sandbox/compress/trunk/src/test/resources/test with spaces.txt URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/resources/test%20with%20spaces.txt?rev=744922&view=auto ============================================================================== --- commons/sandbox/compress/trunk/src/test/resources/test with spaces.txt (added) +++ commons/sandbox/compress/trunk/src/test/resources/test with spaces.txt Mon Feb 16 14:19:43 2009 @@ -0,0 +1,11 @@ +TEST WITH SPACES IN FILENAME +111111111111111111111111111000101011 +111111111111111111111111111000101011 +111111111111111111111111111000101011 +111111111111111111111111111000101011 +111111111111111111111111111000101011 +111111111111111111111111111000101011 +111111111111111111111111111000101011 +111111111111111111111111111000101011 +111111111111111111111111111000101011 +111111111111111111111111111000101011 \ No newline at end of file Propchange: commons/sandbox/compress/trunk/src/test/resources/test with spaces.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/compress/trunk/src/test/resources/test3.xml URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/resources/test3.xml?rev=744922&view=auto ============================================================================== --- commons/sandbox/compress/trunk/src/test/resources/test3.xml (added) +++ commons/sandbox/compress/trunk/src/test/resources/test3.xml Mon Feb 16 14:19:43 2009 @@ -0,0 +1,10 @@ +<?xml version = '1.0'?> +<!DOCTYPE connections> +<text> +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, +sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, +sed diam voluptua. +At vero eos et accusam et justo duo dolores et ea rebum. +Stet clita kasd gubergren, no sea takimata sanctus est +Lorem ipsum dolor sit amet. +</text> Propchange: commons/sandbox/compress/trunk/src/test/resources/test3.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/compress/trunk/src/test/resources/test4.xml URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/test/resources/test4.xml?rev=744922&view=auto ============================================================================== --- commons/sandbox/compress/trunk/src/test/resources/test4.xml (added) +++ commons/sandbox/compress/trunk/src/test/resources/test4.xml Mon Feb 16 14:19:43 2009 @@ -0,0 +1,6 @@ +<?xml version = '1.0'?> +<!DOCTYPE connections> +<connections> +German Umlauts: ÃÃÃÃ +Stored as UTF-8 (Mac OSX 10.4.x) +</connections> Propchange: commons/sandbox/compress/trunk/src/test/resources/test4.xml ------------------------------------------------------------------------------ svn:eol-style = native