Skip to content

Commit

Permalink
Minor cleanups in Quarkas example
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsbasjes committed Jul 22, 2020
1 parent 186cdec commit 173afe4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 73 deletions.
2 changes: 1 addition & 1 deletion examples/quarkus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The application can be packaged using `mvn package`.
It produces the `quarkus-*-runner.jar` file in the `/target` directory.
Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/lib` directory.

The application is now runnable using `java -jar target/quarkus-5.19-SNAPSHOT-runner.jar`.
The application is now runnable using `java -jar target/quarkus-*-runner.jar`.

## Creating a native executable

Expand Down
76 changes: 20 additions & 56 deletions examples/quarkus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>yauaa-example-parent</artifactId>
<groupId>nl.basjes.parse.useragent</groupId>
<version>5.19-SNAPSHOT</version>
</parent>

<groupId>nl.basjes.parse.useragent</groupId>
<artifactId>quarkus</artifactId>
<version>5.19-SNAPSHOT</version>
<name>Yauaa : Examples : Quarkus</name>
Expand All @@ -40,8 +35,10 @@
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>1.6.1.Final</quarkus.platform.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
<surefire-plugin.version>2.22.2</surefire-plugin.version>
<failsafe-plugin.version>2.22.2</failsafe-plugin.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
Expand All @@ -56,67 +53,29 @@

<dependencies>

<!-- ================================================================================================ -->
<!-- These 4 dependencies are excluded by all UDFs because of dependency/shading/ relocating problems -->
<!-- But they do need them for the compilation and testing ... -->
<!-- Documentation of the used shading construct: https://yauaa.basjes.nl/NOTES-shading-dependencies.html -->
<dependency>
<groupId>nl.basjes.parse.useragent</groupId>
<artifactId>yauaa</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- The webapp needs more classes than have been shaded in. -->
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>${antlr.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version>
</dependency>
<!-- ================================================================================================ -->


<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</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>

<dependency>
<groupId>nl.basjes.parse.useragent</groupId>
<artifactId>yauaa</artifactId>
<version>${project.version}</version>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -149,7 +108,9 @@
</plugin>
</plugins>
</build>

<profiles>

<profile>
<id>native</id>
<activation>
Expand All @@ -161,7 +122,7 @@
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<version>${failsafe-plugin.version}</version>
<executions>
<execution>
<goals>
Expand All @@ -180,9 +141,12 @@
</plugin>
</plugins>
</build>

<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
</profile>

</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/")
@Path("/parse")
public class ParseService {

private UserAgentAnalyzer userAgentAnalyzer = null;
Expand All @@ -40,16 +40,7 @@ public void automaticStartup() {

@GET
@Produces(MediaType.TEXT_PLAIN)
public String getYamlGET(@HeaderParam("user-agent") String userAgentString
) {
return doYaml(userAgentString);
}

private String doYaml(String userAgentString) {
if (userAgentString == null) {
return "";
}

public String getYamlGET(@HeaderParam("user-agent") String userAgentString) {
return userAgentAnalyzer.parse(userAgentString).toYamlTestCase();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ public class ParseServiceTest {
@Test
public void testParserEndpoint() {
given()
.header("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36")
.when().get("/")
.then()
.statusCode(200)
.body(containsString("Chrome 84.0.4147.89"));
.header("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36")
.when()
.get("/parse")
.then()
.statusCode(200)
.body(containsString("Chrome 84.0.4147.89"));
}

}

0 comments on commit 173afe4

Please sign in to comment.