Skip to content

Commit

Permalink
Integration tests for compressors
Browse files Browse the repository at this point in the history
  • Loading branch information
Karm committed May 21, 2024
1 parent ee138f6 commit 08419ef
Show file tree
Hide file tree
Showing 19 changed files with 617 additions and 0 deletions.
1 change: 1 addition & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
<module>hibernate-orm-jpamodelgen</module>
<module>hibernate-orm-envers</module>
<module>vertx-http</module>
<module>vertx-http-compressors</module>
<module>vertx-web</module>
<module>vertx-web-jackson</module>
<module>vertx</module>
Expand Down
12 changes: 12 additions & 0 deletions integration-tests/vertx-http-compressors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Compressors
===========

All
---

Adds Brotli compressors, tweaks defaults.

Some
----

Tests compressors in our default setting with Native Image.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file disables the unbind-executions profile in the quarkus-integration-tests-parent.
87 changes: 87 additions & 0 deletions integration-tests/vertx-http-compressors/all/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-integration-test-vertx-http-compressors-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>quarkus-integration-test-vertx-http-compressors-all</artifactId>
<name>Quarkus - Integration Tests - Vertx Http Compressors - All</name>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-integration-test-vertx-http-compressors-app</artifactId>
<version>${project.version}</version>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-integration-test-vertx-http-compressors-app</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>

<!-- Minimal test dependencies to *-deployment artifacts for consistent build order -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.quarkus.compressors.it;

import jakarta.ws.rs.Path;

