-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
335 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
39 changes: 39 additions & 0 deletions
39
...de4j/integration-tests/src/test/java/io/quarkiverse/barcode/it/Barcode4JResourceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.quarkiverse.barcode.it; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static jakarta.ws.rs.core.HttpHeaders.CONTENT_LENGTH; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.greaterThan; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
public class Barcode4JResourceTest { | ||
|
||
@Test | ||
public void testBarcode4JCode39Png() { | ||
given() | ||
.when().get("/barcode4j/code39/png") | ||
.then() | ||
.statusCode(200) | ||
.contentType(equalTo(BaseImageResource.PNG_MIME_TYPE)) | ||
.header(CONTENT_LENGTH, Integer::parseInt, greaterThan(0)) | ||
.body(notNullValue()); | ||
} | ||
|
||
@Test | ||
public void testBarcode4JCode39Svg() { | ||
given() | ||
.when().get("/barcode4j/code39/svg") | ||
.then() | ||
.statusCode(200) | ||
.contentType(equalTo(BaseImageResource.SVG_MIME_TYPE)) | ||
.header(CONTENT_LENGTH, Integer::parseInt, greaterThan(0)) | ||
.body(is( | ||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><svg height=\"17.8219mm\" viewBox=\"0 0 40.76 17.8219\" width=\"40.76mm\" xmlns=\"http://www.w3.org/2000/svg\"><g fill=\"black\" stroke=\"none\"><rect height=\"15\" width=\"0.1693\" x=\"0\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"0.6773\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"1.016\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"1.6933\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"2.3707\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"2.73\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"3.0687\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"3.4073\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"3.746\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"4.762\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"5.46\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"6.476\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"6.8147\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"7.1533\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"7.492\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"8.19\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"8.8673\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"9.206\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"9.8833\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"10.222\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"10.92\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"11.5973\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"11.936\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"12.2747\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"13.2907\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"13.65\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"14.3273\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"14.666\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"15.0047\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"15.682\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"16.38\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"17.396\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"17.7347\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"18.0733\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"18.412\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"19.11\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"19.4487\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"20.126\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"20.4647\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"21.4807\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"21.84\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"22.5173\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"23.1947\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"23.5333\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"24.2107\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"24.57\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"25.2473\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"25.586\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"25.9247\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"26.9407\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"27.3\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"27.9773\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"28.316\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"28.9933\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"29.6707\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"30.03\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"30.7073\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"31.3847\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"32.062\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"32.4007\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"32.76\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"33.4373\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"33.776\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"34.1147\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"34.792\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"35.49\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"35.8287\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"36.506\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"36.8447\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"37.8607\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"38.22\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"38.8973\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"39.236\" y=\"0\"/><rect height=\"15\" width=\"0.508\" x=\"39.9133\" y=\"0\"/><rect height=\"15\" width=\"0.1693\" x=\"40.5907\" y=\"0\"/><text font-family=\"Helvetica\" font-size=\"2.8219\" text-anchor=\"middle\" x=\"20.38\" y=\"17.6228\">Quarkus Rocks</text></g></svg>")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.quarkiverse.barcode</groupId> | ||
<artifactId>quarkus-okapi-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>quarkus-okapi-integration-tests</artifactId> | ||
<name>Quarkus Okapi - Integration Tests</name> | ||
|
||
<properties> | ||
<skipITs>true</skipITs> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-rest</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-smallrye-openapi</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkiverse.barcode</groupId> | ||
<artifactId>quarkus-okapi</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> | ||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> | ||
<maven.home>${maven.home}</maven.home> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>native-image</id> | ||
<activation> | ||
<property> | ||
<name>native</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skipTests>${native.surefire.skip}</skipTests> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<properties> | ||
<skipITs>false</skipITs> | ||
<quarkus.native.enabled>true</quarkus.native.enabled> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
</project> |
33 changes: 33 additions & 0 deletions
33
ext-okapi/integration-tests/src/main/java/io/quarkiverse/barcode/it/BaseImageResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.quarkiverse.barcode.it; | ||
|
||
import jakarta.ws.rs.core.HttpHeaders; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
public class BaseImageResource { | ||
public static final String CONTENT_DISPOSITION = "attachment;filename=%s"; | ||
public static final String PNG_MIME_TYPE = "image/png"; | ||
public static final String SVG_MIME_TYPE = "image/svg+xml"; | ||
|
||
/** | ||
* Builds a Response containing image data with appropriate headers. | ||
* | ||
* @param imageData The raw bytes of the image | ||
* @param mimeType The MIME type of the image (e.g. "image/png") | ||
* @param fileName The filename to use in the Content-Disposition header | ||
* @return A Response object configured with the image data and headers | ||
*/ | ||
protected Response buildImageResponse(byte[] imageData, String mimeType, String fileName) { | ||
final Response.ResponseBuilder response = Response.ok(imageData); | ||
response.header(HttpHeaders.CONTENT_DISPOSITION, CONTENT_DISPOSITION.formatted(fileName)); | ||
response.header(HttpHeaders.CONTENT_TYPE, mimeType); | ||
return response.build(); | ||
} | ||
|
||
protected String stripWhitespace(String svgContent) { | ||
// Remove unnecessary whitespace characters (spaces, tabs, newlines) from SVG content | ||
return svgContent | ||
.replaceAll(">\\s+<", "><") // Remove whitespace between tags | ||
.replaceAll("\\s{2,}", " ") // Replace multiple spaces with a single space | ||
.replaceAll("\\s+/>", "/>"); // Trim spaces before self-closing tags | ||
} | ||
} |
Oops, something went wrong.