Skip to content

Commit c521bb0

Browse files
authored
Merge pull request #7 from P8hJ/feature/JUnit5Migration
Migrate all Tests to JUnit5
2 parents 6d2fb43 + 3e6b5e4 commit c521bb0

11 files changed

+79
-80
lines changed

pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>eblocker-top</artifactId>
55
<groupId>org.eblocker</groupId>
6-
<version>2.4.13</version>
6+
<version>2.4.15</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99

@@ -35,8 +35,8 @@
3535

3636
<!-- Test only -->
3737
<dependency>
38-
<groupId>junit</groupId>
39-
<artifactId>junit</artifactId>
38+
<groupId>org.junit.jupiter</groupId>
39+
<artifactId>junit-jupiter</artifactId>
4040
<scope>test</scope>
4141
</dependency>
4242
</dependencies>
@@ -45,6 +45,7 @@
4545
<repository>
4646
<id>eblocker-registration-api</id>
4747
<name>GitHub Packages</name>
48+
<!--suppress UnresolvedMavenProperty -->
4849
<url>https://maven.pkg.github.com/${githubRepository}</url>
4950
</repository>
5051
</distributionManagement>

src/test/java/org/eblocker/registration/DeviceRegistrationRequestTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717
package org.eblocker.registration;
1818

1919
import com.fasterxml.jackson.databind.ObjectMapper;
20-
import org.junit.Test;
20+
import org.junit.jupiter.api.Test;
2121

2222
import java.io.ByteArrayInputStream;
2323
import java.io.ByteArrayOutputStream;
2424
import java.io.IOException;
2525

26-
import static org.junit.Assert.*;
26+
import static org.junit.jupiter.api.Assertions.*;
2727

