Skip to content

Commit 72cec10

Browse files
authored
Fix Windows build failure in some environments (#10529)
* update surefire to newer version * more fixes * update pet.proto * update model protobuf template * add charset * set line separator * set proper line break in proto test * minor fix * use UTF-8 * use FileUtils.contentEquals * remove line break * remove line breaks * revert utf-8 change
1 parent 9aadd77 commit 72cec10

File tree

14 files changed

+35
-19
lines changed

14 files changed

+35
-19
lines changed

modules/openapi-generator/src/main/resources/protobuf-schema/partial_header.mustache

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
{{{.}}}
88

99
{{/appDescription}}
10-
{{#version}}The version of the OpenAPI document: {{{.}}}{{/version}}
11-
{{#infoEmail}}Contact: {{{.}}}{{/infoEmail}}
10+
{{#version}}
11+
The version of the OpenAPI document: {{{.}}}
12+
13+
{{/version}}
14+
{{#infoEmail}}
15+
Contact: {{{.}}}
16+
17+
{{/infoEmail}}
1218
Generated by OpenAPI Generator: https://openapi-generator.tech
1319
*/

modules/openapi-generator/src/test/java/org/openapitools/codegen/markdown/MarkdownSampleGeneratorTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.util.List;
99

1010
import org.apache.commons.io.FileUtils;
11-
1211
import org.openapitools.codegen.DefaultGenerator;
1312
import org.openapitools.codegen.config.CodegenConfigurator;
1413
import org.testng.Assert;
@@ -21,6 +20,8 @@ public class MarkdownSampleGeneratorTest {
2120

2221
@BeforeClass
2322
public void beforeClassGenerateTestMarkup() throws Exception {
23+
// set line break to \n across all platforms
24+
System.setProperty("line.separator", "\n");
2425

2526
this.outputTempDirectory = Files.createTempDirectory("test-markdown-sample-generator.").toFile();
2627

@@ -44,8 +45,8 @@ public void testSampleMarkdownGeneration() throws IOException {
4445

4546
Assert.assertTrue(expected.exists(), "Could not find " + expected.toString());
4647

47-
Assert.assertEquals(FileUtils.readFileToString(generated),
48-
FileUtils.readFileToString(expected, StandardCharsets.UTF_8));
48+
Assert.assertEquals(FileUtils.readFileToString(generated, StandardCharsets.UTF_8).replace("\n", "").replace("\r", ""),
49+
FileUtils.readFileToString(expected, StandardCharsets.UTF_8).replace("\n", "").replace("\r", ""));
4950
}
5051
}
5152

modules/openapi-generator/src/test/java/org/openapitools/codegen/protobuf/ProtobufSchemaCodegenTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public void testFeatureSet() {
4949

5050
@Test
5151
public void testCodeGenWithAllOf() throws IOException {
52+
// set line break to \n across all platforms
53+
System.setProperty("line.separator", "\n");
54+
5255
File output = Files.createTempDirectory("test").toFile();
5356

5457
final CodegenConfigurator configurator = new CodegenConfigurator()
@@ -69,9 +72,11 @@ public void testCodeGenWithAllOf() throws IOException {
6972
}
7073

7174
private void assertFileEquals(Path generatedFilePath, Path expectedFilePath) throws IOException {
72-
String generatedFile = new String(Files.readAllBytes(generatedFilePath), StandardCharsets.UTF_8);
73-
String expectedFile = new String(Files.readAllBytes(expectedFilePath), StandardCharsets.UTF_8);
75+
String generatedFile = new String(Files.readAllBytes(generatedFilePath), StandardCharsets.UTF_8)
76+
.replace("\n", "").replace("\r", "");
77+
String expectedFile = new String(Files.readAllBytes(expectedFilePath), StandardCharsets.UTF_8)
78+
.replace("\n", "").replace("\r", "");
7479

7580
assertEquals(generatedFile, expectedFile);
7681
}
77-
}
82+
}

modules/openapi-generator/src/test/resources/3_0/protobuf-schema/pet.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
55
66
The version of the OpenAPI document: 1.0.0
7-
7+
88
Generated by OpenAPI Generator: https://openapi-generator.tech
99
*/
1010

pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,14 @@
226226
<version>${surefire-version}</version>
227227
<configuration>
228228
<printSummary>true</printSummary>
229+
<forkedProcessExitTimeoutInSeconds>120</forkedProcessExitTimeoutInSeconds>
229230
<useSystemClassLoader>false</useSystemClassLoader>
230231
<junitArtifactName>none:none</junitArtifactName>
231232
<testNGArtifactName>org.testng:testng</testNGArtifactName>
232233
<argLine>@{argLine} -XX:+StartAttachListener</argLine>
234+
<forkCount>3</forkCount>
235+
<reuseForks>true</reuseForks>
236+
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
233237
<systemPropertyVariables>
234238
<org.openapitools.codegen.utils.oncelogger.expiry>1000</org.openapitools.codegen.utils.oncelogger.expiry>
235239
<org.openapitools.codegen.utils.oncelogger.cachesize>5000</org.openapitools.codegen.utils.oncelogger.cachesize>
@@ -1618,7 +1622,7 @@
16181622
<jmustache-version>1.14</jmustache-version>
16191623
<handlebars.java-version>4.2.1</handlebars.java-version>
16201624
<testng-version>7.1.0</testng-version>
1621-
<surefire-version>3.0.0-M3</surefire-version>
1625+
<surefire-version>3.0.0-M5</surefire-version>
16221626
<reflections-version>0.9.10</reflections-version>
16231627
<mockito-version>3.6.28</mockito-version>
16241628
<jacoco.version>0.8.5</jacoco.version>

samples/config/petstore/protobuf-schema/models/api_response.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
55
66
The version of the OpenAPI document: 1.0.0
7-
7+
88
Generated by OpenAPI Generator: https://openapi-generator.tech
99
*/
1010

samples/config/petstore/protobuf-schema/models/category.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
55
66
The version of the OpenAPI document: 1.0.0
7-
7+
88
Generated by OpenAPI Generator: https://openapi-generator.tech
99
*/
1010

samples/config/petstore/protobuf-schema/models/order.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
55
66
The version of the OpenAPI document: 1.0.0
7-
7+
88
Generated by OpenAPI Generator: https://openapi-generator.tech
99
*/
1010

samples/config/petstore/protobuf-schema/models/pet.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
55
66
The version of the OpenAPI document: 1.0.0
7-
7+
88
Generated by OpenAPI Generator: https://openapi-generator.tech
99
*/
1010

samples/config/petstore/protobuf-schema/models/tag.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
55
66
The version of the OpenAPI document: 1.0.0
7-
7+
88
Generated by OpenAPI Generator: https://openapi-generator.tech
99
*/
1010

0 commit comments

Comments
 (0)