Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Java RESTEasy Echo API client tests #17473

Merged
merged 1 commit into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/samples-java-client-echo-api-jdk11.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- samples/client/echo_api/java/native
- samples/client/echo_api/java/feign-gson
- samples/client/echo_api/java/resttemplate
- samples/client/echo_api/java/resteasy
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/samples-java-client-echo-api-jdk8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ on:
- samples/client/echo_api/java/feign-gson/**
- samples/client/echo_api/java/okhttp-gson/**
- samples/client/echo_api/java/resttemplate/**
- samples/client/echo_api/java/resteasy/**
pull_request:
paths:
- samples/client/echo_api/java/apache-httpclient/**
- samples/client/echo_api/java/feign-gson/**
- samples/client/echo_api/java/okhttp-gson/**
- samples/client/echo_api/java/resttemplate/**
- samples/client/echo_api/java/resteasy/**
jobs:
build:
name: Build Java Client JDK8
Expand All @@ -26,6 +27,7 @@ jobs:
- samples/client/echo_api/java/feign-gson
- samples/client/echo_api/java/okhttp-gson
- samples/client/echo_api/java/resttemplate
- samples/client/echo_api/java/resteasy
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
generatorName: java
outputDir: samples/client/petstore/java/resteasy-echo
outputDir: samples/client/echo_api/java/resteasy
inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Echo Server API
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


package org.openapitools.client.api;

import org.openapitools.client.ApiException;
import java.io.File;
import org.openapitools.client.model.Pet;
import org.openapitools.client.model.Tag;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.Assert;

import java.io.FileWriter;
import java.io.IOException;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;

/**
* API tests
*/
public class CustomTest {

private final BodyApi api = new BodyApi();

/**
* Test single binary in multipart mime
*
* @see
* <a href="https://github.com/OpenAPITools/openapi-generator/issues/17367">#17367</a>
*/
@Test
public void testBodyMultipartFormdataSingleBinaryTest() throws ApiException, IOException {
File myFile = new File("test.txt");
if (!myFile.exists()){
assertTrue(myFile.createNewFile());
}
FileWriter fw = new FileWriter(myFile);
fw.write("testing only");
fw.close();
myFile.deleteOnExit();

String response =
api.testBodyMultipartFormdataSingleBinary(myFile);

EchoServerResponseParser parser =
new EchoServerResponseParser(response);

String contentDisposition = parser.headers.get("Content-Disposition");

assertThat(contentDisposition, containsString(
"form-data; name=\"my-file\"; filename=\"test.txt\""
));
}
}
Loading