Skip to content

Commit 856a2b7

Browse files
authored
Merge pull request #152 from AlexandreCarlton/bump-junit-to-5
Bump JUnit 4.x to JUnit Jupiter 5
2 parents a5485c9 + 5bd1a76 commit 856a2b7

19 files changed

+78
-60
lines changed

build.gradle

+5-1
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@ jar {
6767
dependencies {
6868
api 'org.slf4j:slf4j-api:' + slf4jVersion
6969
testImplementation 'org.slf4j:slf4j-simple:' + slf4jVersion
70-
testImplementation 'junit:junit:4.12'
7170
testImplementation 'org.awaitility:awaitility:2.0.0'
71+
testImplementation "org.hamcrest:hamcrest:2.2"
7272
testImplementation 'com.github.ben-manes.caffeine:caffeine:2.9.0'
73+
testImplementation platform('org.junit:junit-bom:5.10.2')
74+
testImplementation 'org.junit.jupiter:junit-jupiter-api'
75+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
7376
}
7477

7578
task sourcesJar(type: Jar) {
@@ -96,6 +99,7 @@ test {
9699
testLogging {
97100
exceptionFormat = 'full'
98101
}
102+
useJUnitPlatform()
99103
}
100104

101105
publishing {

src/test/java/org/dataloader/DataLoaderBatchLoaderEnvironmentTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.dataloader;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

55
import java.util.ArrayList;
66
import java.util.HashMap;
@@ -14,8 +14,8 @@
1414
import static java.util.Collections.singletonList;
1515
import static org.dataloader.DataLoaderFactory.newDataLoader;
1616
import static org.dataloader.DataLoaderFactory.newMappedDataLoader;
17+
import static org.hamcrest.MatcherAssert.assertThat;
1718
import static org.hamcrest.Matchers.equalTo;
18-
import static org.junit.Assert.assertThat;
1919

2020
/**
2121
* Tests related to context. DataLoaderTest is getting to big and needs refactoring

src/test/java/org/dataloader/DataLoaderCacheMapTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package org.dataloader;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

55
import java.util.ArrayList;
66
import java.util.Collection;
77
import java.util.List;
88
import java.util.concurrent.CompletableFuture;
99

1010
import static org.dataloader.DataLoaderFactory.newDataLoader;
11+
import static org.hamcrest.MatcherAssert.assertThat;
1112
import static org.hamcrest.Matchers.equalTo;
12-
import static org.junit.Assert.assertThat;
1313

1414
/**
1515
* Tests for cacheMap functionality..

src/test/java/org/dataloader/DataLoaderIfPresentTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package org.dataloader;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

55
import java.util.Optional;
66
import java.util.concurrent.CompletableFuture;
77
import java.util.concurrent.CompletionStage;
88

99
import static org.dataloader.DataLoaderFactory.newDataLoader;
10+
import static org.hamcrest.MatcherAssert.assertThat;
1011
import static org.hamcrest.Matchers.equalTo;
1112
import static org.hamcrest.Matchers.sameInstance;
12-
import static org.junit.Assert.assertThat;
1313

1414
/**
1515
* Tests for IfPresent and IfCompleted functionality.

src/test/java/org/dataloader/DataLoaderMapBatchLoaderTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.dataloader;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

55
import java.util.ArrayList;
66
import java.util.Collection;
@@ -19,10 +19,10 @@
1919
import static org.dataloader.fixtures.TestKit.futureError;
2020
import static org.dataloader.fixtures.TestKit.listFrom;
2121
import static org.dataloader.impl.CompletableFutureKit.cause;
22+
import static org.hamcrest.MatcherAssert.assertThat;
2223
import static org.hamcrest.Matchers.equalTo;
2324
import static org.hamcrest.Matchers.instanceOf;
2425
import static org.hamcrest.Matchers.is;
25-
import static org.junit.Assert.assertThat;
2626

2727
/**
2828
* Much of the tests that related to {@link MappedBatchLoader} also related to

src/test/java/org/dataloader/DataLoaderRegistryTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
import org.dataloader.stats.SimpleStatisticsCollector;
44
import org.dataloader.stats.Statistics;
5-
import org.junit.Test;
5+
import org.junit.jupiter.api.Test;
66

77
import java.util.concurrent.CompletableFuture;
88

99
import static java.util.Arrays.asList;
1010
import static org.dataloader.DataLoaderFactory.newDataLoader;
11+
import static org.hamcrest.MatcherAssert.assertThat;
1112
import static org.hamcrest.Matchers.equalTo;
1213
import static org.hamcrest.Matchers.hasItems;
1314
import static org.hamcrest.Matchers.sameInstance;
14-
import static org.junit.Assert.assertThat;
1515

1616
public class DataLoaderRegistryTest {
1717
final BatchLoader<Object, Object> identityBatchLoader = CompletableFuture::completedFuture;

src/test/java/org/dataloader/DataLoaderStatsTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.dataloader.stats.context.IncrementCacheHitCountStatisticsContext;
1010
import org.dataloader.stats.context.IncrementLoadCountStatisticsContext;
1111
import org.dataloader.stats.context.IncrementLoadErrorCountStatisticsContext;
12-
import org.junit.Test;
12+
import org.junit.jupiter.api.Test;
1313

1414
import java.util.ArrayList;
1515
import java.util.List;
@@ -19,9 +19,9 @@
1919
import static java.util.Collections.singletonList;
2020
import static java.util.concurrent.CompletableFuture.completedFuture;
2121
import static org.dataloader.DataLoaderFactory.newDataLoader;
22+
import static org.hamcrest.MatcherAssert.assertThat;
2223
import static org.hamcrest.Matchers.equalTo;
2324
import static org.hamcrest.Matchers.hasSize;
24-
import static org.junit.Assert.assertThat;
2525

2626
/**
2727
* Tests related to stats. DataLoaderTest is getting to big and needs refactoring

src/test/java/org/dataloader/DataLoaderTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.dataloader.fixtures.User;
2323
import org.dataloader.fixtures.UserManager;
2424
import org.dataloader.impl.CompletableFutureKit;
25-
import org.junit.Test;
25+
import org.junit.jupiter.api.Test;
2626

2727
import java.util.ArrayList;
2828
import java.util.Collection;
@@ -43,12 +43,12 @@
4343
import static org.dataloader.DataLoaderOptions.newOptions;
4444
import static org.dataloader.fixtures.TestKit.listFrom;
4545
import static org.dataloader.impl.CompletableFutureKit.cause;
46+
import static org.hamcrest.MatcherAssert.assertThat;
4647
import static org.hamcrest.Matchers.empty;
4748
import static org.hamcrest.Matchers.equalTo;
4849
import static org.hamcrest.Matchers.instanceOf;
4950
import static org.hamcrest.Matchers.is;
50-
import static org.junit.Assert.assertArrayEquals;
51-
import static org.junit.Assert.assertThat;
51+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
5252

5353
/**
5454
* Tests for {@link DataLoader}.

src/test/java/org/dataloader/DataLoaderTimeTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package org.dataloader;
22

33
import org.dataloader.fixtures.TestingClock;
4-
import org.junit.Test;
4+
import org.junit.jupiter.api.Test;
55

66
import java.time.Instant;
77

88
import static org.dataloader.fixtures.TestKit.keysAsValues;
9+
import static org.hamcrest.MatcherAssert.assertThat;
910
import static org.hamcrest.Matchers.equalTo;
10-
import static org.junit.Assert.assertThat;
1111

1212
@SuppressWarnings("UnusedReturnValue")
1313
public class DataLoaderTimeTest {

src/test/java/org/dataloader/DataLoaderValueCacheTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import org.dataloader.fixtures.CaffeineValueCache;
66
import org.dataloader.fixtures.CustomValueCache;
77
import org.dataloader.impl.DataLoaderAssertionException;
8-
import org.junit.Test;
8+
import org.junit.jupiter.api.Test;
99

1010
import java.util.ArrayList;
1111
import java.util.List;
@@ -22,11 +22,11 @@
2222
import static org.dataloader.fixtures.TestKit.snooze;
2323
import static org.dataloader.fixtures.TestKit.sort;
2424
import static org.dataloader.impl.CompletableFutureKit.failedFuture;
25+
import static org.hamcrest.MatcherAssert.assertThat;
2526
import static org.hamcrest.Matchers.equalTo;
26-
import static org.junit.Assert.assertArrayEquals;
27-
import static org.junit.Assert.assertFalse;
28-
import static org.junit.Assert.assertThat;
29-
import static org.junit.Assert.assertTrue;
27+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
28+
import static org.junit.jupiter.api.Assertions.assertFalse;
29+
import static org.junit.jupiter.api.Assertions.assertTrue;
3030

3131
public class DataLoaderValueCacheTest {
3232

src/test/java/org/dataloader/DataLoaderWithTryTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.dataloader;
22

33
import org.hamcrest.Matchers;
4-
import org.junit.Test;
4+
import org.junit.jupiter.api.Test;
55

66
import java.util.ArrayList;
77
import java.util.HashMap;
@@ -12,9 +12,9 @@
1212
import static java.util.Arrays.asList;
1313
import static java.util.Collections.singletonList;
1414
import static org.dataloader.DataLoaderFactory.*;
15+
import static org.hamcrest.MatcherAssert.assertThat;
1516
import static org.hamcrest.Matchers.equalTo;
1617
import static org.hamcrest.Matchers.nullValue;
17-
import static org.junit.Assert.assertThat;
1818

1919
public class DataLoaderWithTryTest {
2020

src/test/java/org/dataloader/TryTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package org.dataloader;
22

3-
import org.junit.Assert;
4-
import org.junit.Test;
3+
import org.junit.jupiter.api.Assertions;
4+
import org.junit.jupiter.api.Test;
55

66
import java.util.Optional;
77
import java.util.concurrent.CompletableFuture;
88
import java.util.concurrent.CompletionStage;
99
import java.util.concurrent.atomic.AtomicReference;
1010
import java.util.function.Function;
1111

12+
import static org.hamcrest.MatcherAssert.assertThat;
1213
import static org.hamcrest.Matchers.equalTo;
1314
import static org.hamcrest.Matchers.nullValue;
14-
import static org.junit.Assert.assertFalse;
15-
import static org.junit.Assert.assertThat;
16-
import static org.junit.Assert.assertTrue;
15+
import static org.junit.jupiter.api.Assertions.assertFalse;
16+
import static org.junit.jupiter.api.Assertions.assertTrue;
1717

1818
public class TryTest {
1919

@@ -29,7 +29,7 @@ private void expectThrowable(RunThatCanThrow runnable, Class<? extends Throwable
2929
return;
3030
}
3131
}
32-
Assert.fail("Expected throwable : " + throwableClass.getName());
32+
Assertions.fail("Expected throwable : " + throwableClass.getName());
3333
}
3434

3535
@SuppressWarnings("SameParameterValue")

src/test/java/org/dataloader/impl/PromisedValuesImplTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.dataloader.impl;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

55
import java.util.Arrays;
66
import java.util.Collections;
@@ -12,12 +12,12 @@
1212
import static java.util.Arrays.asList;
1313
import static java.util.concurrent.CompletableFuture.supplyAsync;
1414
import static org.awaitility.Awaitility.await;
15+
import static org.hamcrest.MatcherAssert.assertThat;
1516
import static org.hamcrest.Matchers.equalTo;
1617
import static org.hamcrest.Matchers.instanceOf;
1718
import static org.hamcrest.Matchers.is;
1819
import static org.hamcrest.Matchers.notNullValue;
1920
import static org.hamcrest.Matchers.nullValue;
20-
import static org.junit.Assert.assertThat;
2121

2222
public class PromisedValuesImplTest {
2323

src/test/java/org/dataloader/registries/DispatchPredicateTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
import org.dataloader.DataLoader;
55
import org.dataloader.fixtures.TestKit;
66
import org.dataloader.fixtures.TestingClock;
7-
import org.junit.Test;
7+
import org.junit.jupiter.api.Test;
88

99
import java.time.Duration;
1010

11-
import static org.junit.Assert.assertFalse;
12-
import static org.junit.Assert.assertTrue;
11+
import static org.junit.jupiter.api.Assertions.assertFalse;
12+
import static org.junit.jupiter.api.Assertions.assertTrue;
1313

1414
public class DispatchPredicateTest {
1515

src/test/java/org/dataloader/registries/ScheduledDataLoaderRegistryPredicateTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.dataloader.BatchLoader;
44
import org.dataloader.DataLoader;
55
import org.dataloader.DataLoaderRegistry;
6-
import org.junit.Test;
6+
import org.junit.jupiter.api.Test;
77

88
import java.time.Duration;
99
import java.util.concurrent.CompletableFuture;
@@ -12,10 +12,9 @@
1212
import static org.awaitility.Awaitility.await;
1313
import static org.dataloader.DataLoaderFactory.newDataLoader;
1414
import static org.dataloader.fixtures.TestKit.asSet;
15-
import static org.dataloader.registries.DispatchPredicate.DISPATCH_NEVER;
15+
import static org.hamcrest.MatcherAssert.assertThat;
1616
import static org.hamcrest.Matchers.equalTo;
1717
import static org.hamcrest.Matchers.is;
18-
import static org.junit.Assert.assertThat;
1918

2019
public class ScheduledDataLoaderRegistryPredicateTest {
2120
final BatchLoader<Object, Object> identityBatchLoader = CompletableFuture::completedFuture;

0 commit comments

Comments
 (0)