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

TEST PR #13

Open
wants to merge 9 commits into
base: 3.8
Choose a base branch
from
Open
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
25 changes: 6 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,9 @@ name: "Pull Request CI"
on:
- pull_request
jobs:
linux-validate-format:
name: Linux - Validate format
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 17 ]
steps:
- uses: actions/checkout@v4
- name: Install JDK {{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
check-latest: true
- name: Build with Maven
run: |
mvn -V -B -s .github/mvn-settings.xml verify -Dall-modules -Dvalidate-format -DskipTests -DskipITs -Dquarkus.container-image.build=false -Dquarkus.container-image.push=false
detect-test-suite-modules:
name: Detect Modules in PR
runs-on: ubuntu-latest
needs: [ linux-validate-format ]
steps:
- uses: actions/checkout@v4
- id: files
Expand All @@ -35,9 +17,14 @@ jobs:
CHANGED=""
MODULES_ARG=""

# If changed file have some special character, its path is surrounded with quotes which causing the if statement fail
CHANGED_FILE=$(echo ${{ steps.files.outputs.all_changed_and_modified_files }} | sed 's/\"/\\"/')

echo $CHANGED_FILE

for module in $MODULES
do
if [[ "${{ steps.files.outputs.all_changed_and_modified_files }}" =~ ("$module") ]] ; then
if [[ "$CHANGED_FILE" =~ ("$module") ]] ; then
CHANGED=$(echo $CHANGED" "$module)
fi
done
Expand Down
5 changes: 5 additions & 0 deletions http/rest-client-reactive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-fault-tolerance</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-junit5</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.quarkus.ts.http.restclient.reactive.multipart;

import static jakarta.ws.rs.core.MediaType.MULTIPART_FORM_DATA;

import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.FormParam;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

import org.jboss.resteasy.reactive.PartType;
import org.jboss.resteasy.reactive.RestForm;

@Path("/encoder-mode")
public interface EncoderModeRestClient {

@POST
@Consumes(MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
MyMultipartDTO doAPostRequestToThisResource(
@PartType(MediaType.TEXT_PLAIN) @FormParam("file1") java.nio.file.Path file1,
@PartType(MediaType.TEXT_PLAIN) @FormParam("file2") java.nio.file.Path file2,
@RestForm String otherField);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.quarkus.ts.http.restclient.reactive.multipart;

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

@RegisterRestClient(configKey = "encoder-mode-html5")
public interface Html5EncoderModeRestClient extends EncoderModeRestClient {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package io.quarkus.ts.http.restclient.reactive.multipart;

import java.util.List;
import java.util.Map;

public class Item {
public final String name;
public final long size;
public final String charset;
public final String fileContent;

public String getFileContent() {
return fileContent;
}

public String getName() {
return name;
}

public long getSize() {
return size;
}

public String getCharset() {
return charset;
}

public String getFileName() {
return fileName;
}

public boolean isFileItem() {
return isFileItem;
}

public Map<String, List<String>> getHeaders() {
return headers;
}

public final String fileName;
public final boolean isFileItem;
public final Map<String, List<String>> headers;
public boolean fileItem;

public Item(String name, long size, String charset, String fileName, boolean isFileItem,
Map<String, List<String>> headers, boolean fileItem, String fileContent) {
this.name = name;
this.size = size;
this.charset = charset;
this.fileName = fileName;
this.isFileItem = isFileItem;
this.headers = headers;
this.fileItem = fileItem;
this.fileContent = fileContent;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.quarkus.ts.http.restclient.reactive.multipart;

import java.util.List;

public class MyMultipartDTO {
private List<Item> items;

public MyMultipartDTO() {
}

public MyMultipartDTO(List<Item> items) {
this.items = items;
}

public List<Item> getItems() {
return items;
}

public void setItems(List<Item> items) {
this.items = items;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.quarkus.ts.http.restclient.reactive.multipart;

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

@RegisterRestClient(configKey = "encoder-mode-rfc1738")
public interface Rfc1738EncoderModeRestClient extends EncoderModeRestClient {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.quarkus.ts.http.restclient.reactive.multipart;

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

@RegisterRestClient(configKey = "encoder-mode-rfc3986")
public interface Rfc3986EncoderModeRestClient extends EncoderModeRestClient {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package io.quarkus.ts.http.restclient.reactive.resources;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import org.eclipse.microprofile.rest.client.inject.RestClient;
import org.jboss.resteasy.reactive.server.multipart.FormValue;
import org.jboss.resteasy.reactive.server.multipart.MultipartFormDataInput;

import io.quarkus.ts.http.restclient.reactive.multipart.EncoderModeRestClient;
import io.quarkus.ts.http.restclient.reactive.multipart.Html5EncoderModeRestClient;
import io.quarkus.ts.http.restclient.reactive.multipart.Item;
import io.quarkus.ts.http.restclient.reactive.multipart.MyMultipartDTO;
import io.quarkus.ts.http.restclient.reactive.multipart.Rfc1738EncoderModeRestClient;
import io.quarkus.ts.http.restclient.reactive.multipart.Rfc3986EncoderModeRestClient;

@Path("/encode")
public class MultipartPostEncoderModeResource {

private final Map<String, EncoderModeRestClient> modeToRestClient;

public MultipartPostEncoderModeResource(@RestClient Html5EncoderModeRestClient html5Client,
@RestClient Rfc1738EncoderModeRestClient rfc1738Client,
@RestClient Rfc3986EncoderModeRestClient rfc3986Client) {
this.modeToRestClient = Map.of("HTML5", html5Client, "RFC1738", rfc1738Client, "RFC3986", rfc3986Client);
}

@Path("{encoder-mode}")
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public MyMultipartDTO doAPostRequestToSimpleEncodeResource(MultipartFormDataInput input,
@PathParam("encoder-mode") String encoderMode) {

EncoderModeRestClient client = modeToRestClient.get(encoderMode);
if (!modeToRestClient.containsKey(encoderMode)) {
throw new WebApplicationException("Unsupported encoder mode" + encoderMode, Response.Status.BAD_REQUEST);
}

Map<String, Collection<FormValue>> formValues = input.getValues();

if (!formValues.containsKey("file1") || !formValues.containsKey("file2") || !formValues.containsKey("otherField")) {
throw new IllegalArgumentException("Missing mandatory fields!");
}

java.nio.file.Path file1 = formValues.get("file1").stream().findFirst().get().getFileItem().getFile();
java.nio.file.Path file2 = formValues.get("file2").stream().findFirst().get().getFileItem().getFile();
String otherField = formValues.get("otherField").stream().findFirst().get().getValue();

MyMultipartDTO response = client.doAPostRequestToThisResource(file1, file2, otherField);

List<Item> items = response.getItems();

return new MyMultipartDTO(items);
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
quarkus.tls.trust-all=true
quarkus.http.ssl.certificate.key-store-file=META-INF/keystore.jks
quarkus.http.ssl.certificate.key-store-password=password
quarkus.http.ssl.certificate.key-store-password=password
vertx-server-url=http://${quarkus.http.host:localhost}:${vertx-server-port}/
quarkus.rest-client.encoder-mode-html5.url=${vertx-server-url}
quarkus.rest-client.encoder-mode-html5.multipart-post-encoder-mode=HTML5
quarkus.rest-client.encoder-mode-rfc1738.url=${vertx-server-url}
quarkus.rest-client.encoder-mode-rfc1738.multipart-post-encoder-mode=RFC1738
quarkus.rest-client.encoder-mode-rfc3986.url=${vertx-server-url}
quarkus.rest-client.encoder-mode-rfc3986.multipart-post-encoder-mode=RFC3986
Loading
Loading