From aa8946d8cb6687189a9725f54795cdfdbede45da Mon Sep 17 00:00:00 2001 From: Reza Rahman Date: Tue, 12 Aug 2014 17:06:23 -0400 Subject: [PATCH 01/15] Minor tweaks --- .../com/actionbazaar/application/DefaultBidService.java | 2 +- .../main/java/com/actionbazaar/domain/BidRepository.java | 2 +- .../com/actionbazaar/interfaces/rest/BidRestService.java | 2 +- .../actionbazaar/interfaces/rest/RestConfiguration.java | 2 +- .../com/actionbazaar/interfaces/socket/ChatMessage.java | 2 +- .../main/java/com/actionbazaar/interfaces/web/AddBid.java | 2 +- .../com/actionbazaar/interfaces/web/AlertServlet.java | 6 +++--- actionbazaar/src/main/resources/META-INF/persistence.xml | 4 ++-- actionbazaar/src/main/webapp/WEB-INF/beans.xml | 8 +++++--- actionbazaar/src/main/webapp/WEB-INF/web.xml | 6 +++--- .../actionbazaar/interfaces/socket/ChatServerTest.java | 2 -- actionbazaar/src/test/resources/arquillian.xml | 2 +- actionbazaar/src/test/resources/test-beans.xml | 8 +++++--- actionbazaar/src/test/resources/test-persistence.xml | 8 +++++--- actionbazaar/src/test/resources/test-web.xml | 5 +++-- 15 files changed, 33 insertions(+), 28 deletions(-) diff --git a/actionbazaar/src/main/java/com/actionbazaar/application/DefaultBidService.java b/actionbazaar/src/main/java/com/actionbazaar/application/DefaultBidService.java index 54e6098..dfe8bb8 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/application/DefaultBidService.java +++ b/actionbazaar/src/main/java/com/actionbazaar/application/DefaultBidService.java @@ -71,4 +71,4 @@ public void updateBid(Bid bid) { public void deleteBid(Bid bid) { bidRepository.deleteBid(bid); } -} \ No newline at end of file +} diff --git a/actionbazaar/src/main/java/com/actionbazaar/domain/BidRepository.java b/actionbazaar/src/main/java/com/actionbazaar/domain/BidRepository.java index 69c599f..4641c42 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/domain/BidRepository.java +++ b/actionbazaar/src/main/java/com/actionbazaar/domain/BidRepository.java @@ -48,4 +48,4 @@ public interface BidRepository { public void updateBid(Bid bid); public void deleteBid(Bid bid); -} \ No newline at end of file +} diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/BidRestService.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/BidRestService.java index 8c2c542..e0f9b8c 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/BidRestService.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/BidRestService.java @@ -87,4 +87,4 @@ public void deleteBid(@PathParam("id") Long id) { Bid bid = bidService.getBid(id); bidService.deleteBid(bid); } -} \ No newline at end of file +} diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/RestConfiguration.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/RestConfiguration.java index 12f6ff4..d8b2ceb 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/RestConfiguration.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/RestConfiguration.java @@ -53,4 +53,4 @@ public RestConfiguration() { // Resource packages(new String[]{BidRestService.class.getPackage().getName()}); // removed. } -} \ No newline at end of file +} diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/socket/ChatMessage.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/socket/ChatMessage.java index fd01b02..6f25f7c 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/socket/ChatMessage.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/socket/ChatMessage.java @@ -111,4 +111,4 @@ public void destroy() { public String toString() { return "ChatMessage{" + "user=" + user + ", message=" + message + '}'; } -} \ No newline at end of file +} diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java index e411568..d56af46 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java @@ -66,4 +66,4 @@ public String onAdd() { return "confirm_add_bid.jsf"; } -} \ No newline at end of file +} diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AlertServlet.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AlertServlet.java index 06ea4ae..3783f0d 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AlertServlet.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AlertServlet.java @@ -85,11 +85,11 @@ public void service(ServletRequest request, ServletResponse response) } generator.writeEnd(); - + generator.write("goodbye", "No more alerts for now, timing out"); - + generator.writeEnd(); generator.close(); } } -} \ No newline at end of file +} diff --git a/actionbazaar/src/main/resources/META-INF/persistence.xml b/actionbazaar/src/main/resources/META-INF/persistence.xml index c4125d2..6237487 100644 --- a/actionbazaar/src/main/resources/META-INF/persistence.xml +++ b/actionbazaar/src/main/resources/META-INF/persistence.xml @@ -1,7 +1,7 @@ - diff --git a/actionbazaar/src/main/webapp/WEB-INF/beans.xml b/actionbazaar/src/main/webapp/WEB-INF/beans.xml index 5a535b3..ee89b04 100644 --- a/actionbazaar/src/main/webapp/WEB-INF/beans.xml +++ b/actionbazaar/src/main/webapp/WEB-INF/beans.xml @@ -1,5 +1,7 @@ - + \ No newline at end of file diff --git a/actionbazaar/src/main/webapp/WEB-INF/web.xml b/actionbazaar/src/main/webapp/WEB-INF/web.xml index ea9d986..21b153f 100644 --- a/actionbazaar/src/main/webapp/WEB-INF/web.xml +++ b/actionbazaar/src/main/webapp/WEB-INF/web.xml @@ -1,6 +1,6 @@ - @@ -19,7 +19,7 @@ 30 - + add_bid.jsf diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java index aefafcb..786f61f 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java @@ -42,7 +42,6 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -import java.net.URL; import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; @@ -59,7 +58,6 @@ import javax.websocket.WebSocketContainer; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; -import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import static org.junit.Assert.assertEquals; diff --git a/actionbazaar/src/test/resources/arquillian.xml b/actionbazaar/src/test/resources/arquillian.xml index e98d17e..8d5b99b 100644 --- a/actionbazaar/src/test/resources/arquillian.xml +++ b/actionbazaar/src/test/resources/arquillian.xml @@ -1,5 +1,5 @@ - - + com.actionbazaar.application.ProfilingInterceptor diff --git a/actionbazaar/src/test/resources/test-persistence.xml b/actionbazaar/src/test/resources/test-persistence.xml index d86e9f3..bb8b9db 100644 --- a/actionbazaar/src/test/resources/test-persistence.xml +++ b/actionbazaar/src/test/resources/test-persistence.xml @@ -1,7 +1,9 @@ - + jdbc/ActionBazaarDB diff --git a/actionbazaar/src/test/resources/test-web.xml b/actionbazaar/src/test/resources/test-web.xml index 4bf2f9a..1fe38bc 100644 --- a/actionbazaar/src/test/resources/test-web.xml +++ b/actionbazaar/src/test/resources/test-web.xml @@ -1,6 +1,7 @@ - From 5fc775f3a8bb50586bb5f386893c3c9dd9067975 Mon Sep 17 00:00:00 2001 From: Reza Rahman Date: Thu, 25 Sep 2014 22:37:33 -0700 Subject: [PATCH 02/15] Workarounds for GlassFish bugs --- README.md | 61 ++++++++++++++++++- actionbazaar/nb-configuration.xml | 2 +- actionbazaar/pom.xml | 10 +-- .../actionbazaar/interfaces/web/AddBid.java | 8 ++- .../main/resources/META-INF/persistence.xml | 23 +++---- actionbazaar/src/main/webapp/WEB-INF/web.xml | 5 ++ .../src/main/webapp/WEB-INF/weblogic.xml | 19 +++--- .../src/main/webapp/confirm_add_bid.xhtml | 6 +- .../application/BidServiceTest.java | 6 +- .../application/BidServiceUnitTest.java | 2 +- .../interfaces/web/AlertServletTest.java | 21 ++----- .../src/test/resources/arquillian.xml | 27 ++++---- .../src/test/resources/test-beans.xml | 12 ++-- .../test/resources/test-persistence-beans.xml | 9 +++ .../test/resources/test-persistence-web.xml | 11 ++++ .../src/test/resources/test-persistence.xml | 2 +- actionbazaar/src/test/resources/test-web.xml | 5 ++ 17 files changed, 142 insertions(+), 87 deletions(-) create mode 100644 actionbazaar/src/test/resources/test-persistence-beans.xml create mode 100644 actionbazaar/src/test/resources/test-persistence-web.xml diff --git a/README.md b/README.md index f1a03ae..856ab43 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,59 @@ -Testing Java EE Applications Using Arquillian -========== +Testing Java EE Applications on WebLogic 12.1.3 Using Arquillian +================================================================ +This application demonstrates how Java EE applications can be effectively +tested using Arquillian on WebLogic 12.1.3. The application contains a +set of JUnit tests that you should examine. The tests will be run as part +of the Maven build. The tests require a running instance of +WebLogic (please see setup instructions). The WebLogic Maven plugin used as +part of the build also requires a running instance of WebLogic to be present. -This application demonstrates how Java EE applications can be effectively tested using Arquillian. \ No newline at end of file +WebLogic 12.1.3 supports Java EE 6 and some key Java EE 7 APIs - +WebSocket, JAX-RS 2, JSON-P and JPA 2.1. The application uses both +these APIs as well as Java EE 6 features such as CDI, EJB 3.1 and JSF 2. + +Setup +----- +* Install WebLogic 12.1.3 +* The Java EE 7 APIs are not automatically enabled. This + [Aquarium blog entry](https://blogs.oracle.com/theaquarium/entry/java_ee_7_support_comes) + is invaluable in better understanding the Java EE 7 API support in + WebLogic 12.1.3. The referenced white paper explains the steps necessary to + enable the APIs. +* The demo application requires a data source. WebLogic 12.1.3 supports the + Java EE 6 standard @DataSourceDefinition and corresponding XML elements. + However, this does not seem to work with JPA 2.1 so we could not use it. A bug + has been filed to get this fixed. Yet another approach is to use WebLogic + proprietary JDBC modules. This requires an EAR file and would significantly + complicate an otherwise simple WAR build. For this reason, this was not an + approach we used. As a result, however, you will need to manually create a + data source for the demo application. The data source is expected to be bound + to 'jdbc/ActionBazaarDB'. We used embedded Derby but any underlying database + should work. If helpful, a sample WebLogic data source definition is provided + [here](ActionBazaarDB-jdbc.xml). +* The demo application uses the WebLogic Maven plugin to automatically deploy + as part of the build. You will need to enable the plugin in your environment. + The detailed instructions to do this can be found + [here](http://docs.oracle.com/middleware/1213/wls/WLPRG/maven.htm). This + resource also contains details on how to configure the Maven plugin, which + you will need to do (see below). +* Please download this repository. You can use Git or just the simple zip + download. +* The demo is just a simple Maven project under the [actionbazaar](actionbazaar) + directory. You should be able to open it up in any Maven capable IDE, we used + NetBeans. +* If desired setup WebLogic in your IDE. This is what we tested. +* The tests in the Maven build are executed against a running WebLogic instance. + You will need to configure + [this file] (actionbazaar/src/test/resources/arquillian.xml) with the details + of your running WebLogic instance (you could run the instance via the IDE). + For details on configuring WebLogic for Arquillian, look + [here] (https://docs.jboss.org/author/display/ARQ/WLS+12.1+-+Remote). +* The build also automatically undeploys and deploys the application to the + running WebLogic instance using the WebLogic Maven plugin. Please configure + the plugin in the [Maven POM](actionbazaar/pom.xml) with the details + of your running WebLogic instance. +* If desired, you can deploy and run the application manually. We did this both + via NetBeans and by using the plain Maven generated war file in addition to + the automated build. +* You can hook up the build to a continuous integration server such as Hudson. + We tested such a setup. \ No newline at end of file diff --git a/actionbazaar/nb-configuration.xml b/actionbazaar/nb-configuration.xml index b00b5e1..5b43433 100644 --- a/actionbazaar/nb-configuration.xml +++ b/actionbazaar/nb-configuration.xml @@ -14,7 +14,7 @@ That way multiple projects can share the same settings (useful for formatting ru Any value defined here will override the pom.xml file value but is only applicable to the current project. --> ide - WebLogic9 + gfv3ee6 Facelets /less:/css diff --git a/actionbazaar/pom.xml b/actionbazaar/pom.xml index c4ec329..a46536e 100644 --- a/actionbazaar/pom.xml +++ b/actionbazaar/pom.xml @@ -47,12 +47,6 @@ 7.0 provided - - org.glassfish.jersey.media - jersey-media-json-processing - 2.5.1 - compile - org.glassfish.jersey.containers jersey-container-servlet-core @@ -85,8 +79,8 @@ org.jboss.arquillian.container - arquillian-wls-remote-12.1 - 1.0.0.Alpha2 + arquillian-glassfish-managed-3.1 + 1.0.0.CR4 test diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java index d56af46..4b5120d 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java @@ -42,13 +42,14 @@ import com.actionbazaar.application.BidService; import com.actionbazaar.domain.Bid; import java.io.Serializable; -import javax.enterprise.context.RequestScoped; +import javax.enterprise.context.SessionScoped; import javax.enterprise.inject.Produces; +import javax.faces.view.ViewScoped; import javax.inject.Inject; import javax.inject.Named; @Named -@RequestScoped +@ViewScoped public class AddBid implements Serializable { private static final long serialVersionUID = 1L; @@ -58,10 +59,11 @@ public class AddBid implements Serializable { @Produces @Named - @RequestScoped + @SessionScoped private final Bid bid = new Bid(); public String onAdd() { + System.err.println(bid); bidService.addBid(bid); return "confirm_add_bid.jsf"; diff --git a/actionbazaar/src/main/resources/META-INF/persistence.xml b/actionbazaar/src/main/resources/META-INF/persistence.xml index 6237487..dde137f 100644 --- a/actionbazaar/src/main/resources/META-INF/persistence.xml +++ b/actionbazaar/src/main/resources/META-INF/persistence.xml @@ -1,15 +1,10 @@ - - - jdbc/ActionBazaarDB - - - - - - \ No newline at end of file + + + java:global/jdbc/ActionBazaarDB + + + + + + diff --git a/actionbazaar/src/main/webapp/WEB-INF/web.xml b/actionbazaar/src/main/webapp/WEB-INF/web.xml index 21b153f..9a80d41 100644 --- a/actionbazaar/src/main/webapp/WEB-INF/web.xml +++ b/actionbazaar/src/main/webapp/WEB-INF/web.xml @@ -23,4 +23,9 @@ add_bid.jsf + + java:global/jdbc/ActionBazaarDB + org.apache.derby.jdbc.EmbeddedDriver + jdbc:derby:/tmp/actionbazaar-database;create=true + \ No newline at end of file diff --git a/actionbazaar/src/main/webapp/WEB-INF/weblogic.xml b/actionbazaar/src/main/webapp/WEB-INF/weblogic.xml index 51fdd77..f18e829 100644 --- a/actionbazaar/src/main/webapp/WEB-INF/weblogic.xml +++ b/actionbazaar/src/main/webapp/WEB-INF/weblogic.xml @@ -1,12 +1,9 @@ - - /actionbazaar - - jax-rs - 2.0 - false - - \ No newline at end of file + + /actionbazaar + + jax-rs + 2.0 + false + + diff --git a/actionbazaar/src/main/webapp/confirm_add_bid.xhtml b/actionbazaar/src/main/webapp/confirm_add_bid.xhtml index 9741540..e10612c 100644 --- a/actionbazaar/src/main/webapp/confirm_add_bid.xhtml +++ b/actionbazaar/src/main/webapp/confirm_add_bid.xhtml @@ -8,11 +8,11 @@

Bid Added

- Item name: + Item name: - Bidder name: + Bidder name: - Bid amount: + Bid amount:
diff --git a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceTest.java b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceTest.java index a176957..4f6fea9 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceTest.java @@ -68,9 +68,9 @@ public static WebArchive createDeployment() { .addClasses(BidService.class, DefaultBidService.class, Profiled.class, ProfilingInterceptor.class, BidRepository.class, DefaultBidRepository.class, Bid.class) - .addAsWebInfResource("test-beans.xml", "beans.xml") - .addAsResource("test-persistence.xml", - "META-INF/persistence.xml"); + .addAsWebInfResource("test-persistence-web.xml", "web.xml") + .addAsWebInfResource("test-persistence-beans.xml", "beans.xml") + .addAsResource("test-persistence.xml", "META-INF/persistence.xml"); } @EJB diff --git a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java index 5efa906..5bb7052 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java @@ -65,7 +65,7 @@ public static WebArchive createDeployment() { .create(WebArchive.class, "actionbazaar-test.war") .addClasses(BidService.class, DefaultBidService.class, BidRepository.class, MockBidRepository.class, Bid.class) - .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + .addAsWebInfResource("test-beans.xml", "beans.xml"); } @EJB diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java index b039040..02cd9cf 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java @@ -39,19 +39,14 @@ */ package com.actionbazaar.interfaces.web; -import static org.junit.Assert.assertEquals; - -import java.io.File; - import javax.json.JsonObject; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; - import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.jboss.shrinkwrap.resolver.api.maven.Maven; +import static org.junit.Assert.assertEquals; import org.junit.Test; import org.junit.runner.RunWith; @@ -61,17 +56,9 @@ public class AlertServletTest { @Deployment public static WebArchive createDeployment() { - WebArchive archive = ShrinkWrap + return ShrinkWrap .create(WebArchive.class, "actionbazaar-test.war") - .addClass(AlertServlet.class) - .addAsWebInfResource("test-weblogic.xml", "weblogic.xml"); - File[] files = Maven - .resolver() - .resolve("org.glassfish.jersey.media:jersey-media-json-processing:2.5.1") - .withTransitivity().asFile(); - archive.addAsLibraries(files); - - return archive; + .addClass(AlertServlet.class); } @Test @@ -80,7 +67,7 @@ public void testGetAlerts() { // Get account balance JsonObject response = client - .target("http://localhost:7001/actionbazaar-test/alerts") + .target("http://localhost:8080/actionbazaar-test/alerts") .queryParam("user_id", "1111").request("application/json") .get(JsonObject.class); // TODO Assert more of the content. diff --git a/actionbazaar/src/test/resources/arquillian.xml b/actionbazaar/src/test/resources/arquillian.xml index 8d5b99b..8c80f6d 100644 --- a/actionbazaar/src/test/resources/arquillian.xml +++ b/actionbazaar/src/test/resources/arquillian.xml @@ -1,19 +1,18 @@ - - - target/ + + target/ - + - t3://localhost:7001 - weblogic - welcome123 - C:\Oracle\Middleware\Oracle_Home\wlserver - AdminServer + C:\glassfish4.1 + localhost + 4848 + admin + admin - - + +
\ No newline at end of file diff --git a/actionbazaar/src/test/resources/test-beans.xml b/actionbazaar/src/test/resources/test-beans.xml index 3e218b7..0af1b98 100644 --- a/actionbazaar/src/test/resources/test-beans.xml +++ b/actionbazaar/src/test/resources/test-beans.xml @@ -1,10 +1,6 @@ - - - com.actionbazaar.application.ProfilingInterceptor - + \ No newline at end of file diff --git a/actionbazaar/src/test/resources/test-persistence-beans.xml b/actionbazaar/src/test/resources/test-persistence-beans.xml new file mode 100644 index 0000000..eefc806 --- /dev/null +++ b/actionbazaar/src/test/resources/test-persistence-beans.xml @@ -0,0 +1,9 @@ + + + + com.actionbazaar.application.ProfilingInterceptor + + \ No newline at end of file diff --git a/actionbazaar/src/test/resources/test-persistence-web.xml b/actionbazaar/src/test/resources/test-persistence-web.xml new file mode 100644 index 0000000..0726838 --- /dev/null +++ b/actionbazaar/src/test/resources/test-persistence-web.xml @@ -0,0 +1,11 @@ + + + + java:global/jdbc/ActionBazaarDB + org.apache.derby.jdbc.EmbeddedDriver + jdbc:derby:/tmp/actionbazaar-database;create=true + + \ No newline at end of file diff --git a/actionbazaar/src/test/resources/test-persistence.xml b/actionbazaar/src/test/resources/test-persistence.xml index bb8b9db..16918a5 100644 --- a/actionbazaar/src/test/resources/test-persistence.xml +++ b/actionbazaar/src/test/resources/test-persistence.xml @@ -5,7 +5,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> - jdbc/ActionBazaarDB + java:global/jdbc/ActionBazaarDB diff --git a/actionbazaar/src/test/resources/test-web.xml b/actionbazaar/src/test/resources/test-web.xml index 1fe38bc..920ba4b 100644 --- a/actionbazaar/src/test/resources/test-web.xml +++ b/actionbazaar/src/test/resources/test-web.xml @@ -20,4 +20,9 @@ add_bid.jsf + + java:global/jdbc/ActionBazaarDB + org.apache.derby.jdbc.EmbeddedDriver + jdbc:derby:/tmp/actionbazaar-database;create=true +
\ No newline at end of file From fa1c800c435ae6a3f790c770164f4e63f570c95d Mon Sep 17 00:00:00 2001 From: Reza Rahman Date: Fri, 26 Sep 2014 13:48:38 -0700 Subject: [PATCH 03/15] Porting to GlassFish --- .../interfaces/socket/ChatServer.java | 2 + .../interfaces/rest/BidRestServiceTest.java | 11 +-- .../interfaces/socket/ChatServerTest.java | 93 +++++++++---------- .../src/test/resources/test-weblogic.xml | 11 --- 4 files changed, 52 insertions(+), 65 deletions(-) delete mode 100644 actionbazaar/src/test/resources/test-weblogic.xml diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/socket/ChatServer.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/socket/ChatServer.java index fb9da44..31ccb8f 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/socket/ChatServer.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/socket/ChatServer.java @@ -42,6 +42,7 @@ import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; +import javax.ejb.Singleton; import javax.websocket.EncodeException; import javax.websocket.OnClose; import javax.websocket.OnMessage; @@ -49,6 +50,7 @@ import javax.websocket.Session; import javax.websocket.server.ServerEndpoint; +@Singleton @ServerEndpoint(value = "/chat", encoders = {ChatMessage.class}, decoders = {ChatMessage.class}) public class ChatServer { diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java index 30bf50e..4c774a4 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java @@ -51,7 +51,6 @@ import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.junit.InSequence; import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -71,8 +70,8 @@ public static WebArchive createDeployment() { .addClasses(BidRestService.class, RestConfiguration.class, BidService.class, DefaultBidService.class, BidRepository.class, DefaultBidRepository.class, Bid.class) - .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") - .addAsWebInfResource("test-weblogic.xml", "weblogic.xml") + .addAsWebInfResource("test-beans.xml", "beans.xml") + .addAsWebInfResource("test-persistence-web.xml", "web.xml") .addAsResource("test-persistence.xml", "META-INF/persistence.xml"); } @@ -81,7 +80,7 @@ public static WebArchive createDeployment() { @InSequence(1) public void testAddBid() { WebTarget target = ClientBuilder.newClient() - .target("http://localhost:7001/actionbazaar-test/rest/bids"); + .target("http://localhost:8080/actionbazaar-test/rest/bids"); // Save a new bid. Bid bid = new Bid(); @@ -106,7 +105,7 @@ public void testAddBid() { @InSequence(2) public void testUpdateBid() { WebTarget target = ClientBuilder.newClient() - .target("http://localhost:7001/actionbazaar-test/rest/bids/{id}") + .target("http://localhost:8080/actionbazaar-test/rest/bids/{id}") .resolveTemplate("id", bidId); // Update bid. @@ -128,7 +127,7 @@ public void testUpdateBid() { @InSequence(3) public void testDeleteBid() { WebTarget target = ClientBuilder.newClient() - .target("http://localhost:7001/actionbazaar-test/rest/bids/{id}") + .target("http://localhost:8080/actionbazaar-test/rest/bids/{id}") .resolveTemplate("id", bidId); target.request().delete(); diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java index 786f61f..7434988 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java @@ -65,6 +65,7 @@ import org.junit.runner.RunWith; @RunWith(Arquillian.class) +// TODO Move test to client side. public class ChatServerTest { private static final Logger logger @@ -73,7 +74,7 @@ public class ChatServerTest { private static ChatMessage testMessage; private static ChatMessage testReply; - @Deployment(testable = false) + @Deployment public static WebArchive createDeployment() { return ShrinkWrap .create(WebArchive.class, "actionbazaar-test.war") @@ -82,64 +83,60 @@ public static WebArchive createDeployment() { } @Test - public void testChat() { - try { - URI uri = new URI("ws://localhost:7001/actionbazaar-test/chat"); + public void testChat() throws URISyntaxException, DeploymentException, IOException, InterruptedException { + URI uri = new URI("ws://localhost:8080/actionbazaar-test/chat"); - WebSocketContainer container = ContainerProvider.getWebSocketContainer(); + WebSocketContainer container = ContainerProvider.getWebSocketContainer(); - ClientEndpointConfig configuration = ClientEndpointConfig.Builder.create() - .decoders(Arrays.>asList(ChatMessage.class)) - .encoders(Arrays.>asList(ChatMessage.class)) - .build(); + ClientEndpointConfig configuration = ClientEndpointConfig.Builder.create() + .decoders(Arrays.>asList(ChatMessage.class)) + .encoders(Arrays.>asList(ChatMessage.class)) + .build(); - Endpoint client1 = new Endpoint() { - @Override - public void onOpen(Session session, EndpointConfig config) { - try { - session.addMessageHandler(new MessageHandler.Whole() { - @Override - public void onMessage(ChatMessage message) { - testReply = message; - } - }); - session.getBasicRemote().sendObject( - new ChatMessage("rrahman", "Test message")); - } catch (IOException | EncodeException e) { - logger.log(Level.SEVERE, "Error in chat client", e); - } - } - }; - - Endpoint client2 = new Endpoint() { - @Override - public void onOpen(final Session session, final EndpointConfig config) { + Endpoint client1 = new Endpoint() { + @Override + public void onOpen(Session session, EndpointConfig config) { + try { session.addMessageHandler(new MessageHandler.Whole() { @Override public void onMessage(ChatMessage message) { - try { - testMessage = message; - session.getBasicRemote().sendObject(new ChatMessage("nrahman", "Test reply")); - } catch (IOException | EncodeException ex) { - logger.log(Level.SEVERE, "Error responding to message", ex); - } + testReply = message; } }); + session.getBasicRemote().sendObject( + new ChatMessage("rrahman", "Test message")); + } catch (IOException | EncodeException e) { + logger.log(Level.SEVERE, "Error in chat client", e); } - }; + } + }; - container.connectToServer(client2, configuration, uri); - container.connectToServer(client1, configuration, uri); + Endpoint client2 = new Endpoint() { + @Override + public void onOpen(final Session session, final EndpointConfig config) { + session.addMessageHandler(new MessageHandler.Whole() { + @Override + public void onMessage(ChatMessage message) { + try { + testMessage = message; + session.getBasicRemote().sendObject(new ChatMessage("nrahman", "Test reply")); + } catch (IOException | EncodeException ex) { + logger.log(Level.SEVERE, "Error responding to message", ex); + } + } + }); + } + }; + + container.connectToServer(client2, configuration, uri); + container.connectToServer(client1, configuration, uri); - // Wait for conversation to finish. - Thread.sleep(2000); + // Wait for conversation to finish. + Thread.sleep(2000); - assertEquals("rrahman", testMessage.getUser()); - assertEquals("Test message", testMessage.getMessage()); - assertEquals("nrahman", testReply.getUser()); - assertEquals("Test reply", testReply.getMessage()); - } catch (URISyntaxException | DeploymentException | IOException | InterruptedException ex) { - logger.log(Level.SEVERE, "Error connecting to server", ex); - } + assertEquals("rrahman", testMessage.getUser()); + assertEquals("Test message", testMessage.getMessage()); + assertEquals("nrahman", testReply.getUser()); + assertEquals("Test reply", testReply.getMessage()); } } diff --git a/actionbazaar/src/test/resources/test-weblogic.xml b/actionbazaar/src/test/resources/test-weblogic.xml deleted file mode 100644 index 444d0aa..0000000 --- a/actionbazaar/src/test/resources/test-weblogic.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - jax-rs - 2.0 - false - - \ No newline at end of file From 1ce2c8a2bcb3908985a7d603e49ad50e2a25f34f Mon Sep 17 00:00:00 2001 From: Reza Rahman Date: Fri, 26 Sep 2014 14:34:18 -0700 Subject: [PATCH 04/15] Porting to GlassFish --- .../com/actionbazaar/interfaces/web/AddBid.java | 4 +--- .../src/main/resources/META-INF/persistence.xml | 14 +++++++------- actionbazaar/src/main/webapp/WEB-INF/beans.xml | 9 ++++----- actionbazaar/src/main/webapp/WEB-INF/web.xml | 11 +++++------ actionbazaar/src/main/webapp/WEB-INF/weblogic.xml | 9 --------- .../application/BidServiceUnitTest.java | 14 +++++--------- .../actionbazaar/interfaces/web/AddBidTest.java | 3 +-- actionbazaar/src/test/resources/test-web.xml | 9 ++++----- 8 files changed, 27 insertions(+), 46 deletions(-) delete mode 100644 actionbazaar/src/main/webapp/WEB-INF/weblogic.xml diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java index 4b5120d..341374f 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java @@ -44,12 +44,11 @@ import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.enterprise.inject.Produces; -import javax.faces.view.ViewScoped; import javax.inject.Inject; import javax.inject.Named; @Named -@ViewScoped +@SessionScoped public class AddBid implements Serializable { private static final long serialVersionUID = 1L; @@ -63,7 +62,6 @@ public class AddBid implements Serializable { private final Bid bid = new Bid(); public String onAdd() { - System.err.println(bid); bidService.addBid(bid); return "confirm_add_bid.jsf"; diff --git a/actionbazaar/src/main/resources/META-INF/persistence.xml b/actionbazaar/src/main/resources/META-INF/persistence.xml index dde137f..8db6d8d 100644 --- a/actionbazaar/src/main/resources/META-INF/persistence.xml +++ b/actionbazaar/src/main/resources/META-INF/persistence.xml @@ -1,10 +1,10 @@ - - java:global/jdbc/ActionBazaarDB - - - - - + + java:global/jdbc/ActionBazaarDB + + + + + diff --git a/actionbazaar/src/main/webapp/WEB-INF/beans.xml b/actionbazaar/src/main/webapp/WEB-INF/beans.xml index ee89b04..0af1b98 100644 --- a/actionbazaar/src/main/webapp/WEB-INF/beans.xml +++ b/actionbazaar/src/main/webapp/WEB-INF/beans.xml @@ -1,7 +1,6 @@ - + \ No newline at end of file diff --git a/actionbazaar/src/main/webapp/WEB-INF/web.xml b/actionbazaar/src/main/webapp/WEB-INF/web.xml index 9a80d41..f5742b9 100644 --- a/actionbazaar/src/main/webapp/WEB-INF/web.xml +++ b/actionbazaar/src/main/webapp/WEB-INF/web.xml @@ -1,9 +1,8 @@ - + javax.faces.PROJECT_STAGE Development @@ -27,5 +26,5 @@ java:global/jdbc/ActionBazaarDB org.apache.derby.jdbc.EmbeddedDriver jdbc:derby:/tmp/actionbazaar-database;create=true - + \ No newline at end of file diff --git a/actionbazaar/src/main/webapp/WEB-INF/weblogic.xml b/actionbazaar/src/main/webapp/WEB-INF/weblogic.xml deleted file mode 100644 index f18e829..0000000 --- a/actionbazaar/src/main/webapp/WEB-INF/weblogic.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - /actionbazaar - - jax-rs - 2.0 - false - - diff --git a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java index 5bb7052..f96ce90 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java @@ -39,23 +39,19 @@ */ package com.actionbazaar.application; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - +import com.actionbazaar.domain.Bid; +import com.actionbazaar.domain.BidRepository; +import com.actionbazaar.infrastructure.database.MockBidRepository; import javax.ejb.EJB; - import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import org.junit.Test; import org.junit.runner.RunWith; -import com.actionbazaar.domain.Bid; -import com.actionbazaar.domain.BidRepository; -import com.actionbazaar.infrastructure.database.MockBidRepository; - @RunWith(Arquillian.class) public class BidServiceUnitTest { diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java index 25b4998..e7d88e0 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java @@ -51,7 +51,6 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import static org.junit.Assert.assertEquals; import org.junit.Test; @@ -78,7 +77,7 @@ public static Archive createDeployment() { .addAsWebInfResource("test-web.xml", "web.xml") .addAsWebResource("add_bid.xhtml", "add_bid.xhtml") .addAsWebResource("confirm_add_bid.xhtml", "confirm_add_bid.xhtml") - .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") + .addAsWebInfResource("test-beans.xml", "beans.xml") .addAsResource("test-persistence.xml", "META-INF/persistence.xml"); } diff --git a/actionbazaar/src/test/resources/test-web.xml b/actionbazaar/src/test/resources/test-web.xml index 920ba4b..ad99d21 100644 --- a/actionbazaar/src/test/resources/test-web.xml +++ b/actionbazaar/src/test/resources/test-web.xml @@ -1,9 +1,8 @@ - + javax.faces.PROJECT_STAGE UnitTest From 4a73ca06e778c474909c9906f918e0b0ead5d56f Mon Sep 17 00:00:00 2001 From: Reza Rahman Date: Fri, 26 Sep 2014 15:33:57 -0700 Subject: [PATCH 05/15] Porting to GlassFish --- README.md | 64 ++++++------------- .../actionbazaar/interfaces/web/AddBid.java | 6 +- .../application/BidServiceTest.java | 2 +- .../application/BidServiceUnitTest.java | 2 +- .../interfaces/rest/BidRestServiceTest.java | 8 +-- .../interfaces/socket/ChatServerTest.java | 4 +- .../interfaces/web/AddBidTest.java | 2 +- .../interfaces/web/AlertServletTest.java | 4 +- 8 files changed, 33 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index 856ab43..3aaa28a 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,33 @@ -Testing Java EE Applications on WebLogic 12.1.3 Using Arquillian +Testing Java EE Applications using Arquillian ================================================================ This application demonstrates how Java EE applications can be effectively -tested using Arquillian on WebLogic 12.1.3. The application contains a +tested using Arquillian. The application contains a set of JUnit tests that you should examine. The tests will be run as part -of the Maven build. The tests require a running instance of -WebLogic (please see setup instructions). The WebLogic Maven plugin used as -part of the build also requires a running instance of WebLogic to be present. - -WebLogic 12.1.3 supports Java EE 6 and some key Java EE 7 APIs - -WebSocket, JAX-RS 2, JSON-P and JPA 2.1. The application uses both -these APIs as well as Java EE 6 features such as CDI, EJB 3.1 and JSF 2. +of the Maven build. We used GlassFish 4.1 for the application (see setup +instructions below) but it should be easy to port to any Java EE 7 application +server such as JBoss, WildFly, WebLogic or WebSphere. Setup ----- -* Install WebLogic 12.1.3 -* The Java EE 7 APIs are not automatically enabled. This - [Aquarium blog entry](https://blogs.oracle.com/theaquarium/entry/java_ee_7_support_comes) - is invaluable in better understanding the Java EE 7 API support in - WebLogic 12.1.3. The referenced white paper explains the steps necessary to - enable the APIs. -* The demo application requires a data source. WebLogic 12.1.3 supports the - Java EE 6 standard @DataSourceDefinition and corresponding XML elements. - However, this does not seem to work with JPA 2.1 so we could not use it. A bug - has been filed to get this fixed. Yet another approach is to use WebLogic - proprietary JDBC modules. This requires an EAR file and would significantly - complicate an otherwise simple WAR build. For this reason, this was not an - approach we used. As a result, however, you will need to manually create a - data source for the demo application. The data source is expected to be bound - to 'jdbc/ActionBazaarDB'. We used embedded Derby but any underlying database - should work. If helpful, a sample WebLogic data source definition is provided - [here](ActionBazaarDB-jdbc.xml). -* The demo application uses the WebLogic Maven plugin to automatically deploy - as part of the build. You will need to enable the plugin in your environment. - The detailed instructions to do this can be found - [here](http://docs.oracle.com/middleware/1213/wls/WLPRG/maven.htm). This - resource also contains details on how to configure the Maven plugin, which - you will need to do (see below). +* Install GlassFish 4.1 * Please download this repository. You can use Git or just the simple zip download. * The demo is just a simple Maven project under the [actionbazaar](actionbazaar) directory. You should be able to open it up in any Maven capable IDE, we used NetBeans. -* If desired setup WebLogic in your IDE. This is what we tested. -* The tests in the Maven build are executed against a running WebLogic instance. +* If desired setup GlassFish in your IDE. +* The tests in the Maven build are executed against an installed GlassFish instance. You will need to configure [this file] (actionbazaar/src/test/resources/arquillian.xml) with the details - of your running WebLogic instance (you could run the instance via the IDE). - For details on configuring WebLogic for Arquillian, look - [here] (https://docs.jboss.org/author/display/ARQ/WLS+12.1+-+Remote). -* The build also automatically undeploys and deploys the application to the - running WebLogic instance using the WebLogic Maven plugin. Please configure - the plugin in the [Maven POM](actionbazaar/pom.xml) with the details - of your running WebLogic instance. + of your GlassFish installation. For details on configuring GlassFish for + Arquillian, look + [here] (https://docs.jboss.org/author/display/ARQ/GlassFish+3.1+-+Managed). + Note that in this case we are using GlassFish in managed mode. This means that + Arquillian still automatically start and stop GlassFish as needed. You must + set an admin password for GlassFish. Due to a GlassFish bug, Arquillian can't + start GlassFish with an empty admin password. Also, GlassFish embedded is + no longer supported as of GlassFish 4 and cannot be used. Similarly, we ran + into GlassFish bugs trying to use remote mode (normally the fastest option + with Arquillian). * If desired, you can deploy and run the application manually. We did this both - via NetBeans and by using the plain Maven generated war file in addition to - the automated build. -* You can hook up the build to a continuous integration server such as Hudson. - We tested such a setup. \ No newline at end of file + via NetBeans and by using the plain Maven generated war file. \ No newline at end of file diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java index 341374f..2df85b8 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java @@ -42,13 +42,13 @@ import com.actionbazaar.application.BidService; import com.actionbazaar.domain.Bid; import java.io.Serializable; -import javax.enterprise.context.SessionScoped; +import javax.enterprise.context.ApplicationScoped; import javax.enterprise.inject.Produces; import javax.inject.Inject; import javax.inject.Named; @Named -@SessionScoped +@ApplicationScoped public class AddBid implements Serializable { private static final long serialVersionUID = 1L; @@ -58,7 +58,7 @@ public class AddBid implements Serializable { @Produces @Named - @SessionScoped + @ApplicationScoped private final Bid bid = new Bid(); public String onAdd() { diff --git a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceTest.java b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceTest.java index 4f6fea9..b8699dc 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceTest.java @@ -64,7 +64,7 @@ public class BidServiceTest { @Deployment public static WebArchive createDeployment() { return ShrinkWrap - .create(WebArchive.class, "actionbazaar-test.war") + .create(WebArchive.class, "actionbazaar-service-test.war") .addClasses(BidService.class, DefaultBidService.class, Profiled.class, ProfilingInterceptor.class, BidRepository.class, DefaultBidRepository.class, Bid.class) diff --git a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java index f96ce90..38fc949 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java @@ -58,7 +58,7 @@ public class BidServiceUnitTest { @Deployment public static WebArchive createDeployment() { return ShrinkWrap - .create(WebArchive.class, "actionbazaar-test.war") + .create(WebArchive.class, "actionbazaar-service-unit-test.war") .addClasses(BidService.class, DefaultBidService.class, BidRepository.class, MockBidRepository.class, Bid.class) .addAsWebInfResource("test-beans.xml", "beans.xml"); diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java index 4c774a4..70884cc 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java @@ -66,7 +66,7 @@ public class BidRestServiceTest { @Deployment public static WebArchive createDeployment() { return ShrinkWrap - .create(WebArchive.class, "actionbazaar-test.war") + .create(WebArchive.class, "actionbazaar-rest-test.war") .addClasses(BidRestService.class, RestConfiguration.class, BidService.class, DefaultBidService.class, BidRepository.class, DefaultBidRepository.class, Bid.class) @@ -80,7 +80,7 @@ public static WebArchive createDeployment() { @InSequence(1) public void testAddBid() { WebTarget target = ClientBuilder.newClient() - .target("http://localhost:8080/actionbazaar-test/rest/bids"); + .target("http://localhost:8080/actionbazaar-rest-test/rest/bids"); // Save a new bid. Bid bid = new Bid(); @@ -105,7 +105,7 @@ public void testAddBid() { @InSequence(2) public void testUpdateBid() { WebTarget target = ClientBuilder.newClient() - .target("http://localhost:8080/actionbazaar-test/rest/bids/{id}") + .target("http://localhost:8080/actionbazaar-rest-test/rest/bids/{id}") .resolveTemplate("id", bidId); // Update bid. @@ -127,7 +127,7 @@ public void testUpdateBid() { @InSequence(3) public void testDeleteBid() { WebTarget target = ClientBuilder.newClient() - .target("http://localhost:8080/actionbazaar-test/rest/bids/{id}") + .target("http://localhost:8080/actionbazaar-rest-test/rest/bids/{id}") .resolveTemplate("id", bidId); target.request().delete(); diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java index 7434988..efbcd38 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java @@ -77,14 +77,14 @@ public class ChatServerTest { @Deployment public static WebArchive createDeployment() { return ShrinkWrap - .create(WebArchive.class, "actionbazaar-test.war") + .create(WebArchive.class, "actionbazaar-websocket-test.war") .addClass(ChatMessage.class) .addClass(ChatServer.class); } @Test public void testChat() throws URISyntaxException, DeploymentException, IOException, InterruptedException { - URI uri = new URI("ws://localhost:8080/actionbazaar-test/chat"); + URI uri = new URI("ws://localhost:8080/actionbazaar-websocket-test/chat"); WebSocketContainer container = ContainerProvider.getWebSocketContainer(); diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java index e7d88e0..a908e0d 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java @@ -70,7 +70,7 @@ public class AddBidTest { @Deployment(testable = false) public static Archive createDeployment() { return ShrinkWrap - .create(WebArchive.class, "actionbazaar-test.war") + .create(WebArchive.class, "actionbazaar-jsf-test.war") .addClasses(BidService.class, DefaultBidService.class, BidRepository.class, DefaultBidRepository.class, Bid.class, AddBid.class) diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java index 02cd9cf..913d037 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java @@ -57,7 +57,7 @@ public class AlertServletTest { @Deployment public static WebArchive createDeployment() { return ShrinkWrap - .create(WebArchive.class, "actionbazaar-test.war") + .create(WebArchive.class, "actionbazaar-servlet-test.war") .addClass(AlertServlet.class); } @@ -67,7 +67,7 @@ public void testGetAlerts() { // Get account balance JsonObject response = client - .target("http://localhost:8080/actionbazaar-test/alerts") + .target("http://localhost:8080/actionbazaar-servlet-test/alerts") .queryParam("user_id", "1111").request("application/json") .get(JsonObject.class); // TODO Assert more of the content. From c13d3d7d0fd0abd69f61ee3812e54f9479e0d006 Mon Sep 17 00:00:00 2001 From: Reza Rahman Date: Thu, 12 Feb 2015 20:02:31 -0500 Subject: [PATCH 06/15] Minor tweaks --- .../com/actionbazaar/interfaces/rest/RestConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/RestConfiguration.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/RestConfiguration.java index d8b2ceb..f1cd4a6 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/RestConfiguration.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/RestConfiguration.java @@ -51,6 +51,6 @@ public class RestConfiguration extends ResourceConfig { public RestConfiguration() { // Resource - packages(new String[]{BidRestService.class.getPackage().getName()}); // removed. + packages(new String[]{BidRestService.class.getPackage().getName()}); } } From 837e8afb8b88c14c1519399aa5411f312bcd37a0 Mon Sep 17 00:00:00 2001 From: Reza Rahman Date: Thu, 12 Feb 2015 22:39:52 -0500 Subject: [PATCH 07/15] Cleanup --- actionbazaar/nb-configuration.xml | 27 ---------- actionbazaar/nbactions.xml | 50 ------------------- .../actionbazaar/interfaces/web/AddBid.java | 2 +- .../main/resources/META-INF/persistence.xml | 3 +- .../test/resources/test-persistence-web.xml | 2 +- actionbazaar/src/test/resources/test-web.xml | 2 +- 6 files changed, 5 insertions(+), 81 deletions(-) delete mode 100644 actionbazaar/nb-configuration.xml delete mode 100644 actionbazaar/nbactions.xml diff --git a/actionbazaar/nb-configuration.xml b/actionbazaar/nb-configuration.xml deleted file mode 100644 index 5b43433..0000000 --- a/actionbazaar/nb-configuration.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - ide - gfv3ee6 - Facelets - - /less:/css - false - /scss:/css - false - - js/libs - - diff --git a/actionbazaar/nbactions.xml b/actionbazaar/nbactions.xml deleted file mode 100644 index 9636d3e..0000000 --- a/actionbazaar/nbactions.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - run - - war - ear - ejb - - - package - - - true - /add_bid.jsf - - - - debug - - war - ear - ejb - - - package - - - true - true - /add_bid.jsf - - - - profile - - ejb - ear - war - - - package - - - true - true - /add_bid.jsf - - - diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java index 2df85b8..bc32b1f 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java @@ -48,7 +48,7 @@ import javax.inject.Named; @Named -@ApplicationScoped +@ApplicationScoped // TODO Change this to flow scope. public class AddBid implements Serializable { private static final long serialVersionUID = 1L; diff --git a/actionbazaar/src/main/resources/META-INF/persistence.xml b/actionbazaar/src/main/resources/META-INF/persistence.xml index 8db6d8d..fa8bc09 100644 --- a/actionbazaar/src/main/resources/META-INF/persistence.xml +++ b/actionbazaar/src/main/resources/META-INF/persistence.xml @@ -3,7 +3,8 @@ java:global/jdbc/ActionBazaarDB - + diff --git a/actionbazaar/src/test/resources/test-persistence-web.xml b/actionbazaar/src/test/resources/test-persistence-web.xml index 0726838..f22ca8c 100644 --- a/actionbazaar/src/test/resources/test-persistence-web.xml +++ b/actionbazaar/src/test/resources/test-persistence-web.xml @@ -6,6 +6,6 @@ java:global/jdbc/ActionBazaarDB org.apache.derby.jdbc.EmbeddedDriver - jdbc:derby:/tmp/actionbazaar-database;create=true + jdbc:derby:/tmp/actionbazaar-test-database;create=true \ No newline at end of file diff --git a/actionbazaar/src/test/resources/test-web.xml b/actionbazaar/src/test/resources/test-web.xml index ad99d21..c492cde 100644 --- a/actionbazaar/src/test/resources/test-web.xml +++ b/actionbazaar/src/test/resources/test-web.xml @@ -22,6 +22,6 @@ java:global/jdbc/ActionBazaarDB org.apache.derby.jdbc.EmbeddedDriver - jdbc:derby:/tmp/actionbazaar-database;create=true + jdbc:derby:/tmp/actionbazaar-test-database;create=true \ No newline at end of file From 6c978c6ad9ac9dc87acad61565690e87e0d261f4 Mon Sep 17 00:00:00 2001 From: Reza Rahman Date: Thu, 12 Feb 2015 22:47:32 -0500 Subject: [PATCH 08/15] Minor tweak. --- README.md | 2 +- actionbazaar/nb-configuration.xml | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 actionbazaar/nb-configuration.xml diff --git a/README.md b/README.md index 3aaa28a..6ea586b 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,6 @@ Setup start GlassFish with an empty admin password. Also, GlassFish embedded is no longer supported as of GlassFish 4 and cannot be used. Similarly, we ran into GlassFish bugs trying to use remote mode (normally the fastest option - with Arquillian). + with Arquillian). * If desired, you can deploy and run the application manually. We did this both via NetBeans and by using the plain Maven generated war file. \ No newline at end of file diff --git a/actionbazaar/nb-configuration.xml b/actionbazaar/nb-configuration.xml new file mode 100644 index 0000000..4da1f6c --- /dev/null +++ b/actionbazaar/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + ide + + From 946733b19e5ecf6ee753d8dfc5808d9e05d44838 Mon Sep 17 00:00:00 2001 From: Reza Rahman Date: Fri, 13 Feb 2015 21:24:05 -0500 Subject: [PATCH 09/15] Minor cleanup. --- actionbazaar/pom.xml | 11 +++++++++++ .../application/DefaultBidService.java | 18 +++++++++++++++--- .../interfaces/socket/ChatMessage.java | 9 +++++++++ .../interfaces/web/AlertServlet.java | 8 ++++++-- actionbazaar/src/main/webapp/WEB-INF/web.xml | 2 +- .../database/MockBidRepository.java | 15 ++++++++++++--- .../interfaces/rest/BidRestServiceTest.java | 3 ++- .../interfaces/socket/ChatServerTest.java | 3 ++- .../interfaces/web/AlertServletTest.java | 3 ++- actionbazaar/src/test/resources/arquillian.xml | 13 ++++++++----- 10 files changed, 68 insertions(+), 17 deletions(-) diff --git a/actionbazaar/pom.xml b/actionbazaar/pom.xml index a46536e..432f972 100644 --- a/actionbazaar/pom.xml +++ b/actionbazaar/pom.xml @@ -83,6 +83,8 @@ 1.0.0.CR4 test + + + + actionbazaar diff --git a/actionbazaar/src/main/java/com/actionbazaar/application/DefaultBidService.java b/actionbazaar/src/main/java/com/actionbazaar/application/DefaultBidService.java index dfe8bb8..7f316a9 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/application/DefaultBidService.java +++ b/actionbazaar/src/main/java/com/actionbazaar/application/DefaultBidService.java @@ -39,36 +39,48 @@ */ package com.actionbazaar.application; -import javax.ejb.Stateless; -import javax.inject.Inject; - import com.actionbazaar.domain.Bid; import com.actionbazaar.domain.BidRepository; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.ejb.Stateless; +import javax.inject.Inject; @Stateless @Profiled public class DefaultBidService implements BidService { + private static final Logger logger = Logger + .getLogger(DefaultBidService.class.getName()); + @Inject private BidRepository bidRepository; @Override public Bid addBid(Bid bid) { + logger.log(Level.INFO, "Adding bid: {0}", bid); + return bidRepository.addBid(bid); } @Override public Bid getBid(Long id) { + logger.log(Level.INFO, "Getting bid: {0}", id); + return bidRepository.getBid(id); } @Override public void updateBid(Bid bid) { + logger.log(Level.INFO, "Updating bid: {0}", bid); + bidRepository.updateBid(bid); } @Override public void deleteBid(Bid bid) { + logger.log(Level.INFO, "Deleting bid: {0}", bid); + bidRepository.deleteBid(bid); } } diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/socket/ChatMessage.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/socket/ChatMessage.java index 6f25f7c..3cfea7a 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/socket/ChatMessage.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/socket/ChatMessage.java @@ -40,6 +40,8 @@ package com.actionbazaar.interfaces.socket; import java.io.StringReader; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.json.Json; import javax.json.JsonObject; import javax.json.JsonReader; @@ -50,6 +52,9 @@ public class ChatMessage implements Decoder.Text, Encoder.Text { + private static final Logger logger = Logger + .getLogger(ChatMessage.class.getName()); + private String user; private String message; @@ -77,6 +82,8 @@ public void init(EndpointConfig config) { @Override public ChatMessage decode(String value) { + logger.log(Level.FINE, "Decoding JSON: {0}", value); + try (JsonReader jsonReader = Json.createReader( new StringReader(value))) { JsonObject jsonObject = jsonReader.readObject(); @@ -94,6 +101,8 @@ public boolean willDecode(String string) { @Override public String encode(ChatMessage chatMessage) { + logger.log(Level.FINE, "Encoding to JSON: {0}", chatMessage); + JsonObject jsonObject = Json.createObjectBuilder() .add("user", chatMessage.user) .add("message", chatMessage.message) diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AlertServlet.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AlertServlet.java index 3783f0d..6acd3e0 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AlertServlet.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AlertServlet.java @@ -41,7 +41,8 @@ import java.io.IOException; import java.io.PrintWriter; - +import java.util.logging.Level; +import java.util.logging.Logger; import javax.json.Json; import javax.json.stream.JsonGenerator; import javax.servlet.ServletException; @@ -54,17 +55,20 @@ public class AlertServlet extends HttpServlet { private static final long serialVersionUID = 1L; + private static final Logger logger = Logger + .getLogger(AlertServlet.class.getName()); @Override public void service(ServletRequest request, ServletResponse response) throws IOException, ServletException { - response.setContentType("application/json"); PrintWriter out = response.getWriter(); long userId = Long.parseLong(request.getParameter("user_id")); + logger.log(Level.INFO, "Generating alerts for: {0}", userId); + try (JsonGenerator generator = Json.createGenerator(out)) { generator.writeStartObject(); diff --git a/actionbazaar/src/main/webapp/WEB-INF/web.xml b/actionbazaar/src/main/webapp/WEB-INF/web.xml index f5742b9..e03d44c 100644 --- a/actionbazaar/src/main/webapp/WEB-INF/web.xml +++ b/actionbazaar/src/main/webapp/WEB-INF/web.xml @@ -25,6 +25,6 @@ java:global/jdbc/ActionBazaarDB org.apache.derby.jdbc.EmbeddedDriver - jdbc:derby:/tmp/actionbazaar-database;create=true + jdbc:derby:/tmp/actionbazaar-development-database;create=true \ No newline at end of file diff --git a/actionbazaar/src/test/java/com/actionbazaar/infrastructure/database/MockBidRepository.java b/actionbazaar/src/test/java/com/actionbazaar/infrastructure/database/MockBidRepository.java index ee5eb5c..3c0c2d6 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/infrastructure/database/MockBidRepository.java +++ b/actionbazaar/src/test/java/com/actionbazaar/infrastructure/database/MockBidRepository.java @@ -39,18 +39,27 @@ */ package com.actionbazaar.infrastructure.database; -import com.actionbazaar.domain.BidRepository; import com.actionbazaar.domain.Bid; +import com.actionbazaar.domain.BidRepository; +import java.util.logging.Level; +import java.util.logging.Logger; public class MockBidRepository implements BidRepository { + private static final Logger logger = Logger + .getLogger(MockBidRepository.class.getName()); + @Override public Bid addBid(Bid bid) { + logger.log(Level.INFO, "Mock add bid."); + return bid; } @Override public Bid getBid(Long id) { + logger.log(Level.INFO, "Mock get bid."); + Bid bid = new Bid(); bid.setId(id); bid.setBidder("nrahman"); @@ -62,11 +71,11 @@ public Bid getBid(Long id) { @Override public void updateBid(Bid bid) { - // NOOP + logger.log(Level.INFO, "Mock update bid."); } @Override public void deleteBid(Bid bid) { - // NOOP + logger.log(Level.INFO, "Mock delete bid."); } } diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java index 70884cc..b06ee4d 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java @@ -57,8 +57,9 @@ import org.junit.Test; import org.junit.runner.RunWith; +// Ran into weird bugs trying to run this on the client. +// Probably another Maven dependency melee. @RunWith(Arquillian.class) -// TODO Move this to client side. public class BidRestServiceTest { private static Long bidId; diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java index efbcd38..7e1509c 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java @@ -64,8 +64,9 @@ import org.junit.Test; import org.junit.runner.RunWith; +// Ran into weird bugs trying to run this on the client. +// Probably another Maven dependency melee. @RunWith(Arquillian.class) -// TODO Move test to client side. public class ChatServerTest { private static final Logger logger diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java index 913d037..44bd648 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java @@ -50,8 +50,9 @@ import org.junit.Test; import org.junit.runner.RunWith; +// Ran into weird bugs trying to run this on the client. +// Probably another Maven dependency melee. @RunWith(Arquillian.class) -// TODO Move to client side. public class AlertServletTest { @Deployment diff --git a/actionbazaar/src/test/resources/arquillian.xml b/actionbazaar/src/test/resources/arquillian.xml index 8c80f6d..525fb4d 100644 --- a/actionbazaar/src/test/resources/arquillian.xml +++ b/actionbazaar/src/test/resources/arquillian.xml @@ -1,18 +1,21 @@ - - target/ + + target/ + + firefox + C:\glassfish4.1 localhost 4848 admin - admin + admin - + \ No newline at end of file From 277d2d14d3fcf47ff2ae92e451feff8d823b2804 Mon Sep 17 00:00:00 2001 From: Reza Rahman Date: Mon, 20 Jun 2016 16:06:53 -0400 Subject: [PATCH 10/15] Switching to JBoss EAP --- README.md | 26 ++++----- actionbazaar/nb-configuration.xml | 1 + actionbazaar/pom.xml | 36 +----------- .../interfaces/rest/RestConfiguration.java | 58 +++---------------- .../actionbazaar/interfaces/web/AddBid.java | 41 +------------ .../main/resources/META-INF/persistence.xml | 4 +- .../WEB-INF/jboss-deployment-structure.xml | 7 +++ actionbazaar/src/main/webapp/WEB-INF/web.xml | 4 +- .../application/BidServiceTest.java | 40 +------------ .../application/BidServiceUnitTest.java | 39 ------------- .../interfaces/rest/BidRestServiceTest.java | 40 +------------ .../interfaces/web/AddBidTest.java | 40 +------------ .../interfaces/web/AlertServletTest.java | 39 ------------- .../src/test/resources/arquillian.xml | 14 ++--- .../resources/jboss-deployment-structure.xml | 7 +++ .../test/resources/test-persistence-web.xml | 4 +- actionbazaar/src/test/resources/test-web.xml | 4 +- 17 files changed, 56 insertions(+), 348 deletions(-) create mode 100644 actionbazaar/src/main/webapp/WEB-INF/jboss-deployment-structure.xml create mode 100644 actionbazaar/src/test/resources/jboss-deployment-structure.xml diff --git a/README.md b/README.md index 6ea586b..e0c3b68 100644 --- a/README.md +++ b/README.md @@ -3,31 +3,27 @@ Testing Java EE Applications using Arquillian This application demonstrates how Java EE applications can be effectively tested using Arquillian. The application contains a set of JUnit tests that you should examine. The tests will be run as part -of the Maven build. We used GlassFish 4.1 for the application (see setup +of the Maven build. We used JBoss EAP 7 for the application (see setup instructions below) but it should be easy to port to any Java EE 7 application -server such as JBoss, WildFly, WebLogic or WebSphere. +server such as GlassFish, WildFly, WebLogic or WebSphere. Setup ----- -* Install GlassFish 4.1 +* Install JBoss EAP 7. It should be a simple matter of downloading the installation + jar and running the GUI wizard (you will need a Red Hat account). Just accept + all the defaults. Remember the admin password you choose. * Please download this repository. You can use Git or just the simple zip download. * The demo is just a simple Maven project under the [actionbazaar](actionbazaar) directory. You should be able to open it up in any Maven capable IDE, we used NetBeans. -* If desired setup GlassFish in your IDE. -* The tests in the Maven build are executed against an installed GlassFish instance. +* If desired setup JBoss EAP in your IDE; we did. At the current time, NetBeans does + not directly support JBoss EAP 7 yet. You can use the NetBeans features for + WildFly 10; it worked fine for us. +* Make sure JBoss EAP 7 is up and running before you run the tests. +* The tests in the Maven build are executed against a running JBoss EAP instance. You will need to configure [this file] (actionbazaar/src/test/resources/arquillian.xml) with the details - of your GlassFish installation. For details on configuring GlassFish for - Arquillian, look - [here] (https://docs.jboss.org/author/display/ARQ/GlassFish+3.1+-+Managed). - Note that in this case we are using GlassFish in managed mode. This means that - Arquillian still automatically start and stop GlassFish as needed. You must - set an admin password for GlassFish. Due to a GlassFish bug, Arquillian can't - start GlassFish with an empty admin password. Also, GlassFish embedded is - no longer supported as of GlassFish 4 and cannot be used. Similarly, we ran - into GlassFish bugs trying to use remote mode (normally the fastest option - with Arquillian). + of your JBoss EAP installation. You must set the admin password for JBoss EAP. * If desired, you can deploy and run the application manually. We did this both via NetBeans and by using the plain Maven generated war file. \ No newline at end of file diff --git a/actionbazaar/nb-configuration.xml b/actionbazaar/nb-configuration.xml index 4da1f6c..39882f4 100644 --- a/actionbazaar/nb-configuration.xml +++ b/actionbazaar/nb-configuration.xml @@ -14,5 +14,6 @@ That way multiple projects can share the same settings (useful for formatting ru Any value defined here will override the pom.xml file value but is only applicable to the current project. --> ide + WildFly diff --git a/actionbazaar/pom.xml b/actionbazaar/pom.xml index 432f972..b4cbe29 100644 --- a/actionbazaar/pom.xml +++ b/actionbazaar/pom.xml @@ -47,13 +47,6 @@ 7.0 provided - - org.glassfish.jersey.containers - jersey-container-servlet-core - 2.0 - jar - provided - junit junit @@ -78,34 +71,11 @@ test - org.jboss.arquillian.container - arquillian-glassfish-managed-3.1 - 1.0.0.CR4 - test - - - - - actionbazaar diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/RestConfiguration.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/RestConfiguration.java index f1cd4a6..a21b12d 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/RestConfiguration.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/rest/RestConfiguration.java @@ -1,56 +1,16 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * http://glassfish.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ package com.actionbazaar.interfaces.rest; +import java.util.Set; import javax.ws.rs.ApplicationPath; -import org.glassfish.jersey.server.ResourceConfig; +import javax.ws.rs.core.Application; -/** - * JAX-RS configuration. - */ @ApplicationPath("rest") -// TODO Move this to XML. -public class RestConfiguration extends ResourceConfig { +public class RestConfiguration extends Application { - public RestConfiguration() { - // Resource - packages(new String[]{BidRestService.class.getPackage().getName()}); + @Override + public Set> getClasses() { + Set> resources = new java.util.HashSet<>(); + resources.add(BidRestService.class); + return resources; } -} +} \ No newline at end of file diff --git a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java index bc32b1f..1620bc3 100644 --- a/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java +++ b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java @@ -1,42 +1,3 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * http://glassfish.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ package com.actionbazaar.interfaces.web; import com.actionbazaar.application.BidService; @@ -48,7 +9,7 @@ import javax.inject.Named; @Named -@ApplicationScoped // TODO Change this to flow scope. +@ApplicationScoped // TODO Change this to flow scoped. public class AddBid implements Serializable { private static final long serialVersionUID = 1L; diff --git a/actionbazaar/src/main/resources/META-INF/persistence.xml b/actionbazaar/src/main/resources/META-INF/persistence.xml index fa8bc09..80c589f 100644 --- a/actionbazaar/src/main/resources/META-INF/persistence.xml +++ b/actionbazaar/src/main/resources/META-INF/persistence.xml @@ -1,5 +1,7 @@ - + java:global/jdbc/ActionBazaarDB diff --git a/actionbazaar/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/actionbazaar/src/main/webapp/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 0000000..9f03b31 --- /dev/null +++ b/actionbazaar/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/actionbazaar/src/main/webapp/WEB-INF/web.xml b/actionbazaar/src/main/webapp/WEB-INF/web.xml index e03d44c..7dc30dd 100644 --- a/actionbazaar/src/main/webapp/WEB-INF/web.xml +++ b/actionbazaar/src/main/webapp/WEB-INF/web.xml @@ -24,7 +24,7 @@ java:global/jdbc/ActionBazaarDB - org.apache.derby.jdbc.EmbeddedDriver - jdbc:derby:/tmp/actionbazaar-development-database;create=true + org.h2.jdbcx.JdbcDataSource + jdbc:h2:/tmp/actionbazaar-development-database \ No newline at end of file diff --git a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceTest.java b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceTest.java index b8699dc..2646aaa 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceTest.java @@ -1,42 +1,3 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * http://glassfish.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ package com.actionbazaar.application; import static org.junit.Assert.assertEquals; @@ -69,6 +30,7 @@ public static WebArchive createDeployment() { Profiled.class, ProfilingInterceptor.class, BidRepository.class, DefaultBidRepository.class, Bid.class) .addAsWebInfResource("test-persistence-web.xml", "web.xml") + .addAsWebInfResource("jboss-deployment-structure.xml", "jboss-deployment-structure.xml") .addAsWebInfResource("test-persistence-beans.xml", "beans.xml") .addAsResource("test-persistence.xml", "META-INF/persistence.xml"); } diff --git a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java index 38fc949..72bd16e 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java @@ -1,42 +1,3 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * http://glassfish.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ package com.actionbazaar.application; import com.actionbazaar.domain.Bid; diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java index b06ee4d..09ab7ee 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java @@ -1,42 +1,3 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * http://glassfish.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ package com.actionbazaar.interfaces.rest; import com.actionbazaar.application.BidService; @@ -73,6 +34,7 @@ public static WebArchive createDeployment() { BidRepository.class, DefaultBidRepository.class, Bid.class) .addAsWebInfResource("test-beans.xml", "beans.xml") .addAsWebInfResource("test-persistence-web.xml", "web.xml") + .addAsWebInfResource("jboss-deployment-structure.xml", "jboss-deployment-structure.xml") .addAsResource("test-persistence.xml", "META-INF/persistence.xml"); } diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java index a908e0d..d9ad813 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java @@ -1,42 +1,3 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * http://glassfish.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ package com.actionbazaar.interfaces.web; import com.actionbazaar.application.BidService; @@ -75,6 +36,7 @@ public static Archive createDeployment() { BidRepository.class, DefaultBidRepository.class, Bid.class, AddBid.class) .addAsWebInfResource("test-web.xml", "web.xml") + .addAsWebInfResource("jboss-deployment-structure.xml", "jboss-deployment-structure.xml") .addAsWebResource("add_bid.xhtml", "add_bid.xhtml") .addAsWebResource("confirm_add_bid.xhtml", "confirm_add_bid.xhtml") .addAsWebInfResource("test-beans.xml", "beans.xml") diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java index 44bd648..06e7628 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java @@ -1,42 +1,3 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * http://glassfish.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ package com.actionbazaar.interfaces.web; import javax.json.JsonObject; diff --git a/actionbazaar/src/test/resources/arquillian.xml b/actionbazaar/src/test/resources/arquillian.xml index 525fb4d..0671cfa 100644 --- a/actionbazaar/src/test/resources/arquillian.xml +++ b/actionbazaar/src/test/resources/arquillian.xml @@ -6,16 +6,12 @@ target/ - - firefox - - + - C:\glassfish4.1 - localhost - 4848 - admin - admin + jboss eap:7.0.0.Final:remote + localhost + admin + YOUR_JBOSSEAP_PASSWORD \ No newline at end of file diff --git a/actionbazaar/src/test/resources/jboss-deployment-structure.xml b/actionbazaar/src/test/resources/jboss-deployment-structure.xml new file mode 100644 index 0000000..9f03b31 --- /dev/null +++ b/actionbazaar/src/test/resources/jboss-deployment-structure.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/actionbazaar/src/test/resources/test-persistence-web.xml b/actionbazaar/src/test/resources/test-persistence-web.xml index f22ca8c..5b8d245 100644 --- a/actionbazaar/src/test/resources/test-persistence-web.xml +++ b/actionbazaar/src/test/resources/test-persistence-web.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> java:global/jdbc/ActionBazaarDB - org.apache.derby.jdbc.EmbeddedDriver - jdbc:derby:/tmp/actionbazaar-test-database;create=true + org.h2.jdbcx.JdbcDataSource + jdbc:h2:/tmp/actionbazaar-test-database \ No newline at end of file diff --git a/actionbazaar/src/test/resources/test-web.xml b/actionbazaar/src/test/resources/test-web.xml index c492cde..b0a1d82 100644 --- a/actionbazaar/src/test/resources/test-web.xml +++ b/actionbazaar/src/test/resources/test-web.xml @@ -21,7 +21,7 @@ java:global/jdbc/ActionBazaarDB - org.apache.derby.jdbc.EmbeddedDriver - jdbc:derby:/tmp/actionbazaar-test-database;create=true + org.h2.jdbcx.JdbcDataSource + jdbc:h2:/tmp/actionbazaar-test-database \ No newline at end of file From bbe7d817d38f57f08353e95fced8fa8fb6dc5aab Mon Sep 17 00:00:00 2001 From: Bruno Borges Date: Tue, 28 Jun 2016 23:18:01 -0700 Subject: [PATCH 11/15] use default datasource --- actionbazaar/src/main/resources/META-INF/persistence.xml | 3 +-- actionbazaar/src/main/webapp/WEB-INF/web.xml | 7 +------ actionbazaar/src/test/resources/test-persistence-web.xml | 7 +------ actionbazaar/src/test/resources/test-persistence.xml | 4 ++-- actionbazaar/src/test/resources/test-web.xml | 7 +------ 5 files changed, 6 insertions(+), 22 deletions(-) diff --git a/actionbazaar/src/main/resources/META-INF/persistence.xml b/actionbazaar/src/main/resources/META-INF/persistence.xml index 80c589f..4aad9b0 100644 --- a/actionbazaar/src/main/resources/META-INF/persistence.xml +++ b/actionbazaar/src/main/resources/META-INF/persistence.xml @@ -3,11 +3,10 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> - java:global/jdbc/ActionBazaarDB + java:comp/DefaultDataSource - diff --git a/actionbazaar/src/main/webapp/WEB-INF/web.xml b/actionbazaar/src/main/webapp/WEB-INF/web.xml index 7dc30dd..1fb7453 100644 --- a/actionbazaar/src/main/webapp/WEB-INF/web.xml +++ b/actionbazaar/src/main/webapp/WEB-INF/web.xml @@ -22,9 +22,4 @@ add_bid.jsf - - java:global/jdbc/ActionBazaarDB - org.h2.jdbcx.JdbcDataSource - jdbc:h2:/tmp/actionbazaar-development-database - - \ No newline at end of file + diff --git a/actionbazaar/src/test/resources/test-persistence-web.xml b/actionbazaar/src/test/resources/test-persistence-web.xml index 5b8d245..0ab3fff 100644 --- a/actionbazaar/src/test/resources/test-persistence-web.xml +++ b/actionbazaar/src/test/resources/test-persistence-web.xml @@ -3,9 +3,4 @@ xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> - - java:global/jdbc/ActionBazaarDB - org.h2.jdbcx.JdbcDataSource - jdbc:h2:/tmp/actionbazaar-test-database - - \ No newline at end of file + diff --git a/actionbazaar/src/test/resources/test-persistence.xml b/actionbazaar/src/test/resources/test-persistence.xml index 16918a5..aa8fd47 100644 --- a/actionbazaar/src/test/resources/test-persistence.xml +++ b/actionbazaar/src/test/resources/test-persistence.xml @@ -5,11 +5,11 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> - java:global/jdbc/ActionBazaarDB + java:comp/DefaultDataSource - \ No newline at end of file +
diff --git a/actionbazaar/src/test/resources/test-web.xml b/actionbazaar/src/test/resources/test-web.xml index b0a1d82..a50f76d 100644 --- a/actionbazaar/src/test/resources/test-web.xml +++ b/actionbazaar/src/test/resources/test-web.xml @@ -19,9 +19,4 @@ add_bid.jsf - - java:global/jdbc/ActionBazaarDB - org.h2.jdbcx.JdbcDataSource - jdbc:h2:/tmp/actionbazaar-test-database - - \ No newline at end of file + From 8510e5d64e73cf60aa211f94cceb04611beb0f04 Mon Sep 17 00:00:00 2001 From: Bruno Borges Date: Fri, 1 Jul 2016 05:28:41 -0700 Subject: [PATCH 12/15] maven and arquillian setup for weblogic --- actionbazaar/pom.xml | 104 ++++++++++++++---- .../src/test/resources/arquillian.xml | 22 +++- 2 files changed, 100 insertions(+), 26 deletions(-) diff --git a/actionbazaar/pom.xml b/actionbazaar/pom.xml index b4cbe29..9200d51 100644 --- a/actionbazaar/pom.xml +++ b/actionbazaar/pom.xml @@ -9,37 +9,87 @@ actionbazaar 1.0-SNAPSHOT war - - - jboss-public-repository-group - https://repository.jboss.org/nexus/content/groups/public-jboss/ - - + + + + jboss + + true + + + localhost + 9990 + admin + jboss + + + + + jboss-public-repository-group + https://repository.jboss.org/nexus/content/groups/public-jboss/ + + + + + + org.arquillian.container + arquillian-container-chameleon + 1.0.0.Alpha6 + test + + + + + + weblogic + + false + + + + http://localhost:8080 + weblogic + welcome1 + AdminServer + + + + + org.jboss.arquillian.container + arquillian-wls-remote-rest + 1.0.1.Final + test + + + + + org.jboss.arquillian arquillian-bom - 1.1.5.Final - import + 1.1.11.Final pom + import org.jboss.shrinkwrap.resolver shrinkwrap-resolver-bom - 2.1.1 + 2.2.2 pom import org.jboss.arquillian.extension arquillian-drone-bom - 1.3.1.Final + 2.0.0.Final pom import + javax @@ -50,7 +100,7 @@ junit junit - 4.11 + 4.12 test @@ -71,14 +121,17 @@ test - org.arquillian.container - arquillian-container-chameleon - 1.0.0.Alpha6 - test + com.oracle.weblogic + weblogic-server-pom + 12.2.1-0-0 + pom + provided + actionbazaar + src/test/resources @@ -87,19 +140,20 @@ src/main/webapp + maven-compiler-plugin - 2.3.2 + 3.5.1 - 1.7 - 1.7 + 1.8 + 1.8 org.apache.maven.plugins maven-war-plugin - 2.1.1 + 2.6 false actionbazaar @@ -107,11 +161,19 @@ maven-surefire-plugin - 2.15 + 2.19.1 false + false + + ${wls.server} + ${wls.user} + ${wls.pass} + ${wls.target} + weblogic + - \ No newline at end of file + diff --git a/actionbazaar/src/test/resources/arquillian.xml b/actionbazaar/src/test/resources/arquillian.xml index 0671cfa..92da43e 100644 --- a/actionbazaar/src/test/resources/arquillian.xml +++ b/actionbazaar/src/test/resources/arquillian.xml @@ -6,12 +6,24 @@ target/ - + + jboss eap:7.0.0.Final:remote - localhost - admin - YOUR_JBOSSEAP_PASSWORD + ${jboss.address} + ${jboss.port} + ${jboss.user} + ${jboss.pass} - \ No newline at end of file + + + + + ${wls.server} + ${wls.user} + ${wls.pass} + ${wls.target} + + + From 6ffcec4ce3636046d1355c05722290edb83e1f23 Mon Sep 17 00:00:00 2001 From: Bruno Borges Date: Wed, 6 Jul 2016 22:52:29 -0300 Subject: [PATCH 13/15] use dynamic URL --- .../interfaces/rest/BidRestServiceTest.java | 11 ++++++++--- .../interfaces/socket/ChatServerTest.java | 7 ++++++- .../actionbazaar/interfaces/web/AlertServletTest.java | 7 ++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java index 09ab7ee..01c3bbb 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java @@ -5,12 +5,14 @@ import com.actionbazaar.domain.Bid; import com.actionbazaar.domain.BidRepository; import com.actionbazaar.infrastructure.database.DefaultBidRepository; +import java.net.URL; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Entity; import javax.ws.rs.client.WebTarget; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.junit.InSequence; +import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import static org.junit.Assert.assertEquals; @@ -25,6 +27,9 @@ public class BidRestServiceTest { private static Long bidId; + @ArquillianResource + URL contextPath; + @Deployment public static WebArchive createDeployment() { return ShrinkWrap @@ -43,7 +48,7 @@ public static WebArchive createDeployment() { @InSequence(1) public void testAddBid() { WebTarget target = ClientBuilder.newClient() - .target("http://localhost:8080/actionbazaar-rest-test/rest/bids"); + .target(contextPath + "rest/bids"); // Save a new bid. Bid bid = new Bid(); @@ -68,7 +73,7 @@ public void testAddBid() { @InSequence(2) public void testUpdateBid() { WebTarget target = ClientBuilder.newClient() - .target("http://localhost:8080/actionbazaar-rest-test/rest/bids/{id}") + .target(contextPath + "rest/bids/{id}") .resolveTemplate("id", bidId); // Update bid. @@ -90,7 +95,7 @@ public void testUpdateBid() { @InSequence(3) public void testDeleteBid() { WebTarget target = ClientBuilder.newClient() - .target("http://localhost:8080/actionbazaar-rest-test/rest/bids/{id}") + .target(contextPath + "rest/bids/{id}") .resolveTemplate("id", bidId); target.request().delete(); diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java index 7e1509c..759bea6 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java @@ -42,6 +42,7 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.net.URL; import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; @@ -58,6 +59,7 @@ import javax.websocket.WebSocketContainer; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; +import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import static org.junit.Assert.assertEquals; @@ -74,6 +76,9 @@ public class ChatServerTest { private static ChatMessage testMessage; private static ChatMessage testReply; + + @ArquillianResource + URL contextPath; @Deployment public static WebArchive createDeployment() { @@ -85,7 +90,7 @@ public static WebArchive createDeployment() { @Test public void testChat() throws URISyntaxException, DeploymentException, IOException, InterruptedException { - URI uri = new URI("ws://localhost:8080/actionbazaar-websocket-test/chat"); + URI uri = new URI("ws://"+contextPath.getHost()+":"+contextPath.getPort()+"/actionbazaar-websocket-test/chat"); WebSocketContainer container = ContainerProvider.getWebSocketContainer(); diff --git a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java index 06e7628..d426cb2 100644 --- a/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java +++ b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java @@ -1,10 +1,12 @@ package com.actionbazaar.interfaces.web; +import java.net.URL; import javax.json.JsonObject; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; +import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import static org.junit.Assert.assertEquals; @@ -15,6 +17,9 @@ // Probably another Maven dependency melee. @RunWith(Arquillian.class) public class AlertServletTest { + + @ArquillianResource + URL contextPath; @Deployment public static WebArchive createDeployment() { @@ -29,7 +34,7 @@ public void testGetAlerts() { // Get account balance JsonObject response = client - .target("http://localhost:8080/actionbazaar-servlet-test/alerts") + .target(contextPath + "alerts") .queryParam("user_id", "1111").request("application/json") .get(JsonObject.class); // TODO Assert more of the content. From a817daadd1b5aedc3a55e0cd144fc43006e08c5b Mon Sep 17 00:00:00 2001 From: Bruno Borges Date: Wed, 6 Jul 2016 22:52:42 -0300 Subject: [PATCH 14/15] no need for jboss profile --- actionbazaar/pom.xml | 65 ++++++++------------------------------------ 1 file changed, 12 insertions(+), 53 deletions(-) diff --git a/actionbazaar/pom.xml b/actionbazaar/pom.xml index 9200d51..4b587ab 100644 --- a/actionbazaar/pom.xml +++ b/actionbazaar/pom.xml @@ -10,59 +10,12 @@ 1.0-SNAPSHOT war - - - jboss - - true - - - localhost - 9990 - admin - jboss - - - - - jboss-public-repository-group - https://repository.jboss.org/nexus/content/groups/public-jboss/ - - - - - - org.arquillian.container - arquillian-container-chameleon - 1.0.0.Alpha6 - test - - - - - - weblogic - - false - - - - http://localhost:8080 - weblogic - welcome1 - AdminServer - - - - - org.jboss.arquillian.container - arquillian-wls-remote-rest - 1.0.1.Final - test - - - - + + http://localhost:7001 + weblogic + welcome1 + AdminServer + @@ -91,6 +44,12 @@ + + org.jboss.arquillian.container + arquillian-wls-remote-rest + 1.0.1.Final + test + javax javaee-api From 130986e543f4e8eee9e9c80c8163aa0d6be765cc Mon Sep 17 00:00:00 2001 From: Bruno Borges Date: Wed, 6 Jul 2016 22:53:00 -0300 Subject: [PATCH 15/15] wls config --- actionbazaar/src/main/webapp/WEB-INF/weblogic.xml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 actionbazaar/src/main/webapp/WEB-INF/weblogic.xml diff --git a/actionbazaar/src/main/webapp/WEB-INF/weblogic.xml b/actionbazaar/src/main/webapp/WEB-INF/weblogic.xml new file mode 100644 index 0000000..cd44780 --- /dev/null +++ b/actionbazaar/src/main/webapp/WEB-INF/weblogic.xml @@ -0,0 +1,8 @@ + + + + true + true + + +