28-
public class DeviceRegistrationRequestTest {
28+
class DeviceRegistrationRequestTest {
2929

3030
private static ObjectMapper mapper = new ObjectMapper();
3131

3232
@Test
33-
public void test() throws IOException {
33+
void test() throws IOException {
3434
DeviceRegistrationRequest request = new DeviceRegistrationRequest(
3535
"email@address",
3636
"deviceName",
@@ -64,7 +64,7 @@ public void test() throws IOException {
6464
}
6565

6666
@Test
67-
public void test_noConfirmationInfo() throws IOException {
67+
void test_noConfirmationInfo() throws IOException {
6868
DeviceRegistrationRequest request = new DeviceRegistrationRequest(
6969
"email@address",
7070
"deviceName",
@@ -103,7 +103,7 @@ public void test_noConfirmationInfo() throws IOException {
103103

104104

105105
@Test
106-
public void test_toString() {
106+
void test_toString() {
107107
DeviceRegistrationRequest request = new DeviceRegistrationRequest(
108108
"email@address",
109109
"deviceName",
@@ -122,7 +122,7 @@ public void test_toString() {
122122
}
123123

124124
@Test
125-
public void test_toStringNoConfirmationInfo() {
125+
void test_toStringNoConfirmationInfo() {
126126
DeviceRegistrationRequest request = new DeviceRegistrationRequest(
127127
"email@address",
128128
"deviceName",

src/test/java/org/eblocker/registration/DeviceRegistrationResponseTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,21 @@
1717
package org.eblocker.registration;
1818

1919
import com.fasterxml.jackson.databind.ObjectMapper;
20-
import org.junit.Test;
20+
import org.junit.jupiter.api.Test;
2121

2222
import java.io.ByteArrayInputStream;
2323
import java.io.ByteArrayOutputStream;
2424
import java.io.IOException;
2525

26-
import static org.junit.Assert.*;
26+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
27+
import static org.junit.jupiter.api.Assertions.assertEquals;
2728

28-
public class DeviceRegistrationResponseTest {
29+
class DeviceRegistrationResponseTest {
2930

3031
private static ObjectMapper mapper = new ObjectMapper();
3132

3233
@Test
33-
public void test() throws IOException {
34+
void test() throws IOException {
3435
DeviceRegistrationResponse response = new DeviceRegistrationResponse(
3536
"email@address",
3637
"deviceName",
@@ -65,7 +66,7 @@ public void test() throws IOException {
6566
}
6667

6768
@Test
68-
public void test_compatibility() throws IOException {
69+
void test_compatibility() throws IOException {
6970
DeviceRegistrationResponse response = new DeviceRegistrationResponse(
7071
"email@address",
7172
"deviceName",

src/test/java/org/eblocker/registration/LicenseTypeTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
*/
1717
package org.eblocker.registration;
1818

19-
import org.junit.Test;
19+
import org.junit.jupiter.api.Test;
2020

21-
import static org.junit.Assert.*;
21+
import static org.junit.jupiter.api.Assertions.*;
2222

23-
public class LicenseTypeTest {
23+
class LicenseTypeTest {
2424

2525
@Test
26-
public void test() {
26+
void test() {
2727

2828
assertFalse(LicenseType.COMMUNITY.isSubscription());
2929
assertTrue(LicenseType.SUBSCRIPTION.isSubscription());

src/test/java/org/eblocker/registration/MobileConnectionCheckTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@
1717
package org.eblocker.registration;
1818

1919
import com.fasterxml.jackson.databind.ObjectMapper;
20-
import org.junit.Test;
20+
import org.junit.jupiter.api.Test;
2121

2222
import java.io.IOException;
2323
import java.util.Date;
2424
import java.util.UUID;
2525

26-
import static org.junit.Assert.*;
26+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
27+
import static org.junit.jupiter.api.Assertions.assertEquals;
2728

28-
public class MobileConnectionCheckTest {
29+
class MobileConnectionCheckTest {
2930
private static ObjectMapper mapper = new ObjectMapper();
3031

3132
@Test
32-
public void test() throws IOException {
33+
void test() throws IOException {
3334
MobileConnectionCheck mobileConnectionCheck = new MobileConnectionCheck(
3435
UUID.randomUUID().toString(),
3536
MobileConnectionCheck.State.NEW,

src/test/java/org/eblocker/registration/ProductFeatureTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
*/
1717
package org.eblocker.registration;
1818

19-
import org.junit.Test;
19+
import org.junit.jupiter.api.Test;
2020

21-
import static org.junit.Assert.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
2222

23-
public class ProductFeatureTest {
23+
class ProductFeatureTest {
2424

2525
@Test
26-
public void test() {
26+
void test() {
2727

2828
assertEquals(ProductFeature.WOL, ProductFeature.defaultProductFeature());
2929

src/test/java/org/eblocker/registration/ProductInfoTest.java

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,21 @@
1717
package org.eblocker.registration;
1818

1919
import com.fasterxml.jackson.databind.ObjectMapper;
20-
21-
import org.junit.Before;
22-
import org.junit.Test;
20+
import org.junit.jupiter.api.Assertions;
21+
import org.junit.jupiter.api.BeforeEach;
22+
import org.junit.jupiter.api.Test;
2323

2424
import java.io.ByteArrayInputStream;
2525
import java.io.ByteArrayOutputStream;
2626
import java.io.IOException;
2727

28-
import static org.junit.Assert.assertArrayEquals;
29-
import static org.junit.Assert.assertEquals;
30-
import static org.junit.Assert.assertFalse;
31-
import static org.junit.Assert.assertTrue;
28+
import static org.junit.jupiter.api.Assertions.*;
3229

33-
public class ProductInfoTest {
30+
class ProductInfoTest {
3431
private static ObjectMapper mapper = new ObjectMapper();
3532
private ProductInfo entity;
3633

37-
@Before
34+
@BeforeEach
3835
public void initFixtures() {
3936
entity = new ProductInfo(
4037
"productId",
@@ -44,7 +41,7 @@ public void initFixtures() {
4441
}
4542

4643
@Test
47-
public void testConstructor() {
44+
void testConstructor() {
4845
entity = new ProductInfo(
4946
"productId",
5047
"productName",
@@ -53,7 +50,7 @@ public void testConstructor() {
5350
}
5451

5552
@Test
56-
public void test() throws IOException {
53+
void test() throws IOException {
5754
ByteArrayOutputStream out = new ByteArrayOutputStream();
5855
mapper.writerWithDefaultPrettyPrinter().writeValue(out, entity);
5956

@@ -68,30 +65,30 @@ public void test() throws IOException {
6865
}
6966

7067
@Test
71-
public void testToString() {
72-
assertTrue(entity.toString().contains("productId"));
68+
void testToString() {
69+
Assertions.assertTrue(entity.toString().contains("productId"));
7370
}
7471

7572
@Test
76-
public void testRemoveProductFeature() {
73+
void testRemoveProductFeature() {
7774
entity.removeProductFeature("F01");
7875
entity.removeProductFeature("XYZ");
79-
assertTrue(entity.getProductFeatures().length == 2);
76+
assertEquals(2, entity.getProductFeatures().length);
8077
}
8178

8279
@SuppressWarnings("unlikely-arg-type")
8380
@Test
84-
public void testEquals() {
85-
assertFalse(entity.equals(null));
86-
assertFalse(entity.equals("test"));
87-
assertTrue(entity.equals(entity));
81+
void testEquals() {
82+
assertNotEquals(null, entity);
83+
assertNotEquals("test", entity);
84+
assertEquals(entity, entity);
8885

8986
ProductInfo entity2 = new ProductInfo(
9087
"productId",
9188
"productName",
9289
new String[]{"F01", "F02", "F03"}
9390
);
94-
assertTrue(entity2.equals(entity));
91+
assertEquals(entity2, entity);
9592

9693
entity2 = new ProductInfo(
9794
null,
@@ -103,8 +100,8 @@ public void testEquals() {
103100
"productName",
104101
new String[]{"F01", "F02", "F03"}
105102
);
106-
assertFalse(entity2.equals(entity));
107-
assertTrue(entity3.equals(entity2));
103+
assertNotEquals(entity2, entity);
104+
assertEquals(entity3, entity2);
108105

109106
entity2 = new ProductInfo(
110107
"productId",
@@ -116,29 +113,29 @@ public void testEquals() {
116113
null,
117114
new String[]{"F01", "F02", "F03"}
118115
);
119-
assertFalse(entity2.equals(entity));
120-
assertTrue(entity3.equals(entity2));
116+
assertNotEquals(entity2, entity);
117+
assertEquals(entity3, entity2);
121118

122119
entity2 = new ProductInfo(
123120
"productId-XZ",
124121
"productName",
125122
new String[]{"F01", "F02", "F03"}
126123
);
127-
assertFalse(entity2.equals(entity));
124+
assertNotEquals(entity2, entity);
128125

129126
entity2 = new ProductInfo(
130127
"productId",
131128
"productName-XZ",
132129
new String[]{"F01", "F02", "F03"}
133130
);
134-
assertFalse(entity2.equals(entity));
131+
assertNotEquals(entity2, entity);
135132

136133
entity.removeProductFeature("F01");
137-
assertFalse(entity2.equals(entity));
134+
assertNotEquals(entity2, entity);
138135
}
139136

140137
@Test
141-
public void testHashCode () {
138+
void testHashCode() {
142139
assertEquals(1526013430, entity.hashCode());
143140

144141
entity = new ProductInfo(

src/test/java/org/eblocker/registration/RegistrationStateTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
*/
1717
package org.eblocker.registration;
1818

19-
import org.junit.Test;
19+
import org.junit.jupiter.api.Test;
2020

21-
import static org.junit.Assert.*;
21+
import static org.junit.jupiter.api.Assertions.assertFalse;
22+
import static org.junit.jupiter.api.Assertions.assertTrue;
2223

23-
public class RegistrationStateTest {
24+
class RegistrationStateTest {
2425

2526
@Test
26-
public void test() {
27+
void test() {
2728

2829
assertTrue(RegistrationState.NEW.isUnregistered());
2930

src/test/java/org/eblocker/registration/UpdateModeTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
*/
1717
package org.eblocker.registration;
1818

19-
import org.junit.Test;
19+
import org.junit.jupiter.api.Test;
2020

21-
import static org.junit.Assert.*;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
2222

23-
public class UpdateModeTest {
23+
class UpdateModeTest {
2424

2525
@Test
26-
public void test() {
26+
void test() {
2727

2828
assertEquals(UpdateMode.AUTO, UpdateMode.getFailSafeValue(1));
2929

src/test/java/org/eblocker/registration/UpgradeProductInfoTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,20 @@
1717
package org.eblocker.registration;
1818

1919
import com.fasterxml.jackson.databind.ObjectMapper;
20-
import org.junit.Test;
20+
import org.junit.jupiter.api.Test;
2121

2222
import java.io.ByteArrayInputStream;
2323
import java.io.ByteArrayOutputStream;
2424
import java.io.IOException;
2525

26-
import static org.junit.Assert.assertArrayEquals;
27-
import static org.junit.Assert.assertEquals;
26+
import static org.junit.jupiter.api.Assertions.assertEquals;
2827

29-
public class UpgradeProductInfoTest {
28+
class UpgradeProductInfoTest {
3029

3130
private static ObjectMapper mapper = new ObjectMapper();
3231

3332
@Test
34-
public void test() throws IOException {
33+
void test() throws IOException {
3534
UpgradeProductInfo entity = new UpgradeProductInfo(
3635
true,
3736
null

0 commit comments

Comments
 (0)