resources for 7z

git-svn-id: https://svn.apache.org/repos/asf/ant/antlibs/compress/trunk@1527064 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/changes.xml b/changes.xml
index 1889522..8d14d51 100644
--- a/changes.xml
+++ b/changes.xml
@@ -56,6 +56,9 @@
         Read-only support for LZMA standalone compression has been
         added.
       </action>
+      <action type="add">
+        Read-only support for file based 7z archives has been added.
+      </action>
     </release>
 
     <release version="1.2" date="2012-04-20">
diff --git a/docs/compresource.html b/docs/compresource.html
index ad30f63..0ee8f33 100644
--- a/docs/compresource.html
+++ b/docs/compresource.html
@@ -89,6 +89,8 @@
 
 <h2><a name="lzmaresource">lzmaresource</a></h2>
 
+<p><em>Since Apache Compress Antlib 1.3</em>.</p>
+
 <p>This is a <a href="#compresource">compressed resource</a> using the
   LZMA compression.</p>
 
diff --git a/docs/entry.html b/docs/entry.html
index 8138afa..a0e5dfb 100644
--- a/docs/entry.html
+++ b/docs/entry.html
@@ -76,7 +76,23 @@
 &lt;/cmp:arentry&gt;
 </pre>
 
-<p>Represents the entry named some-file.txt in archive some-archive.ar.</p>
+<h2><a name="arjentry">arjentry</a></h2>
+
+<p><em>Since Apache Compress Antlib 1.3</em>.</p>
+
+<p>An <a href="#archiveentry">archive entry</a> representing an entry
+  in a ARJ archive.</p>
+
+<h4>Examples</h4>
+
+<pre>
+&lt;cmp:arjentry xmlns:cmp="antlib:org.apache.ant.compress"
+    name="some-file.txt"&gt;
+  &lt;file file="some-archive.arj"/&gt;
+&lt;/cmp:arjentry&gt;
+</pre>
+
+<p>Represents the entry named some-file.txt in archive some-archive.arj.</p>
 
 <h2><a name="cpioentry">cpioentry</a></h2>
 
@@ -112,6 +128,24 @@
 
 <p>Represents the entry named /some-file.txt in archive some-archive.dump.</p>
 
+<h2><a name="sevenzentry">sevenzentry</a></h2>
+
+<p><em>Since Apache Compress Antlib 1.3</em>.</p>
+
+<p>An <a href="#archiveentry">archive entry</a> representing an entry
+  in a 7z archive.</p>
+
+<h4>Examples</h4>
+
+<pre>
+&lt;cmp:sevenzentry xmlns:cmp="antlib:org.apache.ant.compress"
+    name="some-file.txt"&gt;
+  &lt;file file="some-archive.7z"/&gt;
+&lt;/cmp:sevenzentry&gt;
+</pre>
+
+<p>Represents the entry named some-file.txt in archive some-archive.7z.</p>
+
 <h2><a name="tarentry">tarentry</a></h2>
 
 <p>An <a href="#archiveentry">archive entry</a> representing an entry
diff --git a/docs/fileset.html b/docs/fileset.html
index 4e9da2e..53a8d59 100644
--- a/docs/fileset.html
+++ b/docs/fileset.html
@@ -341,6 +341,13 @@
   target directory, no files get overwritten unless they are
   out-of-date.</p>
 
+<h2><a name="sevenzfileset">SevenZFileSet</a></h2>
+
+<p><em>Since Apache Compress Antlib 1.3</em>.</p>
+
+<p>A <code>&lt;sevenzfileset&gt;</code> is
+  an <a href="#archivefileset">archive fileset</a> for 7z archives.</p>
+
 <h2><a name="tarfileset">TarFileSet</a></h2>
 
 <p>A <code>&lt;tarfileset&gt;</code> is
diff --git a/src/main/org/apache/ant/compress/antlib.xml b/src/main/org/apache/ant/compress/antlib.xml
index a4c4de7..90e20c4 100644
--- a/src/main/org/apache/ant/compress/antlib.xml
+++ b/src/main/org/apache/ant/compress/antlib.xml
@@ -118,6 +118,10 @@
      classname="org.apache.ant.compress.resources.DumpResource"
      />
   <typedef
+     name="sevenzentry"
+     classname="org.apache.ant.compress.resources.SevenZResource"
+     />
+  <typedef
      name="tarentry"
      classname="org.apache.ant.compress.resources.TarResource"
      />
@@ -143,6 +147,10 @@
      classname="org.apache.ant.compress.resources.DumpFileSet"
      />
   <typedef
