diff --git a/boost-maven/boost-boms/boost-jakarta-ee8-apis-bom/pom.xml b/boost-maven/boost-boms/boost-jakarta-ee8-apis-bom/pom.xml new file mode 100644 index 00000000..9430ccbf --- /dev/null +++ b/boost-maven/boost-boms/boost-jakarta-ee8-apis-bom/pom.xml @@ -0,0 +1,64 @@ + + + + 4.0.0 + + + org.microshed.boost + boost-boms + 0.2.2-SNAPSHOT + + + org.microshed.boost.boms + boost-jakarta-ee8-apis-bom + pom + + Boost Jakarta EE8 APIs BOM + + + + + + jakarta.ws.rs + jakarta.ws.rs-api + 2.1.6 + + + + jakarta.persistence + jakarta.persistence-api + 2.2.3 + + + jakarta.transaction + jakarta.transaction-api + 1.3.3 + + + jakarta.enterprise + jakarta.enterprise.cdi-api + 2.0.2 + + + jakarta.json + jakarta.json-api + 1.1.6 + + + jakarta.json.bind + jakarta.json.bind-api + 1.0.2 + + + jakarta.validation + jakarta.validation-api + 2.0.2 + + + + \ No newline at end of file diff --git a/boost-maven/boost-boms/booster-jakarta-ee8-bom/pom.xml b/boost-maven/boost-boms/booster-jakarta-ee8-bom/pom.xml new file mode 100644 index 00000000..416fbcc4 --- /dev/null +++ b/boost-maven/boost-boms/booster-jakarta-ee8-bom/pom.xml @@ -0,0 +1,80 @@ + + + 4.0.0 + + + org.microshed.boost + boost-boms + 0.2.2-SNAPSHOT + + + org.microshed.boost.boms + boost-jakarta-ee8-bom + pom + + Booster Jakarta EE8 Feature Bom + + + + + org.microshed.boost.boms + boost-jakarta-ee8-apis-bom + 0.2.2-SNAPSHOT + import + pom + + + org.microshed.boost.boms + runtimes-bom + 0.2.2-SNAPSHOT + import + pom + + + org.microshed.boost.boosters + jaxrs + + + + 2.1-0.2.2-SNAPSHOT + provided + + + org.microshed.boost.boosters + jdbc + 0.2.2-SNAPSHOT + provided + + + org.microshed.boost.boosters + jpa + 2.2-0.2.2-SNAPSHOT + provided + + + org.microshed.boost.boosters + cdi + 2.0-0.2.2-SNAPSHOT + provided + + + org.microshed.boost.boosters + jsonp + 1.1-0.2.2-SNAPSHOT + provided + + + org.microshed.boost.boosters + bean-validation + 2.0-0.2.2-SNAPSHOT + provided + + + + diff --git a/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/pom.xml b/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/pom.xml new file mode 100644 index 00000000..0c9746db --- /dev/null +++ b/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/pom.xml @@ -0,0 +1,159 @@ + + 4.0.0 + + org.microshed.boost + test-jaxrs-2.1 + war + 1.0-SNAPSHOT + + + UTF-8 + UTF-8 + 1.8 + 1.8 + + + + + + sonatype-nexus-snapshots + Sonatype Nexus Snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + true + + + false + + + + + + + + org.microshed.boost.boms + jakarta-ee8-bom + @pom.version@ + import + pom + + + + + + + org.microshed.boost.boosters + jaxrs + + + org.microshed.boost.boosters + bean-validation + + + junit + junit + 4.12 + test + + + commons-httpclient + commons-httpclient + 3.1 + test + + + + + + + org.microshed.boost + boost-maven-plugin + @pom.version@ + + + + package + + + + test-start-server + pre-integration-test + + start + + + + test-stop-server + post-integration-test + + stop + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.22.1 + + + + integration-test + verify + + + + + + + + + + ol + + + boostRuntime + ol + + + + + org.microshed.boost.runtimes + openliberty + + + + + wlp + + + boostRuntime + wlp + + + + + org.microshed.boost.runtimes + wlp + + + + + tomee + + + boostRuntime + tomee + + + + + org.microshed.boost.runtimes + tomee + + + + + + diff --git a/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/main/java/com/example/HelloResource.java b/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/main/java/com/example/HelloResource.java new file mode 100644 index 00000000..85f0ea83 --- /dev/null +++ b/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/main/java/com/example/HelloResource.java @@ -0,0 +1,36 @@ +package com.example; + +import java.io.IOException; +import java.util.Set; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.validation.constraints.Size; + +//import com.ibm.json.java.JSON; +//import com.ibm.json.java.JSONArray; +//import com.ibm.json.java.JSONObject; + +// This class define the RESTful API to fetch the database service information +// /api/hello + +@Path("/hello") +public class HelloResource { + + @GET + @Path("/hello") + @Produces("text/plain") + public String getInformation() throws Exception, IOException { + return "Hello World From Your Friends at Liberty Boost EE!"; + } + + @GET + @Path("/{dataIn}") + @Produces("text/plain") + public String getInformationWithString(@PathParam("dataIn") @Size(min = 2, max = 10) String dataIn) + throws Exception, IOException { + return ("Hello World From Your Friends at Liberty Boost EE! Your passed in string data is: " + dataIn); + } +} diff --git a/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/main/webapp/META-INF/MANIFEST.MF b/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 00000000..254272e1 --- /dev/null +++ b/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/main/webapp/WEB-INF/web.xml b/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000..46accb5d --- /dev/null +++ b/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,15 @@ + + + Java REST Sample + + javax.ws.rs.core.Application + 1 + + + javax.ws.rs.core.Application + /api/* + + + index.html + + diff --git a/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/main/webapp/index.html b/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/main/webapp/index.html new file mode 100644 index 00000000..11afc6b6 --- /dev/null +++ b/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/main/webapp/index.html @@ -0,0 +1,28 @@ + + + +Java REST Application + + + + +
+

