Skip to content

Commit 66d858c

Browse files
committed
junit4 is gone
1 parent 63aaf3c commit 66d858c

97 files changed

Lines changed: 323 additions & 338 deletions

File tree

Some content is hidden

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

src/test/java/org/htmlunit/BrowserVersionFeaturesTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
package org.htmlunit;
1616

1717
import static java.nio.charset.StandardCharsets.ISO_8859_1;
18-
import static org.junit.Assert.assertTrue;
19-
import static org.junit.Assert.fail;
18+
import static org.junit.jupiter.api.Assertions.assertTrue;
19+
import static org.junit.jupiter.api.Assertions.fail;
2020

2121
import java.io.File;
2222
import java.io.IOException;
@@ -76,9 +76,9 @@ public void unusedFeatures() throws Exception {
7676
useCount++;
7777
}
7878
}
79-
assertTrue("BrowserVersionFeatures.java: '" + feature.name() + "' in no longer in use.", useCount > 0);
80-
assertTrue("BrowserVersionFeatures.java: '" + feature.name() + "' is enabled for all supported browsers.",
81-
useCount < browsers.size());
79+
assertTrue(useCount > 0, "BrowserVersionFeatures.java: '" + feature.name() + "' in no longer in use.");
80+
assertTrue(useCount < browsers.size(),
81+
"BrowserVersionFeatures.java: '" + feature.name() + "' is enabled for all supported browsers.");
8282
}
8383

8484
for (final BrowserVersionFeatures feature : BrowserVersionFeatures.values()) {
@@ -95,9 +95,10 @@ public void unusedFeatures() throws Exception {
9595
continue;
9696
}
9797
}
98-
assertTrue("BrowserVersionFeatures.java: Annotation '"
98+
assertTrue(inUse,
99+
"BrowserVersionFeatures.java: Annotation '"
99100
+ annotatedBrowser + "' of feature '"
100-
+ feature.name() + "' in no longer in use.", inUse);
101+
+ feature.name() + "' in no longer in use.");
101102
}
102103
}
103104
}

src/test/java/org/htmlunit/BrowserVersionTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
*/
1515
package org.htmlunit;
1616

17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertFalse;
19-
import static org.junit.Assert.assertNotEquals;
20-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.assertEquals;
18+
import static org.junit.jupiter.api.Assertions.assertFalse;
19+
import static org.junit.jupiter.api.Assertions.assertTrue;
2120

2221
import java.util.TimeZone;
2322

23+
import org.junit.jupiter.api.Assertions;
2424
import org.junit.jupiter.api.Test;
2525

2626
/**
@@ -75,6 +75,6 @@ public void differentTimeZone() {
7575
assertFalse(BrowserVersion.FIREFOX == ffBerlin);
7676
assertFalse(BrowserVersion.FIREFOX.equals(ffBerlin));
7777

78-
assertNotEquals(BrowserVersion.FIREFOX.getSystemTimezone(), ffBerlin.getSystemTimezone());
78+
Assertions.assertNotEquals(BrowserVersion.FIREFOX.getSystemTimezone(), ffBerlin.getSystemTimezone());
7979
}
8080
}

src/test/java/org/htmlunit/CodeStyleTest.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
*/
1515
package org.htmlunit;
1616

17-
import static org.junit.Assert.fail;
18-
1917
import java.io.File;
2018
import java.io.IOException;
2119
import java.lang.reflect.Constructor;
@@ -37,10 +35,11 @@
3735
import org.apache.commons.io.FileUtils;
3836
import org.apache.commons.lang3.StringUtils;
3937
import org.apache.commons.logging.Log;
40-
import org.junit.After;
41-
import org.junit.AfterClass;
42-
import org.junit.Before;
43-
import org.junit.BeforeClass;
38+
import org.junit.jupiter.api.AfterAll;
39+
import org.junit.jupiter.api.AfterEach;
40+
import org.junit.jupiter.api.Assertions;
41+
import org.junit.jupiter.api.BeforeAll;
42+
import org.junit.jupiter.api.BeforeEach;
4443
import org.junit.jupiter.api.Test;
4544

