// Path: upload-parser-tests/src/test/java/com/github/elopteryx/upload/internal/integration/RequestSupplier.java
// static ByteBuffer withOneLargerPicture() {
//     return RequestBuilder.newBuilder(BOUNDARY)
//             .addFilePart("filefield", new byte[2048], "image/jpeg", "test.jpg")
//             .finish();
// }
// 
// Path: upload-parser-tests/src/test/java/com/github/elopteryx/upload/internal/integration/RequestSupplier.java
// static ByteBuffer withOneSmallerPicture() {
//     return RequestBuilder.newBuilder(BOUNDARY)
//             .addFilePart("filefield", new byte[512], "image/jpeg", "test.jpg")
//             .finish();
// }


import static com.github.elopteryx.upload.internal.integration.RequestSupplier.withOneLargerPicture;
import static com.github.elopteryx.upload.internal.integration.RequestSupplier.withOneSmallerPicture;
import io.undertow.Handlers;
import io.undertow.Undertow;
import io.undertow.servlet.Servlets;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.ByteBuffer;
import jakarta.servlet.http.HttpServletResponse;
                                .addMapping("/async")
                                .setAsyncSupported(true),
                        Servlets.servlet("BlockingUploadServlet", BlockingUploadServlet.class)
                                .addMapping("/blocking")
                                .setAsyncSupported(false)
                );

        final var manager = Servlets.defaultContainer().addDeployment(servletBuilder);
        manager.deploy();
        final var path = Handlers.path(Handlers.redirect("/")).addPrefixPath("/", manager.start());

        server = Undertow.builder()
                .addHttpListener(8080, "localhost")
                .setHandler(path)
                .build();
        server.start();
    }

    @Test
    void test_with_a_real_request_simple_async() throws IOException {
        performRequest("http://localhost:8080/async?" + ClientRequest.SIMPLE, HttpServletResponse.SC_OK);
    }

    @Test
    void test_with_a_real_request_simple_blocking() throws IOException {
        performRequest("http://localhost:8080/blocking?" + ClientRequest.SIMPLE, HttpServletResponse.SC_OK);
    }

    @Test
    void test_with_a_real_request_threshold_lesser_async() throws IOException {
// Path: upload-parser-tests/src/test/java/com/github/elopteryx/upload/internal/integration/RequestSupplier.java
// static ByteBuffer withOneLargerPicture() {
//     return RequestBuilder.newBuilder(BOUNDARY)
//             .addFilePart("filefield", new byte[2048], "image/jpeg", "test.jpg")
//             .finish();
// }
// 
// Path: upload-parser-tests/src/test/java/com/github/elopteryx/upload/internal/integration/RequestSupplier.java
// static ByteBuffer withOneSmallerPicture() {
//     return RequestBuilder.newBuilder(BOUNDARY)
//             .addFilePart("filefield", new byte[512], "image/jpeg", "test.jpg")
//             .finish();
// }


// Path: upload-parser-tests/src/test/java/com/github/elopteryx/upload/internal/integration/UndertowIntegrationTest.java
import static com.github.elopteryx.upload.internal.integration.RequestSupplier.withOneLargerPicture;
import static com.github.elopteryx.upload.internal.integration.RequestSupplier.withOneSmallerPicture;
import io.undertow.Handlers;
import io.undertow.Undertow;
import io.undertow.servlet.Servlets;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.ByteBuffer;
import jakarta.servlet.http.HttpServletResponse;

                                .addMapping("/async")
                                .setAsyncSupported(true),
                        Servlets.servlet("BlockingUploadServlet", BlockingUploadServlet.class)
                                .addMapping("/blocking")
                                .setAsyncSupported(false)
                );

        final var manager = Servlets.defaultContainer().addDeployment(servletBuilder);
        manager.deploy();
        final var path = Handlers.path(Handlers.redirect("/")).addPrefixPath("/", manager.start());

        server = Undertow.builder()
                .addHttpListener(8080, "localhost")
                .setHandler(path)
                .build();
        server.start();
    }

    @Test
    void test_with_a_real_request_simple_async() throws IOException {
        performRequest("http://localhost:8080/async?" + ClientRequest.SIMPLE, HttpServletResponse.SC_OK);
    }

    @Test
    void test_with_a_real_request_simple_blocking() throws IOException {
        performRequest("http://localhost:8080/blocking?" + ClientRequest.SIMPLE, HttpServletResponse.SC_OK);
    }

    @Test
    void test_with_a_real_request_threshold_lesser_async() throws IOException {
        performRequest("http://localhost:8080/async?" + ClientRequest.THRESHOLD_LESSER, HttpServletResponse.SC_OK, withOneSmallerPicture());