diff --git a/abstract-document/pom.xml b/abstract-document/pom.xml
index cf49544cd..4396b99ae 100644
--- a/abstract-document/pom.xml
+++ b/abstract-document/pom.xml
@@ -34,8 +34,13 @@
abstract-document
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/abstract-document/src/test/java/com/iluwatar/abstractdocument/AbstractDocumentTest.java b/abstract-document/src/test/java/com/iluwatar/abstractdocument/AbstractDocumentTest.java
index f6686ff8f..63a9974b9 100644
--- a/abstract-document/src/test/java/com/iluwatar/abstractdocument/AbstractDocumentTest.java
+++ b/abstract-document/src/test/java/com/iluwatar/abstractdocument/AbstractDocumentTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.abstractdocument;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashMap;
@@ -30,8 +30,8 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
-import static junit.framework.TestCase.assertEquals;
-import static junit.framework.TestCase.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* AbstractDocument test class
diff --git a/abstract-document/src/test/java/com/iluwatar/abstractdocument/AppTest.java b/abstract-document/src/test/java/com/iluwatar/abstractdocument/AppTest.java
index b91f57b27..0546be523 100644
--- a/abstract-document/src/test/java/com/iluwatar/abstractdocument/AppTest.java
+++ b/abstract-document/src/test/java/com/iluwatar/abstractdocument/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.abstractdocument;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Simple App test
diff --git a/abstract-document/src/test/java/com/iluwatar/abstractdocument/DomainTest.java b/abstract-document/src/test/java/com/iluwatar/abstractdocument/DomainTest.java
index 03d75d5e5..891e5a457 100644
--- a/abstract-document/src/test/java/com/iluwatar/abstractdocument/DomainTest.java
+++ b/abstract-document/src/test/java/com/iluwatar/abstractdocument/DomainTest.java
@@ -28,13 +28,13 @@ import com.iluwatar.abstractdocument.domain.HasParts;
import com.iluwatar.abstractdocument.domain.HasPrice;
import com.iluwatar.abstractdocument.domain.HasType;
import com.iluwatar.abstractdocument.domain.Part;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
-import static junit.framework.TestCase.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test for Part and Car
diff --git a/abstract-factory/pom.xml b/abstract-factory/pom.xml
index f3a266f8e..6c5c6f3ac 100644
--- a/abstract-factory/pom.xml
+++ b/abstract-factory/pom.xml
@@ -34,8 +34,13 @@
abstract-factory
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/abstract-factory/src/test/java/com/iluwatar/abstractfactory/AbstractFactoryTest.java b/abstract-factory/src/test/java/com/iluwatar/abstractfactory/AbstractFactoryTest.java
index 7613edf65..5940da6c1 100644
--- a/abstract-factory/src/test/java/com/iluwatar/abstractfactory/AbstractFactoryTest.java
+++ b/abstract-factory/src/test/java/com/iluwatar/abstractfactory/AbstractFactoryTest.java
@@ -22,14 +22,14 @@
*/
package com.iluwatar.abstractfactory;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.iluwatar.abstractfactory.App.FactoryMaker;
import com.iluwatar.abstractfactory.App.FactoryMaker.KingdomType;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test for abstract factory
@@ -40,7 +40,7 @@ public class AbstractFactoryTest {
private KingdomFactory elfFactory;
private KingdomFactory orcFactory;
- @Before
+ @BeforeEach
public void setUp() {
elfFactory = FactoryMaker.makeFactory(KingdomType.ELF);
orcFactory = FactoryMaker.makeFactory(KingdomType.ORC);
diff --git a/abstract-factory/src/test/java/com/iluwatar/abstractfactory/AppTest.java b/abstract-factory/src/test/java/com/iluwatar/abstractfactory/AppTest.java
index b9d5f7d90..80c2815dc 100644
--- a/abstract-factory/src/test/java/com/iluwatar/abstractfactory/AppTest.java
+++ b/abstract-factory/src/test/java/com/iluwatar/abstractfactory/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.abstractfactory;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
diff --git a/adapter/pom.xml b/adapter/pom.xml
index 24245fad7..7f458137a 100644
--- a/adapter/pom.xml
+++ b/adapter/pom.xml
@@ -34,8 +34,13 @@
adapter
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/adapter/src/test/java/com/iluwatar/adapter/AdapterPatternTest.java b/adapter/src/test/java/com/iluwatar/adapter/AdapterPatternTest.java
index 9938f0559..033440b81 100644
--- a/adapter/src/test/java/com/iluwatar/adapter/AdapterPatternTest.java
+++ b/adapter/src/test/java/com/iluwatar/adapter/AdapterPatternTest.java
@@ -22,8 +22,8 @@
*/
package com.iluwatar.adapter;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
@@ -46,7 +46,7 @@ public class AdapterPatternTest {
/**
* This method runs before the test execution and sets the bean objects in the beans Map.
*/
- @Before
+ @BeforeEach
public void setup() {
beans = new HashMap<>();
diff --git a/adapter/src/test/java/com/iluwatar/adapter/AppTest.java b/adapter/src/test/java/com/iluwatar/adapter/AppTest.java
index 213035627..ca2c103c3 100644
--- a/adapter/src/test/java/com/iluwatar/adapter/AppTest.java
+++ b/adapter/src/test/java/com/iluwatar/adapter/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.adapter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
diff --git a/aggregator-microservices/aggregator-service/pom.xml b/aggregator-microservices/aggregator-service/pom.xml
index 32d5caa3f..78d129e2d 100644
--- a/aggregator-microservices/aggregator-service/pom.xml
+++ b/aggregator-microservices/aggregator-service/pom.xml
@@ -54,8 +54,13 @@
spring-boot-starter-web
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/aggregator-microservices/aggregator-service/src/test/java/com/iluwatar/aggregator/microservices/AggregatorTest.java b/aggregator-microservices/aggregator-service/src/test/java/com/iluwatar/aggregator/microservices/AggregatorTest.java
index 2955f6781..bc07ccc21 100644
--- a/aggregator-microservices/aggregator-service/src/test/java/com/iluwatar/aggregator/microservices/AggregatorTest.java
+++ b/aggregator-microservices/aggregator-service/src/test/java/com/iluwatar/aggregator/microservices/AggregatorTest.java
@@ -22,15 +22,15 @@
*/
package com.iluwatar.aggregator.microservices;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.when;
+
/**
* Test Aggregation of domain objects
*/
@@ -45,7 +45,7 @@ public class AggregatorTest {
@Mock
private ProductInventoryClient inventoryClient;
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
}
diff --git a/aggregator-microservices/information-microservice/pom.xml b/aggregator-microservices/information-microservice/pom.xml
index 8b24cdcc0..64a36fc32 100644
--- a/aggregator-microservices/information-microservice/pom.xml
+++ b/aggregator-microservices/information-microservice/pom.xml
@@ -54,8 +54,13 @@
spring-boot-starter-web
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/aggregator-microservices/information-microservice/src/test/java/com/iluwatar/information/microservice/InformationControllerTest.java b/aggregator-microservices/information-microservice/src/test/java/com/iluwatar/information/microservice/InformationControllerTest.java
index 127dd3956..d030cfcb4 100644
--- a/aggregator-microservices/information-microservice/src/test/java/com/iluwatar/information/microservice/InformationControllerTest.java
+++ b/aggregator-microservices/information-microservice/src/test/java/com/iluwatar/information/microservice/InformationControllerTest.java
@@ -22,8 +22,9 @@
*/
package com.iluwatar.information.microservice;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test for Information Rest Controller
@@ -36,7 +37,7 @@ public class InformationControllerTest {
String title = infoController.getProductTitle();
- Assert.assertEquals("The Product Title.", title);
+ assertEquals("The Product Title.", title);
}
}
diff --git a/aggregator-microservices/inventory-microservice/pom.xml b/aggregator-microservices/inventory-microservice/pom.xml
index 06804343c..aaec8244e 100644
--- a/aggregator-microservices/inventory-microservice/pom.xml
+++ b/aggregator-microservices/inventory-microservice/pom.xml
@@ -54,8 +54,13 @@
spring-boot-starter-web
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/aggregator-microservices/inventory-microservice/src/test/java/com/iluwatar/inventory/microservice/InventoryControllerTest.java b/aggregator-microservices/inventory-microservice/src/test/java/com/iluwatar/inventory/microservice/InventoryControllerTest.java
index b04370fba..78af8582e 100644
--- a/aggregator-microservices/inventory-microservice/src/test/java/com/iluwatar/inventory/microservice/InventoryControllerTest.java
+++ b/aggregator-microservices/inventory-microservice/src/test/java/com/iluwatar/inventory/microservice/InventoryControllerTest.java
@@ -22,8 +22,9 @@
*/
package com.iluwatar.inventory.microservice;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test Inventory Rest Controller
@@ -35,6 +36,6 @@ public class InventoryControllerTest {
int numberOfInventories = inventoryController.getProductInventories();
- Assert.assertEquals(5, numberOfInventories);
+ assertEquals(5, numberOfInventories);
}
}
diff --git a/api-gateway/api-gateway-service/pom.xml b/api-gateway/api-gateway-service/pom.xml
index a97c25cfc..1b817820b 100644
--- a/api-gateway/api-gateway-service/pom.xml
+++ b/api-gateway/api-gateway-service/pom.xml
@@ -53,8 +53,13 @@
spring-boot-starter-web
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/api-gateway/api-gateway-service/src/test/java/com/iluwatar/api/gateway/ApiGatewayTest.java b/api-gateway/api-gateway-service/src/test/java/com/iluwatar/api/gateway/ApiGatewayTest.java
index 6a79e5d00..a86d991c8 100644
--- a/api-gateway/api-gateway-service/src/test/java/com/iluwatar/api/gateway/ApiGatewayTest.java
+++ b/api-gateway/api-gateway-service/src/test/java/com/iluwatar/api/gateway/ApiGatewayTest.java
@@ -22,15 +22,15 @@
*/
package com.iluwatar.api.gateway;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.when;
+
/**
* Test API Gateway Pattern
*/
@@ -45,7 +45,7 @@ public class ApiGatewayTest {
@Mock
private PriceClient priceClient;
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
}
diff --git a/api-gateway/image-microservice/pom.xml b/api-gateway/image-microservice/pom.xml
index 574623b3a..940b295d5 100644
--- a/api-gateway/image-microservice/pom.xml
+++ b/api-gateway/image-microservice/pom.xml
@@ -54,8 +54,13 @@
spring-boot-starter-web
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/api-gateway/image-microservice/src/test/java/com/iluwatar/image/microservice/ImageControllerTest.java b/api-gateway/image-microservice/src/test/java/com/iluwatar/image/microservice/ImageControllerTest.java
index 1b934014a..df9b479ae 100644
--- a/api-gateway/image-microservice/src/test/java/com/iluwatar/image/microservice/ImageControllerTest.java
+++ b/api-gateway/image-microservice/src/test/java/com/iluwatar/image/microservice/ImageControllerTest.java
@@ -22,8 +22,9 @@
*/
package com.iluwatar.image.microservice;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test for Image Rest Controller
@@ -35,6 +36,6 @@ public class ImageControllerTest {
String imagePath = imageController.getImagePath();
- Assert.assertEquals("/product-image.png", imagePath);
+ assertEquals("/product-image.png", imagePath);
}
}
diff --git a/api-gateway/price-microservice/pom.xml b/api-gateway/price-microservice/pom.xml
index aed9fb38b..09cb229c9 100644
--- a/api-gateway/price-microservice/pom.xml
+++ b/api-gateway/price-microservice/pom.xml
@@ -54,8 +54,13 @@
spring-boot-starter-web
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/api-gateway/price-microservice/src/test/java/com/iluwatar/price/microservice/PriceControllerTest.java b/api-gateway/price-microservice/src/test/java/com/iluwatar/price/microservice/PriceControllerTest.java
index b1fe66d42..679fb601b 100644
--- a/api-gateway/price-microservice/src/test/java/com/iluwatar/price/microservice/PriceControllerTest.java
+++ b/api-gateway/price-microservice/src/test/java/com/iluwatar/price/microservice/PriceControllerTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.price.microservice;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test for Price Rest Controller
@@ -36,6 +36,6 @@ public class PriceControllerTest {
String price = priceController.getPrice();
- Assert.assertEquals("20", price);
+ assertEquals("20", price);
}
}
diff --git a/async-method-invocation/pom.xml b/async-method-invocation/pom.xml
index 7e15aff73..6c693bdee 100644
--- a/async-method-invocation/pom.xml
+++ b/async-method-invocation/pom.xml
@@ -34,8 +34,13 @@
async-method-invocation
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/async-method-invocation/src/test/java/com/iluwatar/async/method/invocation/AppTest.java b/async-method-invocation/src/test/java/com/iluwatar/async/method/invocation/AppTest.java
index ef2649f8a..a2744306e 100644
--- a/async-method-invocation/src/test/java/com/iluwatar/async/method/invocation/AppTest.java
+++ b/async-method-invocation/src/test/java/com/iluwatar/async/method/invocation/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.async.method.invocation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/async-method-invocation/src/test/java/com/iluwatar/async/method/invocation/ThreadAsyncExecutorTest.java b/async-method-invocation/src/test/java/com/iluwatar/async/method/invocation/ThreadAsyncExecutorTest.java
index d0e730344..b5c4fff67 100644
--- a/async-method-invocation/src/test/java/com/iluwatar/async/method/invocation/ThreadAsyncExecutorTest.java
+++ b/async-method-invocation/src/test/java/com/iluwatar/async/method/invocation/ThreadAsyncExecutorTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.async.method.invocation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Matchers;
@@ -30,8 +30,21 @@ import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static java.time.Duration.ofMillis;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTimeout;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
import static org.mockito.internal.verification.VerificationModeFactory.times;
/**
@@ -44,205 +57,217 @@ public class ThreadAsyncExecutorTest {
/**
* Test used to verify the happy path of {@link ThreadAsyncExecutor#startProcess(Callable)}
*/
- @Test(timeout = 3000)
+ @Test
public void testSuccessfulTaskWithoutCallback() throws Exception {
- // Instantiate a new executor and start a new 'null' task ...
- final ThreadAsyncExecutor executor = new ThreadAsyncExecutor();
+ assertTimeout(ofMillis(3000), () -> {
+ // Instantiate a new executor and start a new 'null' task ...
+ final ThreadAsyncExecutor executor = new ThreadAsyncExecutor();
- final Object result = new Object();
- final Callable
*/
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringApplicationConfiguration(classes = AggregatorRouteTest.class)
@ActiveProfiles("test")
@EnableAutoConfiguration
diff --git a/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/MessageAggregationStrategyTest.java b/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/MessageAggregationStrategyTest.java
index 59aa2955d..7a7a15154 100644
--- a/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/MessageAggregationStrategyTest.java
+++ b/eip-aggregator/src/test/java/com/iluwatar/eip/aggregator/routes/MessageAggregationStrategyTest.java
@@ -25,9 +25,9 @@ package com.iluwatar.eip.aggregator.routes;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultExchange;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests MessageAggregationStrategy
diff --git a/eip-splitter/pom.xml b/eip-splitter/pom.xml
index fb7e4ca9b..edfe45cb7 100644
--- a/eip-splitter/pom.xml
+++ b/eip-splitter/pom.xml
@@ -48,6 +48,21 @@
+
+ com.github.sbrannen
+ spring-test-junit5
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
org.springframework.boot
spring-boot-starter-test
diff --git a/eip-splitter/src/test/java/com/iluwatar/eip/splitter/AppTest.java b/eip-splitter/src/test/java/com/iluwatar/eip/splitter/AppTest.java
index 264e39c46..fe3eca01e 100644
--- a/eip-splitter/src/test/java/com/iluwatar/eip/splitter/AppTest.java
+++ b/eip-splitter/src/test/java/com/iluwatar/eip/splitter/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.eip.splitter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test for App class
diff --git a/eip-splitter/src/test/java/com/iluwatar/eip/splitter/routes/SplitterRouteTest.java b/eip-splitter/src/test/java/com/iluwatar/eip/splitter/routes/SplitterRouteTest.java
index 5bc59cc1a..9257a4410 100644
--- a/eip-splitter/src/test/java/com/iluwatar/eip/splitter/routes/SplitterRouteTest.java
+++ b/eip-splitter/src/test/java/com/iluwatar/eip/splitter/routes/SplitterRouteTest.java
@@ -23,19 +23,16 @@
package com.iluwatar.eip.splitter.routes;
import org.apache.camel.EndpointInject;
-import org.apache.camel.Message;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import static org.junit.Assert.assertEquals;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* Test class for SplitterRoute.
@@ -44,7 +41,7 @@ import static org.junit.Assert.assertEquals;
* original endpoint names to mocks.
*
*/
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringApplicationConfiguration(classes = SplitterRouteTest.class)
@ActiveProfiles("test")
@EnableAutoConfiguration
diff --git a/eip-wire-tap/pom.xml b/eip-wire-tap/pom.xml
index b3bc678b0..cd373c523 100644
--- a/eip-wire-tap/pom.xml
+++ b/eip-wire-tap/pom.xml
@@ -48,6 +48,21 @@
+
+ com.github.sbrannen
+ spring-test-junit5
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
org.springframework.boot
spring-boot-starter-test
diff --git a/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/AppTest.java b/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/AppTest.java
index 31b443660..673803df7 100644
--- a/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/AppTest.java
+++ b/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.eip.wiretap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test for App class
diff --git a/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/routes/WireTapRouteTest.java b/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/routes/WireTapRouteTest.java
index 71c487bd8..449f86208 100644
--- a/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/routes/WireTapRouteTest.java
+++ b/eip-wire-tap/src/test/java/com/iluwatar/eip/wiretap/routes/WireTapRouteTest.java
@@ -26,16 +26,16 @@ import org.apache.camel.EndpointInject;
import org.apache.camel.Message;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test class for WireTapRoute.
@@ -44,7 +44,7 @@ import static org.junit.Assert.assertEquals;
* original endpoint names to mocks.
*
*/
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringApplicationConfiguration(classes = WireTapRouteTest.class)
@ActiveProfiles("test")
@EnableAutoConfiguration
diff --git a/event-aggregator/pom.xml b/event-aggregator/pom.xml
index a3e7f96cf..7e715fb5c 100644
--- a/event-aggregator/pom.xml
+++ b/event-aggregator/pom.xml
@@ -33,8 +33,13 @@
event-aggregator
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/AppTest.java b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/AppTest.java
index 6cd678704..09548e384 100644
--- a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/AppTest.java
+++ b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.event.aggregator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventEmitterTest.java b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventEmitterTest.java
index a67272789..c2f457e28 100644
--- a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventEmitterTest.java
+++ b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventEmitterTest.java
@@ -22,6 +22,8 @@
*/
package com.iluwatar.event.aggregator;
+import org.junit.jupiter.api.Test;
+
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -32,7 +34,6 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
-import org.junit.Test;
/**
* Date: 12/12/15 - 10:58 PM
diff --git a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventTest.java b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventTest.java
index 54c511f8c..28062c613 100644
--- a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventTest.java
+++ b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/EventTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.event.aggregator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Date: 12/12/15 - 2:52 PM
diff --git a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingJoffreyTest.java b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingJoffreyTest.java
index 1743c3211..3f3296c57 100644
--- a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingJoffreyTest.java
+++ b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingJoffreyTest.java
@@ -25,15 +25,15 @@ package com.iluwatar.event.aggregator;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/12/15 - 3:04 PM
@@ -44,12 +44,12 @@ public class KingJoffreyTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender(KingJoffrey.class);
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingsHandTest.java b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingsHandTest.java
index ba1327182..3a5ae8f68 100644
--- a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingsHandTest.java
+++ b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/KingsHandTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.event.aggregator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
diff --git a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/WeekdayTest.java b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/WeekdayTest.java
index ab25d7ccc..df2d8ac79 100644
--- a/event-aggregator/src/test/java/com/iluwatar/event/aggregator/WeekdayTest.java
+++ b/event-aggregator/src/test/java/com/iluwatar/event/aggregator/WeekdayTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.event.aggregator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Date: 12/12/15 - 2:12 PM
diff --git a/event-asynchronous/pom.xml b/event-asynchronous/pom.xml
index afb3213f1..b37dfce72 100644
--- a/event-asynchronous/pom.xml
+++ b/event-asynchronous/pom.xml
@@ -34,8 +34,13 @@
event-asynchronous
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/AppTest.java b/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/AppTest.java
index 2056dcf18..372bc2f58 100644
--- a/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/AppTest.java
+++ b/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/AppTest.java
@@ -16,9 +16,9 @@
*/
package com.iluwatar.event.asynchronous;
-import java.io.IOException;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import java.io.IOException;
/**
* Tests that EventAsynchronous example runs without errors.
diff --git a/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/EventAsynchronousTest.java b/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/EventAsynchronousTest.java
index 8e0860286..aa2c644cb 100644
--- a/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/EventAsynchronousTest.java
+++ b/event-asynchronous/src/test/java/com/iluwatar/event/asynchronous/EventAsynchronousTest.java
@@ -16,12 +16,13 @@
*/
package com.iluwatar.event.asynchronous;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*
@@ -33,7 +34,7 @@ public class EventAsynchronousTest {
private static final Logger LOGGER = LoggerFactory.getLogger(EventAsynchronousTest.class);
- @Before
+ @BeforeEach
public void setUp() {
app = new App();
}
@@ -71,17 +72,19 @@ public class EventAsynchronousTest {
}
}
- @Test(expected = InvalidOperationException.class)
+ @Test
public void testUnsuccessfulSynchronousEvent() throws InvalidOperationException {
- EventManager eventManager = new EventManager();
- try {
- int sEventId = eventManager.create(60);
- eventManager.start(sEventId);
- sEventId = eventManager.create(60);
- eventManager.start(sEventId);
- } catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException e) {
- LOGGER.error(e.getMessage());
- }
+ assertThrows(InvalidOperationException.class, () -> {
+ EventManager eventManager = new EventManager();
+ try {
+ int sEventId = eventManager.create(60);
+ eventManager.start(sEventId);
+ sEventId = eventManager.create(60);
+ eventManager.start(sEventId);
+ } catch (MaxNumOfEventsAllowedException | LongRunningEventException | EventDoesNotExistException e) {
+ LOGGER.error(e.getMessage());
+ }
+ });
}
@Test
diff --git a/event-driven-architecture/pom.xml b/event-driven-architecture/pom.xml
index 4db6b6c0c..282a05e82 100644
--- a/event-driven-architecture/pom.xml
+++ b/event-driven-architecture/pom.xml
@@ -38,8 +38,13 @@
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/event-driven-architecture/src/test/java/com/iluwatar/eda/AppTest.java b/event-driven-architecture/src/test/java/com/iluwatar/eda/AppTest.java
index e7d642b95..f74232ac1 100644
--- a/event-driven-architecture/src/test/java/com/iluwatar/eda/AppTest.java
+++ b/event-driven-architecture/src/test/java/com/iluwatar/eda/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.eda;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
diff --git a/event-driven-architecture/src/test/java/com/iluwatar/eda/event/UserCreatedEventTest.java b/event-driven-architecture/src/test/java/com/iluwatar/eda/event/UserCreatedEventTest.java
index 6e95f5fd2..823605e9d 100644
--- a/event-driven-architecture/src/test/java/com/iluwatar/eda/event/UserCreatedEventTest.java
+++ b/event-driven-architecture/src/test/java/com/iluwatar/eda/event/UserCreatedEventTest.java
@@ -23,10 +23,9 @@
package com.iluwatar.eda.event;
import com.iluwatar.eda.model.User;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* {@link UserCreatedEventTest} tests and verifies {@link AbstractEvent} behaviour.
diff --git a/event-driven-architecture/src/test/java/com/iluwatar/eda/framework/EventDispatcherTest.java b/event-driven-architecture/src/test/java/com/iluwatar/eda/framework/EventDispatcherTest.java
index 7501653f6..6f647245d 100644
--- a/event-driven-architecture/src/test/java/com/iluwatar/eda/framework/EventDispatcherTest.java
+++ b/event-driven-architecture/src/test/java/com/iluwatar/eda/framework/EventDispatcherTest.java
@@ -27,8 +27,7 @@ import com.iluwatar.eda.event.UserUpdatedEvent;
import com.iluwatar.eda.handler.UserCreatedEventHandler;
import com.iluwatar.eda.handler.UserUpdatedEventHandler;
import com.iluwatar.eda.model.User;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
diff --git a/event-queue/pom.xml b/event-queue/pom.xml
index cbfc0976d..e2ca24cb0 100644
--- a/event-queue/pom.xml
+++ b/event-queue/pom.xml
@@ -35,8 +35,13 @@
event-queue
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/event-queue/src/test/java/com/iluwatar/event/queue/AudioTest.java b/event-queue/src/test/java/com/iluwatar/event/queue/AudioTest.java
index 8e31ec6c3..47f332526 100644
--- a/event-queue/src/test/java/com/iluwatar/event/queue/AudioTest.java
+++ b/event-queue/src/test/java/com/iluwatar/event/queue/AudioTest.java
@@ -22,13 +22,15 @@
*/
package com.iluwatar.event.queue;
-import static org.junit.Assert.*;
-import java.io.IOException;
+import org.junit.jupiter.api.Test;
import javax.sound.sampled.UnsupportedAudioFileException;
+import java.io.IOException;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
/**
* Testing the Audio service of the Queue
@@ -53,7 +55,7 @@ public class AudioTest {
// test that service is finished
assertFalse(!Audio.isServiceRunning());
}
-
+
/**
* Test here that the Queue
* @throws UnsupportedAudioFileException when the audio file is not supported
diff --git a/event-sourcing/pom.xml b/event-sourcing/pom.xml
index ac7745fbe..e095893f8 100644
--- a/event-sourcing/pom.xml
+++ b/event-sourcing/pom.xml
@@ -35,8 +35,13 @@
event-sourcing
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/event-sourcing/src/test/java/IntegrationTest.java b/event-sourcing/src/test/java/IntegrationTest.java
index 5a3f5718a..aab1ea7ea 100644
--- a/event-sourcing/src/test/java/IntegrationTest.java
+++ b/event-sourcing/src/test/java/IntegrationTest.java
@@ -21,20 +21,21 @@
* THE SOFTWARE.
*/
-import static com.iluwatar.event.sourcing.app.App.ACCOUNT_OF_DAENERYS;
-import static com.iluwatar.event.sourcing.app.App.ACCOUNT_OF_JON;
-
import com.iluwatar.event.sourcing.domain.Account;
import com.iluwatar.event.sourcing.event.AccountCreateEvent;
import com.iluwatar.event.sourcing.event.MoneyDepositEvent;
import com.iluwatar.event.sourcing.event.MoneyTransferEvent;
import com.iluwatar.event.sourcing.processor.DomainEventProcessor;
import com.iluwatar.event.sourcing.state.AccountAggregate;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import java.math.BigDecimal;
import java.util.Date;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+
+import static com.iluwatar.event.sourcing.app.App.ACCOUNT_OF_DAENERYS;
+import static com.iluwatar.event.sourcing.app.App.ACCOUNT_OF_JON;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Intergartion Test for Event Sourcing state recovery
@@ -51,7 +52,7 @@ public class IntegrationTest {
/**
* Initialize.
*/
- @Before
+ @BeforeEach
public void initialize() {
eventProcessor = new DomainEventProcessor();
}
@@ -90,10 +91,9 @@ public class IntegrationTest {
Account accountOfDaenerysAfterShotDown = AccountAggregate.getAccount(ACCOUNT_OF_DAENERYS);
Account accountOfJonAfterShotDown = AccountAggregate.getAccount(ACCOUNT_OF_JON);
- Assert.assertEquals(accountOfDaenerysBeforeShotDown.getMoney(),
+ assertEquals(accountOfDaenerysBeforeShotDown.getMoney(),
accountOfDaenerysAfterShotDown.getMoney());
- Assert
- .assertEquals(accountOfJonBeforeShotDown.getMoney(), accountOfJonAfterShotDown.getMoney());
+ assertEquals(accountOfJonBeforeShotDown.getMoney(), accountOfJonAfterShotDown.getMoney());
}
}
\ No newline at end of file
diff --git a/execute-around/pom.xml b/execute-around/pom.xml
index 3da4dc440..aea1c38aa 100644
--- a/execute-around/pom.xml
+++ b/execute-around/pom.xml
@@ -34,8 +34,18 @@
execute-around
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-migrationsupport
test
diff --git a/execute-around/src/test/java/com/iluwatar/execute/around/AppTest.java b/execute-around/src/test/java/com/iluwatar/execute/around/AppTest.java
index 7604db16d..298f7e0d7 100644
--- a/execute-around/src/test/java/com/iluwatar/execute/around/AppTest.java
+++ b/execute-around/src/test/java/com/iluwatar/execute/around/AppTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.execute.around;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
@@ -42,8 +42,8 @@ public class AppTest {
App.main(args);
}
- @Before
- @After
+ @BeforeEach
+ @AfterEach
public void cleanup() {
File file = new File("testfile.txt");
file.delete();
diff --git a/execute-around/src/test/java/com/iluwatar/execute/around/SimpleFileWriterTest.java b/execute-around/src/test/java/com/iluwatar/execute/around/SimpleFileWriterTest.java
index fd13a92a9..22bdf68f7 100644
--- a/execute-around/src/test/java/com/iluwatar/execute/around/SimpleFileWriterTest.java
+++ b/execute-around/src/test/java/com/iluwatar/execute/around/SimpleFileWriterTest.java
@@ -22,23 +22,26 @@
*/
package com.iluwatar.execute.around;
-import org.junit.Assert;
import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/12/15 - 3:21 PM
*
* @author Jeroen Meulemeester
*/
+@EnableRuleMigrationSupport
public class SimpleFileWriterTest {
/**
@@ -53,7 +56,7 @@ public class SimpleFileWriterTest {
@Test
public void testWriterNotNull() throws Exception {
final File temporaryFile = this.testFolder.newFile();
- new SimpleFileWriter(temporaryFile.getPath(), Assert::assertNotNull);
+ new SimpleFileWriter(temporaryFile.getPath(), Assertions::assertNotNull);
}
/**
@@ -64,7 +67,7 @@ public class SimpleFileWriterTest {
final File nonExistingFile = new File(this.testFolder.getRoot(), "non-existing-file");
assertFalse(nonExistingFile.exists());
- new SimpleFileWriter(nonExistingFile.getPath(), Assert::assertNotNull);
+ new SimpleFileWriter(nonExistingFile.getPath(), Assertions::assertNotNull);
assertTrue(nonExistingFile.exists());
}
@@ -85,11 +88,13 @@ public class SimpleFileWriterTest {
/**
* Verify if an {@link IOException} during the write ripples through
*/
- @Test(expected = IOException.class)
+ @Test
public void testIoException() throws Exception {
- final File temporaryFile = this.testFolder.newFile();
- new SimpleFileWriter(temporaryFile.getPath(), writer -> {
- throw new IOException("");
+ assertThrows(IOException.class, () -> {
+ final File temporaryFile = this.testFolder.newFile();
+ new SimpleFileWriter(temporaryFile.getPath(), writer -> {
+ throw new IOException("");
+ });
});
}
diff --git a/extension-objects/pom.xml b/extension-objects/pom.xml
index 2215834d7..7fe8358ab 100644
--- a/extension-objects/pom.xml
+++ b/extension-objects/pom.xml
@@ -36,8 +36,13 @@
extension-objects
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/extension-objects/src/test/java/AppTest.java b/extension-objects/src/test/java/AppTest.java
index 485788112..f3111bebb 100644
--- a/extension-objects/src/test/java/AppTest.java
+++ b/extension-objects/src/test/java/AppTest.java
@@ -20,7 +20,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-import org.junit.Test;
+
+import org.junit.jupiter.api.Test;
/**
* Created by Srdjan on 03-May-17.
diff --git a/extension-objects/src/test/java/concreteextensions/CommanderTest.java b/extension-objects/src/test/java/concreteextensions/CommanderTest.java
index 11f0cc60e..5dac551f4 100644
--- a/extension-objects/src/test/java/concreteextensions/CommanderTest.java
+++ b/extension-objects/src/test/java/concreteextensions/CommanderTest.java
@@ -22,7 +22,7 @@
*/
package concreteextensions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import units.CommanderUnit;
/**
diff --git a/extension-objects/src/test/java/concreteextensions/SergeantTest.java b/extension-objects/src/test/java/concreteextensions/SergeantTest.java
index 2deddca90..f26830e2c 100644
--- a/extension-objects/src/test/java/concreteextensions/SergeantTest.java
+++ b/extension-objects/src/test/java/concreteextensions/SergeantTest.java
@@ -22,7 +22,7 @@
*/
package concreteextensions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import units.SergeantUnit;
/**
diff --git a/extension-objects/src/test/java/concreteextensions/SoldierTest.java b/extension-objects/src/test/java/concreteextensions/SoldierTest.java
index affc6ee8b..a9a6c4768 100644
--- a/extension-objects/src/test/java/concreteextensions/SoldierTest.java
+++ b/extension-objects/src/test/java/concreteextensions/SoldierTest.java
@@ -22,7 +22,7 @@
*/
package concreteextensions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import units.SoldierUnit;
/**
diff --git a/extension-objects/src/test/java/units/CommanderUnitTest.java b/extension-objects/src/test/java/units/CommanderUnitTest.java
index 8f4c1ca8d..536c3ae3f 100644
--- a/extension-objects/src/test/java/units/CommanderUnitTest.java
+++ b/extension-objects/src/test/java/units/CommanderUnitTest.java
@@ -23,10 +23,10 @@
package units;
import abstractextensions.CommanderExtension;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Created by Srdjan on 03-May-17.
diff --git a/extension-objects/src/test/java/units/SergeantUnitTest.java b/extension-objects/src/test/java/units/SergeantUnitTest.java
index de773b59e..ac518b488 100644
--- a/extension-objects/src/test/java/units/SergeantUnitTest.java
+++ b/extension-objects/src/test/java/units/SergeantUnitTest.java
@@ -23,10 +23,10 @@
package units;
import abstractextensions.SergeantExtension;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Created by Srdjan on 03-May-17.
diff --git a/extension-objects/src/test/java/units/SoldierUnitTest.java b/extension-objects/src/test/java/units/SoldierUnitTest.java
index 06a1f7611..1aeb9a3cd 100644
--- a/extension-objects/src/test/java/units/SoldierUnitTest.java
+++ b/extension-objects/src/test/java/units/SoldierUnitTest.java
@@ -23,10 +23,10 @@
package units;
import abstractextensions.SoldierExtension;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Created by Srdjan on 03-May-17.
diff --git a/extension-objects/src/test/java/units/UnitTest.java b/extension-objects/src/test/java/units/UnitTest.java
index a7d530032..389c9f753 100644
--- a/extension-objects/src/test/java/units/UnitTest.java
+++ b/extension-objects/src/test/java/units/UnitTest.java
@@ -22,10 +22,10 @@
*/
package units;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Created by Srdjan on 03-May-17.
diff --git a/facade/pom.xml b/facade/pom.xml
index 7a6021530..79d7943d1 100644
--- a/facade/pom.xml
+++ b/facade/pom.xml
@@ -34,13 +34,13 @@
facade
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
- org.mockito
- mockito-core
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/facade/src/test/java/com/iluwatar/facade/AppTest.java b/facade/src/test/java/com/iluwatar/facade/AppTest.java
index e890f42d4..366315e9e 100644
--- a/facade/src/test/java/com/iluwatar/facade/AppTest.java
+++ b/facade/src/test/java/com/iluwatar/facade/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.facade;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/facade/src/test/java/com/iluwatar/facade/DwarvenGoldmineFacadeTest.java b/facade/src/test/java/com/iluwatar/facade/DwarvenGoldmineFacadeTest.java
index 6457307cf..19987acbc 100644
--- a/facade/src/test/java/com/iluwatar/facade/DwarvenGoldmineFacadeTest.java
+++ b/facade/src/test/java/com/iluwatar/facade/DwarvenGoldmineFacadeTest.java
@@ -25,16 +25,16 @@ package com.iluwatar.facade;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/9/15 - 9:40 PM
@@ -45,12 +45,12 @@ public class DwarvenGoldmineFacadeTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/factory-kit/pom.xml b/factory-kit/pom.xml
index eee0cd734..ff580e794 100644
--- a/factory-kit/pom.xml
+++ b/factory-kit/pom.xml
@@ -35,13 +35,13 @@
factory-kit
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
- org.mockito
- mockito-core
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/factory-kit/src/test/java/com/iluwatar/factorykit/app/AppTest.java b/factory-kit/src/test/java/com/iluwatar/factorykit/app/AppTest.java
index 4d8691ef0..0be22b9b0 100644
--- a/factory-kit/src/test/java/com/iluwatar/factorykit/app/AppTest.java
+++ b/factory-kit/src/test/java/com/iluwatar/factorykit/app/AppTest.java
@@ -23,7 +23,7 @@
package com.iluwatar.factorykit.app;
import com.iluwatar.factorykit.App;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Application Test Entrypoint
diff --git a/factory-kit/src/test/java/com/iluwatar/factorykit/factorykit/FactoryKitTest.java b/factory-kit/src/test/java/com/iluwatar/factorykit/factorykit/FactoryKitTest.java
index 3f732546d..f15223feb 100644
--- a/factory-kit/src/test/java/com/iluwatar/factorykit/factorykit/FactoryKitTest.java
+++ b/factory-kit/src/test/java/com/iluwatar/factorykit/factorykit/FactoryKitTest.java
@@ -22,24 +22,25 @@
*/
package com.iluwatar.factorykit.factorykit;
-import static org.junit.Assert.assertTrue;
-
import com.iluwatar.factorykit.Axe;
import com.iluwatar.factorykit.Spear;
import com.iluwatar.factorykit.Sword;
import com.iluwatar.factorykit.Weapon;
import com.iluwatar.factorykit.WeaponFactory;
import com.iluwatar.factorykit.WeaponType;
-import org.junit.Before;
-import org.junit.Test;
-/**
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+ /**
* Test Factory Kit Pattern
*/
public class FactoryKitTest {
private WeaponFactory factory;
- @Before
+ @BeforeEach
public void init() {
factory = WeaponFactory.factory(builder -> {
builder.add(WeaponType.SPEAR, Spear::new);
@@ -83,6 +84,6 @@ public class FactoryKitTest {
* @param clazz expected class of the weapon
*/
private void verifyWeapon(Weapon weapon, Class clazz) {
- assertTrue("Weapon must be an object of: " + clazz.getName(), clazz.isInstance(weapon));
+ assertTrue(clazz.isInstance(weapon), "Weapon must be an object of: " + clazz.getName());
}
}
diff --git a/factory-method/pom.xml b/factory-method/pom.xml
index 8c54f63a1..46875df4f 100644
--- a/factory-method/pom.xml
+++ b/factory-method/pom.xml
@@ -34,13 +34,13 @@
factory-method
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
- org.mockito
- mockito-core
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/factory-method/src/test/java/com/iluwatar/factory/method/AppTest.java b/factory-method/src/test/java/com/iluwatar/factory/method/AppTest.java
index 88b40d4fe..4a73077c1 100644
--- a/factory-method/src/test/java/com/iluwatar/factory/method/AppTest.java
+++ b/factory-method/src/test/java/com/iluwatar/factory/method/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.factory.method;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
diff --git a/factory-method/src/test/java/com/iluwatar/factory/method/FactoryMethodTest.java b/factory-method/src/test/java/com/iluwatar/factory/method/FactoryMethodTest.java
index 71afc5549..75d8e4677 100644
--- a/factory-method/src/test/java/com/iluwatar/factory/method/FactoryMethodTest.java
+++ b/factory-method/src/test/java/com/iluwatar/factory/method/FactoryMethodTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.factory.method;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* The Factory Method is a creational design pattern which uses factory methods to deal with the
@@ -94,8 +94,7 @@ public class FactoryMethodTest {
* @param clazz expected class of the weapon
*/
private void verifyWeapon(Weapon weapon, WeaponType expectedWeaponType, Class> clazz) {
- assertTrue("Weapon must be an object of: " + clazz.getName(), clazz.isInstance(weapon));
- assertEquals("Weapon must be of weaponType: " + expectedWeaponType, expectedWeaponType,
- weapon.getWeaponType());
+ assertTrue(clazz.isInstance(weapon), "Weapon must be an object of: " + clazz.getName());
+ assertEquals(expectedWeaponType, weapon.getWeaponType(), "Weapon must be of weaponType: " + expectedWeaponType);
}
}
diff --git a/feature-toggle/pom.xml b/feature-toggle/pom.xml
index 6536710ba..9db78e798 100644
--- a/feature-toggle/pom.xml
+++ b/feature-toggle/pom.xml
@@ -39,10 +39,14 @@
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
-
\ No newline at end of file
diff --git a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersionTest.java b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersionTest.java
index 846b46bcf..9f0d377fa 100644
--- a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersionTest.java
+++ b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/propertiesversion/PropertiesFeatureToggleVersionTest.java
@@ -23,30 +23,36 @@
package com.iluwatar.featuretoggle.pattern.propertiesversion;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import com.iluwatar.featuretoggle.pattern.Service;
import com.iluwatar.featuretoggle.user.User;
+import org.junit.jupiter.api.Test;
+
import java.util.Properties;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test Properties Toggle
*/
public class PropertiesFeatureToggleVersionTest {
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNullPropertiesPassed() throws Exception {
- new PropertiesFeatureToggleVersion(null);
+ assertThrows(IllegalArgumentException.class, () -> {
+ new PropertiesFeatureToggleVersion(null);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNonBooleanProperty() throws Exception {
- final Properties properties = new Properties();
- properties.setProperty("enhancedWelcome", "Something");
- new PropertiesFeatureToggleVersion(properties);
+ assertThrows(IllegalArgumentException.class, () -> {
+ final Properties properties = new Properties();
+ properties.setProperty("enhancedWelcome", "Something");
+ new PropertiesFeatureToggleVersion(properties);
+ });
}
@Test
diff --git a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersionTest.java b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersionTest.java
index 3966032d5..0ed0afea9 100644
--- a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersionTest.java
+++ b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/pattern/tieredversion/TieredFeatureToggleVersionTest.java
@@ -22,14 +22,14 @@
*/
package com.iluwatar.featuretoggle.pattern.tieredversion;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import com.iluwatar.featuretoggle.pattern.Service;
import com.iluwatar.featuretoggle.user.User;
import com.iluwatar.featuretoggle.user.UserGroup;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test Tiered Feature Toggle
@@ -40,7 +40,7 @@ public class TieredFeatureToggleVersionTest {
final User freeUser = new User("Alan Defect");
final Service service = new TieredFeatureToggleVersion();
- @Before
+ @BeforeEach
public void setUp() throws Exception {
UserGroup.addUserToPaidGroup(paidUser);
UserGroup.addUserToFreeGroup(freeUser);
diff --git a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/user/UserGroupTest.java b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/user/UserGroupTest.java
index b2c6e5859..2771655dd 100644
--- a/feature-toggle/src/test/java/com/iluwatar/featuretoggle/user/UserGroupTest.java
+++ b/feature-toggle/src/test/java/com/iluwatar/featuretoggle/user/UserGroupTest.java
@@ -22,10 +22,11 @@
*/
package com.iluwatar.featuretoggle.user;
-import static junit.framework.TestCase.assertFalse;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test User Group specific feature
@@ -46,17 +47,21 @@ public class UserGroupTest {
assertTrue(UserGroup.isPaid(user));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testAddUserToPaidWhenOnFree() throws Exception {
User user = new User("Paid User");
UserGroup.addUserToFreeGroup(user);
- UserGroup.addUserToPaidGroup(user);
+ assertThrows(IllegalArgumentException.class, () -> {
+ UserGroup.addUserToPaidGroup(user);
+ });
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testAddUserToFreeWhenOnPaid() throws Exception {
User user = new User("Free User");
UserGroup.addUserToPaidGroup(user);
- UserGroup.addUserToFreeGroup(user);
+ assertThrows(IllegalArgumentException.class, () -> {
+ UserGroup.addUserToFreeGroup(user);
+ });
}
}
diff --git a/fluentinterface/pom.xml b/fluentinterface/pom.xml
index 11318e295..ecd829936 100644
--- a/fluentinterface/pom.xml
+++ b/fluentinterface/pom.xml
@@ -36,8 +36,13 @@
fluentinterface
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/fluentinterface/src/test/java/com/iluwatar/fluentinterface/app/AppTest.java b/fluentinterface/src/test/java/com/iluwatar/fluentinterface/app/AppTest.java
index 11740bf1a..6e21bd8e4 100644
--- a/fluentinterface/src/test/java/com/iluwatar/fluentinterface/app/AppTest.java
+++ b/fluentinterface/src/test/java/com/iluwatar/fluentinterface/app/AppTest.java
@@ -22,7 +22,8 @@
*/
package com.iluwatar.fluentinterface.app;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
/**
* Application Test Entry
*/
diff --git a/fluentinterface/src/test/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterableTest.java b/fluentinterface/src/test/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterableTest.java
index 4cc2b1a7a..0eb9e003a 100644
--- a/fluentinterface/src/test/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterableTest.java
+++ b/fluentinterface/src/test/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterableTest.java
@@ -22,13 +22,23 @@
*/
package com.iluwatar.fluentinterface.fluentiterable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.Spliterator;
import java.util.function.Consumer;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
/**
* Date: 12/12/15 - 7:00 PM
@@ -56,7 +66,7 @@ public abstract class FluentIterableTest {
@Test
public void testFirstEmptyCollection() throws Exception {
- final List integers = Collections.emptyList();
+ final List integers = Collections.emptyList();
final Optional first = createFluentIterable(integers).first();
assertNotNull(first);
assertFalse(first.isPresent());
diff --git a/flux/pom.xml b/flux/pom.xml
index 779bd3e97..6325d4550 100644
--- a/flux/pom.xml
+++ b/flux/pom.xml
@@ -34,8 +34,13 @@
flux
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/flux/src/test/java/com/iluwatar/flux/action/ContentTest.java b/flux/src/test/java/com/iluwatar/flux/action/ContentTest.java
index 3ddf7805c..53db61ddd 100644
--- a/flux/src/test/java/com/iluwatar/flux/action/ContentTest.java
+++ b/flux/src/test/java/com/iluwatar/flux/action/ContentTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.flux.action;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Date: 12/12/15 - 10:11 PM
diff --git a/flux/src/test/java/com/iluwatar/flux/action/MenuItemTest.java b/flux/src/test/java/com/iluwatar/flux/action/MenuItemTest.java
index e40133586..60f19d8f3 100644
--- a/flux/src/test/java/com/iluwatar/flux/action/MenuItemTest.java
+++ b/flux/src/test/java/com/iluwatar/flux/action/MenuItemTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.flux.action;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Date: 12/12/15 - 10:15 PM
diff --git a/flux/src/test/java/com/iluwatar/flux/app/AppTest.java b/flux/src/test/java/com/iluwatar/flux/app/AppTest.java
index 7e6475ee7..0a8375916 100644
--- a/flux/src/test/java/com/iluwatar/flux/app/AppTest.java
+++ b/flux/src/test/java/com/iluwatar/flux/app/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.flux.app;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/flux/src/test/java/com/iluwatar/flux/dispatcher/DispatcherTest.java b/flux/src/test/java/com/iluwatar/flux/dispatcher/DispatcherTest.java
index b245de6ac..54760557b 100644
--- a/flux/src/test/java/com/iluwatar/flux/dispatcher/DispatcherTest.java
+++ b/flux/src/test/java/com/iluwatar/flux/dispatcher/DispatcherTest.java
@@ -29,8 +29,8 @@ import com.iluwatar.flux.action.ContentAction;
import com.iluwatar.flux.action.MenuAction;
import com.iluwatar.flux.action.MenuItem;
import com.iluwatar.flux.store.Store;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import java.lang.reflect.Constructor;
@@ -38,9 +38,9 @@ import java.lang.reflect.Field;
import java.util.List;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -58,7 +58,7 @@ public class DispatcherTest {
* Replace the instance with a fresh one before each test to make sure test cases have no
* influence on each other.
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
final Constructor constructor;
constructor = Dispatcher.class.getDeclaredConstructor();
diff --git a/flux/src/test/java/com/iluwatar/flux/store/ContentStoreTest.java b/flux/src/test/java/com/iluwatar/flux/store/ContentStoreTest.java
index 85c0e46f4..02a16ef33 100644
--- a/flux/src/test/java/com/iluwatar/flux/store/ContentStoreTest.java
+++ b/flux/src/test/java/com/iluwatar/flux/store/ContentStoreTest.java
@@ -27,9 +27,9 @@ import com.iluwatar.flux.action.ContentAction;
import com.iluwatar.flux.action.MenuAction;
import com.iluwatar.flux.action.MenuItem;
import com.iluwatar.flux.view.View;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
diff --git a/flux/src/test/java/com/iluwatar/flux/store/MenuStoreTest.java b/flux/src/test/java/com/iluwatar/flux/store/MenuStoreTest.java
index 63d1dfdfb..aa432e1ff 100644
--- a/flux/src/test/java/com/iluwatar/flux/store/MenuStoreTest.java
+++ b/flux/src/test/java/com/iluwatar/flux/store/MenuStoreTest.java
@@ -27,9 +27,9 @@ import com.iluwatar.flux.action.ContentAction;
import com.iluwatar.flux.action.MenuAction;
import com.iluwatar.flux.action.MenuItem;
import com.iluwatar.flux.view.View;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
diff --git a/flux/src/test/java/com/iluwatar/flux/view/ContentViewTest.java b/flux/src/test/java/com/iluwatar/flux/view/ContentViewTest.java
index b97d751bf..c4498bacf 100644
--- a/flux/src/test/java/com/iluwatar/flux/view/ContentViewTest.java
+++ b/flux/src/test/java/com/iluwatar/flux/view/ContentViewTest.java
@@ -24,7 +24,7 @@ package com.iluwatar.flux.view;
import com.iluwatar.flux.action.Content;
import com.iluwatar.flux.store.ContentStore;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
diff --git a/flux/src/test/java/com/iluwatar/flux/view/MenuViewTest.java b/flux/src/test/java/com/iluwatar/flux/view/MenuViewTest.java
index 528549e9c..0967d51a8 100644
--- a/flux/src/test/java/com/iluwatar/flux/view/MenuViewTest.java
+++ b/flux/src/test/java/com/iluwatar/flux/view/MenuViewTest.java
@@ -27,7 +27,7 @@ import com.iluwatar.flux.action.MenuItem;
import com.iluwatar.flux.dispatcher.Dispatcher;
import com.iluwatar.flux.store.MenuStore;
import com.iluwatar.flux.store.Store;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
diff --git a/flyweight/pom.xml b/flyweight/pom.xml
index 9814dc2df..510433ab4 100644
--- a/flyweight/pom.xml
+++ b/flyweight/pom.xml
@@ -34,8 +34,13 @@
flyweight
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/flyweight/src/test/java/com/iluwatar/flyweight/AlchemistShopTest.java b/flyweight/src/test/java/com/iluwatar/flyweight/AlchemistShopTest.java
index 96cc455a7..86d231e22 100644
--- a/flyweight/src/test/java/com/iluwatar/flyweight/AlchemistShopTest.java
+++ b/flyweight/src/test/java/com/iluwatar/flyweight/AlchemistShopTest.java
@@ -22,13 +22,13 @@
*/
package com.iluwatar.flyweight;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Date: 12/12/15 - 10:54 PM
diff --git a/flyweight/src/test/java/com/iluwatar/flyweight/AppTest.java b/flyweight/src/test/java/com/iluwatar/flyweight/AppTest.java
index 5d2d6815f..f7a33f050 100644
--- a/flyweight/src/test/java/com/iluwatar/flyweight/AppTest.java
+++ b/flyweight/src/test/java/com/iluwatar/flyweight/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.flyweight;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/front-controller/pom.xml b/front-controller/pom.xml
index b9080bda7..6246fb0e4 100644
--- a/front-controller/pom.xml
+++ b/front-controller/pom.xml
@@ -35,8 +35,18 @@
front-controller
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
test
diff --git a/front-controller/src/test/java/com/iluwatar/front/controller/AppTest.java b/front-controller/src/test/java/com/iluwatar/front/controller/AppTest.java
index dd15be495..f7fe59cf1 100644
--- a/front-controller/src/test/java/com/iluwatar/front/controller/AppTest.java
+++ b/front-controller/src/test/java/com/iluwatar/front/controller/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.front.controller;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/front-controller/src/test/java/com/iluwatar/front/controller/ApplicationExceptionTest.java b/front-controller/src/test/java/com/iluwatar/front/controller/ApplicationExceptionTest.java
index c68a4ebf6..ee13d47d7 100644
--- a/front-controller/src/test/java/com/iluwatar/front/controller/ApplicationExceptionTest.java
+++ b/front-controller/src/test/java/com/iluwatar/front/controller/ApplicationExceptionTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.front.controller;
-import static org.junit.Assert.assertSame;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
* Date: 12/13/15 - 1:35 PM
diff --git a/front-controller/src/test/java/com/iluwatar/front/controller/CommandTest.java b/front-controller/src/test/java/com/iluwatar/front/controller/CommandTest.java
index edb5032ed..9e8f986e2 100644
--- a/front-controller/src/test/java/com/iluwatar/front/controller/CommandTest.java
+++ b/front-controller/src/test/java/com/iluwatar/front/controller/CommandTest.java
@@ -23,40 +23,36 @@
package com.iluwatar.front.controller;
import com.iluwatar.front.controller.utils.InMemoryAppender;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/13/15 - 1:39 PM
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class CommandTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
- @Parameters
- public static List data() {
+ static List dataProvider() {
final List parameters = new ArrayList<>();
parameters.add(new Object[]{"Archer", "Displaying archers"});
parameters.add(new Object[]{"Catapult", "Displaying catapults"});
@@ -65,28 +61,12 @@ public class CommandTest {
}
/**
- * The view that's been tested
- */
- private final String request;
-
- /**
- * The expected display message
- */
- private final String displayMessage;
-
- /**
- * Create a new instance of the {@link CommandTest} with the given view and expected message
- *
* @param request The request that's been tested
* @param displayMessage The expected display message
*/
- public CommandTest(final String request, final String displayMessage) {
- this.displayMessage = displayMessage;
- this.request = request;
- }
-
- @Test
- public void testDisplay() {
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testDisplay(String request, String displayMessage) {
final FrontController frontController = new FrontController();
assertEquals(0, appender.getLogSize());
frontController.handleRequest(request);
diff --git a/front-controller/src/test/java/com/iluwatar/front/controller/FrontControllerTest.java b/front-controller/src/test/java/com/iluwatar/front/controller/FrontControllerTest.java
index 5367403f9..4b4eb6fdd 100644
--- a/front-controller/src/test/java/com/iluwatar/front/controller/FrontControllerTest.java
+++ b/front-controller/src/test/java/com/iluwatar/front/controller/FrontControllerTest.java
@@ -23,40 +23,36 @@
package com.iluwatar.front.controller;
import com.iluwatar.front.controller.utils.InMemoryAppender;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/13/15 - 1:39 PM
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class FrontControllerTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
- @Parameters
- public static List data() {
+ static List dataProvider() {
final List parameters = new ArrayList<>();
parameters.add(new Object[]{new ArcherCommand(), "Displaying archers"});
parameters.add(new Object[]{new CatapultCommand(), "Displaying catapults"});
@@ -65,30 +61,14 @@ public class FrontControllerTest {
}
/**
- * The view that's been tested
- */
- private final Command command;
-
- /**
- * The expected display message
- */
- private final String displayMessage;
-
- /**
- * Create a new instance of the {@link FrontControllerTest} with the given view and expected message
- *
* @param command The command that's been tested
* @param displayMessage The expected display message
*/
- public FrontControllerTest(final Command command, final String displayMessage) {
- this.displayMessage = displayMessage;
- this.command = command;
- }
-
- @Test
- public void testDisplay() {
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testDisplay(Command command, String displayMessage) {
assertEquals(0, appender.getLogSize());
- this.command.process();
+ command.process();
assertEquals(displayMessage, appender.getLastMessage());
assertEquals(1, appender.getLogSize());
}
diff --git a/front-controller/src/test/java/com/iluwatar/front/controller/ViewTest.java b/front-controller/src/test/java/com/iluwatar/front/controller/ViewTest.java
index a5786b97e..a0c303235 100644
--- a/front-controller/src/test/java/com/iluwatar/front/controller/ViewTest.java
+++ b/front-controller/src/test/java/com/iluwatar/front/controller/ViewTest.java
@@ -23,40 +23,36 @@
package com.iluwatar.front.controller;
import com.iluwatar.front.controller.utils.InMemoryAppender;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/13/15 - 1:39 PM
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class ViewTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
- @Parameters
- public static List data() {
+ static List dataProvider() {
final List parameters = new ArrayList<>();
parameters.add(new Object[]{new ArcherView(), "Displaying archers"});
parameters.add(new Object[]{new CatapultView(), "Displaying catapults"});
@@ -65,30 +61,14 @@ public class ViewTest {
}
/**
- * The view that's been tested
- */
- private final View view;
-
- /**
- * The expected display message
- */
- private final String displayMessage;
-
- /**
- * Create a new instance of the {@link ViewTest} with the given view and expected message
- *
* @param view The view that's been tested
* @param displayMessage The expected display message
*/
- public ViewTest(final View view, final String displayMessage) {
- this.displayMessage = displayMessage;
- this.view = view;
- }
-
- @Test
- public void testDisplay() {
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testDisplay(View view, String displayMessage) {
assertEquals(0, appender.getLogSize());
- this.view.display();
+ view.display();
assertEquals(displayMessage, appender.getLastMessage());
assertEquals(1, appender.getLogSize());
}
diff --git a/guarded-suspension/pom.xml b/guarded-suspension/pom.xml
index bcc9ead06..a0c915559 100644
--- a/guarded-suspension/pom.xml
+++ b/guarded-suspension/pom.xml
@@ -36,8 +36,13 @@
guarded-suspension
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/guarded-suspension/src/test/java/com/iluwatar/guarded/suspension/GuardedQueueTest.java b/guarded-suspension/src/test/java/com/iluwatar/guarded/suspension/GuardedQueueTest.java
index 5a741d399..2834bd4ef 100644
--- a/guarded-suspension/src/test/java/com/iluwatar/guarded/suspension/GuardedQueueTest.java
+++ b/guarded-suspension/src/test/java/com/iluwatar/guarded/suspension/GuardedQueueTest.java
@@ -22,13 +22,14 @@
*/
package com.iluwatar.guarded.suspension;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Test for Guarded Queue
*/
@@ -47,15 +48,14 @@ public class GuardedQueueTest {
} catch (InterruptedException e) {
e.printStackTrace();
}
- Assert.assertEquals(Integer.valueOf(10), value);
+ assertEquals(Integer.valueOf(10), value);
}
@Test
public void testPut() {
GuardedQueue g = new GuardedQueue();
g.put(12);
- Assert.assertEquals(Integer.valueOf(12), g.get());
-
+ assertEquals(Integer.valueOf(12), g.get());
}
}
diff --git a/half-sync-half-async/pom.xml b/half-sync-half-async/pom.xml
index ac8464d75..36955f955 100644
--- a/half-sync-half-async/pom.xml
+++ b/half-sync-half-async/pom.xml
@@ -34,8 +34,13 @@
half-sync-half-async
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/half-sync-half-async/src/test/java/com/iluwatar/halfsynchalfasync/AppTest.java b/half-sync-half-async/src/test/java/com/iluwatar/halfsynchalfasync/AppTest.java
index 2dfc2bf5c..dea242f85 100644
--- a/half-sync-half-async/src/test/java/com/iluwatar/halfsynchalfasync/AppTest.java
+++ b/half-sync-half-async/src/test/java/com/iluwatar/halfsynchalfasync/AppTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.halfsynchalfasync;
-import java.util.concurrent.ExecutionException;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import java.util.concurrent.ExecutionException;
/**
*
diff --git a/half-sync-half-async/src/test/java/com/iluwatar/halfsynchalfasync/AsynchronousServiceTest.java b/half-sync-half-async/src/test/java/com/iluwatar/halfsynchalfasync/AsynchronousServiceTest.java
index c6d00b1ac..a5496415e 100644
--- a/half-sync-half-async/src/test/java/com/iluwatar/halfsynchalfasync/AsynchronousServiceTest.java
+++ b/half-sync-half-async/src/test/java/com/iluwatar/halfsynchalfasync/AsynchronousServiceTest.java
@@ -22,14 +22,21 @@
*/
package com.iluwatar.halfsynchalfasync;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
import java.io.IOException;
import java.util.concurrent.LinkedBlockingQueue;
import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
/**
* Date: 12/12/15 - 11:15 PM
diff --git a/hexagonal/pom.xml b/hexagonal/pom.xml
index 940a7fc61..3e7c1d3dd 100644
--- a/hexagonal/pom.xml
+++ b/hexagonal/pom.xml
@@ -35,8 +35,13 @@
hexagonal
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/hexagonal/src/test/java/com/iluwatar/hexagonal/AppTest.java b/hexagonal/src/test/java/com/iluwatar/hexagonal/AppTest.java
index 1e35847b2..d034ee865 100644
--- a/hexagonal/src/test/java/com/iluwatar/hexagonal/AppTest.java
+++ b/hexagonal/src/test/java/com/iluwatar/hexagonal/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.hexagonal;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Unit test for simple App.
diff --git a/hexagonal/src/test/java/com/iluwatar/hexagonal/banking/InMemoryBankTest.java b/hexagonal/src/test/java/com/iluwatar/hexagonal/banking/InMemoryBankTest.java
index 9c265a2ab..f32a7068f 100644
--- a/hexagonal/src/test/java/com/iluwatar/hexagonal/banking/InMemoryBankTest.java
+++ b/hexagonal/src/test/java/com/iluwatar/hexagonal/banking/InMemoryBankTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.hexagonal.banking;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*
diff --git a/hexagonal/src/test/java/com/iluwatar/hexagonal/banking/MongoBankTest.java b/hexagonal/src/test/java/com/iluwatar/hexagonal/banking/MongoBankTest.java
index 61529f3e4..d3589b0c7 100644
--- a/hexagonal/src/test/java/com/iluwatar/hexagonal/banking/MongoBankTest.java
+++ b/hexagonal/src/test/java/com/iluwatar/hexagonal/banking/MongoBankTest.java
@@ -24,16 +24,16 @@ package com.iluwatar.hexagonal.banking;
import com.iluwatar.hexagonal.mongo.MongoConnectionPropertiesLoader;
import com.mongodb.MongoClient;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests for Mongo banking adapter
*/
-@Ignore
+@Disabled
public class MongoBankTest {
private static final String TEST_DB = "lotteryDBTest";
@@ -41,7 +41,7 @@ public class MongoBankTest {
private MongoBank mongoBank;
- @Before
+ @BeforeEach
public void init() {
MongoConnectionPropertiesLoader.load();
MongoClient mongoClient = new MongoClient(System.getProperty("mongo-host"),
diff --git a/hexagonal/src/test/java/com/iluwatar/hexagonal/database/InMemoryTicketRepositoryTest.java b/hexagonal/src/test/java/com/iluwatar/hexagonal/database/InMemoryTicketRepositoryTest.java
index ce5038369..f14caa94f 100644
--- a/hexagonal/src/test/java/com/iluwatar/hexagonal/database/InMemoryTicketRepositoryTest.java
+++ b/hexagonal/src/test/java/com/iluwatar/hexagonal/database/InMemoryTicketRepositoryTest.java
@@ -22,17 +22,16 @@
*/
package com.iluwatar.hexagonal.database;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
-
import com.iluwatar.hexagonal.domain.LotteryTicket;
import com.iluwatar.hexagonal.domain.LotteryTicketId;
import com.iluwatar.hexagonal.test.LotteryTestUtils;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*
@@ -43,7 +42,7 @@ public class InMemoryTicketRepositoryTest {
private final LotteryTicketRepository repository = new InMemoryTicketRepository();
- @Before
+ @BeforeEach
public void clear() {
repository.deleteAll();
}
diff --git a/hexagonal/src/test/java/com/iluwatar/hexagonal/database/MongoTicketRepositoryTest.java b/hexagonal/src/test/java/com/iluwatar/hexagonal/database/MongoTicketRepositoryTest.java
index 8b248de8c..08dcc51c3 100644
--- a/hexagonal/src/test/java/com/iluwatar/hexagonal/database/MongoTicketRepositoryTest.java
+++ b/hexagonal/src/test/java/com/iluwatar/hexagonal/database/MongoTicketRepositoryTest.java
@@ -28,19 +28,19 @@ import com.iluwatar.hexagonal.domain.LotteryTicketId;
import com.iluwatar.hexagonal.domain.PlayerDetails;
import com.iluwatar.hexagonal.mongo.MongoConnectionPropertiesLoader;
import com.mongodb.MongoClient;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for Mongo based ticket repository
*/
-@Ignore
+@Disabled
public class MongoTicketRepositoryTest {
private static final String TEST_DB = "lotteryTestDB";
@@ -49,7 +49,7 @@ public class MongoTicketRepositoryTest {
private MongoTicketRepository repository;
- @Before
+ @BeforeEach
public void init() {
MongoConnectionPropertiesLoader.load();
MongoClient mongoClient = new MongoClient(System.getProperty("mongo-host"),
diff --git a/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryNumbersTest.java b/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryNumbersTest.java
index 8bd61db9c..b823bc3c7 100644
--- a/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryNumbersTest.java
+++ b/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryNumbersTest.java
@@ -22,14 +22,15 @@
*/
package com.iluwatar.hexagonal.domain;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashSet;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*
@@ -49,11 +50,13 @@ public class LotteryNumbersTest {
assertTrue(numbers.getNumbers().contains(4));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testNumbersCantBeModified() {
LotteryNumbers numbers = LotteryNumbers.create(
new HashSet<>(Arrays.asList(1, 2, 3, 4)));
- numbers.getNumbers().add(5);
+ assertThrows(UnsupportedOperationException.class, () -> {
+ numbers.getNumbers().add(5);
+ });
}
@Test
diff --git a/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTest.java b/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTest.java
index 4af8da3ea..2290b7d49 100644
--- a/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTest.java
+++ b/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTest.java
@@ -22,24 +22,23 @@
*/
package com.iluwatar.hexagonal.domain;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.iluwatar.hexagonal.banking.WireTransfers;
+import com.iluwatar.hexagonal.domain.LotteryTicketCheckResult.CheckResult;
+import com.iluwatar.hexagonal.module.LotteryTestingModule;
+import com.iluwatar.hexagonal.test.LotteryTestUtils;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
-import com.google.inject.Guice;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.iluwatar.hexagonal.module.LotteryTestingModule;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.iluwatar.hexagonal.banking.WireTransfers;
-import com.iluwatar.hexagonal.domain.LotteryTicketCheckResult.CheckResult;
-import com.iluwatar.hexagonal.test.LotteryTestUtils;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*
@@ -60,7 +59,7 @@ public class LotteryTest {
this.injector = Guice.createInjector(new LotteryTestingModule());
}
- @Before
+ @BeforeEach
public void setup() {
injector.injectMembers(this);
// add funds to the test player's bank account
diff --git a/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTicketCheckResultTest.java b/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTicketCheckResultTest.java
index 454d0dd01..4ded94bc4 100644
--- a/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTicketCheckResultTest.java
+++ b/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTicketCheckResultTest.java
@@ -22,12 +22,11 @@
*/
package com.iluwatar.hexagonal.domain;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import org.junit.Test;
-
import com.iluwatar.hexagonal.domain.LotteryTicketCheckResult.CheckResult;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
*
diff --git a/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTicketIdTest.java b/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTicketIdTest.java
index d4f0848ba..6bcaea4f0 100644
--- a/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTicketIdTest.java
+++ b/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTicketIdTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.hexagonal.domain;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for lottery ticket id
diff --git a/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTicketTest.java b/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTicketTest.java
index a83f9033c..2c0332458 100644
--- a/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTicketTest.java
+++ b/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/LotteryTicketTest.java
@@ -22,13 +22,13 @@
*/
package com.iluwatar.hexagonal.domain;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashSet;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* Test Lottery Tickets for equality
diff --git a/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/PlayerDetailsTest.java b/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/PlayerDetailsTest.java
index 2271ebf7c..4d49fcae5 100644
--- a/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/PlayerDetailsTest.java
+++ b/hexagonal/src/test/java/com/iluwatar/hexagonal/domain/PlayerDetailsTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.hexagonal.domain;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
*
diff --git a/hexagonal/src/test/java/com/iluwatar/hexagonal/eventlog/MongoEventLogTest.java b/hexagonal/src/test/java/com/iluwatar/hexagonal/eventlog/MongoEventLogTest.java
index 07c40691b..06942a032 100644
--- a/hexagonal/src/test/java/com/iluwatar/hexagonal/eventlog/MongoEventLogTest.java
+++ b/hexagonal/src/test/java/com/iluwatar/hexagonal/eventlog/MongoEventLogTest.java
@@ -25,16 +25,16 @@ package com.iluwatar.hexagonal.eventlog;
import com.iluwatar.hexagonal.domain.PlayerDetails;
import com.iluwatar.hexagonal.mongo.MongoConnectionPropertiesLoader;
import com.mongodb.MongoClient;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests for Mongo event log
*/
-@Ignore
+@Disabled
public class MongoEventLogTest {
private static final String TEST_DB = "lotteryDBTest";
@@ -42,7 +42,7 @@ public class MongoEventLogTest {
private MongoEventLog mongoEventLog;
- @Before
+ @BeforeEach
public void init() {
MongoConnectionPropertiesLoader.load();
MongoClient mongoClient = new MongoClient(System.getProperty("mongo-host"),
diff --git a/intercepting-filter/pom.xml b/intercepting-filter/pom.xml
index 40888b7f3..0664754d7 100644
--- a/intercepting-filter/pom.xml
+++ b/intercepting-filter/pom.xml
@@ -34,8 +34,18 @@
intercepting-filter
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
test
diff --git a/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/AppTest.java b/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/AppTest.java
index eb347dce7..fb6cfb7e4 100644
--- a/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/AppTest.java
+++ b/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.intercepting.filter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/FilterManagerTest.java b/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/FilterManagerTest.java
index 9b77ea19c..74259c152 100644
--- a/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/FilterManagerTest.java
+++ b/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/FilterManagerTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.intercepting.filter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
diff --git a/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/FilterTest.java b/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/FilterTest.java
index 877340355..43170af42 100644
--- a/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/FilterTest.java
+++ b/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/FilterTest.java
@@ -22,25 +22,22 @@
*/
package com.iluwatar.intercepting.filter;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import java.util.ArrayList;
import java.util.List;
-import static junit.framework.TestCase.assertSame;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
* Date: 12/13/15 - 2:17 PM
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class FilterTest {
private static final Order PERFECT_ORDER = new Order("name", "12345678901", "addr", "dep", "order");
@@ -50,8 +47,7 @@ public class FilterTest {
private static final Order WRONG_CONTACT = new Order("name", "", "addr", "dep", "order");
private static final Order WRONG_NAME = new Order("", "12345678901", "addr", "dep", "order");
- @Parameters
- public static List getTestData() {
+ static List getTestData() {
final List testData = new ArrayList<>();
testData.add(new Object[]{new NameFilter(), PERFECT_ORDER, ""});
testData.add(new Object[]{new NameFilter(), WRONG_NAME, "Invalid name!"});
@@ -91,30 +87,19 @@ public class FilterTest {
return testData;
}
- private final Filter filter;
- private final Order order;
- private final String result;
-
- /**
- * Constructor
- */
- public FilterTest(Filter filter, Order order, String result) {
- this.filter = filter;
- this.order = order;
- this.result = result;
- }
-
- @Test
- public void testExecute() throws Exception {
- final String result = this.filter.execute(this.order);
+ @ParameterizedTest
+ @MethodSource("getTestData")
+ public void testExecute(Filter filter, Order order, String expectedResult) throws Exception {
+ final String result = filter.execute(order);
assertNotNull(result);
- assertEquals(this.result, result.trim());
+ assertEquals(expectedResult, result.trim());
}
- @Test
- public void testNext() throws Exception {
- assertNull(this.filter.getNext());
- assertSame(this.filter, this.filter.getLast());
+ @ParameterizedTest
+ @MethodSource("getTestData")
+ public void testNext(Filter filter) throws Exception {
+ assertNull(filter.getNext());
+ assertSame(filter, filter.getLast());
}
}
diff --git a/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/OrderTest.java b/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/OrderTest.java
index f52f6deec..3b03e4599 100644
--- a/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/OrderTest.java
+++ b/intercepting-filter/src/test/java/com/iluwatar/intercepting/filter/OrderTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.intercepting.filter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/13/15 - 2:57 PM
diff --git a/interpreter/pom.xml b/interpreter/pom.xml
index 8c0ab09a0..794d9b6ca 100644
--- a/interpreter/pom.xml
+++ b/interpreter/pom.xml
@@ -34,8 +34,18 @@
interpreter
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
test
diff --git a/interpreter/src/test/java/com/iluwatar/interpreter/AppTest.java b/interpreter/src/test/java/com/iluwatar/interpreter/AppTest.java
index b2d6db157..547c0fa13 100644
--- a/interpreter/src/test/java/com/iluwatar/interpreter/AppTest.java
+++ b/interpreter/src/test/java/com/iluwatar/interpreter/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.interpreter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/interpreter/src/test/java/com/iluwatar/interpreter/ExpressionTest.java b/interpreter/src/test/java/com/iluwatar/interpreter/ExpressionTest.java
index 2241b882b..a3d9f21f2 100644
--- a/interpreter/src/test/java/com/iluwatar/interpreter/ExpressionTest.java
+++ b/interpreter/src/test/java/com/iluwatar/interpreter/ExpressionTest.java
@@ -22,15 +22,19 @@
*/
package com.iluwatar.interpreter;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.IntBinaryOperator;
+import java.util.stream.Stream;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Date: 12/14/15 - 11:48 AM
@@ -45,37 +49,22 @@ public abstract class ExpressionTest {
* Generate inputs ranging from -10 to 10 for both input params and calculate the expected result
*
* @param resultCalc The function used to calculate the expected result
- * @return A data set with test entries
+ * @return A stream with test entries
*/
- static List prepareParameters(final IntBinaryOperator resultCalc) {
- final List testData = new ArrayList<>();
+ static Stream prepareParameters(final IntBinaryOperator resultCalc) {
+ final List testData = new ArrayList<>();
for (int i = -10; i < 10; i++) {
for (int j = -10; j < 10; j++) {
- testData.add(new Object[]{
- new NumberExpression(i),
- new NumberExpression(j),
- resultCalc.applyAsInt(i, j)
- });
+ testData.add(Arguments.of(
+ new NumberExpression(i),
+ new NumberExpression(j),
+ resultCalc.applyAsInt(i, j)
+ ));
}
}
- return testData;
+ return testData.stream();
}
- /**
- * The input used as first parameter during the test
- */
- private final NumberExpression first;
-
- /**
- * The input used as second parameter during the test
- */
- private final NumberExpression second;
-
- /**
- * The expected result of the calculation, taking the first and second parameter in account
- */
- private final int result;
-
/**
* The expected {@link E#toString()} response
*/
@@ -89,47 +78,34 @@ public abstract class ExpressionTest {
/**
* Create a new test instance with the given parameters and expected results
*
- * @param first The input used as first parameter during the test
- * @param second The input used as second parameter during the test
- * @param result The expected result of the tested expression
* @param expectedToString The expected {@link E#toString()} response
* @param factory Factory, used to create a new test object instance
*/
- ExpressionTest(final NumberExpression first, final NumberExpression second, final int result,
- final String expectedToString, final BiFunction factory) {
-
- this.first = first;
- this.second = second;
- this.result = result;
+ ExpressionTest(final String expectedToString,
+ final BiFunction factory
+ ) {
this.expectedToString = expectedToString;
this.factory = factory;
}
- /**
- * Get the first parameter
- *
- * @return The first parameter
- */
- final NumberExpression getFirst() {
- return this.first;
- }
-
/**
* Verify if the expression calculates the correct result when calling {@link E#interpret()}
*/
- @Test
- public void testInterpret() {
- final E expression = this.factory.apply(this.first, this.second);
+ @ParameterizedTest
+ @MethodSource("expressionProvider")
+ public void testInterpret(NumberExpression first, NumberExpression second, int result) {
+ final E expression = factory.apply(first, second);
assertNotNull(expression);
- assertEquals(this.result, expression.interpret());
+ assertEquals(result, expression.interpret());
}
/**
* Verify if the expression has the expected {@link E#toString()} value
*/
- @Test
- public void testToString() {
- final E expression = this.factory.apply(this.first, this.second);
+ @ParameterizedTest
+ @MethodSource("expressionProvider")
+ public void testToString(NumberExpression first, NumberExpression second) {
+ final E expression = factory.apply(first, second);
assertNotNull(expression);
assertEquals(expectedToString, expression.toString());
}
diff --git a/interpreter/src/test/java/com/iluwatar/interpreter/MinusExpressionTest.java b/interpreter/src/test/java/com/iluwatar/interpreter/MinusExpressionTest.java
index 65e7e4515..eab0ea011 100644
--- a/interpreter/src/test/java/com/iluwatar/interpreter/MinusExpressionTest.java
+++ b/interpreter/src/test/java/com/iluwatar/interpreter/MinusExpressionTest.java
@@ -22,18 +22,15 @@
*/
package com.iluwatar.interpreter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.provider.Arguments;
-import java.util.List;
+import java.util.stream.Stream;
/**
* Date: 12/14/15 - 12:08 PM
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class MinusExpressionTest extends ExpressionTest {
/**
@@ -41,20 +38,15 @@ public class MinusExpressionTest extends ExpressionTest {
*
* @return The list of parameters used during this test
*/
- @Parameters
- public static List data() {
+ public static Stream expressionProvider() {
return prepareParameters((f, s) -> f - s);
}
/**
* Create a new test instance using the given test parameters and expected result
- *
- * @param first The first expression parameter
- * @param second The second expression parameter
- * @param result The expected result
*/
- public MinusExpressionTest(final NumberExpression first, final NumberExpression second, final int result) {
- super(first, second, result, "-", MinusExpression::new);
+ public MinusExpressionTest() {
+ super("-", MinusExpression::new);
}
}
\ No newline at end of file
diff --git a/interpreter/src/test/java/com/iluwatar/interpreter/MultiplyExpressionTest.java b/interpreter/src/test/java/com/iluwatar/interpreter/MultiplyExpressionTest.java
index 12ea35863..6e5384f8b 100644
--- a/interpreter/src/test/java/com/iluwatar/interpreter/MultiplyExpressionTest.java
+++ b/interpreter/src/test/java/com/iluwatar/interpreter/MultiplyExpressionTest.java
@@ -22,18 +22,15 @@
*/
package com.iluwatar.interpreter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.provider.Arguments;
-import java.util.List;
+import java.util.stream.Stream;
/**
* Date: 12/14/15 - 12:08 PM
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class MultiplyExpressionTest extends ExpressionTest {
/**
@@ -41,20 +38,16 @@ public class MultiplyExpressionTest extends ExpressionTest {
*
* @return The list of parameters used during this test
*/
- @Parameters
- public static List data() {
+ public static Stream expressionProvider() {
return prepareParameters((f, s) -> f * s);
}
/**
* Create a new test instance using the given test parameters and expected result
*
- * @param first The first expression parameter
- * @param second The second expression parameter
- * @param result The expected result
*/
- public MultiplyExpressionTest(final NumberExpression first, final NumberExpression second, final int result) {
- super(first, second, result, "*", MultiplyExpression::new);
+ public MultiplyExpressionTest() {
+ super("*", MultiplyExpression::new);
}
}
\ No newline at end of file
diff --git a/interpreter/src/test/java/com/iluwatar/interpreter/NumberExpressionTest.java b/interpreter/src/test/java/com/iluwatar/interpreter/NumberExpressionTest.java
index 9f18355ef..698da52bc 100644
--- a/interpreter/src/test/java/com/iluwatar/interpreter/NumberExpressionTest.java
+++ b/interpreter/src/test/java/com/iluwatar/interpreter/NumberExpressionTest.java
@@ -22,21 +22,19 @@
*/
package com.iluwatar.interpreter;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
-import java.util.List;
+import java.util.stream.Stream;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/14/15 - 12:08 PM
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class NumberExpressionTest extends ExpressionTest {
/**
@@ -44,30 +42,26 @@ public class NumberExpressionTest extends ExpressionTest {
*
* @return The list of parameters used during this test
*/
- @Parameters
- public static List data() {
+ public static Stream expressionProvider() {
return prepareParameters((f, s) -> f);
}
/**
* Create a new test instance using the given test parameters and expected result
- *
- * @param first The first expression parameter
- * @param second The second expression parameter
- * @param result The expected result
*/
- public NumberExpressionTest(final NumberExpression first, final NumberExpression second, final int result) {
- super(first, second, result, "number", (f, s) -> f);
+ public NumberExpressionTest() {
+ super("number", (f, s) -> f);
}
/**
* Verify if the {@link NumberExpression#NumberExpression(String)} constructor works as expected
*/
- @Test
- public void testFromString() throws Exception {
- final int expectedValue = getFirst().interpret();
- final String testStingValue = String.valueOf(expectedValue);
- final NumberExpression numberExpression = new NumberExpression(testStingValue);
+ @ParameterizedTest
+ @MethodSource("expressionProvider")
+ public void testFromString(NumberExpression first) throws Exception {
+ final int expectedValue = first.interpret();
+ final String testStringValue = String.valueOf(expectedValue);
+ final NumberExpression numberExpression = new NumberExpression(testStringValue);
assertEquals(expectedValue, numberExpression.interpret());
}
diff --git a/interpreter/src/test/java/com/iluwatar/interpreter/PlusExpressionTest.java b/interpreter/src/test/java/com/iluwatar/interpreter/PlusExpressionTest.java
index d11ba8a8d..ae2423c7a 100644
--- a/interpreter/src/test/java/com/iluwatar/interpreter/PlusExpressionTest.java
+++ b/interpreter/src/test/java/com/iluwatar/interpreter/PlusExpressionTest.java
@@ -22,18 +22,15 @@
*/
package com.iluwatar.interpreter;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.provider.Arguments;
-import java.util.List;
+import java.util.stream.Stream;
/**
* Date: 12/14/15 - 12:08 PM
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class PlusExpressionTest extends ExpressionTest {
/**
@@ -41,20 +38,15 @@ public class PlusExpressionTest extends ExpressionTest {
*
* @return The list of parameters used during this test
*/
- @Parameters
- public static List data() {
+ public static Stream expressionProvider() {
return prepareParameters((f, s) -> f + s);
}
/**
* Create a new test instance using the given test parameters and expected result
- *
- * @param first The first expression parameter
- * @param second The second expression parameter
- * @param result The expected result
*/
- public PlusExpressionTest(final NumberExpression first, final NumberExpression second, final int result) {
- super(first, second, result, "+", PlusExpression::new);
+ public PlusExpressionTest() {
+ super("+", PlusExpression::new);
}
}
\ No newline at end of file
diff --git a/iterator/pom.xml b/iterator/pom.xml
index 2233e0b32..f33dec661 100644
--- a/iterator/pom.xml
+++ b/iterator/pom.xml
@@ -34,8 +34,18 @@
iterator
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
test
diff --git a/iterator/src/test/java/com/iluwatar/iterator/AppTest.java b/iterator/src/test/java/com/iluwatar/iterator/AppTest.java
index 75cad3ced..f448a378e 100644
--- a/iterator/src/test/java/com/iluwatar/iterator/AppTest.java
+++ b/iterator/src/test/java/com/iluwatar/iterator/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.iterator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/iterator/src/test/java/com/iluwatar/iterator/TreasureChestTest.java b/iterator/src/test/java/com/iluwatar/iterator/TreasureChestTest.java
index 196e08216..665666aa7 100644
--- a/iterator/src/test/java/com/iluwatar/iterator/TreasureChestTest.java
+++ b/iterator/src/test/java/com/iluwatar/iterator/TreasureChestTest.java
@@ -22,23 +22,21 @@
*/
package com.iluwatar.iterator;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Date: 12/14/15 - 2:58 PM
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class TreasureChestTest {
/**
@@ -46,8 +44,7 @@ public class TreasureChestTest {
*
* @return The set of all expected items in the chest
*/
- @Parameterized.Parameters
- public static List data() {
+ public static List dataProvider() {
final List parameters = new ArrayList<>();
parameters.add(new Object[]{new Item(ItemType.POTION, "Potion of courage")});
parameters.add(new Object[]{new Item(ItemType.RING, "Ring of shadows")});
@@ -62,25 +59,12 @@ public class TreasureChestTest {
return parameters;
}
- /**
- * One of the expected items in the chest
- */
- private final Item expectedItem;
-
- /**
- * Create a new test instance, test if the given expected item can be retrieved from the chest
- *
- * @param expectedItem One of the items that should be in the chest
- */
- public TreasureChestTest(final Item expectedItem) {
- this.expectedItem = expectedItem;
- }
-
/**
* Test if the expected item can be retrieved from the chest using the {@link ItemIterator}
*/
- @Test
- public void testIterator() {
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testIterator(Item expectedItem) {
final TreasureChest chest = new TreasureChest();
final ItemIterator iterator = chest.iterator(expectedItem.getType());
assertNotNull(iterator);
@@ -88,16 +72,16 @@ public class TreasureChestTest {
while (iterator.hasNext()) {
final Item item = iterator.next();
assertNotNull(item);
- assertEquals(this.expectedItem.getType(), item.getType());
+ assertEquals(expectedItem.getType(), item.getType());
final String name = item.toString();
assertNotNull(name);
- if (this.expectedItem.toString().equals(name)) {
+ if (expectedItem.toString().equals(name)) {
return;
}
}
- fail("Expected to find item [" + this.expectedItem + "] using iterator, but we didn't.");
+ fail("Expected to find item [" + expectedItem + "] using iterator, but we didn't.");
}
@@ -105,8 +89,9 @@ public class TreasureChestTest {
* Test if the expected item can be retrieved from the chest using the {@link
* TreasureChest#getItems()} method
*/
- @Test
- public void testGetItems() throws Exception {
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testGetItems(Item expectedItem) throws Exception {
final TreasureChest chest = new TreasureChest();
final List- items = chest.getItems();
assertNotNull(items);
@@ -116,14 +101,14 @@ public class TreasureChestTest {
assertNotNull(item.getType());
assertNotNull(item.toString());
- final boolean sameType = this.expectedItem.getType() == item.getType();
- final boolean sameName = this.expectedItem.toString().equals(item.toString());
+ final boolean sameType = expectedItem.getType() == item.getType();
+ final boolean sameName = expectedItem.toString().equals(item.toString());
if (sameType && sameName) {
return;
}
}
- fail("Expected to find item [" + this.expectedItem + "] in the item list, but we didn't.");
+ fail("Expected to find item [" + expectedItem + "] in the item list, but we didn't.");
}
diff --git a/layers/pom.xml b/layers/pom.xml
index d15b524de..e9245815a 100644
--- a/layers/pom.xml
+++ b/layers/pom.xml
@@ -52,8 +52,13 @@
h2
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/layers/src/test/java/com/iluwatar/layers/AppTest.java b/layers/src/test/java/com/iluwatar/layers/AppTest.java
index 841d0ecb5..aa14e039d 100644
--- a/layers/src/test/java/com/iluwatar/layers/AppTest.java
+++ b/layers/src/test/java/com/iluwatar/layers/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.layers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/layers/src/test/java/com/iluwatar/layers/CakeBakingExceptionTest.java b/layers/src/test/java/com/iluwatar/layers/CakeBakingExceptionTest.java
index abefc9f2c..e13e148a3 100644
--- a/layers/src/test/java/com/iluwatar/layers/CakeBakingExceptionTest.java
+++ b/layers/src/test/java/com/iluwatar/layers/CakeBakingExceptionTest.java
@@ -22,10 +22,10 @@
*/
package com.iluwatar.layers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Date: 12/15/15 - 7:57 PM
diff --git a/layers/src/test/java/com/iluwatar/layers/CakeBakingServiceImplTest.java b/layers/src/test/java/com/iluwatar/layers/CakeBakingServiceImplTest.java
index 1c6eb1517..f740fb5f4 100644
--- a/layers/src/test/java/com/iluwatar/layers/CakeBakingServiceImplTest.java
+++ b/layers/src/test/java/com/iluwatar/layers/CakeBakingServiceImplTest.java
@@ -22,16 +22,17 @@
*/
package com.iluwatar.layers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/15/15 - 9:55 PM
@@ -123,7 +124,7 @@ public class CakeBakingServiceImplTest {
}
- @Test(expected = CakeBakingException.class)
+ @Test
public void testBakeCakeMissingTopping() throws CakeBakingException {
final CakeBakingServiceImpl service = new CakeBakingServiceImpl();
@@ -133,10 +134,12 @@ public class CakeBakingServiceImplTest {
service.saveNewLayer(layer2);
final CakeToppingInfo missingTopping = new CakeToppingInfo("Topping1", 1000);
- service.bakeNewCake(new CakeInfo(missingTopping, Arrays.asList(layer1, layer2)));
+ assertThrows(CakeBakingException.class, () -> {
+ service.bakeNewCake(new CakeInfo(missingTopping, Arrays.asList(layer1, layer2)));
+ });
}
- @Test(expected = CakeBakingException.class)
+ @Test
public void testBakeCakeMissingLayer() throws CakeBakingException {
final CakeBakingServiceImpl service = new CakeBakingServiceImpl();
@@ -151,11 +154,12 @@ public class CakeBakingServiceImplTest {
service.saveNewLayer(layer1);
final CakeLayerInfo missingLayer = new CakeLayerInfo("Layer2", 2000);
- service.bakeNewCake(new CakeInfo(topping1, Arrays.asList(layer1, missingLayer)));
-
+ assertThrows(CakeBakingException.class, () -> {
+ service.bakeNewCake(new CakeInfo(topping1, Arrays.asList(layer1, missingLayer)));
+ });
}
- @Test(expected = CakeBakingException.class)
+ @Test
public void testBakeCakesUsedLayer() throws CakeBakingException {
final CakeBakingServiceImpl service = new CakeBakingServiceImpl();
@@ -174,8 +178,9 @@ public class CakeBakingServiceImplTest {
service.saveNewLayer(layer2);
service.bakeNewCake(new CakeInfo(topping1, Arrays.asList(layer1, layer2)));
- service.bakeNewCake(new CakeInfo(topping2, Collections.singletonList(layer2)));
-
+ assertThrows(CakeBakingException.class, () -> {
+ service.bakeNewCake(new CakeInfo(topping2, Collections.singletonList(layer2)));
+ });
}
}
diff --git a/layers/src/test/java/com/iluwatar/layers/CakeTest.java b/layers/src/test/java/com/iluwatar/layers/CakeTest.java
index f43f5508f..f71a0b35d 100644
--- a/layers/src/test/java/com/iluwatar/layers/CakeTest.java
+++ b/layers/src/test/java/com/iluwatar/layers/CakeTest.java
@@ -22,15 +22,15 @@
*/
package com.iluwatar.layers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/15/15 - 8:02 PM
diff --git a/layers/src/test/java/com/iluwatar/layers/CakeViewImplTest.java b/layers/src/test/java/com/iluwatar/layers/CakeViewImplTest.java
index 8a62e074b..4aed18869 100644
--- a/layers/src/test/java/com/iluwatar/layers/CakeViewImplTest.java
+++ b/layers/src/test/java/com/iluwatar/layers/CakeViewImplTest.java
@@ -25,17 +25,18 @@ package com.iluwatar.layers;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
/**
* Date: 12/15/15 - 10:04 PM
@@ -46,12 +47,12 @@ public class CakeViewImplTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender(CakeViewImpl.class);
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/lazy-loading/pom.xml b/lazy-loading/pom.xml
index 9d3652feb..f63756f7e 100644
--- a/lazy-loading/pom.xml
+++ b/lazy-loading/pom.xml
@@ -34,8 +34,13 @@
lazy-loading
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/lazy-loading/src/test/java/com/iluwatar/lazy/loading/AbstractHolderTest.java b/lazy-loading/src/test/java/com/iluwatar/lazy/loading/AbstractHolderTest.java
index 917ccb8d3..56b5a2c3d 100644
--- a/lazy-loading/src/test/java/com/iluwatar/lazy/loading/AbstractHolderTest.java
+++ b/lazy-loading/src/test/java/com/iluwatar/lazy/loading/AbstractHolderTest.java
@@ -22,11 +22,13 @@
*/
package com.iluwatar.lazy.loading;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertSame;
-import static junit.framework.TestCase.assertNull;
+import static java.time.Duration.ofMillis;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTimeout;
/**
* Date: 12/19/15 - 11:58 AM
@@ -52,12 +54,14 @@ public abstract class AbstractHolderTest {
/**
* This test shows that the heavy field is not instantiated until the method getHeavy is called
*/
- @Test(timeout = 3000)
+ @Test
public void testGetHeavy() throws Exception {
- assertNull(getInternalHeavyValue());
- assertNotNull(getHeavy());
- assertNotNull(getInternalHeavyValue());
- assertSame(getHeavy(), getInternalHeavyValue());
+ assertTimeout(ofMillis(3000), () -> {
+ assertNull(getInternalHeavyValue());
+ assertNotNull(getHeavy());
+ assertNotNull(getInternalHeavyValue());
+ assertSame(getHeavy(), getInternalHeavyValue());
+ });
}
}
diff --git a/lazy-loading/src/test/java/com/iluwatar/lazy/loading/AppTest.java b/lazy-loading/src/test/java/com/iluwatar/lazy/loading/AppTest.java
index cefa9918a..bd43b0d35 100644
--- a/lazy-loading/src/test/java/com/iluwatar/lazy/loading/AppTest.java
+++ b/lazy-loading/src/test/java/com/iluwatar/lazy/loading/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.lazy.loading;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/marker/pom.xml b/marker/pom.xml
index 91cf2c48a..bd3c1886e 100644
--- a/marker/pom.xml
+++ b/marker/pom.xml
@@ -31,8 +31,19 @@
marker
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.hamcrest
+ hamcrest-core
+ 1.3
test
diff --git a/marker/src/test/java/AppTest.java b/marker/src/test/java/AppTest.java
index 85fb61b16..856635007 100644
--- a/marker/src/test/java/AppTest.java
+++ b/marker/src/test/java/AppTest.java
@@ -20,7 +20,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-import org.junit.Test;
+
+import org.junit.jupiter.api.Test;
/**
* Application test
diff --git a/marker/src/test/java/GuardTest.java b/marker/src/test/java/GuardTest.java
index eb3a4b757..cadd82f82 100644
--- a/marker/src/test/java/GuardTest.java
+++ b/marker/src/test/java/GuardTest.java
@@ -20,10 +20,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-import org.junit.Test;
+
+import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
/**
* Guard test
diff --git a/marker/src/test/java/ThiefTest.java b/marker/src/test/java/ThiefTest.java
index f950809cc..56492334c 100644
--- a/marker/src/test/java/ThiefTest.java
+++ b/marker/src/test/java/ThiefTest.java
@@ -20,9 +20,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-import org.junit.Test;
-import static org.junit.Assert.assertFalse;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* Thief test
diff --git a/mediator/pom.xml b/mediator/pom.xml
index 978aa7da6..72f7483b4 100644
--- a/mediator/pom.xml
+++ b/mediator/pom.xml
@@ -34,8 +34,18 @@
mediator
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
test
diff --git a/mediator/src/test/java/com/iluwatar/mediator/AppTest.java b/mediator/src/test/java/com/iluwatar/mediator/AppTest.java
index d92b8969b..a375490cd 100644
--- a/mediator/src/test/java/com/iluwatar/mediator/AppTest.java
+++ b/mediator/src/test/java/com/iluwatar/mediator/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.mediator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/mediator/src/test/java/com/iluwatar/mediator/PartyImplTest.java b/mediator/src/test/java/com/iluwatar/mediator/PartyImplTest.java
index bb3c51474..820bf17ee 100644
--- a/mediator/src/test/java/com/iluwatar/mediator/PartyImplTest.java
+++ b/mediator/src/test/java/com/iluwatar/mediator/PartyImplTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.mediator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
diff --git a/mediator/src/test/java/com/iluwatar/mediator/PartyMemberTest.java b/mediator/src/test/java/com/iluwatar/mediator/PartyMemberTest.java
index 4d578c333..61f926c31 100644
--- a/mediator/src/test/java/com/iluwatar/mediator/PartyMemberTest.java
+++ b/mediator/src/test/java/com/iluwatar/mediator/PartyMemberTest.java
@@ -25,11 +25,10 @@ package com.iluwatar.mediator;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
@@ -38,7 +37,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.function.Supplier;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -47,11 +46,9 @@ import static org.mockito.Mockito.verify;
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class PartyMemberTest {
- @Parameterized.Parameters
- public static Collection[]> data() {
+ static Collection[]> dataProvider() {
return Arrays.asList(
new Supplier[]{Hobbit::new},
new Supplier[]{Hunter::new},
@@ -60,28 +57,14 @@ public class PartyMemberTest {
);
}
- /**
- * The factory, used to create a new instance of the tested party member
- */
- private final Supplier memberSupplier;
-
- /**
- * Create a new test instance, using the given {@link PartyMember} factory
- *
- * @param memberSupplier The party member factory
- */
- public PartyMemberTest(final Supplier memberSupplier) {
- this.memberSupplier = memberSupplier;
- }
-
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender(PartyMemberBase.class);
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
@@ -89,9 +72,10 @@ public class PartyMemberTest {
/**
* Verify if a party action triggers the correct output to the std-Out
*/
- @Test
- public void testPartyAction() {
- final PartyMember member = this.memberSupplier.get();
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testPartyAction(Supplier memberSupplier) {
+ final PartyMember member = memberSupplier.get();
for (final Action action : Action.values()) {
member.partyAction(action);
@@ -104,9 +88,10 @@ public class PartyMemberTest {
/**
* Verify if a member action triggers the expected interactions with the party class
*/
- @Test
- public void testAct() {
- final PartyMember member = this.memberSupplier.get();
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testAct(Supplier memberSupplier) {
+ final PartyMember member = memberSupplier.get();
member.act(Action.GOLD);
assertEquals(0, appender.getLogSize());
@@ -127,9 +112,10 @@ public class PartyMemberTest {
/**
* Verify if {@link PartyMember#toString()} generate the expected output
*/
- @Test
- public void testToString() throws Exception {
- final PartyMember member = this.memberSupplier.get();
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testToString(Supplier memberSupplier) throws Exception {
+ final PartyMember member = memberSupplier.get();
final Class extends PartyMember> memberClass = member.getClass();
assertEquals(memberClass.getSimpleName(), member.toString());
}
diff --git a/memento/pom.xml b/memento/pom.xml
index 858b75544..f17e402db 100644
--- a/memento/pom.xml
+++ b/memento/pom.xml
@@ -34,8 +34,13 @@
memento
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/memento/src/test/java/com/iluwatar/memento/AppTest.java b/memento/src/test/java/com/iluwatar/memento/AppTest.java
index b98757122..c6ea91e9b 100644
--- a/memento/src/test/java/com/iluwatar/memento/AppTest.java
+++ b/memento/src/test/java/com/iluwatar/memento/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.memento;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/memento/src/test/java/com/iluwatar/memento/StarTest.java b/memento/src/test/java/com/iluwatar/memento/StarTest.java
index 2a7efc70f..c3d16efe5 100644
--- a/memento/src/test/java/com/iluwatar/memento/StarTest.java
+++ b/memento/src/test/java/com/iluwatar/memento/StarTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.memento;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/20/15 - 10:08 AM
diff --git a/message-channel/pom.xml b/message-channel/pom.xml
index 091c35f85..decc1a7a7 100644
--- a/message-channel/pom.xml
+++ b/message-channel/pom.xml
@@ -43,8 +43,13 @@
camel-stream
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/message-channel/src/test/java/com/iluwatar/message/channel/AppTest.java b/message-channel/src/test/java/com/iluwatar/message/channel/AppTest.java
index e41977a00..97094b864 100644
--- a/message-channel/src/test/java/com/iluwatar/message/channel/AppTest.java
+++ b/message-channel/src/test/java/com/iluwatar/message/channel/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.message.channel;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/model-view-controller/pom.xml b/model-view-controller/pom.xml
index 385953d0a..3111109db 100644
--- a/model-view-controller/pom.xml
+++ b/model-view-controller/pom.xml
@@ -34,8 +34,13 @@
model-view-controller
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/model-view-controller/src/test/java/com/iluwatar/model/view/controller/AppTest.java b/model-view-controller/src/test/java/com/iluwatar/model/view/controller/AppTest.java
index 66062faf5..1c4dc3dad 100644
--- a/model-view-controller/src/test/java/com/iluwatar/model/view/controller/AppTest.java
+++ b/model-view-controller/src/test/java/com/iluwatar/model/view/controller/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.model.view.controller;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/model-view-controller/src/test/java/com/iluwatar/model/view/controller/GiantControllerTest.java b/model-view-controller/src/test/java/com/iluwatar/model/view/controller/GiantControllerTest.java
index ab9b3e0a4..73f348770 100644
--- a/model-view-controller/src/test/java/com/iluwatar/model/view/controller/GiantControllerTest.java
+++ b/model-view-controller/src/test/java/com/iluwatar/model/view/controller/GiantControllerTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.model.view.controller;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
diff --git a/model-view-controller/src/test/java/com/iluwatar/model/view/controller/GiantModelTest.java b/model-view-controller/src/test/java/com/iluwatar/model/view/controller/GiantModelTest.java
index ecf713a61..339c170f4 100644
--- a/model-view-controller/src/test/java/com/iluwatar/model/view/controller/GiantModelTest.java
+++ b/model-view-controller/src/test/java/com/iluwatar/model/view/controller/GiantModelTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.model.view.controller;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/20/15 - 2:10 PM
diff --git a/model-view-controller/src/test/java/com/iluwatar/model/view/controller/GiantViewTest.java b/model-view-controller/src/test/java/com/iluwatar/model/view/controller/GiantViewTest.java
index ec0aabd15..855c97606 100644
--- a/model-view-controller/src/test/java/com/iluwatar/model/view/controller/GiantViewTest.java
+++ b/model-view-controller/src/test/java/com/iluwatar/model/view/controller/GiantViewTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.model.view.controller;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import ch.qos.logback.classic.Logger;
@@ -30,9 +30,10 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
import java.util.LinkedList;
import java.util.List;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
/**
@@ -44,12 +45,12 @@ public class GiantViewTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender(GiantView.class);
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/model-view-presenter/pom.xml b/model-view-presenter/pom.xml
index 5c91846bf..4de47f35f 100644
--- a/model-view-presenter/pom.xml
+++ b/model-view-presenter/pom.xml
@@ -36,8 +36,13 @@
http://maven.apache.org
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/model-view-presenter/src/test/java/com/iluwatar/model/view/presenter/AppTest.java b/model-view-presenter/src/test/java/com/iluwatar/model/view/presenter/AppTest.java
index 83639c0b2..c1b33cb30 100644
--- a/model-view-presenter/src/test/java/com/iluwatar/model/view/presenter/AppTest.java
+++ b/model-view-presenter/src/test/java/com/iluwatar/model/view/presenter/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.model.view.presenter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/model-view-presenter/src/test/java/com/iluwatar/model/view/presenter/FileLoaderTest.java b/model-view-presenter/src/test/java/com/iluwatar/model/view/presenter/FileLoaderTest.java
index 8e9a558a7..56bc3b8bd 100644
--- a/model-view-presenter/src/test/java/com/iluwatar/model/view/presenter/FileLoaderTest.java
+++ b/model-view-presenter/src/test/java/com/iluwatar/model/view/presenter/FileLoaderTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.model.view.presenter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Date: 12/21/15 - 12:12 PM
diff --git a/model-view-presenter/src/test/java/com/iluwatar/model/view/presenter/FileSelectorPresenterTest.java b/model-view-presenter/src/test/java/com/iluwatar/model/view/presenter/FileSelectorPresenterTest.java
index 057d4dcdc..ff68cef6e 100644
--- a/model-view-presenter/src/test/java/com/iluwatar/model/view/presenter/FileSelectorPresenterTest.java
+++ b/model-view-presenter/src/test/java/com/iluwatar/model/view/presenter/FileSelectorPresenterTest.java
@@ -22,13 +22,13 @@
*/
package com.iluwatar.model.view.presenter;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* This test case is responsible for testing our application by taking advantage of the
@@ -54,7 +54,7 @@ public class FileSelectorPresenterTest {
/**
* Initializes the components of the test case.
*/
- @Before
+ @BeforeEach
public void setUp() {
this.stub = new FileSelectorStub();
this.loader = new FileLoader();
diff --git a/module/pom.xml b/module/pom.xml
index 1d45a77a5..354beef6d 100644
--- a/module/pom.xml
+++ b/module/pom.xml
@@ -33,8 +33,13 @@
module
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/module/src/test/java/com/iluwatar/module/AppTest.java b/module/src/test/java/com/iluwatar/module/AppTest.java
index 5df6ab0f3..0514dff3a 100644
--- a/module/src/test/java/com/iluwatar/module/AppTest.java
+++ b/module/src/test/java/com/iluwatar/module/AppTest.java
@@ -18,12 +18,10 @@
*/
package com.iluwatar.module;
+import org.junit.jupiter.api.Test;
+
import java.io.FileNotFoundException;
-import com.iluwatar.module.App;
-
-import org.junit.Test;
-
/**
* Tests that Module example runs without errors.
*/
diff --git a/module/src/test/java/com/iluwatar/module/FileLoggerModuleTest.java b/module/src/test/java/com/iluwatar/module/FileLoggerModuleTest.java
index 7274aab14..bdae597bc 100644
--- a/module/src/test/java/com/iluwatar/module/FileLoggerModuleTest.java
+++ b/module/src/test/java/com/iluwatar/module/FileLoggerModuleTest.java
@@ -18,15 +18,15 @@
*/
package com.iluwatar.module;
-import static org.junit.Assert.assertEquals;
+import org.apache.log4j.Logger;
+import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
-import org.apache.log4j.Logger;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* The Module pattern can be considered a Creational pattern and a Structural pattern. It manages
diff --git a/monad/pom.xml b/monad/pom.xml
index 26cb21b97..d18f75230 100644
--- a/monad/pom.xml
+++ b/monad/pom.xml
@@ -34,8 +34,13 @@
monad
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/monad/src/test/java/com/iluwatar/monad/AppTest.java b/monad/src/test/java/com/iluwatar/monad/AppTest.java
index 69464ff87..d6515dfc2 100644
--- a/monad/src/test/java/com/iluwatar/monad/AppTest.java
+++ b/monad/src/test/java/com/iluwatar/monad/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.monad;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Application Test
diff --git a/monad/src/test/java/com/iluwatar/monad/MonadTest.java b/monad/src/test/java/com/iluwatar/monad/MonadTest.java
index a34243978..d5c4ded80 100644
--- a/monad/src/test/java/com/iluwatar/monad/MonadTest.java
+++ b/monad/src/test/java/com/iluwatar/monad/MonadTest.java
@@ -22,36 +22,34 @@
*/
package com.iluwatar.monad;
-
-import junit.framework.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import java.util.Objects;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
/**
* Test for Monad Pattern
*/
public class MonadTest {
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
public void testForInvalidName() {
- thrown.expect(IllegalStateException.class);
User tom = new User(null, 21, Sex.MALE, "tom@foo.bar");
- Validator.of(tom).validate(User::getName, Objects::nonNull, "name cannot be null").get();
+ assertThrows(IllegalStateException.class, () -> {
+ Validator.of(tom).validate(User::getName, Objects::nonNull, "name cannot be null").get();
+ });
}
@Test
public void testForInvalidAge() {
- thrown.expect(IllegalStateException.class);
User john = new User("John", 17, Sex.MALE, "john@qwe.bar");
- Validator.of(john).validate(User::getName, Objects::nonNull, "name cannot be null")
- .validate(User::getAge, age -> age > 21, "user is underaged")
- .get();
+ assertThrows(IllegalStateException.class, () -> {
+ Validator.of(john).validate(User::getName, Objects::nonNull, "name cannot be null")
+ .validate(User::getAge, age -> age > 21, "user is underaged")
+ .get();
+ });
}
@Test
@@ -62,6 +60,6 @@ public class MonadTest {
.validate(User::getSex, sex -> sex == Sex.FEMALE, "user is not female")
.validate(User::getEmail, email -> email.contains("@"), "email does not contain @ sign")
.get();
- Assert.assertSame(validated, sarah);
+ assertSame(validated, sarah);
}
}
diff --git a/monostate/pom.xml b/monostate/pom.xml
index c4dc213da..ba1834187 100644
--- a/monostate/pom.xml
+++ b/monostate/pom.xml
@@ -34,8 +34,13 @@
monostate
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/monostate/src/test/java/com/iluwatar/monostate/AppTest.java b/monostate/src/test/java/com/iluwatar/monostate/AppTest.java
index 3e88b3bf2..dfa2542aa 100644
--- a/monostate/src/test/java/com/iluwatar/monostate/AppTest.java
+++ b/monostate/src/test/java/com/iluwatar/monostate/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.monostate;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Application Test Entry
diff --git a/monostate/src/test/java/com/iluwatar/monostate/LoadBalancerTest.java b/monostate/src/test/java/com/iluwatar/monostate/LoadBalancerTest.java
index 96b4830c7..51cbcdecd 100644
--- a/monostate/src/test/java/com/iluwatar/monostate/LoadBalancerTest.java
+++ b/monostate/src/test/java/com/iluwatar/monostate/LoadBalancerTest.java
@@ -22,11 +22,17 @@
*/
package com.iluwatar.monostate;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
/**
* Date: 12/21/15 - 12:26 PM
@@ -41,9 +47,9 @@ public class LoadBalancerTest {
final LoadBalancer secondBalancer = new LoadBalancer();
firstBalancer.addServer(new Server("localhost", 8085, 6));
// Both should have the same number of servers.
- Assert.assertTrue(firstBalancer.getNoOfServers() == secondBalancer.getNoOfServers());
+ assertTrue(firstBalancer.getNoOfServers() == secondBalancer.getNoOfServers());
// Both Should have the same LastServedId
- Assert.assertTrue(firstBalancer.getLastServedId() == secondBalancer.getLastServedId());
+ assertTrue(firstBalancer.getLastServedId() == secondBalancer.getLastServedId());
}
@Test
diff --git a/multiton/pom.xml b/multiton/pom.xml
index af75e5ebe..f217f3e05 100644
--- a/multiton/pom.xml
+++ b/multiton/pom.xml
@@ -34,8 +34,13 @@
multiton
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/multiton/src/test/java/com/iluwatar/multiton/AppTest.java b/multiton/src/test/java/com/iluwatar/multiton/AppTest.java
index 370a2665b..14e725b26 100644
--- a/multiton/src/test/java/com/iluwatar/multiton/AppTest.java
+++ b/multiton/src/test/java/com/iluwatar/multiton/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.multiton;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/multiton/src/test/java/com/iluwatar/multiton/NazgulTest.java b/multiton/src/test/java/com/iluwatar/multiton/NazgulTest.java
index ad10a9eb0..941ceeee4 100644
--- a/multiton/src/test/java/com/iluwatar/multiton/NazgulTest.java
+++ b/multiton/src/test/java/com/iluwatar/multiton/NazgulTest.java
@@ -22,11 +22,11 @@
*/
package com.iluwatar.multiton;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
* Date: 12/22/15 - 22:28 AM
diff --git a/mute-idiom/pom.xml b/mute-idiom/pom.xml
index 41d660c73..b92a330b1 100644
--- a/mute-idiom/pom.xml
+++ b/mute-idiom/pom.xml
@@ -26,8 +26,13 @@
mute-idiom
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/mute-idiom/src/test/java/com/iluwatar/mute/AppTest.java b/mute-idiom/src/test/java/com/iluwatar/mute/AppTest.java
index 8534ff2ad..31624c994 100644
--- a/mute-idiom/src/test/java/com/iluwatar/mute/AppTest.java
+++ b/mute-idiom/src/test/java/com/iluwatar/mute/AppTest.java
@@ -23,7 +23,7 @@
package com.iluwatar.mute;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests that Mute idiom example runs without errors.
diff --git a/mute-idiom/src/test/java/com/iluwatar/mute/MuteTest.java b/mute-idiom/src/test/java/com/iluwatar/mute/MuteTest.java
index 7e1d2e1af..73bab01d2 100644
--- a/mute-idiom/src/test/java/com/iluwatar/mute/MuteTest.java
+++ b/mute-idiom/src/test/java/com/iluwatar/mute/MuteTest.java
@@ -23,17 +23,16 @@
package com.iluwatar.mute;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test for the mute-idiom pattern
@@ -44,8 +43,6 @@ public class MuteTest {
private static final String MESSAGE = "should not occur";
- @Rule public ExpectedException exception = ExpectedException.none();
-
@Test
public void muteShouldRunTheCheckedRunnableAndNotThrowAnyExceptionIfCheckedRunnableDoesNotThrowAnyException() {
Mute.mute(() -> methodNotThrowingAnyException());
@@ -53,10 +50,9 @@ public class MuteTest {
@Test
public void muteShouldRethrowUnexpectedExceptionAsAssertionError() throws Exception {
- exception.expect(AssertionError.class);
- exception.expectMessage(MESSAGE);
-
- Mute.mute(() -> methodThrowingException());
+ assertThrows(AssertionError.class, () -> {
+ Mute.mute(() -> methodThrowingException());
+ });
}
@Test
diff --git a/mutex/pom.xml b/mutex/pom.xml
index ff938604b..90d8d718a 100644
--- a/mutex/pom.xml
+++ b/mutex/pom.xml
@@ -34,9 +34,14 @@
mutex
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
-
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
diff --git a/mutex/src/test/java/com/iluwatar/mutex/AppTest.java b/mutex/src/test/java/com/iluwatar/mutex/AppTest.java
index 530db835d..8e9ecf875 100644
--- a/mutex/src/test/java/com/iluwatar/mutex/AppTest.java
+++ b/mutex/src/test/java/com/iluwatar/mutex/AppTest.java
@@ -22,7 +22,8 @@
*/
package com.iluwatar.mutex;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
import java.io.IOException;
/**
diff --git a/mutex/src/test/java/com/iluwatar/mutex/JarTest.java b/mutex/src/test/java/com/iluwatar/mutex/JarTest.java
index b9e0c52ca..4f2e91d7e 100644
--- a/mutex/src/test/java/com/iluwatar/mutex/JarTest.java
+++ b/mutex/src/test/java/com/iluwatar/mutex/JarTest.java
@@ -22,8 +22,10 @@
*/
package com.iluwatar.mutex;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case for taking beans from a Jar
diff --git a/mutex/src/test/java/com/iluwatar/mutex/MutexTest.java b/mutex/src/test/java/com/iluwatar/mutex/MutexTest.java
index 93649002f..4d61764d8 100644
--- a/mutex/src/test/java/com/iluwatar/mutex/MutexTest.java
+++ b/mutex/src/test/java/com/iluwatar/mutex/MutexTest.java
@@ -22,8 +22,11 @@
*/
package com.iluwatar.mutex;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Test case for acquiring and releasing a Mutex
diff --git a/naked-objects/dom/pom.xml b/naked-objects/dom/pom.xml
index 5a6f4e7ba..4cb2c5c49 100644
--- a/naked-objects/dom/pom.xml
+++ b/naked-objects/dom/pom.xml
@@ -50,6 +50,12 @@
test
+
+ org.junit.vintage
+ junit-vintage-engine
+ test
+
+
org.objenesis
diff --git a/naked-objects/integtests/pom.xml b/naked-objects/integtests/pom.xml
index e4006561a..c58c2f11a 100644
--- a/naked-objects/integtests/pom.xml
+++ b/naked-objects/integtests/pom.xml
@@ -79,6 +79,12 @@
test
+
+ org.junit.vintage
+ junit-vintage-engine
+ test
+
+
org.hsqldb
hsqldb
diff --git a/naked-objects/webapp/pom.xml b/naked-objects/webapp/pom.xml
index 244d1737d..485070b4b 100644
--- a/naked-objects/webapp/pom.xml
+++ b/naked-objects/webapp/pom.xml
@@ -221,6 +221,18 @@
+
+
+ junit
+ junit
+ test
+
+
+
+ org.junit.vintage
+ junit-vintage-engine
+ test
+
diff --git a/null-object/pom.xml b/null-object/pom.xml
index 755db259e..15111ef2e 100644
--- a/null-object/pom.xml
+++ b/null-object/pom.xml
@@ -34,13 +34,13 @@
null-object
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
- org.mockito
- mockito-core
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/null-object/src/test/java/com/iluwatar/nullobject/AppTest.java b/null-object/src/test/java/com/iluwatar/nullobject/AppTest.java
index 13e92034a..484807aea 100644
--- a/null-object/src/test/java/com/iluwatar/nullobject/AppTest.java
+++ b/null-object/src/test/java/com/iluwatar/nullobject/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.nullobject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/null-object/src/test/java/com/iluwatar/nullobject/NullNodeTest.java b/null-object/src/test/java/com/iluwatar/nullobject/NullNodeTest.java
index 778344e06..0482b7f89 100644
--- a/null-object/src/test/java/com/iluwatar/nullobject/NullNodeTest.java
+++ b/null-object/src/test/java/com/iluwatar/nullobject/NullNodeTest.java
@@ -22,9 +22,12 @@
*/
package com.iluwatar.nullobject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
* Date: 12/26/15 - 11:47 PM
diff --git a/null-object/src/test/java/com/iluwatar/nullobject/TreeTest.java b/null-object/src/test/java/com/iluwatar/nullobject/TreeTest.java
index 6a683a60e..f0cdbf0c9 100644
--- a/null-object/src/test/java/com/iluwatar/nullobject/TreeTest.java
+++ b/null-object/src/test/java/com/iluwatar/nullobject/TreeTest.java
@@ -25,15 +25,18 @@ package com.iluwatar.nullobject;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/26/15 - 11:44 PM
@@ -44,12 +47,12 @@ public class TreeTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/object-mother/pom.xml b/object-mother/pom.xml
index 9b9171888..9f76e42b4 100644
--- a/object-mother/pom.xml
+++ b/object-mother/pom.xml
@@ -35,8 +35,13 @@
object-mother
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/object-mother/src/test/java/com/iluwatar/objectmother/test/RoyaltyObjectMotherTest.java b/object-mother/src/test/java/com/iluwatar/objectmother/test/RoyaltyObjectMotherTest.java
index cc5af45aa..9bc29611c 100644
--- a/object-mother/src/test/java/com/iluwatar/objectmother/test/RoyaltyObjectMotherTest.java
+++ b/object-mother/src/test/java/com/iluwatar/objectmother/test/RoyaltyObjectMotherTest.java
@@ -22,16 +22,15 @@
*/
package com.iluwatar.objectmother.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
import com.iluwatar.objectmother.King;
import com.iluwatar.objectmother.Queen;
import com.iluwatar.objectmother.Royalty;
import com.iluwatar.objectmother.RoyaltyObjectMother;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test Generation of Royalty Types using the object-mother
diff --git a/object-pool/pom.xml b/object-pool/pom.xml
index 4ebb40385..39180f762 100644
--- a/object-pool/pom.xml
+++ b/object-pool/pom.xml
@@ -34,8 +34,13 @@
object-pool
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/object-pool/src/test/java/com/iluwatar/object/pool/AppTest.java b/object-pool/src/test/java/com/iluwatar/object/pool/AppTest.java
index c92399c32..54524c2f6 100644
--- a/object-pool/src/test/java/com/iluwatar/object/pool/AppTest.java
+++ b/object-pool/src/test/java/com/iluwatar/object/pool/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.object.pool;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/object-pool/src/test/java/com/iluwatar/object/pool/OliphauntPoolTest.java b/object-pool/src/test/java/com/iluwatar/object/pool/OliphauntPoolTest.java
index 46ed22b36..e92709fca 100644
--- a/object-pool/src/test/java/com/iluwatar/object/pool/OliphauntPoolTest.java
+++ b/object-pool/src/test/java/com/iluwatar/object/pool/OliphauntPoolTest.java
@@ -22,15 +22,17 @@
*/
package com.iluwatar.object.pool;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static java.time.Duration.ofMillis;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTimeout;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/27/15 - 1:05 AM
@@ -43,78 +45,80 @@ public class OliphauntPoolTest {
* Use the same object 100 times subsequently. This should not take much time since the heavy
* object instantiation is done only once. Verify if we get the same object each time.
*/
- @Test(timeout = 5000)
+ @Test
public void testSubsequentCheckinCheckout() {
- final OliphauntPool pool = new OliphauntPool();
- assertEquals(pool.toString(), "Pool available=0 inUse=0");
+ assertTimeout(ofMillis(5000), () -> {
+ final OliphauntPool pool = new OliphauntPool();
+ assertEquals(pool.toString(), "Pool available=0 inUse=0");
- final Oliphaunt expectedOliphaunt = pool.checkOut();
- assertEquals(pool.toString(), "Pool available=0 inUse=1");
-
- pool.checkIn(expectedOliphaunt);
- assertEquals(pool.toString(), "Pool available=1 inUse=0");
-
- for (int i = 0; i < 100; i++) {
- final Oliphaunt oliphaunt = pool.checkOut();
+ final Oliphaunt expectedOliphaunt = pool.checkOut();
assertEquals(pool.toString(), "Pool available=0 inUse=1");
- assertSame(expectedOliphaunt, oliphaunt);
- assertEquals(expectedOliphaunt.getId(), oliphaunt.getId());
- assertEquals(expectedOliphaunt.toString(), oliphaunt.toString());
- pool.checkIn(oliphaunt);
+ pool.checkIn(expectedOliphaunt);
assertEquals(pool.toString(), "Pool available=1 inUse=0");
- }
+ for (int i = 0; i < 100; i++) {
+ final Oliphaunt oliphaunt = pool.checkOut();
+ assertEquals(pool.toString(), "Pool available=0 inUse=1");
+ assertSame(expectedOliphaunt, oliphaunt);
+ assertEquals(expectedOliphaunt.getId(), oliphaunt.getId());
+ assertEquals(expectedOliphaunt.toString(), oliphaunt.toString());
+
+ pool.checkIn(oliphaunt);
+ assertEquals(pool.toString(), "Pool available=1 inUse=0");
+ }
+ });
}
/**
* Use the same object 100 times subsequently. This should not take much time since the heavy
* object instantiation is done only once. Verify if we get the same object each time.
*/
- @Test(timeout = 5000)
+ @Test
public void testConcurrentCheckinCheckout() {
- final OliphauntPool pool = new OliphauntPool();
- assertEquals(pool.toString(), "Pool available=0 inUse=0");
+ assertTimeout(ofMillis(5000), () -> {
+ final OliphauntPool pool = new OliphauntPool();
+ assertEquals(pool.toString(), "Pool available=0 inUse=0");
- final Oliphaunt firstOliphaunt = pool.checkOut();
- assertEquals(pool.toString(), "Pool available=0 inUse=1");
+ final Oliphaunt firstOliphaunt = pool.checkOut();
+ assertEquals(pool.toString(), "Pool available=0 inUse=1");
- final Oliphaunt secondOliphaunt = pool.checkOut();
- assertEquals(pool.toString(), "Pool available=0 inUse=2");
+ final Oliphaunt secondOliphaunt = pool.checkOut();
+ assertEquals(pool.toString(), "Pool available=0 inUse=2");
- assertNotSame(firstOliphaunt, secondOliphaunt);
- assertEquals(firstOliphaunt.getId() + 1, secondOliphaunt.getId());
+ assertNotSame(firstOliphaunt, secondOliphaunt);
+ assertEquals(firstOliphaunt.getId() + 1, secondOliphaunt.getId());
- // After checking in the second, we should get the same when checking out a new oliphaunt ...
- pool.checkIn(secondOliphaunt);
- assertEquals(pool.toString(), "Pool available=1 inUse=1");
+ // After checking in the second, we should get the same when checking out a new oliphaunt ...
+ pool.checkIn(secondOliphaunt);
+ assertEquals(pool.toString(), "Pool available=1 inUse=1");
- final Oliphaunt oliphaunt3 = pool.checkOut();
- assertEquals(pool.toString(), "Pool available=0 inUse=2");
- assertSame(secondOliphaunt, oliphaunt3);
+ final Oliphaunt oliphaunt3 = pool.checkOut();
+ assertEquals(pool.toString(), "Pool available=0 inUse=2");
+ assertSame(secondOliphaunt, oliphaunt3);
- // ... and the same applies for the first one
- pool.checkIn(firstOliphaunt);
- assertEquals(pool.toString(), "Pool available=1 inUse=1");
+ // ... and the same applies for the first one
+ pool.checkIn(firstOliphaunt);
+ assertEquals(pool.toString(), "Pool available=1 inUse=1");
- final Oliphaunt oliphaunt4 = pool.checkOut();
- assertEquals(pool.toString(), "Pool available=0 inUse=2");
- assertSame(firstOliphaunt, oliphaunt4);
+ final Oliphaunt oliphaunt4 = pool.checkOut();
+ assertEquals(pool.toString(), "Pool available=0 inUse=2");
+ assertSame(firstOliphaunt, oliphaunt4);
- // When both oliphaunt return to the pool, we should still get the same instances
- pool.checkIn(firstOliphaunt);
- assertEquals(pool.toString(), "Pool available=1 inUse=1");
+ // When both oliphaunt return to the pool, we should still get the same instances
+ pool.checkIn(firstOliphaunt);
+ assertEquals(pool.toString(), "Pool available=1 inUse=1");
- pool.checkIn(secondOliphaunt);
- assertEquals(pool.toString(), "Pool available=2 inUse=0");
-
- // The order of the returned instances is not determined, so just put them in a list
- // and verify if both expected instances are in there.
- final List oliphaunts = Arrays.asList(pool.checkOut(), pool.checkOut());
- assertEquals(pool.toString(), "Pool available=0 inUse=2");
- assertTrue(oliphaunts.contains(firstOliphaunt));
- assertTrue(oliphaunts.contains(secondOliphaunt));
+ pool.checkIn(secondOliphaunt);
+ assertEquals(pool.toString(), "Pool available=2 inUse=0");
+ // The order of the returned instances is not determined, so just put them in a list
+ // and verify if both expected instances are in there.
+ final List oliphaunts = Arrays.asList(pool.checkOut(), pool.checkOut());
+ assertEquals(pool.toString(), "Pool available=0 inUse=2");
+ assertTrue(oliphaunts.contains(firstOliphaunt));
+ assertTrue(oliphaunts.contains(secondOliphaunt));
+ });
}
diff --git a/observer/pom.xml b/observer/pom.xml
index 7113306f3..aa17ca1f5 100644
--- a/observer/pom.xml
+++ b/observer/pom.xml
@@ -34,8 +34,18 @@
observer
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
test
diff --git a/observer/src/test/java/com/iluwatar/observer/AppTest.java b/observer/src/test/java/com/iluwatar/observer/AppTest.java
index 11bbb5496..086a5de76 100644
--- a/observer/src/test/java/com/iluwatar/observer/AppTest.java
+++ b/observer/src/test/java/com/iluwatar/observer/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.observer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/observer/src/test/java/com/iluwatar/observer/HobbitsTest.java b/observer/src/test/java/com/iluwatar/observer/HobbitsTest.java
index 31a4fd667..21e4acd44 100644
--- a/observer/src/test/java/com/iluwatar/observer/HobbitsTest.java
+++ b/observer/src/test/java/com/iluwatar/observer/HobbitsTest.java
@@ -22,9 +22,6 @@
*/
package com.iluwatar.observer;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -34,11 +31,9 @@ import java.util.List;
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class HobbitsTest extends WeatherObserverTest {
- @Parameterized.Parameters
- public static Collection data() {
+ static Collection dataProvider() {
final List testData = new ArrayList<>();
testData.add(new Object[]{WeatherType.SUNNY, "The happy hobbits bade in the warm sun."});
testData.add(new Object[]{WeatherType.RAINY, "The hobbits look for cover from the rain."});
@@ -49,12 +44,9 @@ public class HobbitsTest extends WeatherObserverTest {
/**
* Create a new test with the given weather and expected response
- *
- * @param weather The weather that should be unleashed on the observer
- * @param response The expected response from the observer
*/
- public HobbitsTest(final WeatherType weather, final String response) {
- super(weather, response, Hobbits::new);
+ public HobbitsTest() {
+ super(Hobbits::new);
}
}
diff --git a/observer/src/test/java/com/iluwatar/observer/OrcsTest.java b/observer/src/test/java/com/iluwatar/observer/OrcsTest.java
index b1f0b82d7..78667b678 100644
--- a/observer/src/test/java/com/iluwatar/observer/OrcsTest.java
+++ b/observer/src/test/java/com/iluwatar/observer/OrcsTest.java
@@ -22,9 +22,6 @@
*/
package com.iluwatar.observer;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -34,11 +31,9 @@ import java.util.List;
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class OrcsTest extends WeatherObserverTest {
- @Parameterized.Parameters
- public static Collection data() {
+ static Collection dataProvider() {
final List testData = new ArrayList<>();
testData.add(new Object[]{WeatherType.SUNNY, "The sun hurts the orcs' eyes."});
testData.add(new Object[]{WeatherType.RAINY, "The orcs are dripping wet."});
@@ -49,12 +44,9 @@ public class OrcsTest extends WeatherObserverTest {
/**
* Create a new test with the given weather and expected response
- *
- * @param weather The weather that should be unleashed on the observer
- * @param response The expected response from the observer
*/
- public OrcsTest(final WeatherType weather, final String response) {
- super(weather, response, Orcs::new);
+ public OrcsTest() {
+ super(Orcs::new);
}
}
diff --git a/observer/src/test/java/com/iluwatar/observer/WeatherObserverTest.java b/observer/src/test/java/com/iluwatar/observer/WeatherObserverTest.java
index 70a7922c5..da3fad1eb 100644
--- a/observer/src/test/java/com/iluwatar/observer/WeatherObserverTest.java
+++ b/observer/src/test/java/com/iluwatar/observer/WeatherObserverTest.java
@@ -22,13 +22,16 @@
*/
package com.iluwatar.observer;
-import static org.junit.Assert.assertEquals;
-
import com.iluwatar.observer.utils.InMemoryAppender;
import java.util.function.Supplier;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/27/15 - 11:44 AM
@@ -40,12 +43,12 @@ public abstract class WeatherObserverTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
@@ -55,38 +58,25 @@ public abstract class WeatherObserverTest {
*/
private final Supplier factory;
- /**
- * The weather type currently tested
- */
- private final WeatherType weather;
-
- /**
- * The expected response from the observer
- */
- private final String response;
-
/**
* Create a new test instance using the given parameters
*
- * @param weather The weather currently being tested
- * @param response The expected response from the observer
* @param factory The factory, used to create an instance of the tested observer
*/
- WeatherObserverTest(final WeatherType weather, final String response, final Supplier factory) {
- this.weather = weather;
- this.response = response;
+ WeatherObserverTest(final Supplier factory) {
this.factory = factory;
}
/**
* Verify if the weather has the expected influence on the observer
*/
- @Test
- public void testObserver() {
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testObserver(WeatherType weather, String response) {
final O observer = this.factory.get();
assertEquals(0, appender.getLogSize());
- observer.update(this.weather);
+ observer.update(weather);
assertEquals(response, appender.getLastMessage());
assertEquals(1, appender.getLogSize());
}
diff --git a/observer/src/test/java/com/iluwatar/observer/WeatherTest.java b/observer/src/test/java/com/iluwatar/observer/WeatherTest.java
index 88bf1c4c3..ca84be5f6 100644
--- a/observer/src/test/java/com/iluwatar/observer/WeatherTest.java
+++ b/observer/src/test/java/com/iluwatar/observer/WeatherTest.java
@@ -23,12 +23,12 @@
package com.iluwatar.observer;
import com.iluwatar.observer.utils.InMemoryAppender;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -44,12 +44,12 @@ public class WeatherTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender(Weather.class);
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/observer/src/test/java/com/iluwatar/observer/generic/GHobbitsTest.java b/observer/src/test/java/com/iluwatar/observer/generic/GHobbitsTest.java
index a54f15689..8d86529c7 100644
--- a/observer/src/test/java/com/iluwatar/observer/generic/GHobbitsTest.java
+++ b/observer/src/test/java/com/iluwatar/observer/generic/GHobbitsTest.java
@@ -22,13 +22,8 @@
*/
package com.iluwatar.observer.generic;
-import com.iluwatar.observer.Hobbits;
-import com.iluwatar.observer.WeatherObserverTest;
import com.iluwatar.observer.WeatherType;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -38,11 +33,9 @@ import java.util.List;
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class GHobbitsTest extends ObserverTest {
- @Parameterized.Parameters
- public static Collection data() {
+ static Collection dataProvider() {
final List testData = new ArrayList<>();
testData.add(new Object[]{WeatherType.SUNNY, "The happy hobbits bade in the warm sun."});
testData.add(new Object[]{WeatherType.RAINY, "The hobbits look for cover from the rain."});
@@ -53,12 +46,9 @@ public class GHobbitsTest extends ObserverTest {
/**
* Create a new test with the given weather and expected response
- *
- * @param weather The weather that should be unleashed on the observer
- * @param response The expected response from the observer
*/
- public GHobbitsTest(final WeatherType weather, final String response) {
- super(weather, response, GHobbits::new);
+ public GHobbitsTest() {
+ super(GHobbits::new);
}
}
diff --git a/observer/src/test/java/com/iluwatar/observer/generic/GWeatherTest.java b/observer/src/test/java/com/iluwatar/observer/generic/GWeatherTest.java
index ab15ca884..d7adeff89 100644
--- a/observer/src/test/java/com/iluwatar/observer/generic/GWeatherTest.java
+++ b/observer/src/test/java/com/iluwatar/observer/generic/GWeatherTest.java
@@ -25,12 +25,12 @@ package com.iluwatar.observer.generic;
import com.iluwatar.observer.WeatherObserver;
import com.iluwatar.observer.WeatherType;
import com.iluwatar.observer.utils.InMemoryAppender;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;
/**
@@ -42,12 +42,12 @@ public class GWeatherTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender(GWeather.class);
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/observer/src/test/java/com/iluwatar/observer/generic/ObserverTest.java b/observer/src/test/java/com/iluwatar/observer/generic/ObserverTest.java
index 930f7533f..0feba8ea2 100644
--- a/observer/src/test/java/com/iluwatar/observer/generic/ObserverTest.java
+++ b/observer/src/test/java/com/iluwatar/observer/generic/ObserverTest.java
@@ -22,14 +22,16 @@
*/
package com.iluwatar.observer.generic;
-import static org.junit.Assert.assertEquals;
-
import com.iluwatar.observer.WeatherType;
import com.iluwatar.observer.utils.InMemoryAppender;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
import java.util.function.Supplier;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/27/15 - 11:44 AM
@@ -41,12 +43,12 @@ public abstract class ObserverTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
@@ -56,39 +58,26 @@ public abstract class ObserverTest {
*/
private final Supplier factory;
- /**
- * The weather type currently tested
- */
- private final WeatherType weather;
-
- /**
- * The expected response from the observer
- */
- private final String response;
-
/**
* Create a new test instance using the given parameters
*
- * @param weather The weather currently being tested
- * @param response The expected response from the observer
* @param factory The factory, used to create an instance of the tested observer
*/
- ObserverTest(final WeatherType weather, final String response, final Supplier factory) {
- this.weather = weather;
- this.response = response;
+ ObserverTest(final Supplier factory) {
this.factory = factory;
}
/**
* Verify if the weather has the expected influence on the observer
*/
- @Test
- public void testObserver() {
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testObserver(WeatherType weather, String response) {
final O observer = this.factory.get();
assertEquals(0, appender.getLogSize());
- observer.update(null, this.weather);
- assertEquals(this.response, appender.getLastMessage());
+ observer.update(null, weather);
+ assertEquals(response, appender.getLastMessage());
assertEquals(1, appender.getLogSize());
}
diff --git a/observer/src/test/java/com/iluwatar/observer/generic/OrcsTest.java b/observer/src/test/java/com/iluwatar/observer/generic/OrcsTest.java
index a61a91afe..95adf5a28 100644
--- a/observer/src/test/java/com/iluwatar/observer/generic/OrcsTest.java
+++ b/observer/src/test/java/com/iluwatar/observer/generic/OrcsTest.java
@@ -24,9 +24,6 @@ package com.iluwatar.observer.generic;
import com.iluwatar.observer.WeatherType;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -36,11 +33,9 @@ import java.util.List;
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class OrcsTest extends ObserverTest {
- @Parameterized.Parameters
- public static Collection data() {
+ static Collection dataProvider() {
final List testData = new ArrayList<>();
testData.add(new Object[]{WeatherType.SUNNY, "The sun hurts the orcs' eyes."});
testData.add(new Object[]{WeatherType.RAINY, "The orcs are dripping wet."});
@@ -51,12 +46,9 @@ public class OrcsTest extends ObserverTest {
/**
* Create a new test with the given weather and expected response
- *
- * @param weather The weather that should be unleashed on the observer
- * @param response The expected response from the observer
*/
- public OrcsTest(final WeatherType weather, final String response) {
- super(weather, response, GOrcs::new);
+ public OrcsTest() {
+ super(GOrcs::new);
}
}
diff --git a/page-object/pom.xml b/page-object/pom.xml
index 98842b387..5ed61f527 100644
--- a/page-object/pom.xml
+++ b/page-object/pom.xml
@@ -34,8 +34,13 @@
page-object
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/page-object/src/test/java/com/iluwatar/pageobject/AlbumListPageTest.java b/page-object/src/test/java/com/iluwatar/pageobject/AlbumListPageTest.java
index 79101f3d3..9cc3893f4 100644
--- a/page-object/src/test/java/com/iluwatar/pageobject/AlbumListPageTest.java
+++ b/page-object/src/test/java/com/iluwatar/pageobject/AlbumListPageTest.java
@@ -22,14 +22,13 @@
*/
package com.iluwatar.pageobject;
-
-import static org.junit.Assert.assertTrue;
-
import com.gargoylesoftware.htmlunit.WebClient;
import com.iluwatar.pageobject.pages.AlbumListPage;
import com.iluwatar.pageobject.pages.AlbumPage;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test Album Selection and Album Listing
@@ -38,7 +37,7 @@ public class AlbumListPageTest {
private AlbumListPage albumListPage = new AlbumListPage(new WebClient());
- @Before
+ @BeforeEach
public void setUp() {
albumListPage.navigateToPage();
}
diff --git a/page-object/src/test/java/com/iluwatar/pageobject/AlbumPageTest.java b/page-object/src/test/java/com/iluwatar/pageobject/AlbumPageTest.java
index cb07a8293..4b567fcad 100644
--- a/page-object/src/test/java/com/iluwatar/pageobject/AlbumPageTest.java
+++ b/page-object/src/test/java/com/iluwatar/pageobject/AlbumPageTest.java
@@ -22,13 +22,13 @@
*/
package com.iluwatar.pageobject;
-import static org.junit.Assert.assertTrue;
-
import com.gargoylesoftware.htmlunit.WebClient;
import com.iluwatar.pageobject.pages.AlbumListPage;
import com.iluwatar.pageobject.pages.AlbumPage;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test Album Page Operations
@@ -37,7 +37,7 @@ public class AlbumPageTest {
private AlbumPage albumPage = new AlbumPage(new WebClient());
- @Before
+ @BeforeEach
public void setUp() {
albumPage.navigateToPage();
}
diff --git a/page-object/src/test/java/com/iluwatar/pageobject/LoginPageTest.java b/page-object/src/test/java/com/iluwatar/pageobject/LoginPageTest.java
index ad10a1927..59f69552b 100644
--- a/page-object/src/test/java/com/iluwatar/pageobject/LoginPageTest.java
+++ b/page-object/src/test/java/com/iluwatar/pageobject/LoginPageTest.java
@@ -22,13 +22,13 @@
*/
package com.iluwatar.pageobject;
-import static org.junit.Assert.assertTrue;
-
import com.gargoylesoftware.htmlunit.WebClient;
import com.iluwatar.pageobject.pages.AlbumListPage;
import com.iluwatar.pageobject.pages.LoginPage;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test Login Page Object
@@ -37,7 +37,7 @@ public class LoginPageTest {
private LoginPage loginPage = new LoginPage(new WebClient());
- @Before
+ @BeforeEach
public void setUp() {
loginPage.navigateToPage();
}
diff --git a/partial-response/pom.xml b/partial-response/pom.xml
index 94c583a98..6f4f40f61 100644
--- a/partial-response/pom.xml
+++ b/partial-response/pom.xml
@@ -39,6 +39,11 @@
junit
junit
+
+ org.junit.vintage
+ junit-vintage-engine
+ test
+
org.mockito
mockito-core
diff --git a/poison-pill/pom.xml b/poison-pill/pom.xml
index 3bd0f0967..e5ea45817 100644
--- a/poison-pill/pom.xml
+++ b/poison-pill/pom.xml
@@ -34,8 +34,13 @@
poison-pill
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/poison-pill/src/test/java/com/iluwatar/poison/pill/AppTest.java b/poison-pill/src/test/java/com/iluwatar/poison/pill/AppTest.java
index 8c15bcf0f..0bef8bfee 100644
--- a/poison-pill/src/test/java/com/iluwatar/poison/pill/AppTest.java
+++ b/poison-pill/src/test/java/com/iluwatar/poison/pill/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.poison.pill;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/poison-pill/src/test/java/com/iluwatar/poison/pill/ConsumerTest.java b/poison-pill/src/test/java/com/iluwatar/poison/pill/ConsumerTest.java
index 17bd4f89e..93b5f91e1 100644
--- a/poison-pill/src/test/java/com/iluwatar/poison/pill/ConsumerTest.java
+++ b/poison-pill/src/test/java/com/iluwatar/poison/pill/ConsumerTest.java
@@ -25,16 +25,16 @@ package com.iluwatar.poison.pill;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.List;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/27/15 - 9:45 PM
@@ -45,12 +45,12 @@ public class ConsumerTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender(Consumer.class);
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/poison-pill/src/test/java/com/iluwatar/poison/pill/PoisonMessageTest.java b/poison-pill/src/test/java/com/iluwatar/poison/pill/PoisonMessageTest.java
index b15005695..334c49809 100644
--- a/poison-pill/src/test/java/com/iluwatar/poison/pill/PoisonMessageTest.java
+++ b/poison-pill/src/test/java/com/iluwatar/poison/pill/PoisonMessageTest.java
@@ -22,10 +22,11 @@
*/
package com.iluwatar.poison.pill;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static com.iluwatar.poison.pill.Message.Headers;
import static com.iluwatar.poison.pill.Message.POISON_PILL;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Date: 12/27/15 - 10:30 PM
@@ -34,29 +35,39 @@ import static com.iluwatar.poison.pill.Message.POISON_PILL;
*/
public class PoisonMessageTest {
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testAddHeader() throws Exception {
- POISON_PILL.addHeader(Headers.SENDER, "sender");
+ assertThrows(UnsupportedOperationException.class, () -> {
+ POISON_PILL.addHeader(Headers.SENDER, "sender");
+ });
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testGetHeader() throws Exception {
- POISON_PILL.getHeader(Headers.SENDER);
+ assertThrows(UnsupportedOperationException.class, () -> {
+ POISON_PILL.getHeader(Headers.SENDER);
+ });
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testGetHeaders() throws Exception {
- POISON_PILL.getHeaders();
+ assertThrows(UnsupportedOperationException.class, () -> {
+ POISON_PILL.getHeaders();
+ });
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testSetBody() throws Exception {
- POISON_PILL.setBody("Test message.");
+ assertThrows(UnsupportedOperationException.class, () -> {
+ POISON_PILL.setBody("Test message.");
+ });
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testGetBody() throws Exception {
- POISON_PILL.getBody();
+ assertThrows(UnsupportedOperationException.class, () -> {
+ POISON_PILL.getBody();
+ });
}
}
diff --git a/poison-pill/src/test/java/com/iluwatar/poison/pill/ProducerTest.java b/poison-pill/src/test/java/com/iluwatar/poison/pill/ProducerTest.java
index 7b5982a3d..5d7420ecf 100644
--- a/poison-pill/src/test/java/com/iluwatar/poison/pill/ProducerTest.java
+++ b/poison-pill/src/test/java/com/iluwatar/poison/pill/ProducerTest.java
@@ -22,12 +22,12 @@
*/
package com.iluwatar.poison.pill;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
diff --git a/poison-pill/src/test/java/com/iluwatar/poison/pill/SimpleMessageTest.java b/poison-pill/src/test/java/com/iluwatar/poison/pill/SimpleMessageTest.java
index 2b0b3bd17..20f9287f4 100644
--- a/poison-pill/src/test/java/com/iluwatar/poison/pill/SimpleMessageTest.java
+++ b/poison-pill/src/test/java/com/iluwatar/poison/pill/SimpleMessageTest.java
@@ -22,14 +22,15 @@
*/
package com.iluwatar.poison.pill;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/27/15 - 10:25 PM
@@ -51,11 +52,13 @@ public class SimpleMessageTest {
assertEquals(senderName, message.getHeaders().get(Message.Headers.SENDER));
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testUnModifiableHeaders() {
final SimpleMessage message = new SimpleMessage();
final Map headers = message.getHeaders();
- headers.put(Message.Headers.SENDER, "test");
+ assertThrows(UnsupportedOperationException.class, () -> {
+ headers.put(Message.Headers.SENDER, "test");
+ });
}
diff --git a/pom.xml b/pom.xml
index f94b99230..9fa925d82 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,14 +32,16 @@
1.9.2.RELEASE
1.4.190
4.12
+ 5.0.2
+ ${junit.version}.2
+ 1.0.2
+ 1.0.2
3.0
0.7.2.201409121644
1.4
2.16.1
19.0
- 1.15.1
1.10.19
- 4.12.1
4.5.2
2.22
4.0
@@ -154,6 +156,13 @@
retry
+
+
+ jitpack.io
+ https://jitpack.io
+
+
+
@@ -166,11 +175,6 @@
hibernate-entitymanager
${hibernate.version}
-
- org.springframework
- spring-test
- ${spring.version}
-
org.springframework.boot
spring-boot-dependencies
@@ -218,12 +222,48 @@
camel-stream
${camel.version}
+
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit-jupiter.version}
+ test
+
junit
junit
${junit.version}
test
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit-jupiter.version}
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ ${junit-jupiter.version}
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-migrationsupport
+ ${junit-jupiter.version}
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+ ${junit-vintage.version}
+ test
+
+
+ com.github.sbrannen
+ spring-test-junit5
+ ${sping-test-junit5.version}
+ test
+
org.mockito
mockito-core
@@ -235,18 +275,6 @@
guava
${guava.version}
-
- com.github.stefanbirkner
- system-rules
- ${systemrules.version}
- test
-
-
- de.bechte.junit
- junit-hierarchicalcontextrunner
- ${hierarchical-junit-runner-version}
- test
-
net.sourceforge.htmlunit
htmlunit
@@ -374,12 +402,12 @@
org.apache.maven.plugins
maven-surefire-plugin
- 2.18.1
+ 2.19.1
- org.apache.maven.surefire
- surefire-junit47
- 2.18.1
+ org.junit.platform
+ junit-platform-surefire-provider
+ ${junit-platform.version}
diff --git a/private-class-data/pom.xml b/private-class-data/pom.xml
index 3ac0cf532..5d282faa3 100644
--- a/private-class-data/pom.xml
+++ b/private-class-data/pom.xml
@@ -34,8 +34,13 @@
private-class-data
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/private-class-data/src/test/java/com/iluwatar/privateclassdata/AppTest.java b/private-class-data/src/test/java/com/iluwatar/privateclassdata/AppTest.java
index ef80e87cb..efd387d75 100644
--- a/private-class-data/src/test/java/com/iluwatar/privateclassdata/AppTest.java
+++ b/private-class-data/src/test/java/com/iluwatar/privateclassdata/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.privateclassdata;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/private-class-data/src/test/java/com/iluwatar/privateclassdata/ImmutableStewTest.java b/private-class-data/src/test/java/com/iluwatar/privateclassdata/ImmutableStewTest.java
index 6e337e584..aac2d6ac4 100644
--- a/private-class-data/src/test/java/com/iluwatar/privateclassdata/ImmutableStewTest.java
+++ b/private-class-data/src/test/java/com/iluwatar/privateclassdata/ImmutableStewTest.java
@@ -23,11 +23,11 @@
package com.iluwatar.privateclassdata;
import com.iluwatar.privateclassdata.utils.InMemoryAppender;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/27/15 - 10:46 PM
@@ -38,12 +38,12 @@ public class ImmutableStewTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/private-class-data/src/test/java/com/iluwatar/privateclassdata/StewTest.java b/private-class-data/src/test/java/com/iluwatar/privateclassdata/StewTest.java
index 6ac5b834f..3345a1db2 100644
--- a/private-class-data/src/test/java/com/iluwatar/privateclassdata/StewTest.java
+++ b/private-class-data/src/test/java/com/iluwatar/privateclassdata/StewTest.java
@@ -23,11 +23,11 @@
package com.iluwatar.privateclassdata;
import com.iluwatar.privateclassdata.utils.InMemoryAppender;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/27/15 - 10:46 PM
@@ -38,12 +38,12 @@ public class StewTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/producer-consumer/pom.xml b/producer-consumer/pom.xml
index 893d7a4ff..b04b5c402 100644
--- a/producer-consumer/pom.xml
+++ b/producer-consumer/pom.xml
@@ -34,8 +34,13 @@
producer-consumer
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/producer-consumer/src/test/java/com/iluwatar/producer/consumer/AppTest.java b/producer-consumer/src/test/java/com/iluwatar/producer/consumer/AppTest.java
index e7f7870f7..bae8ba635 100644
--- a/producer-consumer/src/test/java/com/iluwatar/producer/consumer/AppTest.java
+++ b/producer-consumer/src/test/java/com/iluwatar/producer/consumer/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.producer.consumer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/producer-consumer/src/test/java/com/iluwatar/producer/consumer/ConsumerTest.java b/producer-consumer/src/test/java/com/iluwatar/producer/consumer/ConsumerTest.java
index 4c110cad2..114b39255 100644
--- a/producer-consumer/src/test/java/com/iluwatar/producer/consumer/ConsumerTest.java
+++ b/producer-consumer/src/test/java/com/iluwatar/producer/consumer/ConsumerTest.java
@@ -22,9 +22,12 @@
*/
package com.iluwatar.producer.consumer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
/**
* Date: 12/27/15 - 11:01 PM
diff --git a/producer-consumer/src/test/java/com/iluwatar/producer/consumer/ProducerTest.java b/producer-consumer/src/test/java/com/iluwatar/producer/consumer/ProducerTest.java
index 5f756c938..c8fe60e09 100644
--- a/producer-consumer/src/test/java/com/iluwatar/producer/consumer/ProducerTest.java
+++ b/producer-consumer/src/test/java/com/iluwatar/producer/consumer/ProducerTest.java
@@ -22,8 +22,10 @@
*/
package com.iluwatar.producer.consumer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import static java.time.Duration.ofMillis;
+import static org.junit.jupiter.api.Assertions.assertTimeout;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -36,15 +38,17 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
*/
public class ProducerTest {
- @Test(timeout = 6000)
+ @Test
public void testProduce() throws Exception {
- final ItemQueue queue = mock(ItemQueue.class);
- final Producer producer = new Producer("producer", queue);
+ assertTimeout(ofMillis(6000), () -> {
+ final ItemQueue queue = mock(ItemQueue.class);
+ final Producer producer = new Producer("producer", queue);
- producer.produce();
- verify(queue).put(any(Item.class));
+ producer.produce();
+ verify(queue).put(any(Item.class));
- verifyNoMoreInteractions(queue);
+ verifyNoMoreInteractions(queue);
+ });
}
}
\ No newline at end of file
diff --git a/promise/pom.xml b/promise/pom.xml
index 05fd4c3ee..9253785ba 100644
--- a/promise/pom.xml
+++ b/promise/pom.xml
@@ -34,8 +34,13 @@
promise
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/promise/src/test/java/com/iluwatar/promise/AppTest.java b/promise/src/test/java/com/iluwatar/promise/AppTest.java
index f7df415e8..eb8790a4a 100644
--- a/promise/src/test/java/com/iluwatar/promise/AppTest.java
+++ b/promise/src/test/java/com/iluwatar/promise/AppTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.promise;
-import java.util.concurrent.ExecutionException;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import java.util.concurrent.ExecutionException;
/**
*
diff --git a/promise/src/test/java/com/iluwatar/promise/PromiseTest.java b/promise/src/test/java/com/iluwatar/promise/PromiseTest.java
index 6e17b9794..68868bd1e 100644
--- a/promise/src/test/java/com/iluwatar/promise/PromiseTest.java
+++ b/promise/src/test/java/com/iluwatar/promise/PromiseTest.java
@@ -22,13 +22,8 @@
*/
package com.iluwatar.promise;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -39,10 +34,14 @@ import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import java.util.function.Function;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
/**
* Tests Promise class.
*/
@@ -50,9 +49,8 @@ public class PromiseTest {
private Executor executor;
private Promise promise;
- @Rule public ExpectedException exception = ExpectedException.none();
- @Before
+ @BeforeEach
public void setUp() {
executor = Executors.newSingleThreadExecutor();
promise = new Promise<>();
diff --git a/property/pom.xml b/property/pom.xml
index db2ff8f60..d34218bac 100644
--- a/property/pom.xml
+++ b/property/pom.xml
@@ -34,8 +34,13 @@
property
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/property/src/test/java/com/iluwatar/property/AppTest.java b/property/src/test/java/com/iluwatar/property/AppTest.java
index 08e0dbba1..4bc0beba4 100644
--- a/property/src/test/java/com/iluwatar/property/AppTest.java
+++ b/property/src/test/java/com/iluwatar/property/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.property;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/property/src/test/java/com/iluwatar/property/CharacterTest.java b/property/src/test/java/com/iluwatar/property/CharacterTest.java
index 5dc996f4d..95a66a2fb 100644
--- a/property/src/test/java/com/iluwatar/property/CharacterTest.java
+++ b/property/src/test/java/com/iluwatar/property/CharacterTest.java
@@ -22,13 +22,13 @@
*/
package com.iluwatar.property;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static com.iluwatar.property.Character.Type;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/28/15 - 7:46 PM
diff --git a/prototype/pom.xml b/prototype/pom.xml
index 62d4f0eb1..89483494e 100644
--- a/prototype/pom.xml
+++ b/prototype/pom.xml
@@ -34,8 +34,18 @@
prototype
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
test
diff --git a/prototype/src/test/java/com/iluwatar/prototype/AppTest.java b/prototype/src/test/java/com/iluwatar/prototype/AppTest.java
index 48c70429a..e7a8c81ae 100644
--- a/prototype/src/test/java/com/iluwatar/prototype/AppTest.java
+++ b/prototype/src/test/java/com/iluwatar/prototype/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.prototype;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/prototype/src/test/java/com/iluwatar/prototype/HeroFactoryImplTest.java b/prototype/src/test/java/com/iluwatar/prototype/HeroFactoryImplTest.java
index bee05bc5e..ea164befd 100644
--- a/prototype/src/test/java/com/iluwatar/prototype/HeroFactoryImplTest.java
+++ b/prototype/src/test/java/com/iluwatar/prototype/HeroFactoryImplTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.prototype;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
diff --git a/prototype/src/test/java/com/iluwatar/prototype/PrototypeTest.java b/prototype/src/test/java/com/iluwatar/prototype/PrototypeTest.java
index 839f27bc7..0102428c6 100644
--- a/prototype/src/test/java/com/iluwatar/prototype/PrototypeTest.java
+++ b/prototype/src/test/java/com/iluwatar/prototype/PrototypeTest.java
@@ -22,27 +22,24 @@
*/
package com.iluwatar.prototype;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import java.util.Arrays;
import java.util.Collection;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
* Date: 12/28/15 - 8:45 PM
* @param Prototype
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class PrototypeTest
{
-
- @Parameterized.Parameters
- public static Collection data() {
+ static Collection dataProvider() {
return Arrays.asList(
new Object[]{new OrcBeast(), "Orcish wolf"},
new Object[]{new OrcMage(), "Orcish mage"},
@@ -53,35 +50,15 @@ public class PrototypeTest {
);
}
- /**
- * The tested prototype instance
- */
- private final P testedPrototype;
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testPrototype(P testedPrototype, String expectedToString) throws Exception {
+ assertEquals(expectedToString, testedPrototype.toString());
- /**
- * The expected {@link Prototype#toString()} value
- */
- private final String expectedToString;
-
- /**
- * Create a new test instance, using the given test object and expected value
- *
- * @param testedPrototype The tested prototype instance
- * @param expectedToString The expected {@link Prototype#toString()} value
- */
- public PrototypeTest(final P testedPrototype, final String expectedToString) {
- this.expectedToString = expectedToString;
- this.testedPrototype = testedPrototype;
- }
-
- @Test
- public void testPrototype() throws Exception {
- assertEquals(this.expectedToString, this.testedPrototype.toString());
-
- final Object clone = this.testedPrototype.clone();
+ final Object clone = testedPrototype.clone();
assertNotNull(clone);
- assertNotSame(clone, this.testedPrototype);
- assertSame(this.testedPrototype.getClass(), clone.getClass());
+ assertNotSame(clone, testedPrototype);
+ assertSame(testedPrototype.getClass(), clone.getClass());
}
}
diff --git a/proxy/pom.xml b/proxy/pom.xml
index ea55330b7..4a07f820f 100644
--- a/proxy/pom.xml
+++ b/proxy/pom.xml
@@ -34,8 +34,13 @@
proxy
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/proxy/src/test/java/com/iluwatar/proxy/AppTest.java b/proxy/src/test/java/com/iluwatar/proxy/AppTest.java
index d22d9c4bd..45bb38adc 100644
--- a/proxy/src/test/java/com/iluwatar/proxy/AppTest.java
+++ b/proxy/src/test/java/com/iluwatar/proxy/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.proxy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/proxy/src/test/java/com/iluwatar/proxy/IvoryTowerTest.java b/proxy/src/test/java/com/iluwatar/proxy/IvoryTowerTest.java
index 944193a0a..728223fa9 100644
--- a/proxy/src/test/java/com/iluwatar/proxy/IvoryTowerTest.java
+++ b/proxy/src/test/java/com/iluwatar/proxy/IvoryTowerTest.java
@@ -23,14 +23,12 @@
package com.iluwatar.proxy;
import com.iluwatar.proxy.utils.InMemoryAppender;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for {@link IvoryTower}
@@ -39,12 +37,12 @@ public class IvoryTowerTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender(IvoryTower.class);
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/proxy/src/test/java/com/iluwatar/proxy/WizardTest.java b/proxy/src/test/java/com/iluwatar/proxy/WizardTest.java
index ce5637214..f6bbe4a2d 100644
--- a/proxy/src/test/java/com/iluwatar/proxy/WizardTest.java
+++ b/proxy/src/test/java/com/iluwatar/proxy/WizardTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.proxy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests for {@link Wizard}
diff --git a/proxy/src/test/java/com/iluwatar/proxy/WizardTowerProxyTest.java b/proxy/src/test/java/com/iluwatar/proxy/WizardTowerProxyTest.java
index 2958376d6..b8c6c9ff5 100644
--- a/proxy/src/test/java/com/iluwatar/proxy/WizardTowerProxyTest.java
+++ b/proxy/src/test/java/com/iluwatar/proxy/WizardTowerProxyTest.java
@@ -23,12 +23,12 @@
package com.iluwatar.proxy;
import com.iluwatar.proxy.utils.InMemoryAppender;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests for {@link WizardTowerProxy}
@@ -37,12 +37,12 @@ public class WizardTowerProxyTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/publish-subscribe/pom.xml b/publish-subscribe/pom.xml
index ebd82f3a7..2356c57ac 100644
--- a/publish-subscribe/pom.xml
+++ b/publish-subscribe/pom.xml
@@ -41,8 +41,14 @@
camel-stream
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
\ No newline at end of file
diff --git a/publish-subscribe/src/test/java/com/iluwatar/publish/subscribe/AppTest.java b/publish-subscribe/src/test/java/com/iluwatar/publish/subscribe/AppTest.java
index 216ba49f0..128385faf 100644
--- a/publish-subscribe/src/test/java/com/iluwatar/publish/subscribe/AppTest.java
+++ b/publish-subscribe/src/test/java/com/iluwatar/publish/subscribe/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.publish.subscribe;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/queue-load-leveling/pom.xml b/queue-load-leveling/pom.xml
index 57741ed52..032534eeb 100644
--- a/queue-load-leveling/pom.xml
+++ b/queue-load-leveling/pom.xml
@@ -34,8 +34,13 @@
queue-load-leveling
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/AppTest.java b/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/AppTest.java
index d1cf75ca8..820062574 100644
--- a/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/AppTest.java
+++ b/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/AppTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.queue.load.leveling;
-import java.io.IOException;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import java.io.IOException;
/**
* Application Test
diff --git a/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/MessageQueueTest.java b/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/MessageQueueTest.java
index 30b5d7ce0..13a1db706 100644
--- a/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/MessageQueueTest.java
+++ b/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/MessageQueueTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.queue.load.leveling;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
*
diff --git a/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/MessageTest.java b/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/MessageTest.java
index 93ef723ea..d6b0167cf 100644
--- a/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/MessageTest.java
+++ b/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/MessageTest.java
@@ -22,8 +22,9 @@
*/
package com.iluwatar.queue.load.leveling;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
*
diff --git a/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/TaskGenSrvExeTest.java b/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/TaskGenSrvExeTest.java
index a773c377e..12fb4bf33 100644
--- a/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/TaskGenSrvExeTest.java
+++ b/queue-load-leveling/src/test/java/com/iluwatar/queue/load/leveling/TaskGenSrvExeTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.queue.load.leveling;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/reactor/pom.xml b/reactor/pom.xml
index 9ab44d2c0..f9c546e21 100644
--- a/reactor/pom.xml
+++ b/reactor/pom.xml
@@ -34,8 +34,13 @@
reactor
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/reactor/src/test/java/com/iluwatar/reactor/app/ReactorTest.java b/reactor/src/test/java/com/iluwatar/reactor/app/ReactorTest.java
index 7aa80f8cc..7b45c6053 100644
--- a/reactor/src/test/java/com/iluwatar/reactor/app/ReactorTest.java
+++ b/reactor/src/test/java/com/iluwatar/reactor/app/ReactorTest.java
@@ -22,16 +22,14 @@
*/
package com.iluwatar.reactor.app;
-import java.io.IOException;
-
-import com.iluwatar.reactor.framework.NioReactor;
-import org.junit.Test;
-
import com.iluwatar.reactor.framework.SameThreadDispatcher;
import com.iluwatar.reactor.framework.ThreadPoolDispatcher;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+
/**
*
* This class tests the Distributed Logging service by starting a Reactor and then sending it
diff --git a/reader-writer-lock/pom.xml b/reader-writer-lock/pom.xml
index d5ea9114c..79d6f93ff 100644
--- a/reader-writer-lock/pom.xml
+++ b/reader-writer-lock/pom.xml
@@ -35,8 +35,13 @@
reader-writer-lock
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/AppTest.java b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/AppTest.java
index fd0cd4b27..fbdf3f846 100644
--- a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/AppTest.java
+++ b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.reader.writer.lock;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Application test
diff --git a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderAndWriterTest.java b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderAndWriterTest.java
index adc2adae2..c8de8c511 100644
--- a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderAndWriterTest.java
+++ b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderAndWriterTest.java
@@ -24,9 +24,9 @@
package com.iluwatar.reader.writer.lock;
import com.iluwatar.reader.writer.lock.utils.InMemoryAppender;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,7 +34,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author hongshuwei@gmail.com
@@ -43,12 +43,12 @@ public class ReaderAndWriterTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderTest.java b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderTest.java
index c9b3eb72c..8fe5912ea 100644
--- a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderTest.java
+++ b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/ReaderTest.java
@@ -23,9 +23,9 @@
package com.iluwatar.reader.writer.lock;
import com.iluwatar.reader.writer.lock.utils.InMemoryAppender;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,7 +33,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import static junit.framework.TestCase.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.spy;
/**
@@ -43,12 +43,12 @@ public class ReaderTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender(Reader.class);
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/WriterTest.java b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/WriterTest.java
index 7c4b4148d..bb01e11b0 100644
--- a/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/WriterTest.java
+++ b/reader-writer-lock/src/test/java/com/iluwatar/reader/writer/lock/WriterTest.java
@@ -23,9 +23,9 @@
package com.iluwatar.reader.writer.lock;
import com.iluwatar.reader.writer.lock.utils.InMemoryAppender;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,7 +33,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.spy;
/**
@@ -43,12 +43,12 @@ public class WriterTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender(Writer.class);
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/repository/pom.xml b/repository/pom.xml
index f12c40113..c5b644b3d 100644
--- a/repository/pom.xml
+++ b/repository/pom.xml
@@ -34,8 +34,9 @@
repository
- org.springframework
- spring-test
+ com.github.sbrannen
+ spring-test-junit5
+ test
org.springframework.data
@@ -54,8 +55,13 @@
h2
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/repository/src/test/java/com/iluwatar/repository/AnnotationBasedRepositoryTest.java b/repository/src/test/java/com/iluwatar/repository/AnnotationBasedRepositoryTest.java
index cb84b1ae8..4cfb6e022 100644
--- a/repository/src/test/java/com/iluwatar/repository/AnnotationBasedRepositoryTest.java
+++ b/repository/src/test/java/com/iluwatar/repository/AnnotationBasedRepositoryTest.java
@@ -22,21 +22,21 @@
*/
package com.iluwatar.repository;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Resource;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import com.google.common.collect.Lists;
@@ -46,7 +46,7 @@ import com.google.common.collect.Lists;
* by {@link org.springframework.data.jpa.domain.Specification} are also test.
*
*/
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = { AppConfig.class }, loader = AnnotationConfigContextLoader.class)
public class AnnotationBasedRepositoryTest {
@@ -63,7 +63,7 @@ public class AnnotationBasedRepositoryTest {
/**
* Prepare data for test
*/
- @Before
+ @BeforeEach
public void setup() {
repository.save(persons);
@@ -123,7 +123,7 @@ public class AnnotationBasedRepositoryTest {
assertEquals(terry, actual);
}
- @After
+ @AfterEach
public void cleanup() {
repository.deleteAll();
diff --git a/repository/src/test/java/com/iluwatar/repository/AppConfigTest.java b/repository/src/test/java/com/iluwatar/repository/AppConfigTest.java
index 6d6a58e8d..882d2bef7 100644
--- a/repository/src/test/java/com/iluwatar/repository/AppConfigTest.java
+++ b/repository/src/test/java/com/iluwatar/repository/AppConfigTest.java
@@ -22,19 +22,19 @@
*/
package com.iluwatar.repository;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import org.springframework.transaction.annotation.Transactional;
@@ -42,7 +42,7 @@ import org.springframework.transaction.annotation.Transactional;
* This case is Just for test the Annotation Based configuration
*
*/
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = { AppConfig.class }, loader = AnnotationConfigContextLoader.class)
public class AppConfigTest {
diff --git a/repository/src/test/java/com/iluwatar/repository/AppTest.java b/repository/src/test/java/com/iluwatar/repository/AppTest.java
index d3f05caaa..17052b51e 100644
--- a/repository/src/test/java/com/iluwatar/repository/AppTest.java
+++ b/repository/src/test/java/com/iluwatar/repository/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.repository;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
diff --git a/repository/src/test/java/com/iluwatar/repository/RepositoryTest.java b/repository/src/test/java/com/iluwatar/repository/RepositoryTest.java
index 3201c024c..6a347ffd4 100644
--- a/repository/src/test/java/com/iluwatar/repository/RepositoryTest.java
+++ b/repository/src/test/java/com/iluwatar/repository/RepositoryTest.java
@@ -22,21 +22,21 @@
*/
package com.iluwatar.repository;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Resource;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import com.google.common.collect.Lists;
@@ -44,7 +44,7 @@ import com.google.common.collect.Lists;
* Test case to test the functions of {@link PersonRepository}, beside the CRUD functions, the query
* by {@link org.springframework.data.jpa.domain.Specification} are also test.
*/
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = { "classpath:applicationContext.xml" })
public class RepositoryTest {
@@ -61,7 +61,7 @@ public class RepositoryTest {
/**
* Prepare data for test
*/
- @Before
+ @BeforeEach
public void setup() {
repository.save(persons);
@@ -121,7 +121,7 @@ public class RepositoryTest {
assertEquals(terry, actual);
}
- @After
+ @AfterEach
public void cleanup() {
repository.deleteAll();
diff --git a/resource-acquisition-is-initialization/pom.xml b/resource-acquisition-is-initialization/pom.xml
index 7a6716d7b..0e9c5116d 100644
--- a/resource-acquisition-is-initialization/pom.xml
+++ b/resource-acquisition-is-initialization/pom.xml
@@ -34,8 +34,13 @@
resource-acquisition-is-initialization
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/resource-acquisition-is-initialization/src/test/java/com/iluwatar/resource/acquisition/is/initialization/AppTest.java b/resource-acquisition-is-initialization/src/test/java/com/iluwatar/resource/acquisition/is/initialization/AppTest.java
index 1d7b4137a..f2b0cdbe0 100644
--- a/resource-acquisition-is-initialization/src/test/java/com/iluwatar/resource/acquisition/is/initialization/AppTest.java
+++ b/resource-acquisition-is-initialization/src/test/java/com/iluwatar/resource/acquisition/is/initialization/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.resource.acquisition.is.initialization;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/resource-acquisition-is-initialization/src/test/java/com/iluwatar/resource/acquisition/is/initialization/ClosableTest.java b/resource-acquisition-is-initialization/src/test/java/com/iluwatar/resource/acquisition/is/initialization/ClosableTest.java
index 6786416fa..4bfdf4a8b 100644
--- a/resource-acquisition-is-initialization/src/test/java/com/iluwatar/resource/acquisition/is/initialization/ClosableTest.java
+++ b/resource-acquisition-is-initialization/src/test/java/com/iluwatar/resource/acquisition/is/initialization/ClosableTest.java
@@ -22,18 +22,19 @@
*/
package com.iluwatar.resource.acquisition.is.initialization;
-import static org.junit.Assert.assertTrue;
-
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
import java.util.LinkedList;
import java.util.List;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Date: 12/28/15 - 9:31 PM
*
@@ -43,12 +44,12 @@ public class ClosableTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/retry/pom.xml b/retry/pom.xml
index 5271f43de..1e23bf7d9 100644
--- a/retry/pom.xml
+++ b/retry/pom.xml
@@ -32,8 +32,13 @@
jar
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/retry/src/test/java/com/iluwatar/retry/FindCustomerTest.java b/retry/src/test/java/com/iluwatar/retry/FindCustomerTest.java
index 634443fef..46c4c62e6 100644
--- a/retry/src/test/java/com/iluwatar/retry/FindCustomerTest.java
+++ b/retry/src/test/java/com/iluwatar/retry/FindCustomerTest.java
@@ -24,9 +24,11 @@
package com.iluwatar.retry;
+import org.junit.jupiter.api.Test;
+
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
-import org.junit.Test;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Unit tests for {@link FindCustomer}.
@@ -50,9 +52,11 @@ public class FindCustomerTest {
*
* @throws Exception the expected exception
*/
- @Test(expected = BusinessException.class)
+ @Test
public void oneException() throws Exception {
- new FindCustomer("123", new BusinessException("test")).perform();
+ assertThrows(BusinessException.class, () -> {
+ new FindCustomer("123", new BusinessException("test")).perform();
+ });
}
/**
diff --git a/retry/src/test/java/com/iluwatar/retry/RetryTest.java b/retry/src/test/java/com/iluwatar/retry/RetryTest.java
index c66c41354..233e0e588 100644
--- a/retry/src/test/java/com/iluwatar/retry/RetryTest.java
+++ b/retry/src/test/java/com/iluwatar/retry/RetryTest.java
@@ -24,10 +24,11 @@
package com.iluwatar.retry;
+import org.junit.jupiter.api.Test;
+
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
/**
* Unit tests for {@link Retry}.
diff --git a/semaphore/pom.xml b/semaphore/pom.xml
index 4fa1733f4..680cdeba5 100644
--- a/semaphore/pom.xml
+++ b/semaphore/pom.xml
@@ -34,8 +34,13 @@
semaphore
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/semaphore/src/test/java/com/iluwatar/semaphore/AppTest.java b/semaphore/src/test/java/com/iluwatar/semaphore/AppTest.java
index 5eaed3b2e..6ad023e5d 100644
--- a/semaphore/src/test/java/com/iluwatar/semaphore/AppTest.java
+++ b/semaphore/src/test/java/com/iluwatar/semaphore/AppTest.java
@@ -22,7 +22,8 @@
*/
package com.iluwatar.semaphore;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
import java.io.IOException;
/**
diff --git a/semaphore/src/test/java/com/iluwatar/semaphore/FruitBowlTest.java b/semaphore/src/test/java/com/iluwatar/semaphore/FruitBowlTest.java
index 30a7dce44..7bc391478 100644
--- a/semaphore/src/test/java/com/iluwatar/semaphore/FruitBowlTest.java
+++ b/semaphore/src/test/java/com/iluwatar/semaphore/FruitBowlTest.java
@@ -22,8 +22,11 @@
*/
package com.iluwatar.semaphore;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Test taking from and putting Fruit into a FruitBowl
diff --git a/semaphore/src/test/java/com/iluwatar/semaphore/SemaphoreTest.java b/semaphore/src/test/java/com/iluwatar/semaphore/SemaphoreTest.java
index b787a3301..ad67026ae 100644
--- a/semaphore/src/test/java/com/iluwatar/semaphore/SemaphoreTest.java
+++ b/semaphore/src/test/java/com/iluwatar/semaphore/SemaphoreTest.java
@@ -22,8 +22,10 @@
*/
package com.iluwatar.semaphore;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Test case for acquiring and releasing a Semaphore
diff --git a/servant/pom.xml b/servant/pom.xml
index daa44d223..c12ff043c 100644
--- a/servant/pom.xml
+++ b/servant/pom.xml
@@ -34,8 +34,13 @@
servant
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/servant/src/test/java/com/iluwatar/servant/AppTest.java b/servant/src/test/java/com/iluwatar/servant/AppTest.java
index 5b8908d80..6226c272d 100644
--- a/servant/src/test/java/com/iluwatar/servant/AppTest.java
+++ b/servant/src/test/java/com/iluwatar/servant/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.servant;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/servant/src/test/java/com/iluwatar/servant/KingTest.java b/servant/src/test/java/com/iluwatar/servant/KingTest.java
index 3ebbaf28b..969cc3d43 100644
--- a/servant/src/test/java/com/iluwatar/servant/KingTest.java
+++ b/servant/src/test/java/com/iluwatar/servant/KingTest.java
@@ -22,9 +22,10 @@
*/
package com.iluwatar.servant;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/28/15 - 9:40 PM
diff --git a/servant/src/test/java/com/iluwatar/servant/QueenTest.java b/servant/src/test/java/com/iluwatar/servant/QueenTest.java
index d425886ba..17498e248 100644
--- a/servant/src/test/java/com/iluwatar/servant/QueenTest.java
+++ b/servant/src/test/java/com/iluwatar/servant/QueenTest.java
@@ -22,9 +22,11 @@
*/
package com.iluwatar.servant;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/28/15 - 9:52 PM
diff --git a/servant/src/test/java/com/iluwatar/servant/ServantTest.java b/servant/src/test/java/com/iluwatar/servant/ServantTest.java
index 900ccc418..16e1d3c00 100644
--- a/servant/src/test/java/com/iluwatar/servant/ServantTest.java
+++ b/servant/src/test/java/com/iluwatar/servant/ServantTest.java
@@ -22,12 +22,12 @@
*/
package com.iluwatar.servant;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
diff --git a/service-layer/pom.xml b/service-layer/pom.xml
index 6edbeba44..45c7c32f3 100644
--- a/service-layer/pom.xml
+++ b/service-layer/pom.xml
@@ -40,11 +40,16 @@
com.h2database
h2
-
+
- junit
- junit
- test
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
org.mockito
diff --git a/service-layer/src/test/java/com/iluwatar/servicelayer/app/AppTest.java b/service-layer/src/test/java/com/iluwatar/servicelayer/app/AppTest.java
index a667252a1..295383513 100644
--- a/service-layer/src/test/java/com/iluwatar/servicelayer/app/AppTest.java
+++ b/service-layer/src/test/java/com/iluwatar/servicelayer/app/AppTest.java
@@ -23,9 +23,8 @@
package com.iluwatar.servicelayer.app;
import com.iluwatar.servicelayer.hibernate.HibernateUtil;
-
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
/**
*
@@ -40,7 +39,7 @@ public class AppTest {
App.main(args);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
HibernateUtil.dropSession();
}
diff --git a/service-layer/src/test/java/com/iluwatar/servicelayer/common/BaseDaoTest.java b/service-layer/src/test/java/com/iluwatar/servicelayer/common/BaseDaoTest.java
index 694fc746d..2bc557d75 100644
--- a/service-layer/src/test/java/com/iluwatar/servicelayer/common/BaseDaoTest.java
+++ b/service-layer/src/test/java/com/iluwatar/servicelayer/common/BaseDaoTest.java
@@ -22,17 +22,18 @@
*/
package com.iluwatar.servicelayer.common;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
import com.iluwatar.servicelayer.hibernate.HibernateUtil;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Date: 12/28/15 - 10:53 PM
@@ -74,7 +75,7 @@ public abstract class BaseDaoTest
this.dao = dao;
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
for (int i = 0; i < INITIAL_COUNT; i++) {
final String className = dao.persistentClass.getSimpleName();
@@ -83,7 +84,7 @@ public abstract class BaseDaoTest
}
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
HibernateUtil.dropSession();
}
diff --git a/service-layer/src/test/java/com/iluwatar/servicelayer/magic/MagicServiceImplTest.java b/service-layer/src/test/java/com/iluwatar/servicelayer/magic/MagicServiceImplTest.java
index 05ad6f887..66750c5b2 100644
--- a/service-layer/src/test/java/com/iluwatar/servicelayer/magic/MagicServiceImplTest.java
+++ b/service-layer/src/test/java/com/iluwatar/servicelayer/magic/MagicServiceImplTest.java
@@ -28,15 +28,14 @@ import com.iluwatar.servicelayer.spellbook.Spellbook;
import com.iluwatar.servicelayer.spellbook.SpellbookDao;
import com.iluwatar.servicelayer.wizard.Wizard;
import com.iluwatar.servicelayer.wizard.WizardDao;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
diff --git a/service-layer/src/test/java/com/iluwatar/servicelayer/spell/SpellDaoImplTest.java b/service-layer/src/test/java/com/iluwatar/servicelayer/spell/SpellDaoImplTest.java
index b6b4917c8..e4a5bfa65 100644
--- a/service-layer/src/test/java/com/iluwatar/servicelayer/spell/SpellDaoImplTest.java
+++ b/service-layer/src/test/java/com/iluwatar/servicelayer/spell/SpellDaoImplTest.java
@@ -23,13 +23,12 @@
package com.iluwatar.servicelayer.spell;
import com.iluwatar.servicelayer.common.BaseDaoTest;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Date: 12/28/15 - 11:02 PM
diff --git a/service-layer/src/test/java/com/iluwatar/servicelayer/spellbook/SpellbookDaoImplTest.java b/service-layer/src/test/java/com/iluwatar/servicelayer/spellbook/SpellbookDaoImplTest.java
index fb7eca15a..a6f1b3ea3 100644
--- a/service-layer/src/test/java/com/iluwatar/servicelayer/spellbook/SpellbookDaoImplTest.java
+++ b/service-layer/src/test/java/com/iluwatar/servicelayer/spellbook/SpellbookDaoImplTest.java
@@ -23,13 +23,12 @@
package com.iluwatar.servicelayer.spellbook;
import com.iluwatar.servicelayer.common.BaseDaoTest;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Date: 12/28/15 - 11:44 PM
diff --git a/service-layer/src/test/java/com/iluwatar/servicelayer/wizard/WizardDaoImplTest.java b/service-layer/src/test/java/com/iluwatar/servicelayer/wizard/WizardDaoImplTest.java
index 64bd72c7a..d8a093319 100644
--- a/service-layer/src/test/java/com/iluwatar/servicelayer/wizard/WizardDaoImplTest.java
+++ b/service-layer/src/test/java/com/iluwatar/servicelayer/wizard/WizardDaoImplTest.java
@@ -23,13 +23,12 @@
package com.iluwatar.servicelayer.wizard;
import com.iluwatar.servicelayer.common.BaseDaoTest;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Date: 12/28/15 - 11:46 PM
diff --git a/service-locator/pom.xml b/service-locator/pom.xml
index 7cd4028ff..e54e1d01c 100644
--- a/service-locator/pom.xml
+++ b/service-locator/pom.xml
@@ -34,8 +34,13 @@
service-locator
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/service-locator/src/test/java/com/iluwatar/servicelocator/AppTest.java b/service-locator/src/test/java/com/iluwatar/servicelocator/AppTest.java
index 1228898f2..be844b16a 100644
--- a/service-locator/src/test/java/com/iluwatar/servicelocator/AppTest.java
+++ b/service-locator/src/test/java/com/iluwatar/servicelocator/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.servicelocator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/service-locator/src/test/java/com/iluwatar/servicelocator/ServiceLocatorTest.java b/service-locator/src/test/java/com/iluwatar/servicelocator/ServiceLocatorTest.java
index 5dbbcdaf7..1741f6d94 100644
--- a/service-locator/src/test/java/com/iluwatar/servicelocator/ServiceLocatorTest.java
+++ b/service-locator/src/test/java/com/iluwatar/servicelocator/ServiceLocatorTest.java
@@ -22,13 +22,13 @@
*/
package com.iluwatar.servicelocator;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/29/15 - 19:07 PM
diff --git a/singleton/pom.xml b/singleton/pom.xml
index 00794e25a..3a6b21139 100644
--- a/singleton/pom.xml
+++ b/singleton/pom.xml
@@ -34,8 +34,13 @@
singleton
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/singleton/src/test/java/com/iluwatar/singleton/AppTest.java b/singleton/src/test/java/com/iluwatar/singleton/AppTest.java
index 951c5c4fd..2452b923d 100644
--- a/singleton/src/test/java/com/iluwatar/singleton/AppTest.java
+++ b/singleton/src/test/java/com/iluwatar/singleton/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.singleton;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/singleton/src/test/java/com/iluwatar/singleton/SingletonTest.java b/singleton/src/test/java/com/iluwatar/singleton/SingletonTest.java
index f468ad0b8..ff9045339 100644
--- a/singleton/src/test/java/com/iluwatar/singleton/SingletonTest.java
+++ b/singleton/src/test/java/com/iluwatar/singleton/SingletonTest.java
@@ -22,8 +22,8 @@
*/
package com.iluwatar.singleton;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
@@ -32,7 +32,11 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.function.Supplier;
-import org.junit.Test;
+
+import static java.time.Duration.ofMillis;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTimeout;
/**
* This class provides several test case that test singleton construction.
@@ -80,29 +84,30 @@ public abstract class SingletonTest {
/**
* Test singleton instance in a concurrent setting
*/
- @Test(timeout = 10000)
+ @Test
public void testMultipleCallsReturnTheSameObjectInDifferentThreads() throws Exception {
+ assertTimeout(ofMillis(10000), () -> {
+ // Create 10000 tasks and inside each callable instantiate the singleton class
+ final List> tasks = new ArrayList<>();
+ for (int i = 0; i < 10000; i++) {
+ tasks.add(this.singletonInstanceMethod::get);
+ }
- // Create 10000 tasks and inside each callable instantiate the singleton class
- final List> tasks = new ArrayList<>();
- for (int i = 0; i < 10000; i++) {
- tasks.add(this.singletonInstanceMethod::get);
- }
+ // Use up to 8 concurrent threads to handle the tasks
+ final ExecutorService executorService = Executors.newFixedThreadPool(8);
+ final List> results = executorService.invokeAll(tasks);
- // Use up to 8 concurrent threads to handle the tasks
- final ExecutorService executorService = Executors.newFixedThreadPool(8);
- final List> results = executorService.invokeAll(tasks);
+ // wait for all of the threads to complete
+ final S expectedInstance = this.singletonInstanceMethod.get();
+ for (Future res : results) {
+ final S instance = res.get();
+ assertNotNull(instance);
+ assertSame(expectedInstance, instance);
+ }
- // wait for all of the threads to complete
- final S expectedInstance = this.singletonInstanceMethod.get();
- for (Future res : results) {
- final S instance = res.get();
- assertNotNull(instance);
- assertSame(expectedInstance, instance);
- }
-
- // tidy up the executor
- executorService.shutdown();
+ // tidy up the executor
+ executorService.shutdown();
+ });
}
diff --git a/specification/pom.xml b/specification/pom.xml
index 76732b964..f84464d22 100644
--- a/specification/pom.xml
+++ b/specification/pom.xml
@@ -34,8 +34,18 @@
specification
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
test
diff --git a/specification/src/test/java/com/iluwatar/specification/app/AppTest.java b/specification/src/test/java/com/iluwatar/specification/app/AppTest.java
index a11101670..8cd648e58 100644
--- a/specification/src/test/java/com/iluwatar/specification/app/AppTest.java
+++ b/specification/src/test/java/com/iluwatar/specification/app/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.specification.app;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/specification/src/test/java/com/iluwatar/specification/creature/CreatureTest.java b/specification/src/test/java/com/iluwatar/specification/creature/CreatureTest.java
index 1c969891b..2d43c8d59 100644
--- a/specification/src/test/java/com/iluwatar/specification/creature/CreatureTest.java
+++ b/specification/src/test/java/com/iluwatar/specification/creature/CreatureTest.java
@@ -25,30 +25,26 @@ package com.iluwatar.specification.creature;
import com.iluwatar.specification.property.Color;
import com.iluwatar.specification.property.Movement;
import com.iluwatar.specification.property.Size;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import java.util.Arrays;
import java.util.Collection;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Date: 12/29/15 - 7:47 PM
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class CreatureTest {
/**
* @return The tested {@link Creature} instance and its expected specs
*/
- @Parameterized.Parameters
- public static Collection data() {
+ public static Collection dataProvider() {
return Arrays.asList(
new Object[]{new Dragon(), "Dragon", Size.LARGE, Movement.FLYING, Color.RED},
new Object[]{new Goblin(), "Goblin", Size.SMALL, Movement.WALKING, Color.GREEN},
@@ -59,71 +55,36 @@ public class CreatureTest {
);
}
- /**
- * The tested creature
- */
- private final Creature testedCreature;
-
- /**
- * The expected name of the tested creature
- */
- private final String name;
-
- /**
- * The expected size of the tested creature
- */
- private final Size size;
-
- /**
- * The expected movement type of the tested creature
- */
- private final Movement movement;
-
- /**
- * The expected color of the tested creature
- */
- private final Color color;
-
- /**
- * @param testedCreature The tested creature
- * @param name The expected name of the creature
- * @param size The expected size of the creature
- * @param movement The expected movement type of the creature
- * @param color The expected color of the creature
- */
- public CreatureTest(final Creature testedCreature, final String name, final Size size,
- final Movement movement, final Color color) {
- this.testedCreature = testedCreature;
- this.name = name;
- this.size = size;
- this.movement = movement;
- this.color = color;
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testGetName(Creature testedCreature, String name) throws Exception {
+ assertEquals(name, testedCreature.getName());
}
-
- @Test
- public void testGetName() throws Exception {
- assertEquals(this.name, this.testedCreature.getName());
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testGetSize(Creature testedCreature, String name, Size size) throws Exception {
+ assertEquals(size, testedCreature.getSize());
}
- @Test
- public void testGetSize() throws Exception {
- assertEquals(this.size, this.testedCreature.getSize());
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testGetMovement(Creature testedCreature, String name, Size size, Movement movement) throws Exception {
+ assertEquals(movement, testedCreature.getMovement());
}
- @Test
- public void testGetMovement() throws Exception {
- assertEquals(this.movement, this.testedCreature.getMovement());
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testGetColor(Creature testedCreature, String name, Size size, Movement movement,
+ Color color) throws Exception {
+ assertEquals(color, testedCreature.getColor());
}
- @Test
- public void testGetColor() throws Exception {
- assertEquals(this.color, this.testedCreature.getColor());
- }
-
- @Test
- public void testToString() throws Exception {
- final String toString = this.testedCreature.toString();
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testToString(Creature testedCreature, String name, Size size, Movement movement,
+ Color color) throws Exception {
+ final String toString = testedCreature.toString();
assertNotNull(toString);
assertEquals(
String.format("%s [size=%s, movement=%s, color=%s]", name, size, movement, color),
diff --git a/specification/src/test/java/com/iluwatar/specification/selector/ColorSelectorTest.java b/specification/src/test/java/com/iluwatar/specification/selector/ColorSelectorTest.java
index 52b176915..5765c1c56 100644
--- a/specification/src/test/java/com/iluwatar/specification/selector/ColorSelectorTest.java
+++ b/specification/src/test/java/com/iluwatar/specification/selector/ColorSelectorTest.java
@@ -24,11 +24,10 @@ package com.iluwatar.specification.selector;
import com.iluwatar.specification.creature.Creature;
import com.iluwatar.specification.property.Color;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/specification/src/test/java/com/iluwatar/specification/selector/MovementSelectorTest.java b/specification/src/test/java/com/iluwatar/specification/selector/MovementSelectorTest.java
index b9e86193e..8c7c0a54e 100644
--- a/specification/src/test/java/com/iluwatar/specification/selector/MovementSelectorTest.java
+++ b/specification/src/test/java/com/iluwatar/specification/selector/MovementSelectorTest.java
@@ -23,13 +23,11 @@
package com.iluwatar.specification.selector;
import com.iluwatar.specification.creature.Creature;
-import com.iluwatar.specification.property.Color;
import com.iluwatar.specification.property.Movement;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/specification/src/test/java/com/iluwatar/specification/selector/SizeSelectorTest.java b/specification/src/test/java/com/iluwatar/specification/selector/SizeSelectorTest.java
index f2b6b80b7..c15e932bc 100644
--- a/specification/src/test/java/com/iluwatar/specification/selector/SizeSelectorTest.java
+++ b/specification/src/test/java/com/iluwatar/specification/selector/SizeSelectorTest.java
@@ -24,11 +24,10 @@ package com.iluwatar.specification.selector;
import com.iluwatar.specification.creature.Creature;
import com.iluwatar.specification.property.Size;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/state/pom.xml b/state/pom.xml
index 256a5e9e2..e1c458b73 100644
--- a/state/pom.xml
+++ b/state/pom.xml
@@ -34,13 +34,13 @@
state
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
test
- org.mockito
- mockito-core
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/state/src/test/java/com/iluwatar/state/AppTest.java b/state/src/test/java/com/iluwatar/state/AppTest.java
index cb40d0481..16bffb2af 100644
--- a/state/src/test/java/com/iluwatar/state/AppTest.java
+++ b/state/src/test/java/com/iluwatar/state/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.state;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/state/src/test/java/com/iluwatar/state/MammothTest.java b/state/src/test/java/com/iluwatar/state/MammothTest.java
index 60f4b18f4..5c3bf3e69 100644
--- a/state/src/test/java/com/iluwatar/state/MammothTest.java
+++ b/state/src/test/java/com/iluwatar/state/MammothTest.java
@@ -25,16 +25,16 @@ package com.iluwatar.state;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Date: 12/29/15 - 8:27 PM
@@ -45,12 +45,12 @@ public class MammothTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/step-builder/pom.xml b/step-builder/pom.xml
index 432d5477a..9cbfa9abf 100644
--- a/step-builder/pom.xml
+++ b/step-builder/pom.xml
@@ -35,8 +35,13 @@
step-builder
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/step-builder/src/test/java/com/iluwatar/stepbuilder/AppTest.java b/step-builder/src/test/java/com/iluwatar/stepbuilder/AppTest.java
index af1ddfb58..a5b7c952f 100644
--- a/step-builder/src/test/java/com/iluwatar/stepbuilder/AppTest.java
+++ b/step-builder/src/test/java/com/iluwatar/stepbuilder/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.stepbuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/step-builder/src/test/java/com/iluwatar/stepbuilder/CharacterStepBuilderTest.java b/step-builder/src/test/java/com/iluwatar/stepbuilder/CharacterStepBuilderTest.java
index 962feeabb..220e3f89a 100644
--- a/step-builder/src/test/java/com/iluwatar/stepbuilder/CharacterStepBuilderTest.java
+++ b/step-builder/src/test/java/com/iluwatar/stepbuilder/CharacterStepBuilderTest.java
@@ -22,14 +22,14 @@
*/
package com.iluwatar.stepbuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Date: 12/29/15 - 9:21 PM
diff --git a/strategy/pom.xml b/strategy/pom.xml
index cd2d7e9a0..81b64220b 100644
--- a/strategy/pom.xml
+++ b/strategy/pom.xml
@@ -34,8 +34,18 @@
strategy
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
test
diff --git a/strategy/src/test/java/com/iluwatar/strategy/AppTest.java b/strategy/src/test/java/com/iluwatar/strategy/AppTest.java
index 59b3a22a9..c14af1bde 100644
--- a/strategy/src/test/java/com/iluwatar/strategy/AppTest.java
+++ b/strategy/src/test/java/com/iluwatar/strategy/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.strategy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/strategy/src/test/java/com/iluwatar/strategy/DragonSlayerTest.java b/strategy/src/test/java/com/iluwatar/strategy/DragonSlayerTest.java
index ad8b9784f..d22bf4235 100644
--- a/strategy/src/test/java/com/iluwatar/strategy/DragonSlayerTest.java
+++ b/strategy/src/test/java/com/iluwatar/strategy/DragonSlayerTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.strategy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
diff --git a/strategy/src/test/java/com/iluwatar/strategy/DragonSlayingStrategyTest.java b/strategy/src/test/java/com/iluwatar/strategy/DragonSlayingStrategyTest.java
index 52e596e5c..c988ad2f6 100644
--- a/strategy/src/test/java/com/iluwatar/strategy/DragonSlayingStrategyTest.java
+++ b/strategy/src/test/java/com/iluwatar/strategy/DragonSlayingStrategyTest.java
@@ -25,11 +25,10 @@ package com.iluwatar.strategy;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
@@ -37,21 +36,19 @@ import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Date: 12/29/15 - 10:58 PM
*
* @author Jeroen Meulemeester
*/
-@RunWith(Parameterized.class)
public class DragonSlayingStrategyTest {
/**
* @return The test parameters for each cycle
*/
- @Parameterized.Parameters
- public static Collection data() {
+ static Collection dataProvider() {
return Arrays.asList(
new Object[]{
new MeleeStrategy(),
@@ -68,47 +65,27 @@ public class DragonSlayingStrategyTest {
);
}
- /**
- * The tested strategy
- */
- private final DragonSlayingStrategy strategy;
-
- /**
- * The expected action in the log
- */
- private final String expectedResult;
-
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
- /**
- * Create a new test instance for the given strategy
- *
- * @param strategy The tested strategy
- * @param expectedResult The expected result
- */
- public DragonSlayingStrategyTest(final DragonSlayingStrategy strategy, final String expectedResult) {
- this.strategy = strategy;
- this.expectedResult = expectedResult;
- }
-
/**
* Test if executing the strategy gives the correct response
*/
- @Test
- public void testExecute() {
- this.strategy.execute();
- assertEquals(this.expectedResult, appender.getLastMessage());
+ @ParameterizedTest
+ @MethodSource("dataProvider")
+ public void testExecute(DragonSlayingStrategy strategy, String expectedResult) {
+ strategy.execute();
+ assertEquals(expectedResult, appender.getLastMessage());
assertEquals(1, appender.getLogSize());
}
diff --git a/template-method/pom.xml b/template-method/pom.xml
index 916d61b0b..700417a6e 100644
--- a/template-method/pom.xml
+++ b/template-method/pom.xml
@@ -34,8 +34,13 @@
template-method
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/template-method/src/test/java/com/iluwatar/templatemethod/AppTest.java b/template-method/src/test/java/com/iluwatar/templatemethod/AppTest.java
index da85062f5..2974117ea 100644
--- a/template-method/src/test/java/com/iluwatar/templatemethod/AppTest.java
+++ b/template-method/src/test/java/com/iluwatar/templatemethod/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.templatemethod;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/template-method/src/test/java/com/iluwatar/templatemethod/HalflingThiefTest.java b/template-method/src/test/java/com/iluwatar/templatemethod/HalflingThiefTest.java
index 6cc80446c..86a823386 100644
--- a/template-method/src/test/java/com/iluwatar/templatemethod/HalflingThiefTest.java
+++ b/template-method/src/test/java/com/iluwatar/templatemethod/HalflingThiefTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.templatemethod;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
diff --git a/template-method/src/test/java/com/iluwatar/templatemethod/StealingMethodTest.java b/template-method/src/test/java/com/iluwatar/templatemethod/StealingMethodTest.java
index 98ac62613..884ffe6ee 100644
--- a/template-method/src/test/java/com/iluwatar/templatemethod/StealingMethodTest.java
+++ b/template-method/src/test/java/com/iluwatar/templatemethod/StealingMethodTest.java
@@ -22,19 +22,19 @@
*/
package com.iluwatar.templatemethod;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
import java.util.LinkedList;
import java.util.List;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Date: 12/30/15 - 18:12 PM
* @param Type of StealingMethod
@@ -44,12 +44,12 @@ public abstract class StealingMethodTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/thread-pool/pom.xml b/thread-pool/pom.xml
index 94fce2b16..a20ff22a2 100644
--- a/thread-pool/pom.xml
+++ b/thread-pool/pom.xml
@@ -34,8 +34,13 @@
thread-pool
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/thread-pool/src/test/java/com/iluwatar/threadpool/AppTest.java b/thread-pool/src/test/java/com/iluwatar/threadpool/AppTest.java
index 2d21eec12..fafbce15e 100644
--- a/thread-pool/src/test/java/com/iluwatar/threadpool/AppTest.java
+++ b/thread-pool/src/test/java/com/iluwatar/threadpool/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.threadpool;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Application test
diff --git a/thread-pool/src/test/java/com/iluwatar/threadpool/TaskTest.java b/thread-pool/src/test/java/com/iluwatar/threadpool/TaskTest.java
index 4a2a06de8..099cdc6e8 100644
--- a/thread-pool/src/test/java/com/iluwatar/threadpool/TaskTest.java
+++ b/thread-pool/src/test/java/com/iluwatar/threadpool/TaskTest.java
@@ -22,8 +22,7 @@
*/
package com.iluwatar.threadpool;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
@@ -33,11 +32,13 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import java.util.function.Function;
import java.util.function.IntFunction;
-import java.util.function.ToIntFunction;
import java.util.stream.Collectors;
-import org.junit.Test;
+
+import static java.time.Duration.ofMillis;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTimeout;
/**
* Date: 12/30/15 - 18:22 PM
@@ -82,30 +83,31 @@ public abstract class TaskTest {
* Verify if the generated id is unique for each task, even if the tasks are created in separate
* threads
*/
- @Test(timeout = 10000)
+ @Test
public void testIdGeneration() throws Exception {
- final ExecutorService service = Executors.newFixedThreadPool(THREAD_COUNT);
+ assertTimeout(ofMillis(10000), () -> {
+ final ExecutorService service = Executors.newFixedThreadPool(THREAD_COUNT);
- final List> tasks = new ArrayList<>();
- for (int i = 0; i < TASK_COUNT; i++) {
- tasks.add(() -> factory.apply(1).getId());
- }
+ final List> tasks = new ArrayList<>();
+ for (int i = 0; i < TASK_COUNT; i++) {
+ tasks.add(() -> factory.apply(1).getId());
+ }
- final List ids = service.invokeAll(tasks)
- .stream()
- .map(TaskTest::get)
- .filter(Objects::nonNull)
- .collect(Collectors.toList());
+ final List ids = service.invokeAll(tasks)
+ .stream()
+ .map(TaskTest::get)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
- service.shutdownNow();
+ service.shutdownNow();
- final long uniqueIdCount = ids.stream()
- .distinct()
- .count();
-
- assertEquals(TASK_COUNT, ids.size());
- assertEquals(TASK_COUNT, uniqueIdCount);
+ final long uniqueIdCount = ids.stream()
+ .distinct()
+ .count();
+ assertEquals(TASK_COUNT, ids.size());
+ assertEquals(TASK_COUNT, uniqueIdCount);
+ });
}
/**
diff --git a/thread-pool/src/test/java/com/iluwatar/threadpool/WorkerTest.java b/thread-pool/src/test/java/com/iluwatar/threadpool/WorkerTest.java
index 81962ab2a..3b7186e98 100644
--- a/thread-pool/src/test/java/com/iluwatar/threadpool/WorkerTest.java
+++ b/thread-pool/src/test/java/com/iluwatar/threadpool/WorkerTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.threadpool;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
diff --git a/throttling/pom.xml b/throttling/pom.xml
index 7c2ee8b9a..9ae7055b2 100644
--- a/throttling/pom.xml
+++ b/throttling/pom.xml
@@ -35,10 +35,16 @@
throttling
-
- junit
- junit
-
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
\ No newline at end of file
diff --git a/throttling/src/test/java/com/iluwatar/throttling/AppTest.java b/throttling/src/test/java/com/iluwatar/throttling/AppTest.java
index 37c8e75ec..97a54864c 100644
--- a/throttling/src/test/java/com/iluwatar/throttling/AppTest.java
+++ b/throttling/src/test/java/com/iluwatar/throttling/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.throttling;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Application test
diff --git a/throttling/src/test/java/com/iluwatar/throttling/B2BServiceTest.java b/throttling/src/test/java/com/iluwatar/throttling/B2BServiceTest.java
index aaab62b3a..0c15bac6e 100644
--- a/throttling/src/test/java/com/iluwatar/throttling/B2BServiceTest.java
+++ b/throttling/src/test/java/com/iluwatar/throttling/B2BServiceTest.java
@@ -22,11 +22,11 @@
*/
package com.iluwatar.throttling;
-import org.junit.Assert;
-import org.junit.Test;
-
import com.iluwatar.throttling.timer.ThrottleTimerImpl;
import com.iluwatar.throttling.timer.Throttler;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* B2BServiceTest class to test the B2BService
@@ -43,6 +43,6 @@ public class B2BServiceTest {
service.dummyCustomerApi(tenant);
}
long counter = CallsCount.getCount(tenant.getName());
- Assert.assertTrue("Counter limit must be reached", counter == 2);
+ assertTrue(counter == 2, "Counter limit must be reached");
}
}
diff --git a/throttling/src/test/java/com/iluwatar/throttling/TenantTest.java b/throttling/src/test/java/com/iluwatar/throttling/TenantTest.java
index 2f0b5cf12..00e546d02 100644
--- a/throttling/src/test/java/com/iluwatar/throttling/TenantTest.java
+++ b/throttling/src/test/java/com/iluwatar/throttling/TenantTest.java
@@ -22,19 +22,21 @@
*/
package com.iluwatar.throttling;
-import org.junit.Test;
-
-import com.iluwatar.throttling.Tenant;
+import org.junit.jupiter.api.Test;
import java.security.InvalidParameterException;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
/**
* TenantTest to test the creation of Tenant with valid parameters.
*/
public class TenantTest {
- @Test(expected = InvalidParameterException.class)
+ @Test
public void constructorTest() {
- Tenant tenant = new Tenant("FailTenant", -1);
+ assertThrows(InvalidParameterException.class, () -> {
+ Tenant tenant = new Tenant("FailTenant", -1);
+ });
}
}
diff --git a/tls/pom.xml b/tls/pom.xml
index 40d6b2b21..65bfc2146 100644
--- a/tls/pom.xml
+++ b/tls/pom.xml
@@ -35,8 +35,13 @@
tls
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/tls/src/test/java/com/iluwatar/tls/AppTest.java b/tls/src/test/java/com/iluwatar/tls/AppTest.java
index 073c0988a..12bb1ea3c 100644
--- a/tls/src/test/java/com/iluwatar/tls/AppTest.java
+++ b/tls/src/test/java/com/iluwatar/tls/AppTest.java
@@ -23,7 +23,7 @@
package com.iluwatar.tls;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Tests that thread local storage example runs without errors.
diff --git a/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTest.java b/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTest.java
index b4f24be9b..bb2dfafb7 100644
--- a/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTest.java
+++ b/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTest.java
@@ -32,10 +32,11 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
*
@@ -86,7 +87,7 @@ public class DateFormatCallableTest {
/**
* Run Callable and prepare results for usage in the test methods
*/
- @BeforeClass
+ @BeforeAll
public static void setup() {
// Create a callable
DateFormatCallable callableDf = new DateFormatCallable("dd/MM/yyyy", "15/12/2015");
diff --git a/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTestIncorrectDateFormat.java b/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTestIncorrectDateFormat.java
index e0a1507e9..da1b9c264 100644
--- a/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTestIncorrectDateFormat.java
+++ b/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTestIncorrectDateFormat.java
@@ -30,10 +30,11 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
*
@@ -84,7 +85,7 @@ public class DateFormatCallableTestIncorrectDateFormat {
/**
* Run Callable and prepare results for usage in the test methods
*/
- @BeforeClass
+ @BeforeAll
public static void setup() {
// Create a callable. Pass a string date value not matching the format string
DateFormatCallable callableDf = new DateFormatCallable("dd/MM/yyyy", "15.12.2015");
diff --git a/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTestMultiThread.java b/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTestMultiThread.java
index 635d6f25a..845ab366d 100644
--- a/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTestMultiThread.java
+++ b/tls/src/test/java/com/iluwatar/tls/DateFormatCallableTestMultiThread.java
@@ -32,10 +32,11 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
*
@@ -90,7 +91,7 @@ public class DateFormatCallableTestMultiThread {
/**
* Run Callable and prepare results for usage in the test methods
*/
- @BeforeClass
+ @BeforeAll
public static void setup() {
// Create a callable
DateFormatCallable callableDf = new DateFormatCallable("dd/MM/yyyy", "15/12/2015");
diff --git a/tolerant-reader/pom.xml b/tolerant-reader/pom.xml
index 7e3561f80..01c2cf18a 100644
--- a/tolerant-reader/pom.xml
+++ b/tolerant-reader/pom.xml
@@ -34,8 +34,18 @@
tolerant-reader
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-migrationsupport
test
diff --git a/tolerant-reader/src/test/java/com/iluwatar/tolerantreader/AppTest.java b/tolerant-reader/src/test/java/com/iluwatar/tolerantreader/AppTest.java
index f24393779..07e6f6b89 100644
--- a/tolerant-reader/src/test/java/com/iluwatar/tolerantreader/AppTest.java
+++ b/tolerant-reader/src/test/java/com/iluwatar/tolerantreader/AppTest.java
@@ -22,9 +22,9 @@
*/
package com.iluwatar.tolerantreader;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
@@ -42,8 +42,8 @@ public class AppTest {
App.main(args);
}
- @Before
- @After
+ @BeforeEach
+ @AfterEach
public void cleanup() {
File file1 = new File("fish1.out");
file1.delete();
diff --git a/tolerant-reader/src/test/java/com/iluwatar/tolerantreader/RainbowFishSerializerTest.java b/tolerant-reader/src/test/java/com/iluwatar/tolerantreader/RainbowFishSerializerTest.java
index a6c7fc641..2785c8374 100644
--- a/tolerant-reader/src/test/java/com/iluwatar/tolerantreader/RainbowFishSerializerTest.java
+++ b/tolerant-reader/src/test/java/com/iluwatar/tolerantreader/RainbowFishSerializerTest.java
@@ -23,19 +23,21 @@
package com.iluwatar.tolerantreader;
import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.junit.rules.TemporaryFolder;
import java.io.File;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
/**
* Date: 12/30/15 - 18:39 PM
*
* @author Jeroen Meulemeester
*/
+@EnableRuleMigrationSupport
public class RainbowFishSerializerTest {
/**
diff --git a/twin/pom.xml b/twin/pom.xml
index 62d138fd9..fd9553428 100644
--- a/twin/pom.xml
+++ b/twin/pom.xml
@@ -34,8 +34,13 @@
twin
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/twin/src/test/java/com/iluwatar/twin/AppTest.java b/twin/src/test/java/com/iluwatar/twin/AppTest.java
index 60e02e4c4..76f189f3f 100644
--- a/twin/src/test/java/com/iluwatar/twin/AppTest.java
+++ b/twin/src/test/java/com/iluwatar/twin/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.twin;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/twin/src/test/java/com/iluwatar/twin/BallItemTest.java b/twin/src/test/java/com/iluwatar/twin/BallItemTest.java
index 5dad02481..3c443ef62 100644
--- a/twin/src/test/java/com/iluwatar/twin/BallItemTest.java
+++ b/twin/src/test/java/com/iluwatar/twin/BallItemTest.java
@@ -22,8 +22,8 @@
*/
package com.iluwatar.twin;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@@ -33,9 +33,10 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
import java.util.LinkedList;
import java.util.List;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
import org.slf4j.LoggerFactory;
@@ -48,12 +49,12 @@ public class BallItemTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}
diff --git a/twin/src/test/java/com/iluwatar/twin/BallThreadTest.java b/twin/src/test/java/com/iluwatar/twin/BallThreadTest.java
index f531a2493..010e6c7e2 100644
--- a/twin/src/test/java/com/iluwatar/twin/BallThreadTest.java
+++ b/twin/src/test/java/com/iluwatar/twin/BallThreadTest.java
@@ -22,10 +22,12 @@
*/
package com.iluwatar.twin;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static java.lang.Thread.UncaughtExceptionHandler;
import static java.lang.Thread.sleep;
+import static java.time.Duration.ofMillis;
+import static org.junit.jupiter.api.Assertions.assertTimeout;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
@@ -44,68 +46,74 @@ public class BallThreadTest {
/**
* Verify if the {@link BallThread} can be resumed
*/
- @Test(timeout = 5000)
+ @Test
public void testSuspend() throws Exception {
- final BallThread ballThread = new BallThread();
+ assertTimeout(ofMillis(5000), () -> {
+ final BallThread ballThread = new BallThread();
- final BallItem ballItem = mock(BallItem.class);
- ballThread.setTwin(ballItem);
+ final BallItem ballItem = mock(BallItem.class);
+ ballThread.setTwin(ballItem);
- ballThread.start();
+ ballThread.start();
- verify(ballItem, timeout(2000).atLeastOnce()).draw();
- verify(ballItem, timeout(2000).atLeastOnce()).move();
- ballThread.suspendMe();
+ verify(ballItem, timeout(2000).atLeastOnce()).draw();
+ verify(ballItem, timeout(2000).atLeastOnce()).move();
+ ballThread.suspendMe();
- sleep(1000);
+ sleep(1000);
- ballThread.stopMe();
- ballThread.join();
+ ballThread.stopMe();
+ ballThread.join();
- verifyNoMoreInteractions(ballItem);
+ verifyNoMoreInteractions(ballItem);
+ });
}
/**
* Verify if the {@link BallThread} can be resumed
*/
- @Test(timeout = 5000)
+ @Test
public void testResume() throws Exception {
- final BallThread ballThread = new BallThread();
+ assertTimeout(ofMillis(5000), () -> {
+ final BallThread ballThread = new BallThread();
- final BallItem ballItem = mock(BallItem.class);
- ballThread.setTwin(ballItem);
+ final BallItem ballItem = mock(BallItem.class);
+ ballThread.setTwin(ballItem);
- ballThread.suspendMe();
- ballThread.start();
+ ballThread.suspendMe();
+ ballThread.start();
- sleep(1000);
+ sleep(1000);
- verifyZeroInteractions(ballItem);
+ verifyZeroInteractions(ballItem);
- ballThread.resumeMe();
- verify(ballItem, timeout(2000).atLeastOnce()).draw();
- verify(ballItem, timeout(2000).atLeastOnce()).move();
+ ballThread.resumeMe();
+ verify(ballItem, timeout(2000).atLeastOnce()).draw();
+ verify(ballItem, timeout(2000).atLeastOnce()).move();
- ballThread.stopMe();
- ballThread.join();
+ ballThread.stopMe();
+ ballThread.join();
- verifyNoMoreInteractions(ballItem);
+ verifyNoMoreInteractions(ballItem);
+ });
}
/**
* Verify if the {@link BallThread} is interruptible
*/
- @Test(timeout = 5000)
+ @Test
public void testInterrupt() throws Exception {
- final BallThread ballThread = new BallThread();
- final UncaughtExceptionHandler exceptionHandler = mock(UncaughtExceptionHandler.class);
- ballThread.setUncaughtExceptionHandler(exceptionHandler);
- ballThread.setTwin(mock(BallItem.class));
- ballThread.start();
- ballThread.interrupt();
- ballThread.join();
+ assertTimeout(ofMillis(5000), () -> {
+ final BallThread ballThread = new BallThread();
+ final UncaughtExceptionHandler exceptionHandler = mock(UncaughtExceptionHandler.class);
+ ballThread.setUncaughtExceptionHandler(exceptionHandler);
+ ballThread.setTwin(mock(BallItem.class));
+ ballThread.start();
+ ballThread.interrupt();
+ ballThread.join();
- verify(exceptionHandler).uncaughtException(eq(ballThread), any(RuntimeException.class));
- verifyNoMoreInteractions(exceptionHandler);
+ verify(exceptionHandler).uncaughtException(eq(ballThread), any(RuntimeException.class));
+ verifyNoMoreInteractions(exceptionHandler);
+ });
}
}
\ No newline at end of file
diff --git a/unit-of-work/pom.xml b/unit-of-work/pom.xml
index 0d7fbf5a2..129d8dc51 100644
--- a/unit-of-work/pom.xml
+++ b/unit-of-work/pom.xml
@@ -15,6 +15,11 @@
junit
junit
+
+ org.junit.vintage
+ junit-vintage-engine
+ test
+
org.mockito
mockito-core
diff --git a/value-object/pom.xml b/value-object/pom.xml
index fa4c06697..026b6220a 100644
--- a/value-object/pom.xml
+++ b/value-object/pom.xml
@@ -41,8 +41,13 @@
test
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/value-object/src/test/java/com/iluwatar/value/object/AppTest.java b/value-object/src/test/java/com/iluwatar/value/object/AppTest.java
index cd0b1354f..86dcb5be3 100644
--- a/value-object/src/test/java/com/iluwatar/value/object/AppTest.java
+++ b/value-object/src/test/java/com/iluwatar/value/object/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.value.object;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Application test
diff --git a/value-object/src/test/java/com/iluwatar/value/object/HeroStatTest.java b/value-object/src/test/java/com/iluwatar/value/object/HeroStatTest.java
index b7b65b6c6..f19382d4e 100644
--- a/value-object/src/test/java/com/iluwatar/value/object/HeroStatTest.java
+++ b/value-object/src/test/java/com/iluwatar/value/object/HeroStatTest.java
@@ -22,15 +22,13 @@
*/
package com.iluwatar.value.object;
+import com.google.common.testing.EqualsTester;
+import org.junit.jupiter.api.Test;
+
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
-
import static org.junit.Assert.assertThat;
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-
/**
* Unit test for HeroStat.
*/
diff --git a/visitor/pom.xml b/visitor/pom.xml
index 5445a94cc..ea75fdf5a 100644
--- a/visitor/pom.xml
+++ b/visitor/pom.xml
@@ -34,8 +34,13 @@
visitor
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
test
diff --git a/visitor/src/test/java/com/iluwatar/visitor/AppTest.java b/visitor/src/test/java/com/iluwatar/visitor/AppTest.java
index 23c9bb48f..0fc97cc56 100644
--- a/visitor/src/test/java/com/iluwatar/visitor/AppTest.java
+++ b/visitor/src/test/java/com/iluwatar/visitor/AppTest.java
@@ -22,7 +22,7 @@
*/
package com.iluwatar.visitor;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
*
diff --git a/visitor/src/test/java/com/iluwatar/visitor/UnitTest.java b/visitor/src/test/java/com/iluwatar/visitor/UnitTest.java
index ab8470512..57fe19397 100644
--- a/visitor/src/test/java/com/iluwatar/visitor/UnitTest.java
+++ b/visitor/src/test/java/com/iluwatar/visitor/UnitTest.java
@@ -22,15 +22,16 @@
*/
package com.iluwatar.visitor;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.function.Function;
+
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
-import java.util.Arrays;
-import java.util.function.Function;
-import org.junit.Test;
-
/**
* Date: 12/30/15 - 18:59 PM
* Test related to Units
diff --git a/visitor/src/test/java/com/iluwatar/visitor/VisitorTest.java b/visitor/src/test/java/com/iluwatar/visitor/VisitorTest.java
index ba6705b23..68f4681c6 100644
--- a/visitor/src/test/java/com/iluwatar/visitor/VisitorTest.java
+++ b/visitor/src/test/java/com/iluwatar/visitor/VisitorTest.java
@@ -22,19 +22,20 @@
*/
package com.iluwatar.visitor;
-import static org.junit.Assert.assertEquals;
-
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Date: 12/30/15 - 18:59 PM
* Test case for Visitor Pattern
@@ -45,12 +46,12 @@ public abstract class VisitorTest {
private InMemoryAppender appender;
- @Before
+ @BeforeEach
public void setUp() {
appender = new InMemoryAppender();
}
- @After
+ @AfterEach
public void tearDown() {
appender.stop();
}