+     name="sevenzfileset"
+     classname="org.apache.ant.compress.resources.SevenZFileSet"
+     />
+  <typedef
      name="tarfileset"
      classname="org.apache.ant.compress.resources.TarFileSet"
      />
diff --git a/src/main/org/apache/ant/compress/resources/SevenZFileSet.java b/src/main/org/apache/ant/compress/resources/SevenZFileSet.java
new file mode 100644
index 0000000..9b5f44d
--- /dev/null
+++ b/src/main/org/apache/ant/compress/resources/SevenZFileSet.java
@@ -0,0 +1,82 @@
+/*
+ *  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.ant.compress.resources;
+
+import org.apache.tools.ant.types.ArchiveScanner;
+import org.apache.tools.ant.types.FileSet;
+
+/**
+ * A SevenZFileSet is a FileSet with extra attributes useful in the context of
+ * SevenZ tasks.
+ *
+ * A SevenZFileSet extends FileSets with the ability to extract a subset of the
+ * entries of a SevenZ file for inclusion in another SevenZ file.  It also includes
+ * a prefix attribute which is prepended to each entry in the output SevenZ file.
+ *
+ * @since Apache Compress Antlib 1.3
+ */
+public class SevenZFileSet extends CommonsCompressFileSet {
+
+    /** Constructor for SevenZFileSet */
+    public SevenZFileSet() {
+        super();
+    }
+
+    /**
+     * Constructor using a fileset argument.
+     * @param fileset the fileset to use
+     */
+    protected SevenZFileSet(FileSet fileset) {
+        super(fileset);
+    }
+
+    /**
+     * Constructor using a sevenzfileset argument.
+     * @param fileset the sevenzfileset to use
+     */
+    protected SevenZFileSet(SevenZFileSet fileset) {
+        super(fileset);
+    }
+
+    /**
+     * Constructor using a CommonsCompressFileSet argument.
+     * @param fileset the fileset to use
+     */
+    protected SevenZFileSet(CommonsCompressFileSet fileset) {
+        super(fileset);
+    }
+
+    /**
+     * Return a new archive scanner based on this one.
+     * @return a new SevenZScanner with the same encoding as this one.
+     */
+    protected ArchiveScanner newArchiveScanner() {
+        return new SevenZScanner(getSkipUnreadableEntries(), getProject());
+    }
+
+    protected CommonsCompressFileSet newFileSet(FileSet fs) {
+        if (fs instanceof SevenZFileSet) {
+            return new SevenZFileSet((SevenZFileSet) fs);
+        }
+        if (fs instanceof CommonsCompressFileSet) {
+            return new SevenZFileSet((CommonsCompressFileSet) fs);
+        }
+        return new SevenZFileSet(fs);
+    }
+
+}
diff --git a/src/main/org/apache/ant/compress/resources/SevenZResource.java b/src/main/org/apache/ant/compress/resources/SevenZResource.java
new file mode 100644
index 0000000..c5b6f08
--- /dev/null
+++ b/src/main/org/apache/ant/compress/resources/SevenZResource.java
@@ -0,0 +1,175 @@
+/*
+ *  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.ant.compress.resources;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.IOException;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Resource;
+import org.apache.tools.ant.types.resources.FileProvider;
+import org.apache.tools.ant.util.FileUtils;
+
+import org.apache.ant.compress.util.SevenZStreamFactory;
+
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
+import org.apache.commons.compress.archivers.sevenz.SevenZFile;
+
+/**
+ * A Resource representation of an entry in a sevenzfile.
+ *
+ * @since Apache Compress Antlib 1.3
+ */
+public final class SevenZResource extends CommonsCompressArchiveResource {
+
+    /**
+     * Default constructor.
+     */
+    public SevenZResource() {
+        super(new SevenZStreamFactory(), "7z");
+    }
+
+    /**
+     * Construct a SevenZResource representing the specified
+     * entry in the specified 7z file.
+     * @param z the 7z file as File.
+     * @param enc the encoding used for filenames - ignored.
+     * @param e the SevenZEntry.
+     */
+    public SevenZResource(File z, String enc, SevenZArchiveEntry e) {
+        super(new SevenZStreamFactory(), "7z", z, e);
+        setEntry(e);
+    }
+
+    /**
+     * Construct a SevenZResource representing the specified
+     * entry in the specified 7z archive.
+     * @param z the 7z archive
+     * @param enc the encoding used for filenames - ignored.
+     * @param e the SevenZEntry.
+     */
+    public SevenZResource(Resource z, String enc, SevenZArchiveEntry e) {
+        super(new SevenZStreamFactory(), "sevenz", z, e);
+        setEntry(e);
+    }
+
+    /**
+     * Set the 7z that holds this SevenZResource.
+     * @param z the 7z file as a File.
+     */
+    public void setSevenZFile(File z) {
+        setArchive(z);
+    }
+
+    /**
+     * Set the 7z file that holds this SevenZResource.
+     * @param z the 7z as a Resource.
+     */
+    public void setSevenZResource(Resource z) {
+        addConfigured(z);
+    }
+
+    /**
+     * Get the 7z file that holds this SevenZResource.
+     * @return the 7z file as a File or null if it is not a file.
+     */
+    public File getSevenZFile() {
+        FileProvider fp = (FileProvider) getArchive().as(FileProvider.class);
+        return fp != null ? fp.getFile() : null;
+    }
+
+    /**
+     * Return an InputStream for reading the contents of this Resource.
+     * @return an InputStream object.
+     * @throws IOException if the sevenz file cannot be opened,
+     *         or the entry cannot be read.
+     */
+    public InputStream getInputStream() throws IOException {
+        if (isReference()) {
+            return ((Resource) getCheckedRef()).getInputStream();
+        }
+        File f = getSevenZFile();
+        if (f == null) {
+            return super.getInputStream();
+        }
+
+        final SevenZFile z = new SevenZFile(f);
+        SevenZArchiveEntry ze = z.getNextEntry();
+        while (ze != null) {
+            if (ze.getName().equals(getName())) {
+                return new InputStream() {
+                    public int read() throws IOException {
+                        return z.read();
+                    }
+                    public int read(byte[] b) throws IOException {
+                        return z.read(b);
+                    }
+                    public void close() throws IOException {
+                        z.close();
+                    }
+                    protected void finalize() throws Throwable {
+                        try {
+                            close();
+                        } finally {
+                            super.finalize();
+                        }
+                    }
+                };
+            }
+            ze = z.getNextEntry();
+        }
+        z.close();
+        throw new BuildException("no entry " + getName() + " in "
+                                 + getArchive());
+    }
+
+    /**
+     * fetches information from the named entry inside the archive.
+     */
+    protected void fetchEntry() {
+        File f = getSevenZFile();
+        if (f == null) {
+            super.fetchEntry();
+            return;
+        }
+
+        SevenZFile z = null;
+        try {
+            z = new SevenZFile(f);
+            SevenZArchiveEntry ze = z.getNextEntry();
+            while (ze != null) {
+                if (ze.getName().equals(getName())) {
+                    setEntry(ze);
+                    return;
+                }
+                ze = z.getNextEntry();
+            }
+        } catch (IOException e) {
+            log(e.getMessage(), Project.MSG_DEBUG);
+            throw new BuildException(e);
+        } finally {
+            if (z != null) {
+                z.close();
+            }
+        }
+    }
+
+}
diff --git a/src/main/org/apache/ant/compress/resources/SevenZScanner.java b/src/main/org/apache/ant/compress/resources/SevenZScanner.java
new file mode 100644
index 0000000..8d4c269
--- /dev/null
+++ b/src/main/org/apache/ant/compress/resources/SevenZScanner.java
@@ -0,0 +1,128 @@
+/*
+ *  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.ant.compress.resources;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.ant.compress.util.SevenZStreamFactory;
+
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.ant.compress.util.Messages;
+import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
+import org.apache.commons.compress.archivers.sevenz.SevenZFile;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.Resource;
+import org.apache.tools.ant.types.resources.FileProvider;
+
+/**
+ * Scans 7z archives for resources.
+ *
+ * @since Apache Compress Antlib 1.3
+ */
+public class SevenZScanner extends CommonsCompressArchiveScanner {
+
+    public SevenZScanner() {
+        this(false, null);
+    }
+
+    public SevenZScanner(boolean skipUnreadable, Project project) {
+        super(new SevenZStreamFactory(),
+              new CommonsCompressArchiveScanner.ResourceBuilder() {
+                public Resource buildResource(Resource archive, String encoding,
+                                              ArchiveEntry entry) {
+                    return new SevenZResource(archive, encoding,
+                                              (SevenZArchiveEntry) entry);
+                }
+            }, skipUnreadable, project);
+    }
+
+    /**
+     * Fills the file and directory maps with resources read from the
+     * archive.
+     *
+     * @param src the archive to scan.
+     * @param encoding encoding used to encode file names inside the
+     * archive - ignored.
+     * @param fileEntries Map (name to resource) of non-directory
+     * resources found inside the archive.
+     * @param matchFileEntries Map (name to resource) of non-directory
+     * resources found inside the archive that matched all include
+     * patterns and didn't match any exclude patterns.
+     * @param dirEntries Map (name to resource) of directory
+     * resources found inside the archive.
+     * @param matchDirEntries Map (name to resource) of directory
+     * resources found inside the archive that matched all include
+     * patterns and didn't match any exclude patterns.
+     */
+    protected void fillMapsFromArchive(Resource src, String encoding,
+                                       Map fileEntries, Map matchFileEntries,
+                                       Map dirEntries, Map matchDirEntries) {
+
+        FileProvider fp = (FileProvider) src.as(FileProvider.class);
+        if (fp == null) {
+            super.fillMapsFromArchive(src, encoding, fileEntries,
+                                      matchFileEntries, dirEntries,
+                                      matchDirEntries);
+            return;
+        }
+
+        File srcFile = fp.getFile();
+        SevenZArchiveEntry entry = null;
+        SevenZFile zf = null;
+
+        try {
+            try {
+                zf = new SevenZFile(srcFile);
+                entry = zf.getNextEntry();
+                while (entry != null) {
+                    /* TODO implement canReadEntryData in CC
+                    if (getSkipUnreadableEntries() && !zf.canReadEntryData(entry)) {
+                        log(Messages.skippedIsUnreadable(entry));
+                        continue;
+                    }
+                    */
+                    Resource r = new SevenZResource(srcFile, encoding, entry);
+                    String name = entry.getName();
+                    if (entry.isDirectory()) {
+                        name = trimSeparator(name);
+                        dirEntries.put(name, r);
+                        if (match(name)) {
+                            matchDirEntries.put(name, r);
+                        }
+                    } else {
+                        fileEntries.put(name, r);
+                        if (match(name)) {
+                            matchFileEntries.put(name, r);
+                        }
+                    }
+                    entry = zf.getNextEntry();
+                }
+            } catch (IOException ex) {
+                throw new BuildException("Problem opening " + srcFile, ex);
+            }
+        } finally {
+            if (zf != null) {
+                zf.close();
+            }
+        }
+    }
+}
diff --git a/src/main/org/apache/ant/compress/util/EntryHelper.java b/src/main/org/apache/ant/compress/util/EntryHelper.java
index e56e85c..0e8d2e0 100644
--- a/src/main/org/apache/ant/compress/util/EntryHelper.java
+++ b/src/main/org/apache/ant/compress/util/EntryHelper.java
@@ -27,6 +27,7 @@
 import org.apache.commons.compress.archivers.arj.ArjArchiveEntry;
 import org.apache.commons.compress.archivers.cpio.CpioArchiveEntry;
 import org.apache.commons.compress.archivers.dump.DumpArchiveEntry;
