add LZ4 support
diff --git a/changes.xml b/changes.xml
index 014c051..085cbcd 100644
--- a/changes.xml
+++ b/changes.xml
@@ -40,7 +40,7 @@
<release version="1.5" date="unreleased">
<action type="update" breaks-bwc="true">
The Apache Compress Antlib now requires Apache Commons
- Compress 1.14 or later for 7z, DEFLATE and write support
+ Compress 1.14 or later for 7z, DEFLATE, LZ4 and write support
for LZMA and Snappy.
XZ for Java 1.6 is required for write support for LZMA.
</action>
@@ -66,6 +66,9 @@
<action type="add">
Added write support for the Snappy format.
</action>
+ <action type="add">
+ Added support for the LZ4 format.
+ </action>
</release>
<release version="1.4" date="2014-01-29">
diff --git a/docs/compresource.html b/docs/compresource.html
index 50dc979..3091c72 100644
--- a/docs/compresource.html
+++ b/docs/compresource.html
@@ -33,7 +33,7 @@
<a name="decompressConcatenated">
<p>Resources for the formats that support files holding multiple
- compressed streams (bzip2, gzip and xz) support a boolean attribute
+ compressed streams (bzip2, gzip, lz4 and xz) support a boolean attribute
decompressConcatenated. If set to true all streams will be
concatenated and treated as a single resource. With the default
value false only the first stream is uncompressed.</p>
@@ -111,6 +111,50 @@
some-archive.tar.gz where the <code>gzipresource</code> provides
the decompression of the archive.</p>
+<h2><a name="lz4resource">lz4resource</a></h2>
+
+<p><em>Since Apache Compress Antlib 1.5</em>.</p>
+
+<p>This is a <a href="#compresource">compressed resource</a> using the
+ LZ4 compression.</p>
+
+<p>This resource supports
+ the <a href="#decompressConcatenated">decompressConcatenated</a>
+ attribute if the frame format is used.</p>
+
+<h4>Parameters</h4>
+ <p>In addition to the attributes supported by all uncompressing resources
+ this resource also supports.</p>
+ <table border="1" cellpadding="2" cellspacing="0">
+ <tr>
+ <td valign="top"><b>Attribute</b></td>
+ <td valign="top"><b>Description</b></td>
+ <td align="center" valign="top"><b>Required</b></td>
+ </tr>
+ <tr>
+ <td valign="top">framed</td>
+ <td valign="top">Whether the input is expected to use
+ the <a href="http://lz4.github.io/lz4/lz4_Frame_format.html">frame
+ format</a>.</td>
+ <td align="center" valign="top">No, defaults to true.</td>
+ </tr>
+ </table>
+
+<h4>Examples</h4>
+
+<pre>
+<cmp:tarentry xmlns:cmp="antlib:org.apache.ant.compress"
+ name="some-file.txt">
+ <cmp:lz4resource>
+ <file file="some-archive.tar.lz4"/>
+ </cmp:lz4resource>
+</cmp:tarentry>
+</pre>
+
+<p>Represents the entry named some-file.txt in archive
+ some-archive.tar.lz4 where the <code>lz4resource</code> provides
+ the decompression of the archive.</p>
+
<h2><a name="lzmaresource">lzmaresource</a></h2>
<p><em>Since Apache Compress Antlib 1.3</em>.</p>
diff --git a/docs/index.html b/docs/index.html
index f7e2c4b..c249f43 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -28,10 +28,10 @@
<p>This Antlib contains tasks and resources that provide
compression/uncompression and archival/unarchival capabilities
based on <a href="http://commons.apache.org/compress/">Apache
- Commons Compress</a>. Using Apache Commons Compress 1.13 this
- Antlib supports gzip, bzip2, lzma standalone, xz, .Z, DEFLATE, Snappy and
- pack200 compression and ar, arj, cpio, 7z, Unix dump, tar and
- zip archives. Support for arj, .Z and dump is
+ Commons Compress</a>. Using Apache Commons Compress 1.14 this
+ Antlib supports gzip, bzip2, lzma standalone, xz, .Z, DEFLATE,
+ Snappy, LZ4 and pack200 compression and ar, arj, cpio, 7z, Unix
+ dump, tar and zip archives. Support for arj, .Z and dump is
read-only. 7z can only be used on filesystem resources.</p>
<h3>Known Limitations</h3>
@@ -52,6 +52,7 @@
<li><a href="pack.html#deflate">deflate</a></li>
<li><a href="unpack.html#gunzip">gunzip</a></li>
<li><a href="pack.html#gzip">gzip</a></li>
+ <li><a href="pack.html#lz4">lz4</a></li>
<li><a href="pack.html#lzma">lzma</a></li>
<li><a href="pack.html#pack200">pack200</a></li>
<li><a href="pack200normalize.html">pack200normalize</a></li>
@@ -64,6 +65,7 @@
<li><a href="expand.html#uncpio">uncpio</a></li>
<li><a href="unpack.html#undeflate">undeflate</a></li>
<li><a href="expand.html#undump">undump</a></li>
+ <li><a href="unpack.html#unlz4">unlz4</a></li>
<li><a href="unpack.html#unlzma">unlzma</a></li>
<li><a href="unpack.html#unpack200">unpack200</a></li>
<li><a href="unpack.html#unsnappy">unsnappy</a></li>
@@ -90,6 +92,7 @@
<li><a href="entry.html#dumpentry">dumpentry</a></li>
<li><a href="fileset.html#dumpfileset">dumpfileset</a></li>
<li><a href="compresource.html#gzipresource">gzipresource</a></li>
+ <li><a href="compresource.html#lz4resource">lz4resource</a></li>
<li><a href="compresource.html#lzmaresource">lzmaresource</a></li>
<li><a href="compresource.html#pack200resource">pack200resource</a></li>
<li><a href="compresource.html#snappyresource">snappyresource</a></li>
diff --git a/docs/pack.html b/docs/pack.html
index 39e9b10..2383102 100644
--- a/docs/pack.html
+++ b/docs/pack.html
@@ -151,6 +151,33 @@
</tr>
</table>
+ <h3><a name="lz4">LZ4</a></h3>
+
+ <p>Is a <a href="#pack">compressing task</a> that uses
+ the <a href="http://lz4.github.io/lz4/">LZ4</a> compression
+ algorithm.</p>
+
+ <p><em>Since Compress Antlib 1.5</em>
+
+ <h4>Parameters</h4>
+ <p>In addition to the attributes supported by all compressing task
+ this task also supports.</p>
+ <table border="1" cellpadding="2" cellspacing="0">
+ <tr>
+ <td valign="top"><b>Attribute</b></td>
+ <td valign="top"><b>Description</b></td>
+ <td align="center" valign="top"><b>Required</b></td>
+ </tr>
+ <tr>
+ <td valign="top">framed</td>
+ <td valign="top">Whether to use
+ the <a href="http://lz4.github.io/lz4/lz4_Frame_format.html">frame
+ format</a>.
+ </td>
+ <td align="center" valign="top">No, defaults to true.</td>
+ </tr>
+ </table>
+
<h3><a name="lzma">LZMA</a></h3>
<p>Is a <a href="#pack">compressing task</a> that uses the LZMA
diff --git a/docs/unpack.html b/docs/unpack.html
index 2b96a70..e36d97d 100644
--- a/docs/unpack.html
+++ b/docs/unpack.html
@@ -117,7 +117,36 @@
</tr>
</table>
-<h3><a name="unlzma">UnLZMA</a></h3>
+<h3><a name="unlz4">UnLZ4</a></h3>
+
+<p>Is an <a href="#unpack">uncompressing task</a> that uses the LZ4
+ compression algorithm.</p>
+
+<p><em>Since Apache Compress Antlib 1.5</em>.</p>
+
+<p>This task supports
+ the <a href="#decompressConcatenated">decompressConcatenated</a>
+ attribute if the frame format is used.</p>
+
+<h4>Parameters</h4>
+ <p>In addition to the attributes supported by all uncompressing task
+ this task also supports.</p>
+ <table border="1" cellpadding="2" cellspacing="0">
+ <tr>
+ <td valign="top"><b>Attribute</b></td>
+ <td valign="top"><b>Description</b></td>
+ <td align="center" valign="top"><b>Required</b></td>
+ </tr>
+ <tr>
+ <td valign="top">framed</td>
+ <td valign="top">Whether the input is expected to use
+ the <a href="http://lz4.github.io/lz4/lz4_Frame_format.html">frame
+ format</a>.</td>
+ <td align="center" valign="top">No, defaults to true.</td>
+ </tr>
+ </table>
+
+ <h3><a name="unlzma">UnLZMA</a></h3>
<p>Is an <a href="#unpack">uncompressing task</a> that uses the LZMA
compression algorithm.</p>
diff --git a/ivy.xml b/ivy.xml
index 65bf92b..4eadc03 100644
--- a/ivy.xml
+++ b/ivy.xml
@@ -29,7 +29,7 @@
<description homepage="http://ant.apache.org/antlibs/compress/">
Provides tasks and types that deal with AR, ARJ, CPIO, TAR,
DUMP, 7Z and ZIP archives as well as BZIP2, PACK200, GZIP, LZMA,
- Snappy and XZ compressed files based on Apache Commons Compress.
+ Snappy, LZ4 and XZ compressed files based on Apache Commons Compress.
</description>
</info>
<configurations>
diff --git a/src/main/org/apache/ant/compress/antlib.xml b/src/main/org/apache/ant/compress/antlib.xml
index 8f4ea91..00b762a 100644
--- a/src/main/org/apache/ant/compress/antlib.xml
+++ b/src/main/org/apache/ant/compress/antlib.xml
@@ -73,6 +73,10 @@
classname="org.apache.ant.compress.taskdefs.GUnzip"
/>
<taskdef
+ name="unlz4"
+ classname="org.apache.ant.compress.taskdefs.UnLZ4"
+ />
+ <taskdef
name="unlzma"
classname="org.apache.ant.compress.taskdefs.UnLZMA"
/>
@@ -125,6 +129,10 @@
classname="org.apache.ant.compress.taskdefs.XZ"
/>
<taskdef
+ name="lz4"
+ classname="org.apache.ant.compress.taskdefs.LZ4"
+ />
+ <taskdef
name="lzma"
classname="org.apache.ant.compress.taskdefs.LZMA"
/>
@@ -203,6 +211,10 @@
classname="org.apache.ant.compress.resources.GZipResource"
/>
<typedef
+ name="lz4resource"
+ classname="org.apache.ant.compress.resources.LZ4Resource"
+ />
+ <typedef
name="lzmaresource"
classname="org.apache.ant.compress.resources.LZMAResource"
/>
diff --git a/src/main/org/apache/ant/compress/resources/LZ4Resource.java b/src/main/org/apache/ant/compress/resources/LZ4Resource.java
new file mode 100644
index 0000000..bcdedd0
--- /dev/null
+++ b/src/main/org/apache/ant/compress/resources/LZ4Resource.java
@@ -0,0 +1,50 @@
+/*
+ * 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.ant.compress.util.LZ4StreamFactory;
+import org.apache.tools.ant.types.ResourceCollection;
+
+/**
+ * An LZ4 compressed resource.
+ * @since Apache Compress Antlib 1.5
+ */
+public final class LZ4Resource extends CommonsCompressCompressorResource {
+ private static final String NAME = "LZ4";
+
+ private final LZ4StreamFactory factory;
+
+ public LZ4Resource() {
+ super(NAME);
+ setFactory(factory = new LZ4StreamFactory());
+ }
+
+ public LZ4Resource(ResourceCollection other) {
+ super(NAME, other);
+ setFactory(factory = new LZ4StreamFactory());
+ }
+
+ /**
+ * Whether to use the "frame format".
+ *
+ * <p>Defaults to true.</p>
+ */
+ public void setFramed(boolean framed) {
+ factory.setFramed(framed);
+ }
+}
diff --git a/src/main/org/apache/ant/compress/taskdefs/LZ4.java b/src/main/org/apache/ant/compress/taskdefs/LZ4.java
new file mode 100644
index 0000000..763d700
--- /dev/null
+++ b/src/main/org/apache/ant/compress/taskdefs/LZ4.java
@@ -0,0 +1,56 @@
+/*
+ * 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.taskdefs;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.ant.compress.resources.LZ4Resource;
+import org.apache.ant.compress.resources.CommonsCompressCompressorResource;
+import org.apache.ant.compress.util.LZ4StreamFactory;
+import org.apache.tools.ant.types.Resource;
+
+/**
+ * Compresses using LZ4.
+ * @since Apache Compress Antlib 1.5
+ */
+public final class LZ4 extends PackBase {
+
+ private final LZ4StreamFactory factory;
+
+ public LZ4() {
+ super(new PackBase.ResourceWrapper() {
+ @Override
+ public CommonsCompressCompressorResource wrap(Resource dest) {
+ return new LZ4Resource(dest);
+ }
+ });
+ setFactory(factory = new LZ4StreamFactory());
+ }
+
+ /**
+ * Whether to use the "frame format".
+ *
+ * <p>Defaults to true.</p>
+ */
+ public void setFramed(boolean framed) {
+ factory.setFramed(framed);
+ }
+
+}
diff --git a/src/main/org/apache/ant/compress/taskdefs/UnLZ4.java b/src/main/org/apache/ant/compress/taskdefs/UnLZ4.java
new file mode 100644
index 0000000..079280b
--- /dev/null
+++ b/src/main/org/apache/ant/compress/taskdefs/UnLZ4.java
@@ -0,0 +1,45 @@
+/*
+ * 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.taskdefs;
+
+import org.apache.ant.compress.util.LZ4StreamFactory;
+
+/**
+ * Expands an LZ4 archive.
+ * @since Apache Compress Antlib 1.5
+ */
+public final class UnLZ4 extends UnpackBase {
+
+ private final LZ4StreamFactory factory;
+
+ public UnLZ4() {
+ super(".lz4");
+ setFactory(factory = new LZ4StreamFactory());
+ }
+
+ /**
+ * Whether to use the "frame format".
+ *
+ * <p>Defaults to true.</p>
+ */
+ public void setFramed(boolean framed) {
+ factory.setFramed(framed);
+ }
+
+}
diff --git a/src/main/org/apache/ant/compress/util/LZ4StreamFactory.java b/src/main/org/apache/ant/compress/util/LZ4StreamFactory.java
new file mode 100644
index 0000000..59fb360
--- /dev/null
+++ b/src/main/org/apache/ant/compress/util/LZ4StreamFactory.java
@@ -0,0 +1,95 @@
+/*
+ * 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.util;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.commons.compress.compressors.CompressorInputStream;
+import org.apache.commons.compress.compressors.CompressorOutputStream;
+import org.apache.commons.compress.compressors.lz4.BlockLZ4CompressorInputStream;
+import org.apache.commons.compress.compressors.lz4.BlockLZ4CompressorOutputStream;
+import org.apache.commons.compress.compressors.lz4.FramedLZ4CompressorInputStream;
+import org.apache.commons.compress.compressors.lz4.FramedLZ4CompressorOutputStream;
+
+/**
+ * Creates streams for LZ4 format.
+ * @since Apache Compress Antlib 1.5
+ * @see <a href="http://lz4.github.io/lz4/">LZ4 Project</a>
+ */
+public class LZ4StreamFactory implements CompressorWithConcatenatedStreamsFactory {
+
+ private boolean framed = true;
+
+ /**
+ * Whether to use the "frame format".
+ *
+ * <p>Defaults to true.</p>
+ */
+ public void setFramed(boolean framed) {
+ this.framed = framed;
+ }
+
+ /**
+ * Whether to use the "frame format".
+ */
+ protected boolean isFramed() {
+ return framed;
+ }
+
+ /**
+ * @param stream the stream to read from, should be buffered
+ */
+ @Override
+ public CompressorInputStream getCompressorStream(InputStream stream)
+ throws IOException {
+ return framed ? new FramedLZ4CompressorInputStream(stream)
+ : (CompressorInputStream) new BlockLZ4CompressorInputStream(stream);
+ }
+
+ /**
+ * @param stream the stream to read from, should be buffered
+ * @param decompressConcatenated
+ * if true, decompress until the end of the
+ * input; if false, stop after the first
+ * stream
+ */
+ @Override
+ public CompressorInputStream getCompressorStream(InputStream stream,
+ boolean decompressConcatenated)
+ throws IOException {
+ if (!framed && decompressConcatenated) {
+ throw new UnsupportedOperationException("only the frame format supports"
+ + " concatenated streams");
+ }
+ return framed ? new FramedLZ4CompressorInputStream(stream, decompressConcatenated)
+ : (CompressorInputStream) new BlockLZ4CompressorInputStream(stream);
+ }
+
+ /**
+ * @param stream the stream to write to, should be buffered
+ */
+ @Override
+ public CompressorOutputStream getCompressorStream(OutputStream stream)
+ throws IOException {
+ return framed ? new FramedLZ4CompressorOutputStream(stream)
+ : (CompressorOutputStream) new BlockLZ4CompressorOutputStream(stream);
+ }
+}
diff --git a/src/tests/antunit/lz4-test.xml b/src/tests/antunit/lz4-test.xml
new file mode 100644
index 0000000..c1cc22d
--- /dev/null
+++ b/src/tests/antunit/lz4-test.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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="${output}/empty" />
+ <touch file="${output}/fileone" />
+ <touch file="${output}/filetwo" />
+ </target>
+
+ <target name="testFailNone" depends="setUp">
+ <au:expectfailure expectedmessage="source is required.">
+ <cmp:lz4 destfile="${output}/file.lz4">
+ <fileset dir="${output}/empty" />
+ </cmp:lz4>
+ </au:expectfailure>
+ </target>
+
+ <target name="testFailTwo" depends="setUp">
+ <au:expectfailure expectedmessage="Can only have one source.">
+ <cmp:lz4 destfile="${output}/file.lz4">
+ <fileset dir="${output}" />
+ </cmp:lz4>
+ </au:expectfailure>
+ </target>
+
+ <target name="testFailNoDest" depends="setUp">
+ <au:expectfailure expectedmessage="dest resource is required.">
+ <cmp:lz4 src="${output}/fileone">
+ <dest>
+ <fileset dir="${output}/empty" />
+ </dest>
+ </cmp:lz4>
+ </au:expectfailure>
+ </target>
+
+ <target name="testFailTwoDests" depends="setUp">
+ <au:expectfailure expectedmessage="Can only have one destination resource.">
+ <cmp:lz4 src="${output}/fileone">
+ <dest>
+ <fileset dir="${output}" />
+ </dest>
+ </cmp:lz4>
+ </au:expectfailure>
+ </target>
+
+ <target name="testRealTest" depends="setUp">
+ <cmp:lz4 src="../resources/asf-logo.gif"
+ destfile="${output}/asf-logo.gif.lz4" />
+ <au:assertLogContains text="Building: asf-logo.gif.lz4"/>
+ <au:assertFileExists file="${output}/asf-logo.gif.lz4"/>
+ </target>
+
+ <target name="testRealTestWithResource" depends="setUp">
+ <cmp:lz4 destfile="${output}/asf-logo.gif.lz4">
+ <file file="../resources/asf-logo.gif"/>
+ </cmp:lz4>
+ <au:assertLogContains text="Building: asf-logo.gif.lz4"/>
+ <au:assertFileExists file="${output}/asf-logo.gif.lz4"/>
+ </target>
+
+ <target name="testDateCheck" depends="setUp">
+ <touch file="${output}/asf-logo.gif.lz4"/>
+ <cmp:lz4 src="../resources/asf-logo.gif"
+ destfile="${output}/asf-logo.gif.lz4" />
+ <au:assertLogContains text="Nothing to do: asf-logo.gif.lz4 is up to date."/>
+ </target>
+
+ <target name="testNestedTask" depends="setUp">
+ <cmp:lz4 destfile="${output}/asf-logo.tar.lz4">
+ <cmp:tar>
+ <cmp:cpiofileset src="../resources/asf-logo.gif.bin.cpio"
+ includes="asf-logo.gif"/>
+ </cmp:tar>
+ </cmp:lz4>
+ <au:assertFileExists file="${output}/asf-logo.tar.lz4"/>
+ <au:assertTrue>
+ <cond:islastmodified datetime="2009-07-31-20:11:13 +0200"
+ pattern="yyyy-MM-dd-HH:mm:ss Z">
+ <cmp:tarentry name="asf-logo.gif">
+ <cmp:lz4resource>
+ <file file="${output}/asf-logo.tar.lz4"/>
+ </cmp:lz4resource>
+ </cmp:tarentry>
+ </cond:islastmodified>
+ </au:assertTrue>
+ </target>
+</project>
diff --git a/src/tests/antunit/lz4resource-test.xml b/src/tests/antunit/lz4resource-test.xml
new file mode 100644
index 0000000..d027dab
--- /dev/null
+++ b/src/tests/antunit/lz4resource-test.xml
@@ -0,0 +1,79 @@
+<?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}"/>
+ </target>
+
+ <target name="testNativeLZ4" depends="setUp">
+ <copy todir="${output}">
+ <cmp:lz4resource>
+ <file file="../resources/asf-logo.gif.lz4"/>
+ </cmp:lz4resource>
+ <globmapper from="*.lz4" to="*"/>
+ </copy>
+ <au:assertFilesMatch expected="../resources/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+
+ <target name="testConcatenatedStreamsDefault"
+ depends="setUp">
+ <echo file="${output}/expected">a</echo>
+ <copy todir="${output}">
+ <cmp:lz4resource>
+ <file file="../resources/multiple.lz4"/>
+ </cmp:lz4resource>
+ <mergemapper to="actual"/>
+ </copy>
+ <au:assertFilesMatch expected="${output}/expected"
+ actual="${output}/actual"/>
+ </target>
+
+ <target name="testConcatenatedStreamsOnlyFirstStream"
+ depends="setUp">
+ <echo file="${output}/expected">a</echo>
+ <copy todir="${output}">
+ <cmp:lz4resource decompressconcatenated="false">
+ <file file="../resources/multiple.lz4"/>
+ </cmp:lz4resource>
+ <mergemapper to="actual"/>
+ </copy>
+ <au:assertFilesMatch expected="${output}/expected"
+ actual="${output}/actual"/>
+ </target>
+
+ <target name="testConcatenatedStreamsAllStreams"
+ depends="setUp">
+ <echo file="${output}/expected">ab</echo>
+ <copy todir="${output}">
+ <cmp:lz4resource decompressconcatenated="true">
+ <file file="../resources/multiple.lz4"/>
+ </cmp:lz4resource>
+ <mergemapper to="actual"/>
+ </copy>
+ <au:assertFilesMatch expected="${output}/expected"
+ actual="${output}/actual"/>
+ </target>
+</project>
diff --git a/src/tests/antunit/unlz4-test.xml b/src/tests/antunit/unlz4-test.xml
new file mode 100644
index 0000000..22e8256
--- /dev/null
+++ b/src/tests/antunit/unlz4-test.xml
@@ -0,0 +1,105 @@
+<?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}"/>
+ </target>
+
+ <target name="test1">
+ <au:expectfailure>
+ <cmp:unlz4/>
+ </au:expectfailure>
+ </target>
+
+ <target name="test2">
+ <au:expectfailure>
+ <cmp:unlz4 src=""/>
+ </au:expectfailure>
+ </target>
+
+ <target name="testLz4Task" depends="setUp">
+ <cmp:lz4 src="../resources/asf-logo.gif"
+ destfile="${output}/asf-logo.gif.lz4"/>
+ <cmp:unlz4 src="${output}/asf-logo.gif.lz4" dest="${output}/asf-logo.gif" />
+ <au:assertFilesMatch expected="../resources/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+
+ <target name="testLz4TaskWithoutFrame" depends="setUp">
+ <cmp:lz4 src="../resources/asf-logo.gif"
+ destfile="${output}/asf-logo.gif.lz4"
+ framed="false"/>
+ <cmp:unlz4 src="${output}/asf-logo.gif.lz4"
+ dest="${output}/asf-logo.gif"
+ framed="false"/>
+ <au:assertFilesMatch expected="../resources/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+
+ <target name="testNativeLz4" depends="setUp">
+ <cmp:unlz4 src="../resources/asf-logo.gif.lz4"
+ dest="${output}/asf-logo.gif" />
+ <au:assertFilesMatch expected="../resources/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+
+ <target name="testWithResource" depends="setUp">
+ <cmp:unlz4 dest="${output}/asf-logo.gif">
+ <file file="../resources/asf-logo.gif.lz4"/>
+ </cmp:unlz4>
+ <au:assertFilesMatch expected="../resources/asf-logo.gif"
+ actual="${output}/asf-logo.gif"/>
+ </target>
+
+ <target name="testConcatenatedStreamsDefault"
+ depends="setUp">
+ <echo file="${output}/expected">a</echo>
+ <cmp:unlz4 dest="${output}/actual">
+ <file file="../resources/multiple.lz4"/>
+ </cmp:unlz4>
+ <au:assertFilesMatch expected="${output}/expected"
+ actual="${output}/actual"/>
+ </target>
+
+ <target name="testConcatenatedStreamsOnlyFirstStream"
+ depends="setUp">
+ <echo file="${output}/expected">a</echo>
+ <cmp:unlz4 dest="${output}/actual" decompressconcatenated="false">
+ <file file="../resources/multiple.lz4"/>
+ </cmp:unlz4>
+ <au:assertFilesMatch expected="${output}/expected"
+ actual="${output}/actual"/>
+ </target>
+
+ <target name="testConcatenatedStreamsAllStreams"
+ depends="setUp">
+ <echo file="${output}/expected">ab</echo>
+ <cmp:unlz4 dest="${output}/actual" decompressconcatenated="true">
+ <file file="../resources/multiple.lz4"/>
+ </cmp:unlz4>
+ <au:assertFilesMatch expected="${output}/expected"
+ actual="${output}/actual"/>
+ </target>
+</project>
diff --git a/src/tests/resources/asf-logo.gif.lz4 b/src/tests/resources/asf-logo.gif.lz4
new file mode 100644
index 0000000..cc875dd
--- /dev/null
+++ b/src/tests/resources/asf-logo.gif.lz4
Binary files differ
diff --git a/src/tests/resources/multiple.lz4 b/src/tests/resources/multiple.lz4
new file mode 100644
index 0000000..0814e93
--- /dev/null
+++ b/src/tests/resources/multiple.lz4
Binary files differ