You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2015/02/17 01:40:21 UTC
svn commit: r1660261 - in
/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress:
archivers/ archivers/jar/ archivers/memory/ archivers/tar/ archivers/zip/
compressors/ compressors/xz/
Author: sebb
Date: Tue Feb 17 00:40:20 2015
New Revision: 1660261
URL: http://svn.apache.org/r1660261
Log:
COMPRESS-305 Convert all tests to JUnit4 style
All but AbstractTestCase and subclasses
Modified:
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ExceptionMessageTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStreamTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveTestCase.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/AsiExtraFieldTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/BinaryTreeTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/BitStreamTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/CircularBufferTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/EncryptedArchiveTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExplodeSupportTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/GeneralPurposeBitTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraFieldTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipEncodingTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipLongTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipShortTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2UtilsTestCase.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTestCase.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GzipUtilsTestCase.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/xz/XZUtilsTestCase.java
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ExceptionMessageTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ExceptionMessageTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ExceptionMessageTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ExceptionMessageTest.java Tue Feb 17 00:40:20 2015
@@ -1,7 +1,7 @@
package org.apache.commons.compress.archivers;
-import org.junit.Assert;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -21,7 +21,7 @@ import junit.framework.TestCase;
* specific language governing permissions and limitations
* under the License.
*/
-public class ExceptionMessageTest extends TestCase {
+public class ExceptionMessageTest {
private static final String ARCHIVER_NULL_MESSAGE = "Archivername must not be null.";
@@ -30,45 +30,49 @@ public class ExceptionMessageTest extend
private static final String OUTPUTSTREAM_NULL_MESSAGE = "OutputStream must not be null.";
+ @Test
public void testMessageWhenArchiverNameIsNull_1(){
try{
new ArchiveStreamFactory().createArchiveInputStream(null, System.in);
fail("Should raise an IllegalArgumentException.");
}catch (IllegalArgumentException e) {
- Assert.assertEquals(ARCHIVER_NULL_MESSAGE, e.getMessage());
+ assertEquals(ARCHIVER_NULL_MESSAGE, e.getMessage());
} catch (ArchiveException e) {
fail("ArchiveException not expected");
}
}
+ @Test
public void testMessageWhenInputStreamIsNull(){
try{
new ArchiveStreamFactory().createArchiveInputStream("zip", null);
fail("Should raise an IllegalArgumentException.");
}catch (IllegalArgumentException e) {
- Assert.assertEquals(INPUTSTREAM_NULL_MESSAGE, e.getMessage());
+ assertEquals(INPUTSTREAM_NULL_MESSAGE, e.getMessage());
} catch (ArchiveException e) {
fail("ArchiveException not expected");
}
}
+ @Test
public void testMessageWhenArchiverNameIsNull_2(){
try{
new ArchiveStreamFactory().createArchiveOutputStream(null, System.out);
fail("Should raise an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
- Assert.assertEquals(ARCHIVER_NULL_MESSAGE, e.getMessage());
+ assertEquals(ARCHIVER_NULL_MESSAGE, e.getMessage());
} catch (ArchiveException e){
fail("ArchiveException not expected");
}
}
+ @Test
public void testMessageWhenOutputStreamIsNull(){
try{
new ArchiveStreamFactory().createArchiveOutputStream("zip", null);
fail("Should raise an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
- Assert.assertEquals(OUTPUTSTREAM_NULL_MESSAGE, e.getMessage());
+ assertEquals(OUTPUTSTREAM_NULL_MESSAGE, e.getMessage());
} catch (ArchiveException e) {
fail("ArchiveException not expected");
}
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStreamTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStreamTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStreamTest.java Tue Feb 17 00:40:20 2015
@@ -18,20 +18,22 @@
*/
package org.apache.commons.compress.archivers.jar;
+import static org.junit.Assert.*;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import junit.framework.TestCase;
-
+import org.junit.Test;
import org.apache.commons.compress.AbstractTestCase;
import org.apache.commons.compress.archivers.zip.JarMarker;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipExtraField;
import org.apache.commons.compress.archivers.zip.ZipFile;
-public class JarArchiveOutputStreamTest extends TestCase {
+public class JarArchiveOutputStreamTest {
+ @Test
public void testJarMarker() throws IOException {
File testArchive = File.createTempFile("jar-aostest", ".jar");
testArchive.deleteOnExit();
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveTestCase.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveTestCase.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveTestCase.java Tue Feb 17 00:40:20 2015
@@ -18,14 +18,17 @@
*/
package org.apache.commons.compress.archivers.memory;
+import static org.junit.Assert.*;
+
import java.io.IOException;
-import junit.framework.TestCase;
+import org.junit.Test;
import org.apache.commons.compress.archivers.ArchiveEntry;
-public final class MemoryArchiveTestCase extends TestCase {
+public final class MemoryArchiveTestCase {
+ @Test
public void testReading() throws IOException {
final MemoryArchiveInputStream is = new MemoryArchiveInputStream(new String[][] {
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/SparseFilesTest.java Tue Feb 17 00:40:20 2015
@@ -19,14 +19,16 @@
package org.apache.commons.compress.archivers.tar;
import static org.apache.commons.compress.AbstractTestCase.getFile;
+import static org.junit.Assert.*;
+import org.junit.Test;
import java.io.File;
import java.io.FileInputStream;
-import junit.framework.TestCase;
-public class SparseFilesTest extends TestCase {
+public class SparseFilesTest {
+ @Test
public void testOldGNU() throws Throwable {
File file = getFile("oldgnu_sparse.tar");
TarArchiveInputStream tin = null;
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java Tue Feb 17 00:40:20 2015
@@ -18,17 +18,18 @@
package org.apache.commons.compress.archivers.tar;
+import static org.junit.Assert.*;
+import org.junit.Test;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Locale;
-import junit.framework.TestCase;
-
import org.apache.commons.compress.AbstractTestCase;
-public class TarArchiveEntryTest extends TestCase implements TarConstants {
+public class TarArchiveEntryTest implements TarConstants {
private static final String OS =
System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
@@ -40,11 +41,13 @@ public class TarArchiveEntryTest extends
*
* @see "https://issues.apache.org/jira/browse/SANDBOX-284"
*/
+ @Test
public void testFileSystemRoot() {
TarArchiveEntry t = new TarArchiveEntry(new File(ROOT));
assertEquals("/", t.getName());
}
+ @Test
public void testTarFileWithFSRoot() throws IOException {
File f = File.createTempFile("taetest", ".tar");
f.deleteOnExit();
@@ -104,6 +107,7 @@ public class TarArchiveEntryTest extends
}
}
+ @Test
public void testMaxFileSize(){
TarArchiveEntry t = new TarArchiveEntry("");
t.setSize(0);
@@ -117,18 +121,21 @@ public class TarArchiveEntryTest extends
t.setSize(0100000000000L);
}
+ @Test
public void testLinkFlagConstructor() {
TarArchiveEntry t = new TarArchiveEntry("/foo", LF_GNUTYPE_LONGNAME);
assertGnuMagic(t);
assertEquals("foo", t.getName());
}
+ @Test
public void testLinkFlagConstructorWithFileFlag() {
TarArchiveEntry t = new TarArchiveEntry("/foo", LF_NORMAL);
assertPosixMagic(t);
assertEquals("foo", t.getName());
}
+ @Test
public void testLinkFlagConstructorWithPreserve() {
TarArchiveEntry t = new TarArchiveEntry("/foo", LF_GNUTYPE_LONGNAME,
true);
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java Tue Feb 17 00:40:20 2015
@@ -18,15 +18,20 @@
package org.apache.commons.compress.archivers.tar;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.apache.commons.compress.archivers.zip.ZipEncoding;
import org.apache.commons.compress.archivers.zip.ZipEncodingHelper;
import org.apache.commons.compress.utils.CharsetNames;
+import org.junit.Test;
-public class TarUtilsTest extends TestCase {
+public class TarUtilsTest {
+ @Test
public void testName(){
byte [] buff = new byte[20];
String sb1 = "abcdefghijklmnopqrstuvwxyz";
@@ -43,6 +48,7 @@ public class TarUtilsTest extends TestCa
assertEquals(sb1, sb2);
}
+ @Test
public void testParseOctal() throws Exception{
long value;
byte [] buffer;
@@ -69,6 +75,7 @@ public class TarUtilsTest extends TestCa
assertEquals(0, value);
}
+ @Test
public void testParseOctalInvalid() throws Exception{
byte [] buffer;
buffer=new byte[0]; // empty byte array
@@ -109,6 +116,7 @@ public class TarUtilsTest extends TestCa
checkRoundTripOctal(value, TarConstants.SIZELEN);
}
+ @Test
public void testRoundTripOctal() {
checkRoundTripOctal(0);
checkRoundTripOctal(1);
@@ -129,10 +137,12 @@ public class TarUtilsTest extends TestCa
assertEquals(value,parseValue);
}
+ @Test
public void testRoundTripOctalOrBinary8() {
testRoundTripOctalOrBinary(8);
}
+ @Test
public void testRoundTripOctalOrBinary12() {
testRoundTripOctalOrBinary(12);
checkRoundTripOctalOrBinary(Long.MAX_VALUE, 12);
@@ -148,6 +158,7 @@ public class TarUtilsTest extends TestCa
}
// Check correct trailing bytes are generated
+ @Test
public void testTrailers() {
byte [] buffer = new byte[12];
TarUtils.formatLongOctalBytes(123, buffer, 0, buffer.length);
@@ -163,12 +174,14 @@ public class TarUtilsTest extends TestCa
assertEquals('3', buffer[buffer.length-3]); // end of number
}
+ @Test
public void testNegative() throws Exception {
byte [] buffer = new byte[22];
TarUtils.formatUnsignedOctalString(-1, buffer, 0, buffer.length);
assertEquals("1777777777777777777777", new String(buffer, CharsetNames.UTF_8));
}
+ @Test
public void testOverflow() throws Exception {
byte [] buffer = new byte[8-1]; // a lot of the numbers have 8-byte buffers (nul term)
TarUtils.formatUnsignedOctalString(07777777L, buffer, 0, buffer.length);
@@ -180,6 +193,7 @@ public class TarUtilsTest extends TestCa
}
}
+ @Test
public void testRoundTripNames(){
checkName("");
checkName("The quick brown fox\n");
@@ -187,6 +201,7 @@ public class TarUtilsTest extends TestCa
// checkName("\0"); // does not work, because NUL is ignored
}
+ @Test
public void testRoundEncoding() throws Exception {
// COMPRESS-114
ZipEncoding enc = ZipEncodingHelper.getZipEncoding(CharsetNames.ISO_8859_1);
@@ -202,6 +217,7 @@ public class TarUtilsTest extends TestCa
assertEquals(string, TarUtils.parseName(buff, 0, len));
}
+ @Test
public void testReadNegativeBinary8Byte() {
byte[] b = new byte[] {
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
@@ -210,6 +226,7 @@ public class TarUtilsTest extends TestCa
assertEquals(-3601l, TarUtils.parseOctalOrBinary(b, 0, 8));
}
+ @Test
public void testReadNegativeBinary12Byte() {
byte[] b = new byte[] {
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
@@ -220,6 +237,7 @@ public class TarUtilsTest extends TestCa
}
+ @Test
public void testWriteNegativeBinary8Byte() {
byte[] b = new byte[] {
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
@@ -229,6 +247,7 @@ public class TarUtilsTest extends TestCa
}
// https://issues.apache.org/jira/browse/COMPRESS-191
+ @Test
public void testVerifyHeaderCheckSum() {
byte[] valid = { // from bla.tar
116, 101, 115, 116, 49, 46, 120, 109, 108, 0, 0, 0, 0, 0, 0,
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/AsiExtraFieldTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/AsiExtraFieldTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/AsiExtraFieldTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/AsiExtraFieldTest.java Tue Feb 17 00:40:20 2015
@@ -18,20 +18,20 @@
package org.apache.commons.compress.archivers.zip;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
/**
- * JUnit 3 testcases for org.apache.commons.compress.archivers.zip.AsiExtraField.
+ * JUnit testcases for org.apache.commons.compress.archivers.zip.AsiExtraField.
*
*/
-public class AsiExtraFieldTest extends TestCase implements UnixStat {
- public AsiExtraFieldTest(String name) {
- super(name);
- }
+public class AsiExtraFieldTest implements UnixStat {
/**
* Test file mode magic.
- */
+ */
+ @Test
public void testModes() {
AsiExtraField a = new AsiExtraField();
a.setMode(0123);
@@ -45,6 +45,7 @@ public class AsiExtraFieldTest extends T
/**
* Test content.
*/
+ @Test
public void testContent() {
AsiExtraField a = new AsiExtraField();
a.setMode(0123);
@@ -79,6 +80,7 @@ public class AsiExtraFieldTest extends T
/**
* Test reparse
*/
+ @Test
public void testReparse() throws Exception {
// CRC manually calculated, sorry
byte[] data = {(byte)0xC6, 0x02, 0x78, (byte)0xB6, // CRC
@@ -139,6 +141,7 @@ public class AsiExtraFieldTest extends T
}
}
+ @Test
public void testClone() {
AsiExtraField s1 = new AsiExtraField();
s1.setUserId(42);
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/BinaryTreeTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/BinaryTreeTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/BinaryTreeTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/BinaryTreeTest.java Tue Feb 17 00:40:20 2015
@@ -19,14 +19,17 @@
package org.apache.commons.compress.archivers.zip;
+import static org.junit.Assert.*;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import junit.framework.TestCase;
+import org.junit.Test;
-public class BinaryTreeTest extends TestCase {
+public class BinaryTreeTest {
+ @Test
public void testDecode() throws IOException {
InputStream in = new ByteArrayInputStream(new byte[] { 0x02, 0x42, 0x01, 0x13 });
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/BitStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/BitStreamTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/BitStreamTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/BitStreamTest.java Tue Feb 17 00:40:20 2015
@@ -19,12 +19,15 @@
package org.apache.commons.compress.archivers.zip;
+import static org.junit.Assert.*;
+
import java.io.ByteArrayInputStream;
-import junit.framework.TestCase;
+import org.junit.Test;
-public class BitStreamTest extends TestCase {
+public class BitStreamTest {
+ @Test
public void testEmptyStream() throws Exception {
BitStream stream = new BitStream(new ByteArrayInputStream(new byte[0]));
assertEquals("next bit", -1, stream.nextBit());
@@ -33,6 +36,7 @@ public class BitStreamTest extends TestC
stream.close();
}
+ @Test
public void testStream() throws Exception {
BitStream stream = new BitStream(new ByteArrayInputStream(new byte[] { (byte) 0xEA, 0x03 }));
@@ -58,6 +62,7 @@ public class BitStreamTest extends TestC
stream.close();
}
+ @Test
public void testNextByteFromEmptyStream() throws Exception {
BitStream stream = new BitStream(new ByteArrayInputStream(new byte[0]));
assertEquals("next byte", -1, stream.nextByte());
@@ -65,6 +70,7 @@ public class BitStreamTest extends TestC
stream.close();
}
+ @Test
public void testReadAlignedBytes() throws Exception {
BitStream stream = new BitStream(new ByteArrayInputStream(new byte[] { (byte) 0xEA, 0x35 }));
assertEquals("next byte", 0xEA, stream.nextByte());
@@ -73,6 +79,7 @@ public class BitStreamTest extends TestC
stream.close();
}
+ @Test
public void testNextByte() throws Exception {
BitStream stream = new BitStream(new ByteArrayInputStream(new byte[] { (byte) 0xEA, 0x35 }));
assertEquals("bit 0", 0, stream.nextBit());
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/CircularBufferTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/CircularBufferTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/CircularBufferTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/CircularBufferTest.java Tue Feb 17 00:40:20 2015
@@ -19,10 +19,13 @@
package org.apache.commons.compress.archivers.zip;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
-public class CircularBufferTest extends TestCase {
+import org.junit.Test;
+public class CircularBufferTest {
+
+ @Test
public void testPutAndGet() throws Exception {
int size = 16;
CircularBuffer buffer = new CircularBuffer(size);
@@ -40,6 +43,7 @@ public class CircularBufferTest extends
assertFalse("available", buffer.available());
}
+ @Test
public void testCopy() throws Exception {
CircularBuffer buffer = new CircularBuffer(16);
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/EncryptedArchiveTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/EncryptedArchiveTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/EncryptedArchiveTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/EncryptedArchiveTest.java Tue Feb 17 00:40:20 2015
@@ -19,15 +19,17 @@
package org.apache.commons.compress.archivers.zip;
import static org.apache.commons.compress.AbstractTestCase.getFile;
+import static org.junit.Assert.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import junit.framework.TestCase;
+import org.junit.Test;
-public class EncryptedArchiveTest extends TestCase {
+public class EncryptedArchiveTest {
+ @Test
public void testReadPasswordEncryptedEntryViaZipFile()
throws IOException {
File file = getFile("password-encrypted.zip");
@@ -50,6 +52,7 @@ public class EncryptedArchiveTest extend
}
}
+ @Test
public void testReadPasswordEncryptedEntryViaStream()
throws IOException {
File file = getFile("password-encrypted.zip");
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExplodeSupportTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExplodeSupportTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExplodeSupportTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExplodeSupportTest.java Tue Feb 17 00:40:20 2015
@@ -19,6 +19,7 @@
package org.apache.commons.compress.archivers.zip;
+import static org.junit.Assert.*;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -27,11 +28,11 @@ import java.io.InputStream;
import java.util.zip.CRC32;
import java.util.zip.CheckedOutputStream;
-import junit.framework.TestCase;
import org.apache.commons.compress.utils.BoundedInputStream;
import org.apache.commons.compress.utils.IOUtils;
+import org.junit.Test;
-public class ExplodeSupportTest extends TestCase {
+public class ExplodeSupportTest {
private void testArchiveWithImplodeCompression(String filename, String entryName) throws IOException {
ZipFile zip = new ZipFile(new File(filename));
@@ -50,14 +51,17 @@ public class ExplodeSupportTest extends
zip.close();
}
+ @Test
public void testArchiveWithImplodeCompression4K2Trees() throws IOException {
testArchiveWithImplodeCompression("target/test-classes/archives/imploding-4Kdict-2trees.zip", "HEADER.TXT");
}
+ @Test
public void testArchiveWithImplodeCompression8K3Trees() throws IOException {
testArchiveWithImplodeCompression("target/test-classes/archives/imploding-8Kdict-3trees.zip", "LICENSE.TXT");
}
+ @Test
public void testTikaTestArchive() throws IOException {
testArchiveWithImplodeCompression("target/test-classes/moby-imploded.zip", "README");
}
@@ -80,14 +84,17 @@ public class ExplodeSupportTest extends
assertEquals("CRC32", entry.getCrc(), out.getChecksum().getValue());
}
+ @Test
public void testZipStreamWithImplodeCompression4K2Trees() throws IOException {
testZipStreamWithImplodeCompression("target/test-classes/archives/imploding-4Kdict-2trees.zip", "HEADER.TXT");
}
+ @Test
public void testZipStreamWithImplodeCompression8K3Trees() throws IOException {
testZipStreamWithImplodeCompression("target/test-classes/archives/imploding-8Kdict-3trees.zip", "LICENSE.TXT");
}
+ @Test
public void testTikaTestStream() throws IOException {
testZipStreamWithImplodeCompression("target/test-classes/moby-imploded.zip", "README");
}
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtilsTest.java Tue Feb 17 00:40:20 2015
@@ -18,16 +18,16 @@
package org.apache.commons.compress.archivers.zip;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
/**
- * JUnit 3 testcases for org.apache.commons.compress.archivers.zip.ExtraFieldUtils.
+ * JUnit testcases for org.apache.commons.compress.archivers.zip.ExtraFieldUtils.
*
*/
-public class ExtraFieldUtilsTest extends TestCase implements UnixStat {
- public ExtraFieldUtilsTest(String name) {
- super(name);
- }
+public class ExtraFieldUtilsTest implements UnixStat {
/**
* Header-ID of a ZipExtraField not supported by Commons Compress.
@@ -42,7 +42,7 @@ public class ExtraFieldUtilsTest extends
private byte[] data;
private byte[] aLocal;
- @Override
+ @Before
public void setUp() {
a = new AsiExtraField();
a.setMode(0755);
@@ -70,6 +70,7 @@ public class ExtraFieldUtilsTest extends
/**
* test parser.
*/
+ @Test
public void testParse() throws Exception {
ZipExtraField[] ze = ExtraFieldUtils.parse(data);
assertEquals("number of fields", 2, ze.length);
@@ -93,6 +94,7 @@ public class ExtraFieldUtilsTest extends
}
}
+ @Test
public void testParseWithRead() throws Exception {
ZipExtraField[] ze =
ExtraFieldUtils.parse(data, true,
@@ -123,6 +125,7 @@ public class ExtraFieldUtilsTest extends
}
}
+ @Test
public void testParseWithSkip() throws Exception {
ZipExtraField[] ze =
ExtraFieldUtils.parse(data, true,
@@ -148,6 +151,7 @@ public class ExtraFieldUtilsTest extends
/**
* Test merge methods
*/
+ @Test
public void testMerge() {
byte[] local =
ExtraFieldUtils.mergeLocalFileDataData(new ZipExtraField[] {a, dummy});
@@ -174,6 +178,7 @@ public class ExtraFieldUtilsTest extends
}
+ @Test
public void testMergeWithUnparseableData() throws Exception {
ZipExtraField d = new UnparseableExtraFieldData();
byte[] b = UNRECOGNIZED_HEADER.getBytes();
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/GeneralPurposeBitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/GeneralPurposeBitTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/GeneralPurposeBitTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/GeneralPurposeBitTest.java Tue Feb 17 00:40:20 2015
@@ -19,12 +19,15 @@
package org.apache.commons.compress.archivers.zip;
+import static org.junit.Assert.*;
+
import java.util.Arrays;
-import junit.framework.TestCase;
+import org.junit.Test;
-public class GeneralPurposeBitTest extends TestCase {
+public class GeneralPurposeBitTest {
+ @Test
public void testDefaults() {
assertFalse(new GeneralPurposeBit().usesDataDescriptor());
assertFalse(new GeneralPurposeBit().usesUTF8ForNames());
@@ -34,6 +37,7 @@ public class GeneralPurposeBitTest exten
assertTrue(Arrays.equals(b, new GeneralPurposeBit().encode()));
}
+ @Test
public void testParseEdgeCases() {
assertFalse(GeneralPurposeBit.parse(new byte[2], 0)
.usesDataDescriptor());
@@ -57,6 +61,7 @@ public class GeneralPurposeBitTest exten
.usesStrongEncryption());
}
+ @Test
public void testDataDescriptor() {
byte[] flags = new byte[] {(byte) 8, (byte) 0};
assertTrue(GeneralPurposeBit.parse(flags, 0).usesDataDescriptor());
@@ -65,6 +70,7 @@ public class GeneralPurposeBitTest exten
assertTrue(Arrays.equals(flags, b.encode()));
}
+ @Test
public void testLanguageEncodingFlag() {
byte[] flags = new byte[] {(byte) 0, (byte) 8};
assertTrue(GeneralPurposeBit.parse(flags, 0).usesUTF8ForNames());
@@ -73,6 +79,7 @@ public class GeneralPurposeBitTest exten
assertTrue(Arrays.equals(flags, b.encode()));
}
+ @Test
public void testEncryption() {
byte[] flags = new byte[] {(byte) 1, (byte) 0};
assertTrue(GeneralPurposeBit.parse(flags, 0).usesEncryption());
@@ -81,6 +88,7 @@ public class GeneralPurposeBitTest exten
assertTrue(Arrays.equals(flags, b.encode()));
}
+ @Test
public void testStrongEncryption() {
byte[] flags = new byte[] {(byte) 65, (byte) 0};
assertTrue(GeneralPurposeBit.parse(flags, 0).usesStrongEncryption());
@@ -93,6 +101,7 @@ public class GeneralPurposeBitTest exten
assertFalse(GeneralPurposeBit.parse(flags, 0).usesStrongEncryption());
}
+ @Test
public void testClone() {
GeneralPurposeBit b = new GeneralPurposeBit();
b.useStrongEncryption(true);
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java Tue Feb 17 00:40:20 2015
@@ -19,17 +19,17 @@
package org.apache.commons.compress.archivers.zip;
import static org.apache.commons.compress.AbstractTestCase.getFile;
+import static org.junit.Assert.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import junit.framework.TestCase;
-
import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.junit.Test;
/**
- * JUnit 3 testcase for a multi-volume zip file.
+ * JUnit testcase for a multi-volume zip file.
*
* Some tools (like 7-zip) allow users to split a large archives into 'volumes'
* with a given size to fit them into multiple cds, usb drives, or emails with
@@ -42,7 +42,7 @@ import org.apache.commons.compress.archi
* yields an exception.
*
*/
-public class Maven221MultiVolumeTest extends TestCase {
+public class Maven221MultiVolumeTest {
private static final String [] ENTRIES = new String [] {
"apache-maven-2.2.1/",
@@ -65,6 +65,7 @@ public class Maven221MultiVolumeTest ext
private static final String LAST_ENTRY_NAME =
"apache-maven-2.2.1/lib/maven-2.2.1-uber.jar";
+ @Test
public void testRead7ZipMultiVolumeArchiveForStream() throws IOException {
FileInputStream archive =
@@ -111,6 +112,7 @@ public class Maven221MultiVolumeTest ext
}
}
+ @Test
public void testRead7ZipMultiVolumeArchiveForFile() throws IOException {
File file = getFile("apache-maven-2.2.1.zip.001");
try {
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraFieldTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraFieldTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraFieldTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraFieldTest.java Tue Feb 17 00:40:20 2015
@@ -18,15 +18,14 @@
package org.apache.commons.compress.archivers.zip;
+import static org.junit.Assert.*;
+
import java.math.BigInteger;
import java.util.zip.ZipException;
-import junit.framework.TestCase;
+import org.junit.Test;
-public class Zip64ExtendedInformationExtraFieldTest extends TestCase {
- public Zip64ExtendedInformationExtraFieldTest(String name) {
- super(name);
- }
+public class Zip64ExtendedInformationExtraFieldTest {
private static final ZipEightByteInteger SIZE =
new ZipEightByteInteger(0x12345678);
@@ -38,6 +37,7 @@ public class Zip64ExtendedInformationExt
.setBit(3));
private static final ZipLong DISK = new ZipLong(0x12);
+ @Test
public void testWriteCDOnlySizes() {
Zip64ExtendedInformationExtraField f =
new Zip64ExtendedInformationExtraField(SIZE, CSIZE);
@@ -47,6 +47,7 @@ public class Zip64ExtendedInformationExt
checkSizes(b);
}
+ @Test
public void testWriteCDSizeAndOffset() {
Zip64ExtendedInformationExtraField f =
new Zip64ExtendedInformationExtraField(SIZE, CSIZE, OFF, null);
@@ -57,6 +58,7 @@ public class Zip64ExtendedInformationExt
checkOffset(b, 16);
}
+ @Test
public void testWriteCDSizeOffsetAndDisk() {
Zip64ExtendedInformationExtraField f =
new Zip64ExtendedInformationExtraField(SIZE, CSIZE, OFF, DISK);
@@ -68,6 +70,7 @@ public class Zip64ExtendedInformationExt
checkDisk(b, 24);
}
+ @Test
public void testWriteCDSizeAndDisk() {
Zip64ExtendedInformationExtraField f =
new Zip64ExtendedInformationExtraField(SIZE, CSIZE, null, DISK);
@@ -78,6 +81,7 @@ public class Zip64ExtendedInformationExt
checkDisk(b, 16);
}
+ @Test
public void testReadLFHSizesOnly() throws ZipException {
Zip64ExtendedInformationExtraField f =
new Zip64ExtendedInformationExtraField();
@@ -91,6 +95,7 @@ public class Zip64ExtendedInformationExt
assertNull(f.getDiskStartNumber());
}
+ @Test
public void testReadLFHSizesAndOffset() throws ZipException {
Zip64ExtendedInformationExtraField f =
new Zip64ExtendedInformationExtraField();
@@ -105,6 +110,7 @@ public class Zip64ExtendedInformationExt
assertNull(f.getDiskStartNumber());
}
+ @Test
public void testReadLFHSizesOffsetAndDisk() throws ZipException {
Zip64ExtendedInformationExtraField f =
new Zip64ExtendedInformationExtraField();
@@ -120,6 +126,7 @@ public class Zip64ExtendedInformationExt
assertEquals(DISK, f.getDiskStartNumber());
}
+ @Test
public void testReadLFHSizesAndDisk() throws ZipException {
Zip64ExtendedInformationExtraField f =
new Zip64ExtendedInformationExtraField();
@@ -134,6 +141,7 @@ public class Zip64ExtendedInformationExt
assertEquals(DISK, f.getDiskStartNumber());
}
+ @Test
public void testReadCDSizesOffsetAndDisk() throws ZipException {
Zip64ExtendedInformationExtraField f =
new Zip64ExtendedInformationExtraField();
@@ -149,6 +157,7 @@ public class Zip64ExtendedInformationExt
assertEquals(DISK, f.getDiskStartNumber());
}
+ @Test
public void testReadCDSizesAndOffset() throws ZipException {
Zip64ExtendedInformationExtraField f =
new Zip64ExtendedInformationExtraField();
@@ -163,6 +172,7 @@ public class Zip64ExtendedInformationExt
assertNull(f.getDiskStartNumber());
}
+ @Test
public void testReadCDSomethingAndDisk() throws ZipException {
Zip64ExtendedInformationExtraField f =
new Zip64ExtendedInformationExtraField();
@@ -176,6 +186,7 @@ public class Zip64ExtendedInformationExt
assertEquals(DISK, f.getDiskStartNumber());
}
+ @Test
public void testReparseCDSingleEightByteData() throws ZipException {
Zip64ExtendedInformationExtraField f =
new Zip64ExtendedInformationExtraField();
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntryTest.java Tue Feb 17 00:40:20 2015
@@ -18,24 +18,23 @@
package org.apache.commons.compress.archivers.zip;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
import java.io.ByteArrayOutputStream;
import java.util.zip.ZipEntry;
+import org.junit.Test;
+
/**
- * JUnit 3 testcases for org.apache.commons.compress.archivers.zip.ZipEntry.
+ * JUnit testcases for org.apache.commons.compress.archivers.zip.ZipEntry.
*
*/
-public class ZipArchiveEntryTest extends TestCase {
-
- public ZipArchiveEntryTest(String name) {
- super(name);
- }
+public class ZipArchiveEntryTest {
/**
* test handling of extra fields
*/
+ @Test
public void testExtraFields() {
AsiExtraField a = new AsiExtraField();
a.setDirectory(true);
@@ -89,6 +88,7 @@ public class ZipArchiveEntryTest extends
/**
* test handling of extra fields via central directory
*/
+ @Test
public void testExtraFieldMerging() {
AsiExtraField a = new AsiExtraField();
a.setDirectory(true);
@@ -135,6 +135,7 @@ public class ZipArchiveEntryTest extends
/**
* test handling of extra fields
*/
+ @Test
public void testAddAsFirstExtraField() {
AsiExtraField a = new AsiExtraField();
a.setDirectory(true);
@@ -170,6 +171,7 @@ public class ZipArchiveEntryTest extends
assertSame(a, result[2]);
}
+ @Test
public void testUnixMode() {
ZipArchiveEntry ze = new ZipArchiveEntry("foo");
assertEquals(0, ze.getPlatform());
@@ -205,6 +207,7 @@ public class ZipArchiveEntryTest extends
* <a href="https://issues.apache.org/jira/browse/COMPRESS-93"
* >COMPRESS-93</a>.
*/
+ @Test
public void testCompressionMethod() throws Exception {
ZipArchiveOutputStream zos =
new ZipArchiveOutputStream(new ByteArrayOutputStream());
@@ -232,6 +235,7 @@ public class ZipArchiveEntryTest extends
* <a href="https://issues.apache.org/jira/browse/COMPRESS-94"
* >COMPRESS-94</a>.
*/
+ @Test
public void testNotEquals() {
ZipArchiveEntry entry1 = new ZipArchiveEntry("foo");
ZipArchiveEntry entry2 = new ZipArchiveEntry("bar");
@@ -242,6 +246,7 @@ public class ZipArchiveEntryTest extends
* Tests comment's influence on equals comparisons.
* @see "https://issues.apache.org/jira/browse/COMPRESS-187"
*/
+ @Test
public void testNullCommentEqualsEmptyComment() {
ZipArchiveEntry entry1 = new ZipArchiveEntry("foo");
ZipArchiveEntry entry2 = new ZipArchiveEntry("foo");
@@ -254,6 +259,7 @@ public class ZipArchiveEntryTest extends
assertFalse(entry2.equals(entry3));
}
+ @Test
public void testCopyConstructor() throws Exception {
ZipArchiveEntry archiveEntry = new ZipArchiveEntry("fred");
archiveEntry.setUnixMode(0664);
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java Tue Feb 17 00:40:20 2015
@@ -18,23 +18,22 @@
package org.apache.commons.compress.archivers.zip;
+import static org.junit.Assert.*;
+
import java.math.BigInteger;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
- * JUnit 3 testcases for org.apache.commons.compress.archivers.zip.ZipEightByteInteger.
+ * JUnit testcases for org.apache.commons.compress.archivers.zip.ZipEightByteInteger.
*
*/
-public class ZipEightByteIntegerTest extends TestCase {
-
- public ZipEightByteIntegerTest(String name) {
- super(name);
- }
+public class ZipEightByteIntegerTest {
/**
* Test conversion to bytes.
*/
+ @Test
public void testLongToBytes() {
ZipEightByteInteger zl = new ZipEightByteInteger(0xAB12345678l);
byte[] result = zl.getBytes();
@@ -52,6 +51,7 @@ public class ZipEightByteIntegerTest ext
/**
* Test conversion from bytes.
*/
+ @Test
public void testLongFromBytes() {
byte[] val = new byte[] {0x78, 0x56, 0x34, 0x12, (byte) 0xAB, 0x00, 0x00, 0x00};
ZipEightByteInteger zl = new ZipEightByteInteger(val);
@@ -61,6 +61,7 @@ public class ZipEightByteIntegerTest ext
/**
* Test conversion to bytes.
*/
+ @Test
public void testBIToBytes() {
ZipEightByteInteger zl =
new ZipEightByteInteger(BigInteger.valueOf(Long.MAX_VALUE)
@@ -80,6 +81,7 @@ public class ZipEightByteIntegerTest ext
/**
* Test conversion from bytes.
*/
+ @Test
public void testBIFromBytes() {
byte[] val = new byte[] {(byte) 0xFE, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
ZipEightByteInteger zl = new ZipEightByteInteger(val);
@@ -91,6 +93,7 @@ public class ZipEightByteIntegerTest ext
/**
* Test the contract of the equals method.
*/
+ @Test
public void testEquals() {
ZipEightByteInteger zl = new ZipEightByteInteger(0x12345678);
ZipEightByteInteger zl2 = new ZipEightByteInteger(0x12345678);
@@ -110,6 +113,7 @@ public class ZipEightByteIntegerTest ext
/**
* Test sign handling.
*/
+ @Test
public void testSign() {
ZipEightByteInteger zl = new ZipEightByteInteger(new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF});
assertEquals(BigInteger.valueOf(Long.MAX_VALUE).shiftLeft(1).setBit(0),
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipEncodingTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipEncodingTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipEncodingTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipEncodingTest.java Tue Feb 17 00:40:20 2015
@@ -22,14 +22,17 @@ package org.apache.commons.compress.arch
import java.io.IOException;
import java.nio.ByteBuffer;
-import junit.framework.TestCase;
-
import org.apache.commons.compress.utils.CharsetNames;
+import static org.junit.Assert.*;
+
+import org.junit.Assert;
+import org.junit.Test;
+
/**
* Test zip encodings.
*/
-public class ZipEncodingTest extends TestCase {
+public class ZipEncodingTest {
private static final String UNENC_STRING = "\u2016";
// stress test for internal grow method.
@@ -39,16 +42,19 @@ public class ZipEncodingTest extends Tes
private static final String BAD_STRING_ENC =
"%U2016%U2015%U2016%U2015%U2016%U2015%U2016%U2015%U2016%U2015%U2016";
+ @Test
public void testSimpleCp437Encoding() throws IOException {
doSimpleEncodingTest("Cp437", null);
}
+ @Test
public void testSimpleCp850Encoding() throws IOException {
doSimpleEncodingTest("Cp850", null);
}
+ @Test
public void testNioCp1252Encoding() throws IOException {
// CP1252 has some undefined code points, these are
// the defined ones
@@ -108,11 +114,11 @@ public class ZipEncodingTest extends Tes
private static void assertEquals(byte[] expected, ByteBuffer actual) {
- assertEquals(expected.length, actual.limit());
+ Assert.assertEquals(expected.length, actual.limit());
for (byte anExpected : expected) {
byte a = actual.get();
- assertEquals(anExpected, a);
+ Assert.assertEquals(anExpected, a);
}
}
@@ -132,15 +138,15 @@ public class ZipEncodingTest extends Tes
String decoded = enc.decode(testBytes);
- assertEquals(true, enc.canEncode(decoded));
+ assertTrue(enc.canEncode(decoded));
ByteBuffer encoded = enc.encode(decoded);
assertEquals(testBytes, encoded);
- assertEquals(false, enc.canEncode(UNENC_STRING));
+ assertFalse(enc.canEncode(UNENC_STRING));
assertEquals("%U2016".getBytes(CharsetNames.US_ASCII), enc.encode(UNENC_STRING));
- assertEquals(false, enc.canEncode(BAD_STRING));
+ assertFalse(enc.canEncode(BAD_STRING));
assertEquals(BAD_STRING_ENC.getBytes(CharsetNames.US_ASCII),
enc.encode(BAD_STRING));
}
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java Tue Feb 17 00:40:20 2015
@@ -19,7 +19,7 @@
package org.apache.commons.compress.archivers.zip;
import static org.apache.commons.compress.AbstractTestCase.getFile;
-import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.*;
import java.io.File;
import java.io.FileInputStream;
@@ -32,17 +32,19 @@ import java.util.Enumeration;
import java.util.TreeMap;
import java.util.zip.ZipEntry;
-import junit.framework.TestCase;
import org.apache.commons.compress.utils.IOUtils;
+import org.junit.After;
+import org.junit.Test;
-public class ZipFileTest extends TestCase {
+public class ZipFileTest {
private ZipFile zf = null;
- @Override
+ @After
public void tearDown() {
ZipFile.closeQuietly(zf);
}
+ @Test
public void testCDOrder() throws Exception {
readOrderTest();
ArrayList<ZipArchiveEntry> l = Collections.list(zf.getEntries());
@@ -71,6 +73,7 @@ public class ZipFileTest extends TestCas
assertEntryName(l, 22, "ZipFile");
}
+ @Test
public void testPhysicalOrder() throws Exception {
readOrderTest();
ArrayList<ZipArchiveEntry> l = Collections.list(zf.getEntriesInPhysicalOrder());
@@ -99,6 +102,7 @@ public class ZipFileTest extends TestCas
assertEntryName(l, 22, "ZipUtil");
}
+ @Test
public void testDoubleClose() throws Exception {
readOrderTest();
zf.close();
@@ -109,6 +113,7 @@ public class ZipFileTest extends TestCas
}
}
+ @Test
public void testReadingOfStoredEntry() throws Exception {
File f = File.createTempFile("commons-compress-zipfiletest", ".zip");
f.deleteOnExit();
@@ -149,6 +154,7 @@ public class ZipFileTest extends TestCas
/**
* @see "https://issues.apache.org/jira/browse/COMPRESS-176"
*/
+ @Test
public void testWinzipBackSlashWorkaround() throws Exception {
File archive = getFile("test-winzip.zip");
zf = new ZipFile(archive);
@@ -161,6 +167,7 @@ public class ZipFileTest extends TestCas
* <a href="https://issues.apache.org/jira/browse/COMPRESS-208"
* >COMPRESS-208</a>.
*/
+ @Test
public void testSkipsPK00Prefix() throws Exception {
File archive = getFile("COMPRESS-208.zip");
zf = new ZipFile(archive);
@@ -168,6 +175,7 @@ public class ZipFileTest extends TestCas
assertNotNull(zf.getEntry("test2.xml"));
}
+ @Test
public void testUnixSymlinkSampleFile() throws Exception {
final String entryPrefix = "COMPRESS-214_unix_symlinks/";
final TreeMap<String, String> expectedVals = new TreeMap<String, String>();
@@ -210,6 +218,7 @@ public class ZipFileTest extends TestCas
/**
* @see "https://issues.apache.org/jira/browse/COMPRESS-227"
*/
+ @Test
public void testDuplicateEntry() throws Exception {
File archive = getFile("COMPRESS-227.zip");
zf = new ZipFile(archive);
@@ -229,6 +238,7 @@ public class ZipFileTest extends TestCas
/**
* @see "https://issues.apache.org/jira/browse/COMPRESS-228"
*/
+ @Test
public void testExcessDataInZip64ExtraField() throws Exception {
File archive = getFile("COMPRESS-228.zip");
zf = new ZipFile(archive);
@@ -238,6 +248,7 @@ public class ZipFileTest extends TestCas
assertEquals(26101, ze.getSize());
}
+ @Test
public void testUnshrinking() throws Exception {
zf = new ZipFile(getFile("SHRUNK.ZIP"));
ZipArchiveEntry test = zf.getEntry("TEST1.XML");
@@ -263,6 +274,7 @@ public class ZipFileTest extends TestCas
* <a href="https://issues.apache.org/jira/browse/COMPRESS-264"
* >COMPRESS-264</a>.
*/
+ @Test
public void testReadingOfFirstStoredEntry() throws Exception {
File archive = getFile("COMPRESS-264.zip");
zf = new ZipFile(archive);
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipLongTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipLongTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipLongTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipLongTest.java Tue Feb 17 00:40:20 2015
@@ -18,21 +18,20 @@
package org.apache.commons.compress.archivers.zip;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
/**
- * JUnit 3 testcases for org.apache.commons.compress.archivers.zip.ZipLong.
+ * JUnit testcases for org.apache.commons.compress.archivers.zip.ZipLong.
*
*/
-public class ZipLongTest extends TestCase {
-
- public ZipLongTest(String name) {
- super(name);
- }
+public class ZipLongTest {
/**
* Test conversion to bytes.
*/
+ @Test
public void testToBytes() {
ZipLong zl = new ZipLong(0x12345678);
byte[] result = zl.getBytes();
@@ -46,6 +45,7 @@ public class ZipLongTest extends TestCas
/**
* Test conversion to bytes.
*/
+ @Test
public void testPut() {
byte[] arr = new byte[5];
ZipLong.putLong(0x12345678, arr, 1);
@@ -58,6 +58,7 @@ public class ZipLongTest extends TestCas
/**
* Test conversion from bytes.
*/
+ @Test
public void testFromBytes() {
byte[] val = new byte[] {0x78, 0x56, 0x34, 0x12};
ZipLong zl = new ZipLong(val);
@@ -67,6 +68,7 @@ public class ZipLongTest extends TestCas
/**
* Test the contract of the equals method.
*/
+ @Test
public void testEquals() {
ZipLong zl = new ZipLong(0x12345678);
ZipLong zl2 = new ZipLong(0x12345678);
@@ -86,11 +88,13 @@ public class ZipLongTest extends TestCas
/**
* Test sign handling.
*/
+ @Test
public void testSign() {
ZipLong zl = new ZipLong(new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF});
assertEquals(0x00000000FFFFFFFFl, zl.getValue());
}
+ @Test
public void testClone() {
ZipLong s1 = new ZipLong(42);
ZipLong s2 = (ZipLong) s1.clone();
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipShortTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipShortTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipShortTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipShortTest.java Tue Feb 17 00:40:20 2015
@@ -18,21 +18,20 @@
package org.apache.commons.compress.archivers.zip;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
/**
- * JUnit 3 testcases for org.apache.commons.compress.archivers.zip.ZipShort.
+ * JUnit testcases for org.apache.commons.compress.archivers.zip.ZipShort.
*
*/
-public class ZipShortTest extends TestCase {
-
- public ZipShortTest(String name) {
- super(name);
- }
+public class ZipShortTest {
/**
* Test conversion to bytes.
*/
+ @Test
public void testToBytes() {
ZipShort zs = new ZipShort(0x1234);
byte[] result = zs.getBytes();
@@ -45,6 +44,7 @@ public class ZipShortTest extends TestCa
/**
* Test conversion to bytes.
*/
+ @Test
public void testPut() {
byte[] arr = new byte[3];
ZipShort.putShort(0x1234, arr, 1);
@@ -56,6 +56,7 @@ public class ZipShortTest extends TestCa
/**
* Test conversion from bytes.
*/
+ @Test
public void testFromBytes() {
byte[] val = new byte[] {0x34, 0x12};
ZipShort zs = new ZipShort(val);
@@ -65,6 +66,7 @@ public class ZipShortTest extends TestCa
/**
* Test the contract of the equals method.
*/
+ @Test
public void testEquals() {
ZipShort zs = new ZipShort(0x1234);
ZipShort zs2 = new ZipShort(0x1234);
@@ -84,11 +86,13 @@ public class ZipShortTest extends TestCa
/**
* Test sign handling.
*/
+ @Test
public void testSign() {
ZipShort zs = new ZipShort(new byte[] {(byte)0xFF, (byte)0xFF});
assertEquals(0x0000FFFF, zs.getValue());
}
+ @Test
public void testClone() {
ZipShort s1 = new ZipShort(42);
ZipShort s2 = (ZipShort) s1.clone();
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipUtilTest.java Tue Feb 17 00:40:20 2015
@@ -18,7 +18,7 @@
package org.apache.commons.compress.archivers.zip;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
import java.math.BigInteger;
import java.util.Arrays;
@@ -26,20 +26,16 @@ import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
-public class ZipUtilTest extends TestCase {
+import org.junit.Before;
+import org.junit.Test;
+
+public class ZipUtilTest {
private Date time;
private ZipLong zl;
- /**
- * Constructor
- */
- public ZipUtilTest(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
time = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(time);
@@ -60,16 +56,13 @@ public class ZipUtilTest extends TestCas
zl = new ZipLong(result);
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
+ @Test
public void testZipLong() throws Exception {
ZipLong test = ZipUtil.toDosTime(time);
assertEquals(test.getValue(), zl.getValue());
}
+ @Test
public void testAdjustToLong() {
assertEquals(Integer.MAX_VALUE,
ZipUtil.adjustToLong(Integer.MAX_VALUE));
@@ -79,6 +72,7 @@ public class ZipUtilTest extends TestCas
ZipUtil.adjustToLong(2 * Integer.MAX_VALUE));
}
+ @Test
public void testMinTime(){
byte[] b1 = ZipUtil.toDosTime(0);
byte b10 = b1[0]; // Save the first byte
@@ -87,6 +81,7 @@ public class ZipUtilTest extends TestCas
assertEquals(b10,b2[0]); // first byte should still be the same
}
+ @Test
public void testOutsideCalendar(){
byte[] b1 = ZipUtil.toDosTime(160441200000L); // 1.1..1975
assertEquals(0, b1[0]);
@@ -95,6 +90,7 @@ public class ZipUtilTest extends TestCas
assertEquals(0, b1[3]);
}
+ @Test
public void testInsideCalendar(){
TimeZone tz = TimeZone.getDefault();
long date = 476096400000L; // 1.1.1985, 10:00 am GMT
@@ -105,6 +101,7 @@ public class ZipUtilTest extends TestCas
assertEquals(10, b1[3]);
}
+ @Test
public void testReverse() {
byte[][] bTest = new byte[6][];
bTest[0] = new byte[]{};
@@ -131,6 +128,7 @@ public class ZipUtilTest extends TestCas
}
}
+ @Test
public void testBigToLong() {
BigInteger big1 = BigInteger.valueOf(1);
BigInteger big2 = BigInteger.valueOf(Long.MAX_VALUE);
@@ -157,6 +155,7 @@ public class ZipUtilTest extends TestCas
}
}
+ @Test
public void testLongToBig() {
long l0 = 0;
long l1 = 1;
@@ -185,6 +184,7 @@ public class ZipUtilTest extends TestCas
}
}
+ @Test
public void testSignedByteToUnsignedInt() {
// Yay, we can completely test all possible input values in this case!
int expectedVal = 128;
@@ -198,6 +198,7 @@ public class ZipUtilTest extends TestCas
}
}
+ @Test
public void testUnsignedIntToSignedByte() {
int unsignedVal = 128;
for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2UtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2UtilsTestCase.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2UtilsTestCase.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2UtilsTestCase.java Tue Feb 17 00:40:20 2015
@@ -18,12 +18,14 @@
*/
package org.apache.commons.compress.compressors;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
import org.apache.commons.compress.compressors.bzip2.BZip2Utils;
+import org.junit.Test;
-public class BZip2UtilsTestCase extends TestCase {
+public class BZip2UtilsTestCase {
+ @Test
public void testIsCompressedFilename() {
assertFalse(BZip2Utils.isCompressedFilename(""));
assertFalse(BZip2Utils.isCompressedFilename(".gz"));
@@ -45,6 +47,7 @@ public class BZip2UtilsTestCase extends
assertFalse(BZip2Utils.isCompressedFilename("x.tbz2.y"));
}
+ @Test
public void testGetUncompressedFilename() {
assertEquals("", BZip2Utils.getUncompressedFilename(""));
assertEquals(".bz2", BZip2Utils.getUncompressedFilename(".bz2"));
@@ -63,6 +66,7 @@ public class BZip2UtilsTestCase extends
assertEquals("x.tbz2.y", BZip2Utils.getUncompressedFilename("x.tbz2.y"));
}
+ @Test
public void testGetCompressedFilename() {
assertEquals(".bz2", BZip2Utils.getCompressedFilename(""));
assertEquals(" .bz2", BZip2Utils.getCompressedFilename(" "));
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTestCase.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTestCase.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTestCase.java Tue Feb 17 00:40:20 2015
@@ -19,14 +19,13 @@
package org.apache.commons.compress.compressors;
import static org.apache.commons.compress.AbstractTestCase.getFile;
+import static org.junit.Assert.*;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
-import junit.framework.TestCase;
-
import org.apache.commons.compress.compressors.CompressorException;
import org.apache.commons.compress.compressors.CompressorInputStream;
import org.apache.commons.compress.compressors.CompressorStreamFactory;
@@ -34,13 +33,10 @@ import org.apache.commons.compress.compr
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream;
import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
+import org.junit.Test;
@SuppressWarnings("deprecation") // deliberately tests setDecompressConcatenated
-public final class DetectCompressorTestCase extends TestCase {
-
- public DetectCompressorTestCase(String name) {
- super(name);
- }
+public final class DetectCompressorTestCase {
final CompressorStreamFactory factory = new CompressorStreamFactory();
private static final CompressorStreamFactory factoryTrue = new CompressorStreamFactory(true);
@@ -90,6 +86,7 @@ public final class DetectCompressorTestC
new TestData("multiple.xz", new char[]{'a'}, factory, false),
};
+ @Test
public void testDetection() throws Exception {
CompressorInputStream bzip2 = getStreamFor("bla.txt.bz2");
assertNotNull(bzip2);
@@ -115,6 +112,7 @@ public final class DetectCompressorTestC
}
}
+ @Test
public void testOverride() {
CompressorStreamFactory fac = new CompressorStreamFactory();
assertFalse(fac.getDecompressConcatenated());
@@ -140,6 +138,7 @@ public final class DetectCompressorTestC
}
}
+ @Test
public void testMutiples() throws Exception {
for(int i=0; i <tests.length; i++) {
TestData test = tests[i];
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GzipUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GzipUtilsTestCase.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GzipUtilsTestCase.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GzipUtilsTestCase.java Tue Feb 17 00:40:20 2015
@@ -18,12 +18,14 @@
*/
package org.apache.commons.compress.compressors;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
import org.apache.commons.compress.compressors.gzip.GzipUtils;
+import org.junit.Test;
-public class GzipUtilsTestCase extends TestCase {
+public class GzipUtilsTestCase {
+ @Test
public void testIsCompressedFilename() {
assertFalse(GzipUtils.isCompressedFilename(""));
assertFalse(GzipUtils.isCompressedFilename(".gz"));
@@ -53,6 +55,7 @@ public class GzipUtilsTestCase extends T
assertFalse(GzipUtils.isCompressedFilename("x.wmz.y"));
}
+ @Test
public void testGetUncompressedFilename() {
assertEquals("", GzipUtils.getUncompressedFilename(""));
assertEquals(".gz", GzipUtils.getUncompressedFilename(".gz"));
@@ -78,6 +81,7 @@ public class GzipUtilsTestCase extends T
assertEquals("x.wmz.y", GzipUtils.getUncompressedFilename("x.wmz.y"));
}
+ @Test
public void testGetCompressedFilename() {
assertEquals(".gz", GzipUtils.getCompressedFilename(""));
assertEquals("x.gz", GzipUtils.getCompressedFilename("x"));
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/xz/XZUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/xz/XZUtilsTestCase.java?rev=1660261&r1=1660260&r2=1660261&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/xz/XZUtilsTestCase.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/xz/XZUtilsTestCase.java Tue Feb 17 00:40:20 2015
@@ -18,10 +18,13 @@
*/
package org.apache.commons.compress.compressors.xz;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
-public class XZUtilsTestCase extends TestCase {
+import org.junit.Test;
+public class XZUtilsTestCase {
+
+ @Test
public void testIsCompressedFilename() {
assertFalse(XZUtils.isCompressedFilename(""));
assertFalse(XZUtils.isCompressedFilename(".xz"));
@@ -39,6 +42,7 @@ public class XZUtilsTestCase extends Tes
assertFalse(XZUtils.isCompressedFilename("x.txz.y"));
}
+ @Test
public void testGetUncompressedFilename() {
assertEquals("", XZUtils.getUncompressedFilename(""));
assertEquals(".xz", XZUtils.getUncompressedFilename(".xz"));
@@ -52,6 +56,7 @@ public class XZUtilsTestCase extends Tes
assertEquals("x.txz.y", XZUtils.getUncompressedFilename("x.txz.y"));
}
+ @Test
public void testGetCompressedFilename() {
assertEquals(".xz", XZUtils.getCompressedFilename(""));
assertEquals("x.xz", XZUtils.getCompressedFilename("x"));
@@ -63,6 +68,7 @@ public class XZUtilsTestCase extends Tes
assertEquals("x.wmf.y.xz", XZUtils.getCompressedFilename("x.wmf.y"));
}
+ @Test
public void testMatches() {
byte[] data = {
(byte) 0xFD, '7', 'z', 'X', 'Z', '\0'
@@ -74,11 +80,13 @@ public class XZUtilsTestCase extends Tes
assertFalse(XZUtils.matches(data, 6));
}
+ @Test
public void testCachingIsEnabledByDefaultAndXZIsPresent() {
assertEquals(XZUtils.CachedAvailability.CACHED_AVAILABLE, XZUtils.getCachedXZAvailability());
assertTrue(XZUtils.isXZCompressionAvailable());
}
+ @Test
public void testCanTurnOffCaching() {
try {
XZUtils.setCacheXZAvailablity(false);
@@ -89,6 +97,7 @@ public class XZUtilsTestCase extends Tes
}
}
+ @Test
public void testTurningOnCachingReEvaluatesAvailability() {
try {
XZUtils.setCacheXZAvailablity(false);