Skip to content

Commit 11a275d

Browse files
committed
Convert EndOfCenValidation to JUnit 5
1 parent ccfa56e commit 11a275d

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

test/jdk/java/util/zip/ZipFile/EndOfCenValidation.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
* @bug 8272746
2626
* @modules java.base/jdk.internal.util
2727
* @summary Verify that ZipFile rejects files with CEN sizes exceeding the implementation limit
28-
* @run testng/othervm EndOfCenValidation
28+
* @run junit/othervm EndOfCenValidation
2929
*/
3030

3131
import jdk.internal.util.ArraysSupport;
32-
import org.testng.annotations.AfterTest;
33-
import org.testng.annotations.BeforeTest;
34-
import org.testng.annotations.Test;
32+
import org.junit.jupiter.api.BeforeEach;
33+
import org.junit.jupiter.api.AfterEach;
34+
import org.junit.jupiter.api.Test;
3535

3636
import java.io.*;
3737
import java.nio.ByteBuffer;
@@ -49,7 +49,7 @@
4949
import java.util.zip.ZipFile;
5050
import java.util.zip.ZipOutputStream;
5151

52-
import static org.testng.Assert.*;
52+
import static org.junit.jupiter.api.Assertions.*;
5353

5454
/**
5555
* This test augments {@link TestTooManyEntries}. It creates sparse ZIPs where
@@ -89,7 +89,7 @@ public class EndOfCenValidation {
8989
* Create a valid ZIP file, used as a template
9090
* @throws IOException if an error occurs
9191
*/
92-
@BeforeTest
92+
@BeforeEach
9393
public void setup() throws IOException {
9494
zipBytes = templateZip();
9595
}
@@ -98,7 +98,7 @@ public void setup() throws IOException {
9898
* Delete big files after test, in case the file system did not support sparse files.
9999
* @throws IOException if an error occurs
100100
*/
101-
@AfterTest
101+
@AfterEach
102102
public void cleanup() throws IOException {
103103
Files.deleteIfExists(CEN_TOO_LARGE_ZIP);
104104
Files.deleteIfExists(INVALID_CEN_SIZE);
@@ -116,11 +116,11 @@ public void shouldRejectTooLargeCenSize() throws IOException {
116116

117117
Path zip = zipWithModifiedEndRecord(size, true, 0, CEN_TOO_LARGE_ZIP);
118118

119-
ZipException ex = expectThrows(ZipException.class, () -> {
119+
ZipException ex = assertThrows(ZipException.class, () -> {
120120
new ZipFile(zip.toFile());
121121
});
122122

123-
assertEquals(ex.getMessage(), INVALID_CEN_SIZE_TOO_LARGE);
123+
assertEquals(INVALID_CEN_SIZE_TOO_LARGE, ex.getMessage());
124124
}
125125

126126
/**
@@ -136,11 +136,11 @@ public void shouldRejectInvalidCenSize() throws IOException {
136136

137137
Path zip = zipWithModifiedEndRecord(size, false, 0, INVALID_CEN_SIZE);
138138

139-
ZipException ex = expectThrows(ZipException.class, () -> {
139+
ZipException ex = assertThrows(ZipException.class, () -> {
140140
new ZipFile(zip.toFile());
141141
});
142142

143-
assertEquals(ex.getMessage(), INVALID_CEN_BAD_SIZE);
143+
assertEquals(INVALID_CEN_BAD_SIZE, ex.getMessage());
144144
}
145145

146146
/**
@@ -156,11 +156,11 @@ public void shouldRejectInvalidCenOffset() throws IOException {
156156

157157
Path zip = zipWithModifiedEndRecord(size, true, 100, BAD_CEN_OFFSET_ZIP);
158158

159-
ZipException ex = expectThrows(ZipException.class, () -> {
159+
ZipException ex = assertThrows(ZipException.class, () -> {
160160
new ZipFile(zip.toFile());
161161
});
162162

163-
assertEquals(ex.getMessage(), INVALID_CEN_BAD_OFFSET);
163+
assertEquals(INVALID_CEN_BAD_OFFSET, ex.getMessage());
164164
}
165165

166166
/**
@@ -275,12 +275,12 @@ public void shouldRejectBadTotalEntries() throws IOException {
275275
Files.write(zipFile, zipBytes);
276276

277277
// Verify that the END header is rejected
278-
ZipException ex = expectThrows(ZipException.class, () -> {
278+
ZipException ex = assertThrows(ZipException.class, () -> {
279279
try (var zf = new ZipFile(zipFile.toFile())) {
280280
}
281281
});
282282

283-
assertEquals(ex.getMessage(), INVALID_BAD_ENTRY_COUNT);
283+
assertEquals(INVALID_BAD_ENTRY_COUNT, ex.getMessage());
284284
}
285285

286286
/**

0 commit comments

Comments
 (0)