package org.biojava.nbio.core.util;

import org.junit.Test;
import static org.junit.Assert.*;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;

public class TestUncompressInputStream {
	
	/**
	 * The file compress_text.txt.lzc is the output of:
	 * <code>
	 *   cat compress_test.txt | compress > compress_test.txt.lzc
	 * </code>
	 * The original compress_test.txt contains text {@value #TEXT_IN_FILE} 
	 */
	private static final String TEST_FILE = "org/biojava/nbio/core/util/compress_test.txt.lzc";
	private static final String TEXT_IN_FILE = "Test of biojava uncompress.";
	
	@Test
	public void testUncompression() throws Exception {
		
		InputStream is = this.getClass().getClassLoader().getResourceAsStream(TEST_FILE);
		
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		UncompressInputStream.uncompress(is, baos);
		String decompressedText = baos.toString();
		
		assertEquals(TEXT_IN_FILE, decompressedText);
		
	}

}

@@ -28,17 +28,56 @@
 re.util;
-%0A
+%0D%0A%0D%0Aimport java.io.BufferedInputStream;%0D
 %0Aimport 
@@ -91,16 +91,17 @@
 it.Test;
+%0D
 %0Aimport 
@@ -126,17 +126,19 @@
 ssert.*;
-%0A
+%0D%0A%0D
 %0Aimport 
@@ -167,16 +167,17 @@
 tStream;
+%0D
 %0Aimport 
@@ -196,17 +196,45 @@
 tStream;
-%0A
+%0D%0Aimport org.junit.Assert;%0D%0A%0D
 %0Apublic 
@@ -270,15 +270,18 @@
 am %7B
+%0D
 %0A%09
+%0D
 %0A%09/**
+%0D
 %0A%09 *
@@ -329,16 +329,17 @@
 tput of:
+%0D
 %0A%09 * %3Cco
@@ -337,24 +337,25 @@
 %0D%0A%09 * %3Ccode%3E
+%0D
 %0A%09 *   cat c
@@ -405,16 +405,17 @@
 .txt.lzc
+%0D
 %0A%09 * %3C/c
@@ -418,16 +418,17 @@
  %3C/code%3E
+%0D
 %0A%09 * The
@@ -496,13 +496,15 @@
 LE%7D 
+%0D
 %0A%09 */
+%0D
 %0A%09pr
@@ -592,16 +592,17 @@
 xt.lzc%22;
+%0D
 %0A%09privat
@@ -670,19 +670,227 @@
 ess.
+%5Cn
 %22;
+%0D
 %0A%09
+%0D%0A%09private static final String BIGGER_TEST_FILE = %22org/biojava/nbio/core/util/build-copy.xml.Z%22;%0D%0A%09private static final String ORIG_OF_BIGGER_TEST_FILE = %22org/biojava/nbio/core/util/build.xml%22;%0D%0A        %0D
 %0A%09@Test
+%0D
 %0A%09pu
@@ -937,19 +937,21 @@
 eption %7B
+%0D
 %0A%09%09
+%0D
 %0A%09%09Input
@@ -1026,19 +1026,17 @@
 T_FILE);
-%0A%09%09
+%0D
 %0A%09%09ByteA
@@ -1087,16 +1087,17 @@
 tream();
+%0D
 %0A%09%09Uncom
@@ -1134,16 +1134,17 @@
 , baos);
+%0D
 %0A%09%09Strin
@@ -1180,19 +1180,21 @@
 tring();
+%0D
 %0A%09%09
+%0D
 %0A%09%09asser
@@ -1237,14 +1237,787 @@
 xt);
-%0A%09%09%0A%09%7D%0A%0A%7D%0A
+%0D%0A%0D%0A%09%09is = this.getClass().getClassLoader().getResourceAsStream(BIGGER_TEST_FILE);%0D%0A%09%09baos = new ByteArrayOutputStream();%0D%0A%09%09UncompressInputStream.uncompress(is, baos);%0D%0A%0D%0A                ByteArrayOutputStream obaos = new ByteArrayOutputStream();%0D%0A                try (BufferedInputStream oin = new BufferedInputStream(%0D%0A                            this.getClass().getClassLoader()%0D%0A                                .getResourceAsStream(ORIG_OF_BIGGER_TEST_FILE));) %7B%0D%0A                    byte%5B%5D buf = new byte%5B100000%5D;%0D%0A                    int len;%0D%0A                    while ((len = oin.read(buf)) %3E= 0)%0D%0A                        obaos.write(buf, 0, len);%0D%0A                %7D%0D%0A                %0D%0A                Assert.assertArrayEquals(baos.toByteArray(), obaos.toByteArray());%0D%0A%09%7D%0D%0A%7D

add bigger test; fixed the little test