From: Hiroshi Miura Date: Sun, 16 Jan 2022 02:11:47 +0000 (+0900) Subject: Move to JUnit5/Jupiter X-Git-Tag: v0.10.0~22^2~4 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=6f87c4382f23d88b3e8c8ec15b70f4d4a8e1369d;p=dictzip-java%2Fdictzip-java.git Move to JUnit5/Jupiter Signed-off-by: Hiroshi Miura --- diff --git a/build.gradle b/build.gradle index d7721b8..aa6ac40 100644 --- a/build.gradle +++ b/build.gradle @@ -42,9 +42,14 @@ subprojects { dependencies { testImplementation 'commons-io:commons-io:2.8.0' - testImplementation 'org.testng:testng:7.4.0' + testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.1" + testImplementation "org.junit.jupiter:junit-jupiter:5.8.1" + testImplementation "org.junit-pioneer:junit-pioneer:0.1.2" + } + + test { + useJUnitPlatform() } - test.useTestNG() java { sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/dictzip-cli/src/test/java/org/dict/zip/cli/CommandLineTest.java b/dictzip-cli/src/test/java/org/dict/zip/cli/CommandLineTest.java index 238e831..85b8d1b 100644 --- a/dictzip-cli/src/test/java/org/dict/zip/cli/CommandLineTest.java +++ b/dictzip-cli/src/test/java/org/dict/zip/cli/CommandLineTest.java @@ -1,12 +1,12 @@ package org.dict.zip.cli; import org.dict.zip.DictZipHeader; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** diff --git a/dictzip-cli/src/test/java/org/dict/zip/cli/DictDataTest.java b/dictzip-cli/src/test/java/org/dict/zip/cli/DictDataTest.java index 17d509f..a9c5a29 100644 --- a/dictzip-cli/src/test/java/org/dict/zip/cli/DictDataTest.java +++ b/dictzip-cli/src/test/java/org/dict/zip/cli/DictDataTest.java @@ -20,15 +20,14 @@ package org.dict.zip.cli; -import static org.testng.Assert.assertTrue; import java.io.File; import java.net.URL; +import static org.junit.jupiter.api.Assertions.assertTrue; import static tokyo.northside.io.FileUtils2.contentEquals; import org.dict.zip.DictZipHeader; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; /** diff --git a/dictzip-lib/src/test/java/org/dict/zip/DictZipFileUtilsTest.java b/dictzip-lib/src/test/java/org/dict/zip/DictZipFileUtilsTest.java index 33f5e91..418fe6e 100644 --- a/dictzip-lib/src/test/java/org/dict/zip/DictZipFileUtilsTest.java +++ b/dictzip-lib/src/test/java/org/dict/zip/DictZipFileUtilsTest.java @@ -36,13 +36,14 @@ */ package org.dict.zip; -import org.testng.annotations.Test; + +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static tokyo.northside.io.FileUtils2.contentEquals; /** @@ -53,7 +54,6 @@ public class DictZipFileUtilsTest { * Check equals two file contentss. * @throws Exception when fails to open. */ - @Test public void testContentEquals() throws Exception { System.out.println("isFileBinaryEquals"); File firstFile = new File(this.getClass().getResource("/test_util.txt").getFile()); @@ -150,7 +150,6 @@ public class DictZipFileUtilsTest { try (DictZipInputStream dzin = new DictZipInputStream(new RandomAccessInputStream(targetFile, "r"))) { assertTrue(DictZipFileUtils.checkDictZipInputStream(dzin)); - dzin.close(); } } } diff --git a/dictzip-lib/src/test/java/org/dict/zip/DictZipHeaderTest.java b/dictzip-lib/src/test/java/org/dict/zip/DictZipHeaderTest.java index 9061b29..dd2b151 100644 --- a/dictzip-lib/src/test/java/org/dict/zip/DictZipHeaderTest.java +++ b/dictzip-lib/src/test/java/org/dict/zip/DictZipHeaderTest.java @@ -36,16 +36,15 @@ */ package org.dict.zip; -import org.testng.annotations.Test; - import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import org.dict.zip.DictZipHeader.CompressionLevel; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static tokyo.northside.io.FileUtils2.contentEquals; diff --git a/dictzip-lib/src/test/java/org/dict/zip/DictZipInputStreamTest.java b/dictzip-lib/src/test/java/org/dict/zip/DictZipInputStreamTest.java index 3da397c..1e6d8ca 100644 --- a/dictzip-lib/src/test/java/org/dict/zip/DictZipInputStreamTest.java +++ b/dictzip-lib/src/test/java/org/dict/zip/DictZipInputStreamTest.java @@ -37,17 +37,16 @@ package org.dict.zip; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.EOFException; import java.io.FileInputStream; import java.io.IOException; import java.util.Arrays; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static tokyo.northside.io.IOUtils2.contentEquals; /** @@ -57,318 +56,311 @@ import static tokyo.northside.io.IOUtils2.contentEquals; public class DictZipInputStreamTest { private final String dataFile = this.getClass().getResource("/test.dict.dz").getFile(); - private DictZipInputStream din; /** - * rewind dictionary file. - * + * Test constructor @TestFactory. * @throws Exception when i/o error. */ - @BeforeMethod - public void rewind() throws Exception { - if (din != null) { - din.seek(0); - } - } - - /** - * Test constructor. - * @throws Exception when i/o error. - */ - @Test (groups = "init", dependsOnMethods = { "testConstructorFromFilename", - "testConstructorDefaultBufSize"}) - public void testConstructor() throws Exception { - din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534); - } - - /** - * Test constructor. - * @throws Exception when i/o error. - */ - @Test (groups = "init") + @Test public void testConstructorDefaultBufSize() throws Exception { - din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r")); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"))) { + // pass + } } /** * Test constructor from filename. * @throws Exception when i/o error. */ - @Test (groups = "init") + @Test public void testConstructorFromFilename() throws Exception { - din = new DictZipInputStream(dataFile); - } - - /** - * Test close of stream. - * @throws Exception if I/O error occurred. - */ - @Test (groups = "exit", dependsOnGroups = { "test" }) - public void testClose() throws Exception { - din.close(); - din = null; + try (DictZipInputStream din = new DictZipInputStream(dataFile)) { + // pass + } } /** * Test of read method, of class DictZipInputStream. * @throws Exception when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testRead() throws Exception { - System.out.println("read"); int len = 10; byte[] buf = new byte[len]; byte[] expResult = {0x70, 0x72, (byte) 0xc3, (byte) 0xa9, 0x70, 0x2e, 0x20, 0x3a, 0x20, 0x2b}; - din.read(buf, 0, len); - assertTrue(Arrays.equals(expResult, buf)); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + din.seek(0); + din.read(buf, 0, len); + assertTrue(Arrays.equals(expResult, buf)); + } } /** * Test of read method, of class DictZipInputStream. * @throws Exception when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testReadWithSeek() throws Exception { - System.out.println("read with seek"); - int start = 0x20; - int len = 10; - din.seek(start); - byte[] buf = new byte[len]; - byte[] expResult = { - 0x61, 0x70, 0x72, (byte) 0xc3, (byte) 0xa8, 0x73, 0x20, 0x75, 0x6e, 0x20 - }; - din.read(buf, 0, len); - assertTrue(Arrays.equals(buf, expResult)); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + int start = 0x20; + int len = 10; + din.seek(start); + byte[] buf = new byte[len]; + byte[] expResult = { + 0x61, 0x70, 0x72, (byte) 0xc3, (byte) 0xa8, 0x73, 0x20, 0x75, 0x6e, 0x20 + }; + din.read(buf, 0, len); + assertTrue(Arrays.equals(buf, expResult)); + } } /** * Test of read method, of class DictZipInputStream. * @throws Exception when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testReadNull() throws Exception { - System.out.println("read null buffer"); - int len = 10; - byte[] buf = null; - boolean r = false; - try { - din.read(buf, 0, len); - fail("Should be throw exception."); - } catch (NullPointerException e) { - // expected. - r = true; + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + int len = 10; + byte[] buf = null; + boolean r = false; + try { + din.read(buf, 0, len); + Assertions.fail("Should be throw exception."); + } catch (NullPointerException e) { + // expected. + r = true; + } + assertTrue(r, "Got NullPointerException when buffer is null"); } - assertTrue(r, "Got NullPointerException when buffer is null"); } /** * Test of read method, of class DictZipInputStream. * @throws Exception when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testReadOutOfBound() throws Exception { - System.out.println("read out of buffer size"); - int len = 10; - byte[] buf = new byte[len]; - boolean r = false; - try { - din.read(buf, 0, len + 10); - fail("Should be throw exception."); - } catch (IndexOutOfBoundsException e) { - // expected. - r = true; + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + int len = 10; + byte[] buf = new byte[len]; + boolean r = false; + try { + din.read(buf, 0, len + 10); + Assertions.fail("Should be throw exception."); + } catch (IndexOutOfBoundsException e) { + // expected. + r = true; + } + assertTrue(r, "Got IndexOutOfBoundException when size is over the buffer size"); } - assertTrue(r, "Got IndexOutOfBoundException when size is over the buffer size"); } /** * Test of read method, of class DictZipInputStream. * @throws Exception when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testReadZeroSize() throws Exception { - System.out.println("read zero size"); - int len = 512; - byte[] buf = new byte[len]; - int size = din.read(buf, 0, 0); - assertEquals(size, 0); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + int len = 512; + byte[] buf = new byte[len]; + int size = din.read(buf, 0, 0); + assertEquals(size, 0); + } } /** * Test of read method, of class DictZipInputStream. * @throws Exception when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testReadWithSeekLast() throws Exception { - System.out.println("read with seek to last"); - int start = 383273; - int len = 512; - din.seek(start); - byte[] buf = new byte[len]; - din.read(buf, 0, len); - int result = din.read(buf, 0, len); - assertEquals(result, -1); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + int start = 383273; + int len = 512; + din.seek(start); + byte[] buf = new byte[len]; + din.read(buf, 0, len); + int result = din.read(buf, 0, len); + assertEquals(result, -1); + } } - /** + /** * Test of readFully method, of class DictZipInputStream. * @throws Exception when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testReadFullyByteArr() throws Exception { - System.out.println("readFully"); - int start = 100; - int len = 10; - din.seek(start); - byte[] buf = new byte[len]; - din.readFully(buf); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + int start = 100; + int len = 10; + din.seek(start); + byte[] buf = new byte[len]; + din.readFully(buf); + } } /** * Test of readFully method, of class DictZipInputStream. * @throws Exception when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testReadFully3args() throws Exception { - System.out.println("readFully"); - int start = 200; - int len = 10; - din.seek(start); - byte[] buf = new byte[len]; - din.readFully(buf, 0, len); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + int start = 200; + int len = 10; + din.seek(start); + byte[] buf = new byte[len]; + din.readFully(buf, 0, len); + } } /** * Test of readFully method, of class DictZipInputStream. * @throws IOException when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testReadFullyReadTrailer() throws IOException { - System.out.println("readFully and readTrailer"); - byte[] buf = new byte[512]; - try { - din.readFully(buf); - } catch (EOFException e) { - // Normal, continue + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + byte[] buf = new byte[512]; + try { + din.readFully(buf); + } catch (EOFException e) { + // Normal, continue + } + // read trailer + din.readTrailer(); + assertEquals(din.getCrc(), 0x024d1f37); + assertEquals(din.getLength(), 383783); } - // read trailer - din.readTrailer(); - assertEquals(din.getCrc(), 0x024d1f37); - assertEquals(din.getLength(), 383783); } /** * Test getComplength method. * @throws IOException when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testGetCompLength() throws IOException { - System.out.println("getCompLength"); - assertEquals(din.getCompLength(), 136856); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + System.out.println("getCompLength"); + assertEquals(din.getCompLength(), 136856); + } } /** * Test getMtime method. * @throws IOException when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testGetMtime() throws IOException { - System.out.println("getMtime"); - assertEquals(din.getMtime(), 1193780332); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + assertEquals(din.getMtime(), 1193780332); + } } /** * Test getChunkLength method. * @throws IOException when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testGetChunkLength() throws IOException { - System.out.println("getChunkLength"); - assertEquals(din.getChunkLength(), 58315); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + System.out.println("getChunkLength"); + assertEquals(din.getChunkLength(), 58315); + } } /** * Test getChunkCount method. * @throws IOException when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testGetChunkCount() throws IOException { - System.out.println("getChunkCount"); - assertEquals(din.getChunkCount(), 7); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + System.out.println("getChunkCount"); + assertEquals(din.getChunkCount(), 7); + } } /** * Test getFilename method. * @throws IOException when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testGetFilename() throws IOException { - System.out.println("getFilename"); - assertEquals(din.getFilename(), "results.dict"); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + assertEquals(din.getFilename(), "results.dict"); + } } - /** + /** * Test readFully with large seek. - * @throws Exception when i/o error. + * @throws Exception when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + @Test public void testReadFullySeek2() throws Exception { - System.out.println("readFully_seek2"); - int start = 56003; - int len = 195; - try { - din.seek(start); - } catch (IOException ioe) { - fail("Unexpected IOException"); - } - byte[] buf = new byte[len]; - try { - din.readFully(buf); - } catch (EOFException eofe) { - fail("Unexpected EOF"); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + int start = 56003; + int len = 195; + try { + din.seek(start); + } catch (IOException ioe) { + Assertions.fail("Unexpected IOException"); + } + byte[] buf = new byte[len]; + try { + din.readFully(buf); + } catch (EOFException eofe) { + Assertions.fail("Unexpected EOF"); + } } } - /** - * Test with large seek. - * @throws Exception when i/o error. - */ - @Test (groups = "test", dependsOnMethods = { "testConstructor" }) + /** + * Test with large seek. + * @throws Exception when i/o error. + */ + @Test public void testReadSeek2() throws Exception { - System.out.println("read_seek2"); - int start = 56003; - int len = 195; - try { - din.seek(start); - } catch (IOException ioe) { - fail("Unexpected IOException"); - } - byte[] buf = new byte[len]; - int result = 0; - try { - result = din.read(buf, 0, len); - } catch (EOFException eofe) { - fail("Unexpected EOF"); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + System.out.println("read_seek2"); + int start = 56003; + int len = 195; + try { + din.seek(start); + } catch (IOException ioe) { + Assertions.fail("Unexpected IOException"); + } + byte[] buf = new byte[len]; + int result = 0; + try { + result = din.read(buf, 0, len); + } catch (EOFException eofe) { + Assertions.fail("Unexpected EOF"); + } + assertEquals(result, len); } - assertEquals(result, len); } /** * Test with large seek comparison content. * @throws Exception when i/o error. */ - @Test (groups = "test", dependsOnMethods = { "testConstructor"}) + @Test public void testReadSeek3() throws Exception { - System.out.println("read_seek2"); - int start = 56003; - int len = 195; - try { - din.seek(start); - } catch (IOException ioe) { - fail("Unexpected IOException"); + try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"), 65534)) { + int start = 56003; + int len = 195; + try { + din.seek(start); + } catch (IOException ioe) { + Assertions.fail("Unexpected IOException"); + } + FileInputStream in2 = new FileInputStream(this.getClass().getResource("/test.dict.expected").getFile()); + in2.skip(start); + assertTrue(contentEquals(din, in2, 0, len)); } - FileInputStream in2 = new FileInputStream(this.getClass().getResource("/test.dict.expected").getFile()); - in2.skip(start); - assertTrue(contentEquals(din, in2, 0, len)); } } diff --git a/dictzip-lib/src/test/java/org/dict/zip/DictZipLargeFileTest.java b/dictzip-lib/src/test/java/org/dict/zip/DictZipLargeFileTest.java index dce0fb8..d20287d 100644 --- a/dictzip-lib/src/test/java/org/dict/zip/DictZipLargeFileTest.java +++ b/dictzip-lib/src/test/java/org/dict/zip/DictZipLargeFileTest.java @@ -36,7 +36,10 @@ */ package org.dict.zip; -import org.testng.annotations.Test; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junitpioneer.jupiter.TempDirectory; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; @@ -49,6 +52,7 @@ import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.RandomAccessFile; import java.nio.charset.StandardCharsets; +import java.nio.file.Path; import java.util.Random; import java.util.zip.Deflater; @@ -88,16 +92,16 @@ public class DictZipLargeFileTest { *

*/ @Test - public void testLargeFileInputOutput() throws IOException { - System.out.println("LargeFileCompress"); + @ExtendWith(TempDirectory.class) + public void testLargeFileInputOutput(@TempDirectory.TempDir Path tempDir) throws IOException { File inputFile = prepareTextData(); - String zippedFile = "DictZipLargeText.dz"; + Path zippedFile = tempDir.resolve("DictZipLargeText.dz"); int defLevel = Deflater.DEFAULT_COMPRESSION; byte[] buf = new byte[BUF_LEN]; try (FileInputStream ins = new FileInputStream(inputFile); DictZipOutputStream dout = new DictZipOutputStream( - new RandomAccessOutputStream(new RandomAccessFile(zippedFile, "rws")), + new RandomAccessOutputStream(new RandomAccessFile(zippedFile.toFile(), "rws")), BUF_LEN, inputFile.length(), defLevel)) { int len; while ((len = ins.read(buf, 0, BUF_LEN)) > 0) { @@ -106,10 +110,8 @@ public class DictZipLargeFileTest { } catch (EOFException eof) { // ignore it. } - // start assertion - File dictZipFile = new File(zippedFile); - readFromZip(dictZipFile, 0, 10); - readFromZip(dictZipFile, inputFile.length() - 2, 1); + // start assertion, read last bytes + readFromZip(zippedFile.toFile(), inputFile.length() - 2, 1); } private byte[] readFromZip(final File zippedFile, final long start, final int size) throws IOException { diff --git a/dictzip-lib/src/test/java/org/dict/zip/DictZipOutputStreamTest.java b/dictzip-lib/src/test/java/org/dict/zip/DictZipOutputStreamTest.java index 0afa48e..b699d9d 100644 --- a/dictzip-lib/src/test/java/org/dict/zip/DictZipOutputStreamTest.java +++ b/dictzip-lib/src/test/java/org/dict/zip/DictZipOutputStreamTest.java @@ -37,16 +37,16 @@ package org.dict.zip; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; - -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; import java.util.zip.Checksum; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * DictZipOutputStream test. @@ -76,7 +76,7 @@ public class DictZipOutputStreamTest { } assertEquals(r, 1, "DictZip instance can still be used after close is called"); } catch (IOException e) { - fail("an IO error occurred while trying to find the output file or creating DictZip constructor"); + Assertions.fail("an IO error occurred while trying to find the output file or creating DictZip constructor"); } } @@ -130,7 +130,7 @@ public class DictZipOutputStreamTest { instance = new TestDictZipOutputStream(outFile, 10); instance.write(b); } catch (Exception e) { - fail("Unwanted exception happens."); + Assertions.fail("Unwanted exception happens."); } } @@ -157,7 +157,7 @@ public class DictZipOutputStreamTest { } assertEquals(r, 1, "DictZip instance can still be used after finish is called"); } catch (Exception ex) { - fail("an IO error occured while trying to find the output file or creating DictZip constructor"); + Assertions.fail("an IO error occured while trying to find the output file or creating DictZip constructor"); } try { File testOutFile = File.createTempFile("DictZipOutCon", ".txt"); @@ -168,7 +168,7 @@ public class DictZipOutputStreamTest { instance.close(); instance.finish(); - fail("Expected IOException"); + Assertions.fail("Expected IOException"); } catch (IOException e) { // expected } diff --git a/dictzip-lib/src/test/java/org/dict/zip/RandomAccessInputStreamTest.java b/dictzip-lib/src/test/java/org/dict/zip/RandomAccessInputStreamTest.java index 4defd60..3f7a670 100644 --- a/dictzip-lib/src/test/java/org/dict/zip/RandomAccessInputStreamTest.java +++ b/dictzip-lib/src/test/java/org/dict/zip/RandomAccessInputStreamTest.java @@ -37,11 +37,12 @@ package org.dict.zip; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test for project. @@ -113,7 +114,7 @@ public class RandomAccessInputStreamTest { RandomAccessInputStream instance = new RandomAccessInputStream(dataFile, "r"); instance.mark(markpos); } catch (Exception ex) { - fail("get exception."); + Assertions.fail("get exception."); } } @@ -128,7 +129,7 @@ public class RandomAccessInputStreamTest { boolean result = instance.markSupported(); assertTrue(result); } catch (Exception ex) { - fail("get exception."); + Assertions.fail("get exception."); } } @@ -145,7 +146,7 @@ public class RandomAccessInputStreamTest { int result = instance.read(); assertEquals(result, expResult); } catch (Exception ex) { - fail("get exception."); + Assertions.fail("get exception."); } }