Skip to content

Commit 854e521

Browse files
upgrade java native to junit5 (#18617)
* upgrade java native to junit5 * upgrade build.gradle, optimize imports * upgrade gradle, re-generate samples * migrate api_test.mustache and petstore tests of native-async & native-jakarta
1 parent 29cfa33 commit 854e521

214 files changed

Lines changed: 686 additions & 837 deletions

File tree

Some content is hidden

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

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ package {{package}};
55
import {{invokerPackage}}.ApiException;
66
{{#imports}}import {{import}};
77
{{/imports}}
8-
import org.junit.Test;
9-
import org.junit.Ignore;
8+
import org.junit.jupiter.api.Disabled;
9+
import org.junit.jupiter.api.Test;
1010

1111
import java.util.ArrayList;
1212
import java.util.HashMap;
@@ -21,7 +21,7 @@ import java.util.concurrent.CompletableFuture;
2121
/**
2222
* API tests for {{classname}}
2323
*/
24-
@Ignore
24+
@Disabled
2525
public class {{classname}}Test {
2626
2727
private final {{classname}} api = new {{classname}}();

modules/openapi-generator/src/main/resources/Java/libraries/native/build.gradle.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ ext {
7474
{{/swagger2AnnotationLibrary}}
7575
jackson_version = "2.14.1"
7676
jakarta_annotation_version = "1.3.5"
77-
junit_version = "4.13.2"
77+
junit_version = "5.10.2"
7878
{{#hasFormParamsInSpec}}
7979
httpmime_version = "4.5.13"
8080
{{/hasFormParamsInSpec}}
@@ -97,7 +97,7 @@ dependencies {
9797
{{#hasFormParamsInSpec}}
9898
implementation "org.apache.httpcomponents:httpmime:$httpmime_version"
9999
{{/hasFormParamsInSpec}}
100-
testImplementation "junit:junit:$junit_version"
100+
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
101101
}
102102

103103
// Use spotless plugin to automatically format code, remove unused import, etc

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
</plugin>
6565
<plugin>
6666
<artifactId>maven-surefire-plugin</artifactId>
67-
<version>3.0.0-M7</version>
67+
<version>3.2.5</version>
6868
<configuration>
6969
<systemPropertyVariables>
7070
<loggerPath>conf/log4j.properties</loggerPath>
@@ -265,8 +265,8 @@
265265
266266
<!-- test dependencies -->
267267
<dependency>
268-
<groupId>junit</groupId>
269-
<artifactId>junit</artifactId>
268+
<groupId>org.junit.jupiter</groupId>
269+
<artifactId>junit-jupiter-api</artifactId>
270270
<version>${junit-version}</version>
271271
<scope>test</scope>
272272
</dependency>
@@ -293,7 +293,7 @@
293293
{{#hasFormParamsInSpec}}
294294
<httpmime-version>4.5.14</httpmime-version>
295295
{{/hasFormParamsInSpec}}
296-
<junit-version>4.13.2</junit-version>
296+
<junit-version>5.10.2</junit-version>
297297
<spotless.version>2.27.2</spotless.version>
298298
</properties>
299299
</project>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package {{package}};
33
import {{invokerPackage}}.ApiClient;
44
{{#imports}}import {{import}};
55
{{/imports}}
6-
import org.junit.Before;
7-
import org.junit.Test;
6+
import org.junit.jupiter.api.BeforeEach;
7+
import org.junit.jupiter.api.Test;
88

99
import java.util.ArrayList;
1010
import java.util.HashMap;

samples/client/echo_api/java/native/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ artifacts {
6868
ext {
6969
jackson_version = "2.14.1"
7070
jakarta_annotation_version = "1.3.5"
71-
junit_version = "4.13.2"
71+
junit_version = "5.10.2"
7272
httpmime_version = "4.5.13"
7373
}
7474

@@ -81,7 +81,7 @@ dependencies {
8181
implementation "org.openapitools:jackson-databind-nullable:0.2.1"
8282
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
8383
implementation "org.apache.httpcomponents:httpmime:$httpmime_version"
84-
testImplementation "junit:junit:$junit_version"
84+
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
8585
}
8686

8787
// Use spotless plugin to automatically format code, remove unused import, etc

samples/client/echo_api/java/native/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
</plugin>
5858
<plugin>
5959
<artifactId>maven-surefire-plugin</artifactId>
60-
<version>3.0.0-M7</version>
60+
<version>3.2.5</version>
6161
<configuration>
6262
<systemPropertyVariables>
6363
<loggerPath>conf/log4j.properties</loggerPath>
@@ -242,8 +242,8 @@
242242

243243
<!-- test dependencies -->
244244
<dependency>
245-
<groupId>junit</groupId>
246-
<artifactId>junit</artifactId>
245+
<groupId>org.junit.jupiter</groupId>
246+
<artifactId>junit-jupiter-api</artifactId>
247247
<version>${junit-version}</version>
248248
<scope>test</scope>
249249
</dependency>
@@ -257,7 +257,7 @@
257257
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
258258
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
259259
<httpmime-version>4.5.14</httpmime-version>
260-
<junit-version>4.13.2</junit-version>
260+
<junit-version>5.10.2</junit-version>
261261
<spotless.version>2.27.2</spotless.version>
262262
</properties>
263263
</project>

samples/client/echo_api/java/native/src/test/java/org/openapitools/client/CustomTest.java

Lines changed: 78 additions & 78 deletions
Large diffs are not rendered by default.

samples/client/echo_api/java/native/src/test/java/org/openapitools/client/api/AuthApiTest.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,15 @@
1313

1414
package org.openapitools.client.api;
1515

16+
import org.junit.jupiter.api.Disabled;
17+
import org.junit.jupiter.api.Test;
1618
import org.openapitools.client.ApiException;
17-
import org.junit.Test;
18-
import org.junit.Ignore;
19-
20-
import java.util.ArrayList;
21-
import java.util.HashMap;
22-
import java.util.List;
23-
import java.util.Map;
24-
import java.util.Set;
2519

2620

2721
/**
2822
* API tests for AuthApi
2923
*/
30-
@Ignore
24+
@Disabled
3125
public class AuthApiTest {
3226

3327
private final AuthApi api = new AuthApi();

samples/client/echo_api/java/native/src/test/java/org/openapitools/client/api/BodyApiTest.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,16 @@
1313

1414
package org.openapitools.client.api;
1515

16+
import org.junit.jupiter.api.Disabled;
17+
import org.junit.jupiter.api.Test;
1618
import org.openapitools.client.ApiException;
1719
import org.openapitools.client.model.Pet;
18-
import org.junit.Test;
19-
import org.junit.Ignore;
20-
21-
import java.util.ArrayList;
22-
import java.util.HashMap;
23-
import java.util.List;
24-
import java.util.Map;
25-
import java.util.Set;
2620

2721

2822
/**
2923
* API tests for BodyApi
3024
*/
31-
@Ignore
25+
@Disabled
3226
public class BodyApiTest {
3327

3428
private final BodyApi api = new BodyApi();

samples/client/echo_api/java/native/src/test/java/org/openapitools/client/api/FormApiTest.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,15 @@
1313

1414
package org.openapitools.client.api;
1515

16+
import org.junit.jupiter.api.Disabled;
17+
import org.junit.jupiter.api.Test;
1618
import org.openapitools.client.ApiException;
17-
import org.junit.Test;
18-
import org.junit.Ignore;
19-
20-
import java.util.ArrayList;
21-
import java.util.HashMap;
22-
import java.util.List;
23-
import java.util.Map;
24-
import java.util.Set;
2519

2620

2721
/**
2822
* API tests for FormApi
2923
*/
30-
@Ignore
24+
@Disabled
3125
public class FormApiTest {
3226

3327
private final FormApi api = new FormApi();

0 commit comments

Comments
 (0)