Skip to content

Commit b859da9

Browse files
author
Justin Lu
committed
8316696: Remove the testing base classes: IntlTest and CollatorTest
Reviewed-by: naoto
1 parent b438cff commit b859da9

File tree

79 files changed

+3384
-3543
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3384
-3543
lines changed

test/jdk/java/text/BreakIterator/BreakIteratorTest.java

Lines changed: 112 additions & 84 deletions
Large diffs are not rendered by default.

test/jdk/java/text/BreakIterator/Bug4533872.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,18 +24,18 @@
2424
/**
2525
* @test
2626
* @bug 4533872 4640853
27-
* @library /java/text/testlib
2827
* @summary Unit tests for supplementary character support (JSR-204) and Unicode 4.0 support
28+
* @run junit Bug4533872
2929
*/
3030

3131
import java.text.BreakIterator;
3232
import java.util.Locale;
3333

34-
public class Bug4533872 extends IntlTest {
34+
import org.junit.jupiter.api.Test;
3535

36-
public static void main(String[] args) throws Exception {
37-
new Bug4533872().run(args);
38-
}
36+
import static org.junit.jupiter.api.Assertions.fail;
37+
38+
public class Bug4533872 {
3939

4040
static final String[] given = {
4141
/* Lu Nd Lu Ll */
@@ -73,7 +73,7 @@ void TestNext() {
7373
end = iter.next();
7474

7575
if (!expected[i][j].equals(given[i].substring(start, end))) {
76-
errln("Word break failure: printEachForward() expected:<" +
76+
fail("Word break failure: printEachForward() expected:<" +
7777
expected[i][j] + ">, got:<" +
7878
given[i].substring(start, end) +
7979
"> start=" + start + " end=" + end);
@@ -95,7 +95,7 @@ void TestIsBoundary() {
9595

9696
while (end < given[i].length()) {
9797
if (!iter.isBoundary(end)) {
98-
errln("Word break failure: isBoundary() This should be a boundary. Index=" +
98+
fail("Word break failure: isBoundary() This should be a boundary. Index=" +
9999
end + " for " + given[i]);
100100
}
101101
end = iter.next();
@@ -122,7 +122,7 @@ void TestPrintEachForward() {
122122
// Check current()'s return value - should be same as first()'s.
123123
current = iter.current();
124124
if (start != current) {
125-
errln("Word break failure: printEachForward() Unexpected current value: current()=" +
125+
fail("Word break failure: printEachForward() Unexpected current value: current()=" +
126126
current + ", expected(=first())=" + start);
127127
}
128128

@@ -134,12 +134,12 @@ void TestPrintEachForward() {
134134
// Check current()'s return value - should be same as next()'s.
135135
current = iter.current();
136136
if (end != current) {
137-
errln("Word break failure: printEachForward() Unexpected current value: current()=" +
137+
fail("Word break failure: printEachForward() Unexpected current value: current()=" +
138138
current + ", expected(=next())=" + end);
139139
}
140140

141141
if (!expected[i][j].equals(given[i].substring(start, end))) {
142-
errln("Word break failure: printEachForward() expected:<" +
142+
fail("Word break failure: printEachForward() expected:<" +
143143
expected[i][j] + ">, got:<" +
144144
given[i].substring(start, end) +
145145
"> start=" + start + " end=" + end);
@@ -161,7 +161,7 @@ void TestPrintEachBackward() {
161161
// Check current()'s return value - should be same as last()'s.
162162
current = iter.current();
163163
if (end != current) {
164-
errln("Word break failure: printEachBackward() Unexpected current value: current()=" +
164+
fail("Word break failure: printEachBackward() Unexpected current value: current()=" +
165165
current + ", expected(=last())=" + end);
166166
}
167167

@@ -173,12 +173,12 @@ void TestPrintEachBackward() {
173173
// Check current()'s return value - should be same as previous()'s.
174174
current = iter.current();
175175
if (start != current) {
176-
errln("Word break failure: printEachBackward() Unexpected current value: current()=" +
176+
fail("Word break failure: printEachBackward() Unexpected current value: current()=" +
177177
current + ", expected(=previous())=" + start);
178178
}
179179

180180
if (!expected[i][j].equals(given[i].substring(start, end))) {
181-
errln("Word break failure: printEachBackward() expected:<" +
181+
fail("Word break failure: printEachBackward() expected:<" +
182182
expected[i][j] + ">, got:<" +
183183
given[i].substring(start, end) +
184184
"> start=" + start + " end=" + end);
@@ -207,7 +207,7 @@ void TestPrintAt_1() {
207207
start = iter.previous();
208208

209209
if (!expected[i][j].equals(given[i].substring(start, end))) {
210-
errln("Word break failure: printAt_1() expected:<" +
210+
fail("Word break failure: printAt_1() expected:<" +
211211
expected[i][j] + ">, got:<" +
212212
given[i].substring(start, end) +
213213
"> start=" + start + " end=" + end);
@@ -234,7 +234,7 @@ void TestPrintAt_2() {
234234

235235
// Check preceding(0)'s return value - should equals BreakIterator.DONE.
236236
if (iter.preceding(0) != BreakIterator.DONE) {
237-
errln("Word break failure: printAt_2() expected:-1(BreakIterator.DONE), got:" +
237+
fail("Word break failure: printAt_2() expected:-1(BreakIterator.DONE), got:" +
238238
iter.preceding(0));
239239
}
240240

@@ -243,7 +243,7 @@ void TestPrintAt_2() {
243243
end = iter.next();
244244

245245
if (!expected[i][j].equals(given[i].substring(start, end))) {
246-
errln("Word break failure: printAt_2() expected:<" +
246+
fail("Word break failure: printAt_2() expected:<" +
247247
expected[i][j] + ">, got:<" +
248248
given[i].substring(start, end) +
249249
"> start=" + start + " end=" + end);
@@ -254,7 +254,7 @@ void TestPrintAt_2() {
254254
end = iter.last();
255255
start = iter.next();
256256
if (start != BreakIterator.DONE) {
257-
errln("Word break failure: printAt_2() expected:-1(BreakIterator.DONE), got:" + start);
257+
fail("Word break failure: printAt_2() expected:-1(BreakIterator.DONE), got:" + start);
258258
}
259259
}
260260
}

test/jdk/java/text/CharacterIterator/CharacterIteratorTest.java

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,8 @@
2323

2424
/*
2525
* @test
26-
* @library /java/text/testlib
2726
* @summary test for Character Iterator
27+
* @run junit CharacterIteratorTest
2828
*/
2929

3030
/*
@@ -65,14 +65,15 @@
6565

6666
import java.text.*;
6767

68-
public class CharacterIteratorTest extends IntlTest {
69-
public static void main(String[] args) throws Exception {
70-
new CharacterIteratorTest().run(args);
71-
}
68+
import org.junit.jupiter.api.Test;
69+
70+
import static org.junit.jupiter.api.Assertions.fail;
7271

72+
public class CharacterIteratorTest {
7373
public CharacterIteratorTest() {
7474
}
7575

76+
@Test
7677
public void TestConstructionAndEquality() {
7778
String testText = "Now is the time for all good men to come to the aid of their country.";
7879
String testText2 = "Don't bother using this string.";
@@ -84,49 +85,50 @@ public void TestConstructionAndEquality() {
8485
CharacterIterator test5 = (CharacterIterator)test1.clone();
8586

8687
if (test1.equals(test2) || test1.equals(test3) || test1.equals(test4))
87-
errln("Construation or equals() failed: Two unequal iterators tested equal");
88+
fail("Construation or equals() failed: Two unequal iterators tested equal");
8889

8990
if (!test1.equals(test5))
90-
errln("clone() or equals() failed: Two clones tested unequal");
91+
fail("clone() or equals() failed: Two clones tested unequal");
9192

9293
if (test1.hashCode() == test2.hashCode() || test1.hashCode() == test3.hashCode()
9394
|| test1.hashCode() == test4.hashCode())
94-
errln("hash() failed: different objects have same hash code");
95+
fail("hash() failed: different objects have same hash code");
9596

9697
if (test1.hashCode() != test5.hashCode())
97-
errln("hash() failed: identical objects have different hash codes");
98+
fail("hash() failed: identical objects have different hash codes");
9899

99100
test1.setIndex(5);
100101
if (!test1.equals(test2) || test1.equals(test5))
101-
errln("setIndex() failed");
102+
fail("setIndex() failed");
102103
}
103104

105+
@Test
104106
public void TestIteration() {
105107
String text = "Now is the time for all good men to come to the aid of their country.";
106108

107109
CharacterIterator iter = new StringCharacterIterator(text, 5);
108110

109111
if (iter.current() != text.charAt(5))
110-
errln("Iterator didn't start out in the right place.");
112+
fail("Iterator didn't start out in the right place.");
111113

112114
char c = iter.first();
113115
int i = 0;
114116

115117
if (iter.getBeginIndex() != 0 || iter.getEndIndex() != text.length())
116-
errln("getBeginIndex() or getEndIndex() failed");
118+
fail("getBeginIndex() or getEndIndex() failed");
117119

118-
logln("Testing forward iteration...");
120+
System.out.println("Testing forward iteration...");
119121
do {
120122
if (c == CharacterIterator.DONE && i != text.length())
121-
errln("Iterator reached end prematurely");
123+
fail("Iterator reached end prematurely");
122124
else if (c != text.charAt(i))
123-
errln("Character mismatch at position " + i + ", iterator has " + c +
125+
fail("Character mismatch at position " + i + ", iterator has " + c +
124126
", string has " + text.charAt(c));
125127

126128
if (iter.current() != c)
127-
errln("current() isn't working right");
129+
fail("current() isn't working right");
128130
if (iter.getIndex() != i)
129-
errln("getIndex() isn't working right");
131+
fail("getIndex() isn't working right");
130132

131133
if (c != CharacterIterator.DONE) {
132134
c = iter.next();
@@ -137,18 +139,18 @@ else if (c != text.charAt(i))
137139
c = iter.last();
138140
i = text.length() - 1;
139141

140-
logln("Testing backward iteration...");
142+
System.out.println("Testing backward iteration...");
141143
do {
142144
if (c == CharacterIterator.DONE && i >= 0)
143-
errln("Iterator reached end prematurely");
145+
fail("Iterator reached end prematurely");
144146
else if (c != text.charAt(i))
145-
errln("Character mismatch at position " + i + ", iterator has " + c +
147+
fail("Character mismatch at position " + i + ", iterator has " + c +
146148
", string has " + text.charAt(c));
147149

148150
if (iter.current() != c)
149-
errln("current() isn't working right");
151+
fail("current() isn't working right");
150152
if (iter.getIndex() != i)
151-
errln("getIndex() isn't working right");
153+
fail("getIndex() isn't working right");
152154

153155
if (c != CharacterIterator.DONE) {
154156
c = iter.previous();
@@ -158,26 +160,26 @@ else if (c != text.charAt(i))
158160

159161
iter = new StringCharacterIterator(text, 5, 15, 10);
160162
if (iter.getBeginIndex() != 5 || iter.getEndIndex() != 15)
161-
errln("creation of a restricted-range iterator failed");
163+
fail("creation of a restricted-range iterator failed");
162164

163165
if (iter.getIndex() != 10 || iter.current() != text.charAt(10))
164-
errln("starting the iterator in the middle didn't work");
166+
fail("starting the iterator in the middle didn't work");
165167

166168
c = iter.first();
167169
i = 5;
168170

169-
logln("Testing forward iteration over a range...");
171+
System.out.println("Testing forward iteration over a range...");
170172
do {
171173
if (c == CharacterIterator.DONE && i != 15)
172-
errln("Iterator reached end prematurely");
174+
fail("Iterator reached end prematurely");
173175
else if (c != text.charAt(i))
174-
errln("Character mismatch at position " + i + ", iterator has " + c +
176+
fail("Character mismatch at position " + i + ", iterator has " + c +
175177
", string has " + text.charAt(c));
176178

177179
if (iter.current() != c)
178-
errln("current() isn't working right");
180+
fail("current() isn't working right");
179181
if (iter.getIndex() != i)
180-
errln("getIndex() isn't working right");
182+
fail("getIndex() isn't working right");
181183

182184
if (c != CharacterIterator.DONE) {
183185
c = iter.next();
@@ -188,18 +190,18 @@ else if (c != text.charAt(i))
188190
c = iter.last();
189191
i = 14;
190192

191-
logln("Testing backward iteration over a range...");
193+
System.out.println("Testing backward iteration over a range...");
192194
do {
193195
if (c == CharacterIterator.DONE && i >= 5)
194-
errln("Iterator reached end prematurely");
196+
fail("Iterator reached end prematurely");
195197
else if (c != text.charAt(i))
196-
errln("Character mismatch at position " + i + ", iterator has " + c +
198+
fail("Character mismatch at position " + i + ", iterator has " + c +
197199
", string has " + text.charAt(c));
198200

199201
if (iter.current() != c)
200-
errln("current() isn't working right");
202+
fail("current() isn't working right");
201203
if (iter.getIndex() != i)
202-
errln("getIndex() isn't working right");
204+
fail("getIndex() isn't working right");
203205

204206
if (c != CharacterIterator.DONE) {
205207
c = iter.previous();
@@ -211,6 +213,7 @@ else if (c != text.charAt(i))
211213
/**
212214
* @bug 4082050 4078261 4078255
213215
*/
216+
@Test
214217
public void TestPathologicalCases() {
215218
String text = "This is only a test.";
216219

@@ -227,7 +230,7 @@ public void TestPathologicalCases() {
227230
|| iter.previous() != CharacterIterator.DONE
228231
|| iter.current() != CharacterIterator.DONE
229232
|| iter.getIndex() != 5)
230-
errln("Got something other than DONE when performing operations on an empty StringCharacterIterator");
233+
fail("Got something other than DONE when performing operations on an empty StringCharacterIterator");
231234
*/
232235
CharacterIterator iter = null;
233236

@@ -242,7 +245,7 @@ public void TestPathologicalCases() {
242245
gotException = true;
243246
}
244247
if (!gotException)
245-
errln("StringCharacterIterator didn't throw an exception when given an invalid substring range.");
248+
fail("StringCharacterIterator didn't throw an exception when given an invalid substring range.");
246249

247250
// test for bug #4078255 (getting wrong value from next() when we're at the end
248251
// of the string)
@@ -253,24 +256,25 @@ public void TestPathologicalCases() {
253256
iter.last();
254257
actualIndex = iter.getIndex();
255258
if (actualIndex != expectedIndex - 1)
256-
errln("last() failed: expected " + (expectedIndex - 1) + ", got " + actualIndex);
259+
fail("last() failed: expected " + (expectedIndex - 1) + ", got " + actualIndex);
257260

258261
iter.next();
259262
actualIndex = iter.getIndex();
260263
if (actualIndex != expectedIndex)
261-
errln("next() after last() failed: expected " + expectedIndex + ", got " + actualIndex);
264+
fail("next() after last() failed: expected " + expectedIndex + ", got " + actualIndex);
262265

263266
iter.next();
264267
actualIndex = iter.getIndex();
265268
if (actualIndex != expectedIndex)
266-
errln("second next() after last() failed: expected " + expectedIndex + ", got " + actualIndex);
269+
fail("second next() after last() failed: expected " + expectedIndex + ", got " + actualIndex);
267270
}
268271

269272
/*
270273
* @bug 4123771 4051073
271274
* #4123771 is actually a duplicate of bug #4051073, which was fixed some time ago, but
272275
* no one ever added a regression test for it.
273276
*/
277+
@Test
274278
public void TestBug4123771() {
275279
String text = "Some string for testing";
276280
StringCharacterIterator iter = new StringCharacterIterator(text);
@@ -283,7 +287,7 @@ public void TestBug4123771() {
283287
System.out.println(" position: " + index);
284288
System.out.println(" getEndIndex(): " + iter.getEndIndex());
285289
System.out.println(" text.length(): " + text.length());
286-
errln(""); // re-throw the exception through our test framework
290+
fail(""); // re-throw the exception through our test framework
287291
}
288292
}
289293
}

0 commit comments

Comments
 (0)