Skip to content

Commit b60f983

Browse files
committed
Upgrade JUnit4 dependency to version 4.13.1. (#426)
Replacing deprecated methods with designated replacements.
1 parent 1d3f849 commit b60f983

4 files changed

Lines changed: 17 additions & 41 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ subprojects {
4646
'jquery': '3.3.1-1',
4747
'jsonpath': '2.10.0',
4848
'jsoup': '1.15.4',
49-
'junit': '4.12',
49+
'junit': '4.13.1',
5050
'junit_jupiter': '5.8.2',
5151
'junit_platform': '1.4.2',
5252
'mockito': '2.27.0',

metafacture-json/src/test/java/org/metafacture/json/JsonDecoderTest.java

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.junit.Before;
2424
import org.junit.Rule;
2525
import org.junit.Test;
26-
import org.junit.rules.ExpectedException;
2726
import org.mockito.InOrder;
2827
import org.mockito.Mock;
2928
import org.mockito.Mockito;
@@ -41,9 +40,6 @@ public final class JsonDecoderTest {
4140
@Rule
4241
public MockitoRule mockitoRule = MockitoJUnit.rule();
4342

44-
@Rule
45-
public ExpectedException exception = ExpectedException.none();
46-
4743
@Mock
4844
private StreamReceiver receiver;
4945

@@ -322,44 +318,33 @@ public void testShouldProcessMultipleRecords() {
322318

323319
@Test
324320
public void testShouldOnlyParseObjects() {
325-
exception.expect(MetafactureException.class);
326-
exception.expectMessage("Unexpected token 'VALUE_NULL'");
327-
328-
jsonDecoder.process("null");
321+
Assert.assertThrows("Unexpected token 'VALUE_NULL'", MetafactureException.class, () ->
322+
jsonDecoder.process("null"));
329323
}
330324

331325
@Test
332326
public void testShouldNotParseIncompleteObjects() {
333-
exception.expect(MetafactureException.class);
334-
exception.expectMessage("Unexpected end-of-input");
335-
336-
jsonDecoder.process("{");
327+
Assert.assertThrows("Unexpected end-of-input", MetafactureException.class, () ->
328+
jsonDecoder.process("{"));
337329
}
338330

339331
@Test
340332
public void testShouldNotParseTrailingContent() {
341-
exception.expect(MetafactureException.class);
342-
exception.expectMessage("Unexpected token 'VALUE_NULL'");
343-
344-
jsonDecoder.process("{\"lit\":\"value\"}null");
333+
Assert.assertThrows("Unexpected token 'VALUE_NULL'", MetafactureException.class, () ->
334+
jsonDecoder.process("{\"lit\":\"value\"}null"));
345335
}
346336

347337
@Test
348338
public void testShouldNotParseTrailingGarbage() {
349-
exception.expect(MetafactureException.class);
350-
exception.expectMessage("Unrecognized token 'XXX'");
351-
352-
jsonDecoder.process("{\"lit\":\"value\"}XXX");
339+
Assert.assertThrows("Unrecognized token 'XXX'", MetafactureException.class, () ->
340+
jsonDecoder.process("{\"lit\":\"value\"}XXX"));
353341
}
354342

355343
@Test
356344
public void testShouldNotParseComments() {
357-
exception.expect(MetafactureException.class);
358-
exception.expectMessage("Unexpected character ('/' (code 47))");
359-
360345
Assert.assertFalse(jsonDecoder.getAllowComments());
361-
362-
jsonDecoder.process("//{\"lit\":\"value\"}");
346+
Assert.assertThrows("Unexpected character ('/' (code 47))", MetafactureException.class, () ->
347+
jsonDecoder.process("//{\"lit\":\"value\"}"));
363348
}
364349

365350
@Test
@@ -374,12 +359,9 @@ public void testShouldParseCommentsIfEnabled() {
374359

375360
@Test
376361
public void testShouldNotParseInlineComments() {
377-
exception.expect(MetafactureException.class);
378-
exception.expectMessage("Unexpected character ('/' (code 47))");
379-
380362
Assert.assertFalse(jsonDecoder.getAllowComments());
381-
382-
jsonDecoder.process("{\"lit\":/*comment*/\"value\"}");
363+
Assert.assertThrows("Unexpected character ('/' (code 47))", MetafactureException.class, () ->
364+
jsonDecoder.process("{\"lit\":/*comment*/\"value\"}"));
383365
}
384366

385367
@Test

metafacture-json/src/test/java/org/metafacture/json/JsonValidatorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
2424
import com.github.tomakehurst.wiremock.junit.WireMockRule;
2525
import org.hamcrest.CoreMatchers;
26+
import org.hamcrest.MatcherAssert;
2627
import org.junit.After;
27-
import org.junit.Assert;
2828
import org.junit.Before;
2929
import org.junit.Rule;
3030
import org.junit.Test;
@@ -114,7 +114,7 @@ private String readToString(final URL url) throws IOException {
114114
@Test
115115
public void callWireMockSchema() throws MalformedURLException, IOException {
116116
final String schemaContent = readToString(new URL(wireMockRule.baseUrl() + MAIN_SCHEMA));
117-
Assert.assertThat(schemaContent, CoreMatchers.both(CoreMatchers.containsString("$schema")).and(CoreMatchers.containsString("$ref")));
117+
MatcherAssert.assertThat(schemaContent, CoreMatchers.both(CoreMatchers.containsString("$schema")).and(CoreMatchers.containsString("$ref")));
118118
}
119119

120120
@Test

metafacture-yaml/src/test/java/org/metafacture/yaml/YamlDecoderTest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import org.metafacture.framework.MetafactureException;
2020
import org.metafacture.framework.StreamReceiver;
2121

22+
import org.junit.Assert;
2223
import org.junit.Rule;
2324
import org.junit.Test;
24-
import org.junit.rules.ExpectedException;
2525
import org.mockito.InOrder;
2626
import org.mockito.Mock;
2727
import org.mockito.Mockito;
@@ -45,9 +45,6 @@ public final class YamlDecoderTest {
4545
@Rule
4646
public MockitoRule mockitoRule = MockitoJUnit.rule();
4747

48-
@Rule
49-
public ExpectedException exception = ExpectedException.none();
50-
5148
@Mock
5249
private StreamReceiver receiver;
5350

@@ -300,10 +297,7 @@ public void testShouldParseInlineShellStyleComments() {
300297
}
301298

302299
private void assertException(final String message, final Consumer<YamlDecoder> in) {
303-
exception.expect(MetafactureException.class);
304-
exception.expectMessage(message);
305-
306-
assertDecode(in, o -> { });
300+
Assert.assertThrows(message, MetafactureException.class, () -> assertDecode(in, o -> { }));
307301
}
308302

309303
private void assertDecode(final Consumer<YamlDecoder> in, final Consumer<Supplier<StreamReceiver>> out) {

0 commit comments

Comments
 (0)