Skip to content

Commit 0b5a2e7

Browse files
author
Alexey Bakhtin
committed
8346140: [8u] tools/jar/ExtractFilesTest.java and tools/jar/MultipleManifestTest.java fails with jtreg5.1
Reviewed-by: syan, sgehwolf
1 parent 8eccf89 commit 0b5a2e7

File tree

2 files changed

+24
-41
lines changed

2 files changed

+24
-41
lines changed

jdk/test/tools/jar/ExtractFilesTest.java

+14-20
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@
3131
* @run junit/othervm ExtractFilesTest
3232
*/
3333

34-
import org.junit.jupiter.api.AfterAll;
35-
import org.junit.jupiter.api.Assertions;
36-
import org.junit.jupiter.api.BeforeAll;
37-
import org.junit.jupiter.api.Test;
38-
import org.junit.jupiter.api.TestInstance;
39-
import org.junit.jupiter.api.TestInstance.Lifecycle;
34+
import org.junit.*;
4035

4136
import java.io.ByteArrayOutputStream;
4237
import java.io.IOException;
@@ -51,13 +46,12 @@
5146
import jdk.testlibrary.FileUtils;
5247
import sun.tools.jar.Main;
5348

54-
@TestInstance(Lifecycle.PER_CLASS)
5549
public class ExtractFilesTest {
5650
private final String nl = System.lineSeparator();
5751
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
5852
private final PrintStream out = new PrintStream(baos);
5953

60-
@BeforeAll
54+
@Before
6155
public void setupJar() throws IOException {
6256
mkdir("test1 test2");
6357
echo("testfile1", "test1/testfile1");
@@ -66,7 +60,7 @@ public void setupJar() throws IOException {
6660
rm("test1 test2");
6761
}
6862

69-
@AfterAll
63+
@After
7064
public void cleanup() {
7165
rm("test.jar");
7266
}
@@ -83,7 +77,7 @@ public void testExtract() throws IOException {
8377
" inflated: testfile1" + nl +
8478
" inflated: testfile2" + nl;
8579
rm("META-INF testfile1 testfile2");
86-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
80+
Assert.assertArrayEquals(baos.toByteArray(), output.getBytes());
8781
}
8882

8983
/**
@@ -98,9 +92,9 @@ public void testOverwrite() throws IOException {
9892
" inflated: META-INF/MANIFEST.MF" + nl +
9993
" inflated: testfile1" + nl +
10094
" inflated: testfile2" + nl;
101-
Assertions.assertEquals("testfile1", cat("testfile1"));
95+
Assert.assertEquals("testfile1", cat("testfile1"));
10296
rm("META-INF testfile1 testfile2");
103-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
97+
Assert.assertArrayEquals(baos.toByteArray(), output.getBytes());
10498
}
10599

106100
/**
@@ -115,10 +109,10 @@ public void testKeptOldFile() throws IOException {
115109
" inflated: META-INF/MANIFEST.MF" + nl +
116110
" skipped: testfile1 exists" + nl +
117111
" inflated: testfile2" + nl;
118-
Assertions.assertEquals("", cat("testfile1"));
119-
Assertions.assertEquals("testfile2", cat("testfile2"));
112+
Assert.assertEquals("", cat("testfile1"));
113+
Assert.assertEquals("testfile2", cat("testfile2"));
120114
rm("META-INF testfile1 testfile2");
121-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
115+
Assert.assertArrayEquals(baos.toByteArray(), output.getBytes());
122116
}
123117

124118
/**
@@ -133,10 +127,10 @@ public void testGnuOptionsKeptOldFile() throws IOException {
133127
" inflated: META-INF/MANIFEST.MF" + nl +
134128
" skipped: testfile1 exists" + nl +
135129
" skipped: testfile2 exists" + nl;
136-
Assertions.assertEquals("", cat("testfile1"));
137-
Assertions.assertEquals("", cat("testfile2"));
130+
Assert.assertEquals("", cat("testfile1"));
131+
Assert.assertEquals("", cat("testfile2"));
138132
rm("META-INF testfile1 testfile2");
139-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
133+
Assert.assertArrayEquals(baos.toByteArray(), output.getBytes());
140134
}
141135

142136
/**
@@ -152,8 +146,8 @@ public void testWarningOnInvalidKeepOption() throws IOException {
152146
"testfile1" + nl +
153147
"testfile2" + nl;
154148

155-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
156-
Assertions.assertEquals("Warning: The k option is not valid with current usage, will be ignored." + nl, err);
149+
Assert.assertArrayEquals(baos.toByteArray(), output.getBytes());
150+
Assert.assertEquals("Warning: The k option is not valid with current usage, will be ignored." + nl, err);
157151
}
158152

159153
private Stream<Path> mkpath(String... args) {

jdk/test/tools/jar/MultipleManifestTest.java

+10-21
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@
3333

3434
import java.io.ByteArrayOutputStream;
3535

36-
import org.junit.jupiter.api.AfterAll;
37-
import org.junit.jupiter.api.AfterEach;
38-
import org.junit.jupiter.api.Assertions;
39-
import org.junit.jupiter.api.BeforeAll;
40-
import org.junit.jupiter.api.Test;
41-
import org.junit.jupiter.api.TestInstance;
42-
import org.junit.jupiter.api.TestInstance.Lifecycle;
36+
import org.junit.*;
4337

4438
import java.io.IOException;
4539
import java.io.InputStream;
@@ -60,8 +54,7 @@
6054
import jdk.testlibrary.FileUtils;
6155
import sun.tools.jar.Main;
6256

63-
@TestInstance(Lifecycle.PER_CLASS)
64-
class MultipleManifestTest {
57+
public class MultipleManifestTest {
6558
private final String nl = System.lineSeparator();
6659
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
6760
private final PrintStream jarOut = new PrintStream(baos);
@@ -85,8 +78,9 @@ class MultipleManifestTest {
8578
*
8679
* @throws IOException if an unexpected IOException occurs
8780
*/
88-
@AfterAll
81+
@After
8982
public void cleanup() throws IOException {
83+
rm("META-INF entry1.txt entry2.txt");
9084
Files.deleteIfExists(zip);
9185
}
9286

@@ -95,7 +89,7 @@ public void cleanup() throws IOException {
9589
*
9690
* @throws IOException if an error occurs
9791
*/
98-
@BeforeAll
92+
@Before
9993
public void writeManifestAsFirstSecondAndFourthEntry() throws IOException {
10094
int locPosA, locPosB, cenPos;
10195
System.out.printf("%n%n*****Creating Jar with the Manifest as the 1st, 2nd and 4th entry*****%n%n");
@@ -132,25 +126,20 @@ public void writeManifestAsFirstSecondAndFourthEntry() throws IOException {
132126
Files.write(zip, template);
133127
}
134128

135-
@AfterEach
136-
public void removeExtractedFiles() {
137-
rm("META-INF entry1.txt entry2.txt");
138-
}
139-
140129
/**
141130
* Extract by default should have the last manifest.
142131
*/
143132
@Test
144133
public void testOverwrite() throws IOException {
145134
jar("xvf " + zip.toString());
146135
println();
147-
Assertions.assertEquals("3.0", getManifestVersion());
136+
Assert.assertEquals("3.0", getManifestVersion());
148137
String output = " inflated: META-INF/MANIFEST.MF" + nl +
149138
" inflated: META-INF/MANIFEST.MF" + nl +
150139
" inflated: entry1.txt" + nl +
151140
" inflated: META-INF/MANIFEST.MF" + nl +
152141
" inflated: entry2.txt" + nl;
153-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
142+
Assert.assertArrayEquals(baos.toByteArray(), output.getBytes());
154143
}
155144

156145
/**
@@ -160,13 +149,13 @@ public void testOverwrite() throws IOException {
160149
public void testKeptOldFile() throws IOException {
161150
jar("xkvf " + zip.toString());
162151
println();
163-
Assertions.assertEquals("1.0", getManifestVersion());
152+
Assert.assertEquals("1.0", getManifestVersion());
164153
String output = " inflated: META-INF/MANIFEST.MF" + nl +
165154
" skipped: META-INF/MANIFEST.MF exists" + nl +
166155
" inflated: entry1.txt" + nl +
167156
" skipped: META-INF/MANIFEST.MF exists" + nl +
168157
" inflated: entry2.txt" + nl;
169-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
158+
Assert.assertArrayEquals(baos.toByteArray(), output.getBytes());
170159
}
171160

172161
private String getManifestVersion() throws IOException {
@@ -216,4 +205,4 @@ private void rm(String cmdline) {
216205
}
217206
});
218207
}
219-
}
208+
}

0 commit comments

Comments
 (0)