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
This commit is contained in:
William Cheng 2021-10-05 20:37:24 +08:00 committed by GitHub
parent 9aadd7724c
commit 72cec10edf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 35 additions and 19 deletions

View File

@ -7,7 +7,13 @@
{{{.}}}
{{/appDescription}}
{{#version}}The version of the OpenAPI document: {{{.}}}{{/version}}
{{#infoEmail}}Contact: {{{.}}}{{/infoEmail}}
{{#version}}
The version of the OpenAPI document: {{{.}}}
{{/version}}
{{#infoEmail}}
Contact: {{{.}}}
{{/infoEmail}}
Generated by OpenAPI Generator: https://openapi-generator.tech
*/

View File

@ -8,7 +8,6 @@ import java.nio.file.Path;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.openapitools.codegen.DefaultGenerator;
import org.openapitools.codegen.config.CodegenConfigurator;
import org.testng.Assert;
@ -21,6 +20,8 @@ public class MarkdownSampleGeneratorTest {
@BeforeClass
public void beforeClassGenerateTestMarkup() throws Exception {
// set line break to \n across all platforms
System.setProperty("line.separator", "\n");
this.outputTempDirectory = Files.createTempDirectory("test-markdown-sample-generator.").toFile();
@ -44,8 +45,8 @@ public class MarkdownSampleGeneratorTest {
Assert.assertTrue(expected.exists(), "Could not find " + expected.toString());
Assert.assertEquals(FileUtils.readFileToString(generated),
FileUtils.readFileToString(expected, StandardCharsets.UTF_8));
Assert.assertEquals(FileUtils.readFileToString(generated, StandardCharsets.UTF_8).replace("\n", "").replace("\r", ""),
FileUtils.readFileToString(expected, StandardCharsets.UTF_8).replace("\n", "").replace("\r", ""));
}
}

View File

@ -49,6 +49,9 @@ public class ProtobufSchemaCodegenTest {
@Test
public void testCodeGenWithAllOf() throws IOException {
// set line break to \n across all platforms
System.setProperty("line.separator", "\n");
File output = Files.createTempDirectory("test").toFile();
final CodegenConfigurator configurator = new CodegenConfigurator()
@ -69,9 +72,11 @@ public class ProtobufSchemaCodegenTest {
}
private void assertFileEquals(Path generatedFilePath, Path expectedFilePath) throws IOException {
String generatedFile = new String(Files.readAllBytes(generatedFilePath), StandardCharsets.UTF_8);
String expectedFile = new String(Files.readAllBytes(expectedFilePath), StandardCharsets.UTF_8);
String generatedFile = new String(Files.readAllBytes(generatedFilePath), StandardCharsets.UTF_8)
.replace("\n", "").replace("\r", "");
String expectedFile = new String(Files.readAllBytes(expectedFilePath), StandardCharsets.UTF_8)
.replace("\n", "").replace("\r", "");
assertEquals(generatedFile, expectedFile);
}
}
}

View File

@ -4,7 +4,7 @@
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/

View File

@ -226,10 +226,14 @@
<version>${surefire-version}</version>
<configuration>
<printSummary>true</printSummary>
<forkedProcessExitTimeoutInSeconds>120</forkedProcessExitTimeoutInSeconds>
<useSystemClassLoader>false</useSystemClassLoader>
<junitArtifactName>none:none</junitArtifactName>
<testNGArtifactName>org.testng:testng</testNGArtifactName>
<argLine>@{argLine} -XX:+StartAttachListener</argLine>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
<systemPropertyVariables>
<org.openapitools.codegen.utils.oncelogger.expiry>1000</org.openapitools.codegen.utils.oncelogger.expiry>
<org.openapitools.codegen.utils.oncelogger.cachesize>5000</org.openapitools.codegen.utils.oncelogger.cachesize>
@ -1618,7 +1622,7 @@
<jmustache-version>1.14</jmustache-version>
<handlebars.java-version>4.2.1</handlebars.java-version>
<testng-version>7.1.0</testng-version>
<surefire-version>3.0.0-M3</surefire-version>
<surefire-version>3.0.0-M5</surefire-version>
<reflections-version>0.9.10</reflections-version>
<mockito-version>3.6.28</mockito-version>
<jacoco.version>0.8.5</jacoco.version>

View File

@ -4,7 +4,7 @@
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/

View File

@ -4,7 +4,7 @@
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/

View File

@ -4,7 +4,7 @@
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/

View File

@ -4,7 +4,7 @@
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/

View File

@ -4,7 +4,7 @@
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/

View File

@ -4,7 +4,7 @@
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/

View File

@ -4,7 +4,7 @@
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/

View File

@ -4,7 +4,7 @@
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/

View File

@ -4,7 +4,7 @@
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator: https://openapi-generator.tech
*/