4645
/**
@@ -64,7 +63,7 @@ public class CodeStyleTest {
6463
* After.
6564
* @throws IOException in case of error
6665
*/
67-
@After
66+
@AfterEach
6867
public void after() throws IOException {
6968
final StringBuilder sb = new StringBuilder();
7069
for (final String error : failures_) {
@@ -77,10 +76,10 @@ public void after() throws IOException {
7776

7877
final int errorsNumber = failures_.size();
7978
if (errorsNumber == 1) {
80-
fail(title_ + " error: " + sb);
79+
Assertions.fail(title_ + " error: " + sb);
8180
}
8281
else if (errorsNumber > 1) {
83-
fail(title_ + " " + errorsNumber + " errors: " + sb);
82+
Assertions.fail(title_ + " " + errorsNumber + " errors: " + sb);
8483
}
8584
}
8685

@@ -922,10 +921,10 @@ private void testTests(final File dir) throws Exception {
922921
if (ctor.getParameterTypes().length == 0) {
923922
for (final Method method : clazz.getDeclaredMethods()) {
924923
if (Modifier.isPublic(method.getModifiers())
925-
&& method.getAnnotation(Before.class) == null
926-
&& method.getAnnotation(BeforeClass.class) == null
927-
&& method.getAnnotation(After.class) == null
928-
&& method.getAnnotation(AfterClass.class) == null
924+
&& method.getAnnotation(BeforeEach.class) == null
925+
&& method.getAnnotation(BeforeAll.class) == null
926+
&& method.getAnnotation(AfterEach.class) == null
927+
&& method.getAnnotation(AfterAll.class) == null
929928
&& method.getAnnotation(Test.class) == null
930929
&& method.getReturnType() == Void.TYPE
931930
&& method.getParameterTypes().length == 0) {

src/test/java/org/htmlunit/CookieManager3Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
*/
1515
package org.htmlunit;
1616

17-
import static org.junit.Assert.assertEquals;
18-
import static org.junit.Assert.assertFalse;
19-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.jupiter.api.Assertions.assertEquals;
18+
import static org.junit.jupiter.api.Assertions.assertFalse;
19+
import static org.junit.jupiter.api.Assertions.assertTrue;
2020

2121
import java.util.Date;
2222

src/test/java/org/htmlunit/CookieManager4Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package org.htmlunit;
1616

1717
import static org.htmlunit.CookieManagerTest.HTML_ALERT_COOKIE;
18-
import static org.junit.Assert.fail;
18+
import static org.junit.jupiter.api.Assertions.fail;
1919

2020
import java.net.InetAddress;
2121
import java.net.URL;

src/test/java/org/htmlunit/DefaultCredentialsProvider2Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
package org.htmlunit;
1616

17-
import static org.junit.Assert.fail;
17+
import static org.junit.jupiter.api.Assertions.fail;
1818

1919
import java.io.StringWriter;
2020
import java.net.URL;

src/test/java/org/htmlunit/DefaultCredentialsProvider3Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
*/
1515
package org.htmlunit;
1616

17-
import static org.junit.Assert.assertNotNull;
18-
import static org.junit.Assert.assertNull;
17+
import static org.junit.jupiter.api.Assertions.assertNotNull;
18+
import static org.junit.jupiter.api.Assertions.assertNull;
1919

2020
import org.apache.commons.lang3.SerializationUtils;
2121
import org.apache.http.auth.AuthScope;

src/test/java/org/htmlunit/DefaultPageCreator2Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
package org.htmlunit;
1616

17-
import static org.junit.Assert.assertEquals;
17+
import static org.junit.jupiter.api.Assertions.assertEquals;
1818

1919
import org.htmlunit.DefaultPageCreator.PageType;
2020
import org.htmlunit.util.MimeType;

src/test/java/org/htmlunit/ExternalTest.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
package org.htmlunit;
1616

1717
import static java.nio.charset.StandardCharsets.ISO_8859_1;
18-
import static org.junit.Assert.assertEquals;
19-
import static org.junit.Assert.assertNotNull;
20-
import static org.junit.Assert.assertTrue;
2118

2219
import java.io.File;
2320
import java.net.UnknownHostException;
@@ -39,8 +36,8 @@
3936
import org.htmlunit.html.HtmlAnchor;
4037
import org.htmlunit.html.HtmlPage;
4138
import org.htmlunit.xml.XmlPage;
42-
import org.junit.Assert;
43-
import org.junit.Ignore;
39+
import org.junit.jupiter.api.Assertions;
40+
import org.junit.jupiter.api.Disabled;
4441
import org.junit.jupiter.api.Test;
4542

4643
/**
@@ -72,7 +69,7 @@ public class ExternalTest {
7269
*/
7370
@Test
7471
public void testEnvironment() throws Exception {
75-
assertEquals("en_US", Locale.getDefault().toString());
72+
Assertions.assertEquals("en_US", Locale.getDefault().toString());
7673
}
7774

7875
/**
@@ -114,7 +111,7 @@ public void pom() throws Exception {
114111
}
115112

116113
if (wrongVersions.size() > 0) {
117-
Assert.fail(String.join("\n ", wrongVersions));
114+
Assertions.fail(String.join("\n ", wrongVersions));
118115
}
119116

120117
assertVersion("org.sonatype.oss", "oss-parent", "9");
@@ -153,7 +150,7 @@ public void assertChromeDriver() throws Exception {
153150
break;
154151
}
155152
}
156-
assertEquals("Chrome Driver", version, CHROME_DRIVER_);
153+
Assertions.assertEquals(version, CHROME_DRIVER_);
157154
}
158155
}
159156

@@ -162,7 +159,7 @@ public void assertChromeDriver() throws Exception {
162159
* @throws Exception if an error occurs
163160
*/
164161
@Test
165-
@Ignore("javascript errors")
162+
@Disabled("javascript errors")
166163
public void assertEdgeDriver() throws Exception {
167164
try (WebClient webClient = buildWebClient()) {
168165
final HtmlPage page = webClient.getPage(EDGE_DRIVER_URL_);
@@ -182,7 +179,7 @@ public void assertEdgeDriver() throws Exception {
182179
break;
183180
}
184181
}
185-
assertEquals("Edge Driver", version, EDGE_DRIVER_);
182+
Assertions.assertEquals(version, EDGE_DRIVER_);
186183
}
187184
}
188185

@@ -196,7 +193,7 @@ public void assertGeckoDriver() throws Exception {
196193
try {
197194
final HtmlPage page = webClient.getPage(GECKO_DRIVER_URL_);
198195
final DomNodeList<DomNode> divs = page.querySelectorAll("li.breadcrumb-item-selected");
199-
assertEquals("Gecko Driver", divs.get(0).asNormalizedText(), "v" + GECKO_DRIVER_);
196+
Assertions.assertEquals(divs.get(0).asNormalizedText(), "v" + GECKO_DRIVER_);
200197
}
201198
catch (final FailingHttpStatusCodeException e) {
202199
// ignore
@@ -221,7 +218,7 @@ public void snapshot() throws Exception {
221218
break;
222219
}
223220
}
224-
assertNotNull(version);
221+
Assertions.assertNotNull(version);
225222
if (version.contains("SNAPSHOT")) {
226223
try (WebClient webClient = buildWebClient()) {
227224
final XmlPage page = webClient.getPage(SONATYPE_SNAPSHOT_REPO_URL_
@@ -231,7 +228,7 @@ public void snapshot() throws Exception {
231228
final long snapshotMillis = format.parse(timestamp).getTime();
232229
final long nowMillis = System.currentTimeMillis();
233230
final long days = TimeUnit.MILLISECONDS.toDays(nowMillis - snapshotMillis);
234-
assertTrue("Snapshot not deployed for " + days + " days", days < 14);
231+
Assertions.assertTrue(days < 14, "Snapshot not deployed for " + days + " days");
235232
}
236233
}
237234
}
@@ -271,7 +268,7 @@ private static void assertVersion(final String groupId, final String artifactId,
271268

272269
// it is ok if the pom uses a more recent version
273270
if (!isVersionAfter(pomVersion, latestMavenCentralVersion)) {
274-
assertEquals(groupId + ":" + artifactId, latestMavenCentralVersion, pomVersion);
271+
Assertions.assertEquals(/* groupId + ":" + artifactId, */ latestMavenCentralVersion, pomVersion);
275272
}
276273
}
277274
}

src/test/java/org/htmlunit/FailingHttpStatusCodeExceptionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
package org.htmlunit;
1616

17-
import static org.junit.Assert.fail;
17+
import static org.junit.jupiter.api.Assertions.fail;
1818

1919
import java.util.Collections;
2020

0 commit comments

Comments
 (0)