diff --git a/README.md b/README.md index 22667edb..90795fc8 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,36 @@ To set up in Visual Studio Code, follow these steps: You can similarly use GlassFish in Visual Studio Code. + +## Getting Started with Open Liberty + +To set up the project with Open Liberty and Maven: + +* Ensure you are running Java SE 11, or Java SE 17. IBM Semeru is the recommended Java SDK for Open Liberty. Go to [IBM Semeru Runtimes Downloads](https://developer.ibm.com/languages/java/semeru-runtimes/downloads/) and select Java 11 or Java 17 from the version dropdown menu. +* Make sure the `JAVA_HOME`environment variable is set on your system. +* Navigate to the `cargotracker` directory and develop the application with the [Liberty Maven Plugin](https://github.com/OpenLiberty/ci.maven#cimaven--): `mvn -P openliberty liberty:dev`. +* You can safely ignore the shrinkwrap features warning, message-driven bean warning, and the AggregateObjectMapping nested foreign key warning, as they don't affect the application functionality. +* The application starts without any additional errors and you can visit it at the http://localhost:8080/cargo-tracker URL. + +To set up the project with Open Liberty in Visual Studio Code: + +* Ensure you are running [Visual Studio Code](https://code.visualstudio.com/download) with Java 17. +* Install [Liberty Tools for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=Open-Liberty.liberty-dev-vscode-ext). +* Open the Cargo Tracker project by selecting **Explorer** > **Open Folder**. Select the `cargotracker` directory. +* The `cargo-tracker` project appears under the `LIBERTY DASHBOARD` extension in the Explorer sidebar. +* Right-click the `cargo-tracker` project and select `Start...` to start the application. Type `-P openliberty` in the pop-up entry field and then press the Enter/return key. +* A terminal window in the IDE opens and the Liberty Maven Plugin starts the application. Liberty is running in dev mode. +* You can safely ignore the shrinkwrap features warning, message-driven bean warning, and the AggregateObjectMapping nested foreign key warning, as they don't affect the application functionality. +* You can visit the application at http://localhost:8080/cargo-tracker when you see the following message at the terminal: +``` +************************************************************************ +[INFO] * Liberty is running in dev mode. +... +[INFO] Source compilation was successful. +[INFO] Tests compilation was successful. +``` + + ## Exploring the Application After the application runs, it will be available at: diff --git a/pom.xml b/pom.xml index d0445bde..01311dcd 100644 --- a/pom.xml +++ b/pom.xml @@ -423,5 +423,81 @@ + + openliberty + + false + + + UTF-8 + UTF-8 + org.hsqldb.jdbc.JDBCDriver + jdbc:hsqldb:file:./cargo-tracker-data/cargo-tracker-database;create=true + + + + + org.hsqldb + hsqldb + 2.7.2 + provided + + + org.glassfish.jersey.core + jersey-server + 3.1.2 + provided + + + io.openliberty.arquillian + arquillian-liberty-managed-jakarta-junit5 + 2.1.4 + pom + test + + + + + + + + io.openliberty.tools + liberty-maven-plugin + 3.8.2 + + + + ${project.build.directory}/liberty/wlp/usr/shared/resources + + org.hsqldb + hsqldb + + + + + + + install-liberty + compile + + create + install-feature + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.1.2 + + + openliberty + + + + + + diff --git a/src/main/liberty/config/bootstrap.properties b/src/main/liberty/config/bootstrap.properties new file mode 100644 index 00000000..95fb375e --- /dev/null +++ b/src/main/liberty/config/bootstrap.properties @@ -0,0 +1,6 @@ +org.apache.el.parser.SKIP_IDENTIFIER_CHECK=true +com.ibm.ws.logging.max.file.size=100 +com.ibm.ws.logging.max.files=3 +default.http.port=8080 +default.https.port=8081 +# com.ibm.ws.logging.trace.specification=*=info=enabled:logservice=all:com.ibm.ws.jaxrs*=all:com.ibm.websphere.jaxrs*=all:org.apache.cxf.*=all:EJBContainer=all:Injection=all diff --git a/src/main/liberty/config/server.xml b/src/main/liberty/config/server.xml new file mode 100644 index 00000000..1fdefc28 --- /dev/null +++ b/src/main/liberty/config/server.xml @@ -0,0 +1,143 @@ + + + + + batch-2.1 + beanValidation-3.0 + cdi-4.0 + enterpriseBeansLite-4.0 + enterpriseBeansPersistentTimer-4.0 + faces-4.0 + jdbc-4.3 + jndi-1.0 + jsonb-3.0 + localConnector-1.0 + mdb-4.0 + messaging-3.1 + messagingClient-3.0 + messagingServer-3.0 + persistence-3.1 + restfulWS-3.1 + xmlBinding-4.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/eclipse/cargotracker/application/BookingServiceTest.java b/src/test/java/org/eclipse/cargotracker/application/BookingServiceTest.java index f96fe4db..2fd563ee 100644 --- a/src/test/java/org/eclipse/cargotracker/application/BookingServiceTest.java +++ b/src/test/java/org/eclipse/cargotracker/application/BookingServiceTest.java @@ -86,6 +86,13 @@ public class BookingServiceTest { @Deployment public static WebArchive createDeployment() { + + String launch = System.getProperty("arquillian.launch", "payara"); + String webXml = launch.equals("openliberty") ? "test-liberty-web.xml" : "test-web.xml"; + String[] dependencies = launch.equals("openliberty") ? + new String[] { "org.apache.commons:commons-lang3" } : + new String[] { "org.apache.commons:commons-lang3", "com.h2database:h2"}; + return ShrinkWrap.create(WebArchive.class, "cargo-tracker-test.war") // Application layer component directly under test. .addClass(BookingService.class) @@ -147,16 +154,18 @@ public static WebArchive createDeployment() { // Persistence unit descriptor .addAsResource("test-persistence.xml", "META-INF/persistence.xml") // Web application descriptor - .addAsWebInfResource("test-web.xml", "web.xml") + .addAsWebInfResource(webXml, "web.xml") + // Bean archive descriptor + .addAsWebInfResource("test-beans.xml", "beans.xml") // Library dependencies .addAsLibraries( Maven.resolver() .loadPomFromFile("pom.xml") - .resolve("org.apache.commons:commons-lang3", "com.h2database:h2") + .resolve(dependencies) .withTransitivity() .asFile()); } - + @Test @Order(1) public void testRegisterNew() { diff --git a/src/test/resources/arquillian.xml b/src/test/resources/arquillian.xml index 3b17308f..89b2e908 100644 --- a/src/test/resources/arquillian.xml +++ b/src/test/resources/arquillian.xml @@ -23,4 +23,14 @@ true + + + true + target/liberty/wlp + defaultServer + 8080 + xml + dbLib + + \ No newline at end of file diff --git a/src/test/resources/test-beans.xml b/src/test/resources/test-beans.xml new file mode 100644 index 00000000..44819c2f --- /dev/null +++ b/src/test/resources/test-beans.xml @@ -0,0 +1,6 @@ + + + diff --git a/src/test/resources/test-liberty-web.xml b/src/test/resources/test-liberty-web.xml new file mode 100644 index 00000000..7763229e --- /dev/null +++ b/src/test/resources/test-liberty-web.xml @@ -0,0 +1,17 @@ + + + + java:app/configuration/GraphTraversalUrl + java.lang.String + http://localhost:8080/cargo-tracker-test/rest/graph-traversal/shortest-path + + + java:app/jdbc/CargoTrackerDatabase + org.hsqldb.jdbc.JDBCDriver + jdbc:hsqldb:mem:CargoTrackerDB + usr + pwd + +