Skip to content

Commit 4e61738

Browse files
upgrade microprofile to junit5 (#18669)
* upgrade microprofile to junit5 * re-generate samples * fix junit(DOT)version * update tests for java microprofile server * update samples * update * update * update * update --------- Co-authored-by: Thorsten Hirsch <[email protected]>
1 parent cc5c50b commit 4e61738

File tree

64 files changed

+712
-809
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+712
-809
lines changed

modules/openapi-generator/src/main/resources/Java/libraries/microprofile/api_test.mustache

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ package {{package}};
44

55
{{#imports}}import {{import}};
66
{{/imports}}
7-
import org.junit.Test;
8-
import org.junit.Before;
9-
import static org.junit.Assert.*;
7+
import org.junit.jupiter.api.BeforeEach;
8+
import org.junit.jupiter.api.Test;
9+
import org.junit.jupiter.api.Assertions;
10+
{{#generateSpringBootApplication}}
11+
import org.junit.jupiter.api.extension.ExtendWith;
12+
import org.springframework.test.context.junit.jupiter.SpringExtension;
13+
{{/generateSpringBootApplication}}
1014

1115
import org.eclipse.microprofile.rest.client.RestClientBuilder;
1216

@@ -26,7 +30,7 @@ import java.util.Set;
2630
* API tests for {{classname}}
2731
*/
2832
{{#generateSpringBootApplication}}
29-
@RunWith(SpringJUnit4ClassRunner.class)
33+
@ExtendWith(SpringExtension.class)
3034
@SpringApplicationConfiguration(classes = SpringBootApplication.class)
3135
@WebAppConfiguration
3236
@IntegrationTest("server.port=0")
@@ -36,7 +40,7 @@ public class {{classname}}Test {
3640
private {{classname}} client;
3741
private String baseUrl = "http://localhost:9080";
3842

39-
@Before
43+
@BeforeEach
4044
public void setup() throws MalformedURLException {
4145
{{#microprofile3}}
4246
// TODO initialize the client
@@ -69,7 +73,7 @@ public class {{classname}}Test {
6973
{{^isFile}}{{{dataType}}} {{paramName}} = null;{{/isFile}}{{#isFile}}org.apache.cxf.jaxrs.ext.multipart.Attachment {{paramName}} = null;{{/isFile}}
7074
{{/allParams}}
7175
//{{^vendorExtensions.x-java-is-response-void}}{{#microprofileMutiny}}Uni<{{{returnType}}}>{{/microprofileMutiny}}{{^microprofileMutiny}}{{{returnType}}}{{/microprofileMutiny}} response = {{/vendorExtensions.x-java-is-response-void}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
72-
//{{#returnType}}assertNotNull(response);{{/returnType}}
76+
//{{#returnType}}Assertions.assertNotNull(response);{{/returnType}}
7377

7478

7579
}

modules/openapi-generator/src/main/resources/Java/libraries/microprofile/kumuluzee.pom.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<kumuluzee-rest.version>1.2.3</kumuluzee-rest.version>
1919
<kumuluzee-rest-client.version>1.4.1</kumuluzee-rest-client.version>
2020
<cxf-rt-rs-extension-providers.version>3.2.6</cxf-rt-rs-extension-providers.version>
21-
<junit-version>4.13</junit-version>
21+
<junit-version>5.10.2</junit-version>
2222
<jersey-version>2.28</jersey-version>
2323
</properties>
2424

@@ -70,8 +70,8 @@
7070
<version>${cxf-rt-rs-extension-providers.version}</version>
7171
</dependency>
7272
<dependency>
73-
<groupId>junit</groupId>
74-
<artifactId>junit</artifactId>
73+
<groupId>org.junit.jupiter</groupId>
74+
<artifactId>junit-jupiter-api</artifactId>
7575
<version>${junit-version}</version>
7676
<scope>test</scope>
7777
</dependency>

modules/openapi-generator/src/main/resources/Java/libraries/microprofile/pom.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
</plugins>
5959
</build>
6060
<dependencies>
61-
<dependency>
62-
<groupId>junit</groupId>
63-
<artifactId>junit</artifactId>
61+
<dependency>
62+
<groupId>org.junit.jupiter</groupId>
63+
<artifactId>junit-jupiter-api</artifactId>
6464
<version>${junit.version}</version>
6565
<scope>test</scope>
6666
</dependency>
@@ -212,7 +212,7 @@
212212
<maven.compiler.target>${java.version}</maven.compiler.target>
213213
<swagger.core.version>1.5.18</swagger.core.version>
214214
<jetty.version>9.2.9.v20150224</jetty.version>
215-
<junit.version>4.13.2</junit.version>
215+
<junit.version>5.10.2</junit.version>
216216
<logback.version>1.4.14</logback.version>
217217
{{#useBeanValidation}}
218218
<beanvalidation.version>3.0.2</beanvalidation.version>

modules/openapi-generator/src/main/resources/Java/libraries/microprofile/pom_3.0.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
</plugins>
5959
</build>
6060
<dependencies>
61-
<dependency>
62-
<groupId>junit</groupId>
63-
<artifactId>junit</artifactId>
61+
<dependency>
62+
<groupId>org.junit.jupiter</groupId>
63+
<artifactId>junit-jupiter-api</artifactId>
6464
<version>${junit.version}</version>
6565
<scope>test</scope>
6666
</dependency>
@@ -205,7 +205,7 @@
205205
<maven.compiler.target>${java.version}</maven.compiler.target>
206206
<swagger.core.version>1.5.18</swagger.core.version>
207207
<jetty.version>9.2.9.v20150224</jetty.version>
208-
<junit.version>4.13.2</junit.version>
208+
<junit.version>5.10.2</junit.version>
209209
<logback.version>1.4.14</logback.version>
210210
{{#useBeanValidation}}
211211
<beanvalidation.version>3.0.1</beanvalidation.version>

samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@
5656
</plugins>
5757
</build>
5858
<dependencies>
59-
<dependency>
60-
<groupId>junit</groupId>
61-
<artifactId>junit</artifactId>
59+
<dependency>
60+
<groupId>org.junit.jupiter</groupId>
61+
<artifactId>junit-jupiter-api</artifactId>
6262
<version>${junit.version}</version>
6363
<scope>test</scope>
6464
</dependency>
@@ -154,7 +154,7 @@
154154
<maven.compiler.target>${java.version}</maven.compiler.target>
155155
<swagger.core.version>1.5.18</swagger.core.version>
156156
<jetty.version>9.2.9.v20150224</jetty.version>
157-
<junit.version>4.13.2</junit.version>
157+
<junit.version>5.10.2</junit.version>
158158
<logback.version>1.4.14</logback.version>
159159
<cxf.version>3.2.7</cxf.version>
160160
<jackson.jaxrs.version>2.15.2</jackson.jaxrs.version>

samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml/src/test/java/org/openapitools/client/api/PetApiTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
import java.io.File;
1717
import org.openapitools.client.model.ModelApiResponse;
1818
import org.openapitools.client.model.Pet;
19-
import org.junit.Test;
20-
import org.junit.Before;
21-
import static org.junit.Assert.*;
19+
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.api.Test;
21+
import org.junit.jupiter.api.Assertions;
2222

2323
import org.eclipse.microprofile.rest.client.RestClientBuilder;
2424

@@ -40,7 +40,7 @@ public class PetApiTest {
4040
private PetApi client;
4141
private String baseUrl = "http://localhost:9080";
4242

43-
@Before
43+
@BeforeEach
4444
public void setup() throws MalformedURLException {
4545
// TODO initialize the client
4646
}
@@ -59,7 +59,7 @@ public void addPetTest() {
5959
// TODO: test validations
6060
Pet pet = null;
6161
//Pet response = api.addPet(pet);
62-
//assertNotNull(response);
62+
//Assertions.assertNotNull(response);
6363

6464

6565
}
@@ -78,7 +78,7 @@ public void deletePetTest() {
7878
Long petId = null;
7979
String apiKey = null;
8080
//api.deletePet(petId, apiKey);
81-
//assertNotNull(response);
81+
//Assertions.assertNotNull(response);
8282

8383

8484
}
@@ -96,7 +96,7 @@ public void findPetsByStatusTest() {
9696
// TODO: test validations
9797
List<String> status = null;
9898
//List<Pet> response = api.findPetsByStatus(status);
99-
//assertNotNull(response);
99+
//Assertions.assertNotNull(response);
100100

101101

102102
}
@@ -114,7 +114,7 @@ public void findPetsByTagsTest() {
114114
// TODO: test validations
115115
List<String> tags = null;
116116
//List<Pet> response = api.findPetsByTags(tags);
117-
//assertNotNull(response);
117+
//Assertions.assertNotNull(response);
118118

119119

120120
}
@@ -132,7 +132,7 @@ public void getPetByIdTest() {
132132
// TODO: test validations
133133
Long petId = null;
134134
//Pet response = api.getPetById(petId);
135-
//assertNotNull(response);
135+
//Assertions.assertNotNull(response);
136136

137137

138138
}
@@ -150,7 +150,7 @@ public void updatePetTest() {
150150
// TODO: test validations
151151
Pet pet = null;
152152
//Pet response = api.updatePet(pet);
153-
//assertNotNull(response);
153+
//Assertions.assertNotNull(response);
154154

155155

156156
}
@@ -170,7 +170,7 @@ public void updatePetWithFormTest() {
170170
String name = null;
171171
String status = null;
172172
//api.updatePetWithForm(petId, name, status);
173-
//assertNotNull(response);
173+
//Assertions.assertNotNull(response);
174174

175175

176176
}
@@ -190,7 +190,7 @@ public void uploadFileTest() {
190190
String additionalMetadata = null;
191191
org.apache.cxf.jaxrs.ext.multipart.Attachment _file = null;
192192
//ModelApiResponse response = api.uploadFile(petId, additionalMetadata, _file);
193-
//assertNotNull(response);
193+
//Assertions.assertNotNull(response);
194194

195195

196196
}

samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml/src/test/java/org/openapitools/client/api/StoreApiTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
package org.openapitools.client.api;
1515

1616
import org.openapitools.client.model.Order;
17-
import org.junit.Test;
18-
import org.junit.Before;
19-
import static org.junit.Assert.*;
17+
import org.junit.jupiter.api.BeforeEach;
18+
import org.junit.jupiter.api.Test;
19+
import org.junit.jupiter.api.Assertions;
2020

2121
import org.eclipse.microprofile.rest.client.RestClientBuilder;
2222

@@ -38,7 +38,7 @@ public class StoreApiTest {
3838
private StoreApi client;
3939
private String baseUrl = "http://localhost:9080";
4040

41-
@Before
41+
@BeforeEach
4242
public void setup() throws MalformedURLException {
4343
// TODO initialize the client
4444
}
@@ -57,7 +57,7 @@ public void deleteOrderTest() {
5757
// TODO: test validations
5858
String orderId = null;
5959
//api.deleteOrder(orderId);
60-
//assertNotNull(response);
60+
//Assertions.assertNotNull(response);
6161

6262

6363
}
@@ -74,7 +74,7 @@ public void deleteOrderTest() {
7474
public void getInventoryTest() {
7575
// TODO: test validations
7676
//Map<String, Integer> response = api.getInventory();
77-
//assertNotNull(response);
77+
//Assertions.assertNotNull(response);
7878

7979

8080
}
@@ -92,7 +92,7 @@ public void getOrderByIdTest() {
9292
// TODO: test validations
9393
Long orderId = null;
9494
//Order response = api.getOrderById(orderId);
95-
//assertNotNull(response);
95+
//Assertions.assertNotNull(response);
9696

9797

9898
}
@@ -110,7 +110,7 @@ public void placeOrderTest() {
110110
// TODO: test validations
111111
Order order = null;
112112
//Order response = api.placeOrder(order);
113-
//assertNotNull(response);
113+
//Assertions.assertNotNull(response);
114114

115115

116116
}

samples/client/petstore/java/microprofile-rest-client-3.0-jackson-with-xml/src/test/java/org/openapitools/client/api/UserApiTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
import java.util.Date;
1717
import org.openapitools.client.model.User;
18-
import org.junit.Test;
19-
import org.junit.Before;
20-
import static org.junit.Assert.*;
18+
import org.junit.jupiter.api.BeforeEach;
19+
import org.junit.jupiter.api.Test;
20+
import org.junit.jupiter.api.Assertions;
2121

2222
import org.eclipse.microprofile.rest.client.RestClientBuilder;
2323

@@ -39,7 +39,7 @@ public class UserApiTest {
3939
private UserApi client;
4040
private String baseUrl = "http://localhost:9080";
4141

42-
@Before
42+
@BeforeEach
4343
public void setup() throws MalformedURLException {
4444
// TODO initialize the client
4545
}
@@ -58,7 +58,7 @@ public void createUserTest() {
5858
// TODO: test validations
5959
User user = null;
6060
//api.createUser(user);
61-
//assertNotNull(response);
61+
//Assertions.assertNotNull(response);
6262

6363

6464
}
@@ -76,7 +76,7 @@ public void createUsersWithArrayInputTest() {
7676
// TODO: test validations
7777
List<User> user = null;
7878
//api.createUsersWithArrayInput(user);
79-
//assertNotNull(response);
79+
//Assertions.assertNotNull(response);
8080

8181

8282
}
@@ -94,7 +94,7 @@ public void createUsersWithListInputTest() {
9494
// TODO: test validations
9595
List<User> user = null;
9696
//api.createUsersWithListInput(user);
97-
//assertNotNull(response);
97+
//Assertions.assertNotNull(response);
9898

9999

100100
}
@@ -112,7 +112,7 @@ public void deleteUserTest() {
112112
// TODO: test validations
113113
String username = null;
114114
//api.deleteUser(username);
115-
//assertNotNull(response);
115+
//Assertions.assertNotNull(response);
116116

117117

118118
}
@@ -130,7 +130,7 @@ public void getUserByNameTest() {
130130
// TODO: test validations
131131
String username = null;
132132
//User response = api.getUserByName(username);
133-
//assertNotNull(response);
133+
//Assertions.assertNotNull(response);
134134

135135

136136
}
@@ -149,7 +149,7 @@ public void loginUserTest() {
149149
String username = null;
150150
String password = null;
151151
//String response = api.loginUser(username, password);
152-
//assertNotNull(response);
152+
//Assertions.assertNotNull(response);
153153

154154

155155
}
@@ -166,7 +166,7 @@ public void loginUserTest() {
166166
public void logoutUserTest() {
167167
// TODO: test validations
168168
//api.logoutUser();
169-
//assertNotNull(response);
169+
//Assertions.assertNotNull(response);
170170

171171

172172
}
@@ -185,7 +185,7 @@ public void updateUserTest() {
185185
String username = null;
186186
User user = null;
187187
//api.updateUser(username, user);
188-
//assertNotNull(response);
188+
//Assertions.assertNotNull(response);
189189

190190

191191
}

0 commit comments

Comments
 (0)