+ Message from /api/hello : + +

+ + diff --git a/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/test/java/it/EndpointIT.java b/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/test/java/it/EndpointIT.java new file mode 100644 index 00000000..f2e7a831 --- /dev/null +++ b/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/test/java/it/EndpointIT.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2018 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package it; + +import static org.junit.Assert.*; +import org.junit.BeforeClass; +import org.junit.Test; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.httpclient.methods.GetMethod; +import javax.ws.rs.BadRequestException; + +public class EndpointIT { + private static String URL; + + @BeforeClass + public static void init() { + String port = System.getProperty("boost_http_port"); + URL = "http://localhost:" + port + "/api/hello"; + } + + @Test + public void testServlet() throws Exception { + HttpClient client = new HttpClient(); + + GetMethod method = new GetMethod(URL + "/hello"); + + try { + int statusCode = client.executeMethod(method); + + assertEquals("HTTP GET failed", HttpStatus.SC_OK, statusCode); + + String response = method.getResponseBodyAsString(10000); + + assertTrue("Unexpected response body", + response.contains("Hello World From Your Friends at Liberty Boost EE!")); + } finally { + method.releaseConnection(); + } + } + + @Test + public void testServletWithString() throws Exception { + HttpClient client = new HttpClient(); + + // this request should fail the bean validation on the string data param + // min=2, max=10 + GetMethod method = new GetMethod(URL + "/AndyAndyAndy"); + + try { + int statusCode = client.executeMethod(method); + + assertEquals("HTTP GET succeeded", HttpStatus.SC_BAD_REQUEST, statusCode); + + String response = method.getResponseBodyAsString(10000); + + assertTrue("Unexpected response body", (response.isEmpty())); + } finally { + method.releaseConnection(); + } + } +} diff --git a/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/test/java/it/LibertyFeatureVersionIT.java b/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/test/java/it/LibertyFeatureVersionIT.java new file mode 100644 index 00000000..abe3545a --- /dev/null +++ b/boost-maven/boost-maven-plugin/src/it/test-jaxrs-2.1-jakarta-ee8/src/test/java/it/LibertyFeatureVersionIT.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2018 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package it; + +import static org.junit.Assert.*; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; + +import org.junit.BeforeClass; +import org.junit.Test; + +public class LibertyFeatureVersionIT { + + private static final String JAXRS_21_FEATURE = "jaxrs-2.1"; + private static String SERVER_XML = "target/liberty/wlp/usr/servers/defaultServer/server.xml"; + + @BeforeClass + public static void init() { + String runtime = System.getProperty("boostRuntime"); + org.junit.Assume.assumeTrue("ol".equals(runtime) || "wlp".equals(runtime)); + } + + @Test + public void testFeatureVersion() throws Exception { + File targetFile = new File(SERVER_XML); + assertTrue(targetFile.getCanonicalFile() + "does not exist.", targetFile.exists()); + + // Check contents of file for jaxrs feature + boolean found = false; + BufferedReader br = null; + + try { + br = new BufferedReader(new FileReader(SERVER_XML)); + String line; + while ((line = br.readLine()) != null) { + if (line.contains(JAXRS_21_FEATURE)) { + found = true; + break; + } + } + } finally { + if (br != null) { + br.close(); + } + } + + assertTrue("The " + JAXRS_21_FEATURE + " feature was not found in the server configuration", found); + } +}