@Path("/compressed")
public class AllCompressedResource extends CompressedResource {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.quarkus.compressors.it;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
public class RESTEndpointsIT extends RESTEndpointsTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.quarkus.compressors.it;

import static io.quarkus.compressors.it.Testflow.runTest;

import java.net.URL;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

import io.quarkus.test.common.http.TestHTTPResource;
import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
public class RESTEndpointsTest {

@TestHTTPResource(value = "/compressed")
URL url;

@ParameterizedTest
@CsvSource(value = {
//@formatter:off
// Context | Accept-Encoding | Content-Encoding | Content-Length
"/yes/text | deflate,gzip,br | br | 2316",
"/yes/text | deflate | deflate | 2402",
"/no/text | deflate,gzip,br | null | 6483",
"/yes/json | deflate | deflate | 2402",
"/no/json | deflate,gzip,br | null | 6483",
"/yes/xml | deflate,gzip,br | br | 2316",
"/no/xml | deflate,gzip,br | null | 6483",
"/yes/xhtml| deflate,gzip | gzip | 2414",
//@formatter:on
}, delimiter = '|', ignoreLeadingAndTrailingWhitespace = true, nullValues = "null")
public void testCompressors(String endpoint, String acceptEncoding, String contentEncoding, String contentLength) {
runTest(url.toString() + endpoint, acceptEncoding, contentEncoding, contentLength);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
quarkus.http.enable-compression=true
# Brotli is not present by default, so we add it all here:
quarkus.http.compressors=deflate,gzip,br
# This test the level actually makes impact. When left to default,
# the test fails.
quarkus.http.compression-level=9
# Overriding default to test it plays well with @Uncompressed and
# @Compressed annotations.
quarkus.http.compress-media-types=application/xhtml+xml,text/xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file disables the unbind-executions profile in the quarkus-integration-tests-parent.
57 changes: 57 additions & 0 deletions integration-tests/vertx-http-compressors/app/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-integration-test-vertx-http-compressors-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>quarkus-integration-test-vertx-http-compressors-app</artifactId>
<name>Quarkus - Integration Tests - Vertx Http Compressors - App</name>
<dependencies>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package io.quarkus.compressors.it;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import io.quarkus.vertx.http.Compressed;
import io.quarkus.vertx.http.Uncompressed;

public class CompressedResource {

// If you touch this block of text, you need to adjust byte numbers in RESTEndpointsTest too.
// The text is not entirely arbitrary, it shows different compress ratios for
// Brotli and GZip while still being reasonably short.
public static final String TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor "
+ "incididunt ut labore et <SOME TAG></SOME TAG> <SOME TAG></SOME TAG> minim veniam, quis nostrud exercitation"
+ "dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip "
+ "ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu "
+ "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
+ "mollit anim id est laborum. consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et "
+ "dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip "
+ "ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu "
+ "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
+ "mollit anim id est laborum. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia XXX "
+ "❀ੈ✩‧₊˚✧˚༘ ☹#️©️®️‼️⁉️™️ℹ️↔️↕️↖️↗️↘️↙️↩️↪️⌚⌛⌨️⏏️⏩⏬⏭️⏮️⏯️⏰⏱️⏲️⏳⏸️⏹️⏺️Ⓜ️▪️▫️▶️◀️◻️◼️◽◾☀️☁️☂️☃️☄️☎️☑️☔☕☘️☝️☝☝☝☝☝☠️☢️☣️☦️☪️"
+ "☮️☯️☸️☹️☺️♀️♂️♈♓♟️♠️♣️♥️♦️♨️♻️♾️♿⚒️⚓⚔️⚕️⚖️⚗️⚙️⚛️⚜️⚠️⚡⚧️⚪⚫⚰️⚱️⚽⚾⛄⛅⛈️⛎⛏️⛑️⛓️⛔⛩️⛪⛰️⛱️⛲⛳⛴️⛵⛷️⛸️⛹️⛹⛹⛹⛹⛹⛺"
+ "⛽✂️✅✈️✉️✊✋✊✊✊✊✊✋✋✋✋✋✌️✌✌✌✌✌✍️✍✍✍✍✍✏️✒️✔️✖️✝️✡️✨✳️✴️❄️❇️❌❎❓❕❗❣️❤️➕➗➡️➰➿⤴️⤵️⬅️⬆️⬇️⬛⬜⭐"
+ "⭕〰️〽️㊗️㊙️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️️⋆。♡˚✧˚ ༘ ⋆。♡˚ consectetur adipiscing elit. Phasellus interdum erat ligula, eget consectetur consect"
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus interdum erat ligula, eget consectetur justo"
+ "porttitor nec. Sed at est auctor, suscipit erat at, volutpat purus. Nulla facilisi. Praesent suscipit purus vel"
+ "nisl pharetra, in sagittis neque tincidunt. Curabitur sit amet ligula nec nisi mollis vehicula. Morbi sit amet "
+ "magna vitae arcu bibendum interdum. Vestibulum luctus felis sed tellus egestas, non suscipit risus dignissim. "
+ "Integer auctor tincidunt purus, ac posuere massa tristique id. Fusce varius eu ex ut cursus. Vestibulum vehicula"
+ "purus ut orci fermentum, ut feugiat dui fringilla. Ut in turpis at odio bibendum lacinia. 4231032147093284721037"
+ "Duis ultrices semper velit ut varius. Nam porttitor magna sed dui vestibulum, nec bibendum tortor convallis. 666"
+ "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In at augue quis "
+ "justo aliquet aliquet ut non eros. Vestibulum finibus ligula magna, at euismod tortor efficitur sit amet. Aliquam"
+ "erat volutpat. Curabitur bibendum orci vel risus fermentum, a gravida nulla placerat. Morbi condimentum dolor et "
+ "ex finibus, et finibus magna congue. Integer et odio ut sapien aliquam pharetra. Curabitur pharetra urna id felis"
+ "fringilla tincidunt. Suspendisse a erat quis enim pharetra mollis. Fusce vel est non odio tincidunt vulputate a "
+ "nec sem. Donec finibus sapien sed purus tincidunt, ac venenatis felis hendrerit. Ut consectetur lacus vel urna "
+ "suscipit, sed laoreet nulla volutpat.\n\r\n\r\n\r\n\t\t\t\n\r\n\r\n\r\n\r\n\t\t\t\n\r\n\r\n\r\n\r\n\t\t\t\n\r\r\r"
+ "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec consequat "
+ "purus a odio gravida, vel convallis justo volutpat. Integer in magna a ante porttitor ultricies at id dui. Nullam "
+ "elementum sapien ut magna posuere suscipit. Proin aliquam dolor et quam suscipit bibendum. Aenean suscipit velit "
+ "vel lectus posuere, ut convallis nulla consequat. In at lorem fermentum, dignissim nulla ut, consectetur enim. "
+ "Maecenas vestibulum felis id justo blandit suscipit. Nulla facilisi. Duis elementum orci nec sapien accumsan, eget "
+ "tempus turpis rhoncus. Quisque porttitor, mi in auctor fermentum, mi orci hendrerit risus, in dignissim erat nunc "
+ "Morbi faucibus quam vel libero pharetra, non ultricies felis laoreet. Duis vulputate purus id sem interdum, vel "
+ "risus gravida. Vestibulum vulputate purus non lorem ultricies varius. Donec bibendum libero a mi sollicitudin \n"
+ "Praesent sed diam nec nunc pharetra malesuada nec ac urna. Nam id dui id eros vulputate pellentesque. Nulla malesuada e"
+ "ros eu enim finibus, sit amet posuere leo condimentum. Curabitur in mauris lacus. Aenean nec enim ut elit bibendum suscipit ac "
+ "nec nunc. Vestibulum vitae libero ac ipsum faucibus scelerisque. Curabitur ut lorem feugiat, pellentesque risus sit amet, "
+ "vehicula metus. Quisque vulputate arcu et magna vehicula pharetra. Integer gravida diam et dolor hendrerit, nec suscipit odio "
+ "vehicula. Donec sit amet turpis ut nulla viverra pharetra. Aenean commodo nisl ut risus fermentum vehicula. Suspendisse "
+ "at augue in lorem suscipit venenatis. Morbi interdum nibh eget ex posuere, sed convallis ipsum pharetra. Aliquam auctor "
+ "tincidunt urna, non dapibus risus fermentum ut. Phasellus convallis ipsum a diam consectetur, sit amet posuere erat viverra.\n"
+ "Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Quisque non orci scelerisque, "
+ "dapibus ipsum nec, laoreet magna. Suspendisse eget bibendum dui. Aenean bibendum augue vel risus laoreet faucibus. Donec "
+ "quis massa sapien. Nulla facilisi. Nulla facilisi. Nullam vel varius ipsum. Cras a tincidunt libero. Fusce efficitur felis "
+ "et pharetra cursus. Nullam venenatis mi nec libero auctor, nec cursus ligula dignissim. Phasellus eget libero consequat, "
+ "elementum erat sed, viverra odio. Suspendisse potenti. Aenean feugiat mi a tincidunt tristique. Sed fringilla magna nec "
+ "magna ultricies, id bibendum lacus faucibus. Maecenas porttitor libero sed lacus efficitur bibendum. Proin eget felis "
+ "dictum, malesuada ipsum ac, finibus nisl. ipsum ac, finibus nisl. 1234567890 148130 01394829387293 932583275295 2938573592\n";

@GET
@Path("/yes/text")
@Produces(MediaType.TEXT_PLAIN)
@Compressed
public Response textCompressed() {
return Response.ok(TEXT).build();
}

@GET
@Path("/no/text")
@Produces(MediaType.TEXT_PLAIN)
@Uncompressed
public String textUncompressed() {
return TEXT;
}

@GET
@Path("/yes/json")
@Produces(MediaType.APPLICATION_JSON)
@Compressed
public String jsonCompressed() {
// Doesn't matter the text ain't JSON, the test doesn't care.
// We need just the correct header.
return TEXT;
}

@GET
@Path("/no/json")
@Produces(MediaType.APPLICATION_JSON)
@Uncompressed
public String jsonUncompressed() {
return TEXT;
}

@GET
@Path("/yes/xml")
@Produces(MediaType.TEXT_XML)
// This one is compressed via default quarkus.http.compress-media-types
public String xmlCompressed() {
// Doesn't matter the text ain't XML, the test doesn't care.
// We need just the correct header.
return TEXT;
}

@GET
@Path("/no/xml")
@Produces(MediaType.TEXT_XML)
@Uncompressed
public String xmlUncompressed() {
return TEXT;
}

@GET
@Path("/yes/xhtml")
@Produces(MediaType.APPLICATION_XHTML_XML)
// This one is compressed quarkus.http.compress-media-types setting
public String xhtmlCompressed() {
// Doesn't matter the text ain't XML, the test doesn't care.
// We need just the correct header.
return TEXT;
}
}
Loading

0 comments on commit 08419ef

Please sign in to comment.