Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Migrating to JUnit 5
  • Loading branch information
charlesfinley committed Mar 5, 2021
commit 28245c589f8b39160323de2c66c860953adab907
5 changes: 0 additions & 5 deletions async-method-invocation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
6 changes: 0 additions & 6 deletions combinator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@

<artifactId>combinator</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

package com.iluwatar.combinator;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

Expand Down
15 changes: 6 additions & 9 deletions combinator/src/test/java/com/iluwatar/combinator/FinderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,19 @@

package com.iluwatar.combinator;

import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.List;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.*;

public class FinderTest {
class FinderTest {

@Test
public void contains() {
void contains() {
var example = "the first one \nthe second one \n";

var result = Finder.contains("second").find(example);
Assert.assertEquals(result.size(),1);
Assert.assertEquals(result.get(0),"the second one ");
assertEquals(1, result.size());
assertEquals("the second one ", result.get(0));
}

}
42 changes: 21 additions & 21 deletions combinator/src/test/java/com/iluwatar/combinator/FindersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,44 @@

package com.iluwatar.combinator;

import org.junit.Assert;
import org.junit.Test;
import static com.iluwatar.combinator.Finders.advancedFinder;
import static com.iluwatar.combinator.Finders.expandedFinder;
import static com.iluwatar.combinator.Finders.filteredFinder;
import static com.iluwatar.combinator.Finders.specializedFinder;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.List;
import org.junit.jupiter.api.Test;

import static com.iluwatar.combinator.Finders.*;
import static org.junit.Assert.*;

public class FindersTest {
class FindersTest {

@Test
public void advancedFinderTest() {
void advancedFinderTest() {
var res = advancedFinder("it was","kingdom","sea").find(text());
Assert.assertEquals(res.size(),1);
Assert.assertEquals(res.get(0),"It was many and many a year ago,");
assertEquals(1, res.size());
assertEquals("It was many and many a year ago,", res.get(0));
}

@Test
public void filteredFinderTest() {
void filteredFinderTest() {
var res = filteredFinder(" was ", "many", "child").find(text());
Assert.assertEquals(res.size(),1);
Assert.assertEquals(res.get(0),"But we loved with a love that was more than love-");
assertEquals(1, res.size());
assertEquals("But we loved with a love that was more than love-", res.get(0));
}

@Test
public void specializedFinderTest() {
void specializedFinderTest() {
var res = specializedFinder("love","heaven").find(text());
Assert.assertEquals(res.size(),1);
Assert.assertEquals(res.get(0),"With a love that the winged seraphs of heaven");
assertEquals(1, res.size());
assertEquals("With a love that the winged seraphs of heaven", res.get(0));
}

@Test
public void expandedFinderTest() {
void expandedFinderTest() {
var res = expandedFinder("It was","kingdom").find(text());
Assert.assertEquals(res.size(),3);
Assert.assertEquals(res.get(0),"It was many and many a year ago,");
Assert.assertEquals(res.get(1),"In a kingdom by the sea,");
Assert.assertEquals(res.get(2),"In this kingdom by the sea;");
assertEquals(3, res.size());
assertEquals("It was many and many a year ago,", res.get(0));
assertEquals("In a kingdom by the sea,", res.get(1));
assertEquals("In this kingdom by the sea;", res.get(2));
}


Expand Down
4 changes: 0 additions & 4 deletions factory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
5 changes: 0 additions & 5 deletions game-loop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@

<artifactId>game-loop</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down
5 changes: 0 additions & 5 deletions half-sync-half-async/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
5 changes: 0 additions & 5 deletions leader-followers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
</parent>
<artifactId>leader-followers</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down
10 changes: 5 additions & 5 deletions leader-followers/src/test/java/com/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@

package com;

import com.iluwatar.leaderfollowers.App;
import org.junit.Test;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

import com.iluwatar.leaderfollowers.App;
import org.junit.jupiter.api.Test;

/**
*
* Application test
*
*/
public class AppTest {
class AppTest {

@Test
public void shouldExecuteApplicationWithoutException() {
void shouldExecuteApplicationWithoutException() {
assertDoesNotThrow(() -> App.main(new String[]{}));
}

Expand Down
11 changes: 6 additions & 5 deletions leader-followers/src/test/java/com/TaskHandlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,23 @@

package com;

import static org.junit.jupiter.api.Assertions.assertTrue;

import com.iluwatar.leaderfollowers.Task;
import com.iluwatar.leaderfollowers.TaskHandler;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* Tests for TaskHandler
*/
public class TaskHandlerTest {
class TaskHandlerTest {

@Test
public void testHandleTask() throws InterruptedException {
void testHandleTask() throws InterruptedException {
var taskHandler = new TaskHandler();
var handle = new Task(100);
taskHandler.handleTask(handle);
Assert.assertTrue(handle.isFinished());
assertTrue(handle.isFinished());
}

}
17 changes: 9 additions & 8 deletions leader-followers/src/test/java/com/TaskSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,31 @@

package com;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.iluwatar.leaderfollowers.Task;
import com.iluwatar.leaderfollowers.TaskSet;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* Tests for TaskSet
*/
public class TaskSetTest {
class TaskSetTest {

@Test
public void testAddTask() throws InterruptedException {
void testAddTask() throws InterruptedException {
var taskSet = new TaskSet();
taskSet.addTask(new Task(10));
Assert.assertTrue(taskSet.getSize() == 1);
assertEquals(1, taskSet.getSize());
}

@Test
public void testGetTask() throws InterruptedException {
void testGetTask() throws InterruptedException {
var taskSet = new TaskSet();
taskSet.addTask(new Task(100));
Task task = taskSet.getTask();
Assert.assertTrue(task.getTime() == 100);
Assert.assertTrue(taskSet.getSize() == 0);
assertEquals(100, task.getTime());
assertEquals(0, taskSet.getSize());
}

}
24 changes: 13 additions & 11 deletions leader-followers/src/test/java/com/WorkCenterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,45 @@

package com;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import com.iluwatar.leaderfollowers.TaskHandler;
import com.iluwatar.leaderfollowers.TaskSet;
import com.iluwatar.leaderfollowers.WorkCenter;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* Tests for WorkCenter
*/
public class WorkCenterTest {
class WorkCenterTest {

@Test
public void testCreateWorkers() {
void testCreateWorkers() {
var taskSet = new TaskSet();
var taskHandler = new TaskHandler();
var workCenter = new WorkCenter();
workCenter.createWorkers(5, taskSet, taskHandler);
Assert.assertEquals(workCenter.getWorkers().size(), 5);
Assert.assertEquals(workCenter.getWorkers().get(0), workCenter.getLeader());
assertEquals(5, workCenter.getWorkers().size());
assertEquals(workCenter.getWorkers().get(0), workCenter.getLeader());
}

@Test
public void testNullLeader() {
void testNullLeader() {
var workCenter = new WorkCenter();
workCenter.promoteLeader();
Assert.assertNull(workCenter.getLeader());
assertNull(workCenter.getLeader());
}

@Test
public void testPromoteLeader() {
void testPromoteLeader() {
var taskSet = new TaskSet();
var taskHandler = new TaskHandler();
var workCenter = new WorkCenter();
workCenter.createWorkers(5, taskSet, taskHandler);
workCenter.removeWorker(workCenter.getLeader());
workCenter.promoteLeader();
Assert.assertEquals(workCenter.getWorkers().size(), 4);
Assert.assertEquals(workCenter.getWorkers().get(0), workCenter.getLeader());
assertEquals(4, workCenter.getWorkers().size());
assertEquals(workCenter.getWorkers().get(0), workCenter.getLeader());
}
}
8 changes: 4 additions & 4 deletions marker/src/test/java/GuardTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
* THE SOFTWARE.
*/

import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;

import org.junit.jupiter.api.Test;

/**
* Guard test
*/
public class GuardTest {
class GuardTest {

@Test
public void testGuard() {
void testGuard() {
var guard = new Guard();
assertThat(guard, instanceOf(Permission.class));
}
Expand Down
4 changes: 0 additions & 4 deletions registry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
5 changes: 0 additions & 5 deletions role-object/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@

<artifactId>role-object</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@

package com.iluwatar.roleobject;

import org.junit.Test;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

public class ApplicationRoleObjectTest {
import org.junit.jupiter.api.Test;

class ApplicationRoleObjectTest {

@Test
public void shouldExecuteApplicationWithoutException() {
void shouldExecuteApplicationWithoutException() {
assertDoesNotThrow(() -> ApplicationRoleObject.main(new String[]{}));
}
}
Loading