+import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
 
@@ -55,6 +56,9 @@
         if (entry instanceof CpioArchiveEntry) {
             return (int) ((CpioArchiveEntry) entry).getMode();
         }
+        if (entry instanceof SevenZArchiveEntry) {
+            return UNKNOWN_ID;
+        }
         if (entry instanceof TarArchiveEntry) {
             return ((TarArchiveEntry) entry).getMode();
         }
@@ -87,6 +91,9 @@
         if (entry instanceof CpioArchiveEntry) {
             return (int) ((CpioArchiveEntry) entry).getUID();
         }
+        if (entry instanceof SevenZArchiveEntry) {
+            return UNKNOWN_ID;
+        }
         if (entry instanceof TarArchiveEntry) {
             return ((TarArchiveEntry) entry).getUserId();
         }
@@ -117,6 +124,9 @@
         if (entry instanceof CpioArchiveEntry) {
             return (int) ((CpioArchiveEntry) entry).getGID();
         }
+        if (entry instanceof SevenZArchiveEntry) {
+            return UNKNOWN_ID;
+        }
         if (entry instanceof TarArchiveEntry) {
             return ((TarArchiveEntry) entry).getGroupId();
         }
diff --git a/src/tests/antunit/sevenzentry-test.xml b/src/tests/antunit/sevenzentry-test.xml
new file mode 100644
index 0000000..e406402
--- /dev/null
+++ b/src/tests/antunit/sevenzentry-test.xml
@@ -0,0 +1,52 @@
+<?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.
+-->
+<project default="antunit"
+         xmlns:au="antlib:org.apache.ant.antunit"
+         xmlns:cond="antlib:org.apache.tools.ant.types.conditions"
+         xmlns:cmp="antlib:org.apache.ant.compress">
+
+  <import file="antunit-base.xml" />
+
+  <target name="setUp">
+    <mkdir dir="${output}"/>
+    <mkdir dir="${input}"/>
+  </target>
+
+  <target name="testFileSource" depends="setUp">
+    <copy todir="${output}">
+      <cmp:sevenzentry name="asf-logo.gif">
+        <file file="../resources/asf-logo.gif.7z"/>
+      </cmp:sevenzentry>
+    </copy>
+    <au:assertFilesMatch
+       actual="${output}/asf-logo.gif"
+       expected="../resources/asf-logo.gif"
+       />
+  </target>
+
+  <target name="testResourceProperties">
+    <au:assertTrue>
+      <cond:islastmodified datetime="2013-09-27-20:54:32"
+                           pattern="yyyy-MM-dd-HH:mm:ss">
+        <cmp:sevenzentry name="asf-logo.gif">
+          <file file="../resources/asf-logo.gif.7z"/>
+        </cmp:sevenzentry>
+      </cond:islastmodified>
+    </au:assertTrue>
+  </target>
+</project>
diff --git a/src/tests/antunit/sevenzfileset-test.xml b/src/tests/antunit/sevenzfileset-test.xml
new file mode 100644
index 0000000..965c45a
--- /dev/null
+++ b/src/tests/antunit/sevenzfileset-test.xml
@@ -0,0 +1,99 @@
+<?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.
+-->
+<project default="antunit"
+         xmlns:au="antlib:org.apache.ant.antunit"
+         xmlns:cmp="antlib:org.apache.ant.compress">
+  <import file="antunit-base.xml"/>
+
+  <target name="setUp">
+    <mkdir dir="${output}"/>
+    <mkdir dir="${input}"/>
+  </target>
+
+  <target name="test-refid-modify">
+    <fileset id="modify-refid-1"
+             dir="${basedir}"
+             includes="*.xml"
+             />
+    <cmp:sevenzfileset id="modify-refid-2"
+                refid="modify-refid-1"
+                prefix="WEB-INF/lib/"/>
+    <delete quiet="yes" dir="${build.dir}"/>
+    <mkdir dir="${output}"/>
+    <jar jarfile="${output}/jar.jar">
+      <cmp:sevenzfileset refid="modify-refid-2"/>
+    </jar>
+    <unjar src="${output}/jar.jar"
+           dest="${output}"/>
+    <au:assertTrue>
+      <available file="${output}/WEB-INF/lib/sevenzfileset-test.xml"/>
+    </au:assertTrue>
+  </target>
+
+  <target name="test-refid-check-prefix">
+    <cmp:sevenzfileset id="test-refid"
+                       dir="${basedir}"/>
+    <au:expectfailure>
+      <cmp:sevenzfileset id="ref2"
+                         refid="test-refid"
+                         prefix="WEB-INF/lib/"/>
+    </au:expectfailure>
+    <au:expectfailure>
+      <cmp:sevenzfileset id="ref3"
+                         prefix="WEB-INF/lib/"
+                         ReFiD="test-refid"/>
+    </au:expectfailure>
+  </target>
+
+  <target name="test-refid-check-encoding">
+    <cmp:sevenzfileset id="test-refid2"
+                       encoding="utf-8"
+                       dir="${basedir}"/>
+    <au:expectfailure>
+      <cmp:sevenzfileset id="ref4"
+                         encoding="utf-8"
+                         refid="test-refid2"/>
+    </au:expectfailure>
+  </target>
+
+  <target name="testMissingArchive" depends="setUp">
+    <au:expectfailure expectedMessage="The archive foo.7z doesn't exist">
+      <copy todir="${output}">
+        <cmp:sevenzfileset src="foo.7z"/>
+      </copy>
+    </au:expectfailure>
+  </target>
+
+  <target name="testMissingArchiveDoesntMatter" depends="setUp">
+    <copy todir="${output}">
+      <cmp:sevenzfileset src="foo.7z" errorOnMissingArchive="false"/>
+    </copy>
+  </target>
+
+  <target name="testSevenZSource" depends="setUp">
+    <copy todir="${output}">
+      <cmp:sevenzfileset src="../resources/asf-logo.gif.7z"
+                         includes="*.gif"/>
+    </copy>
+    <au:assertFilesMatch
+       actual="${output}/asf-logo.gif"
+       expected="../resources/asf-logo.gif"
+       />
+  </target>
+
+</project>