Skip to content

Commit 4a73ca0

Browse files
author
Reza Rahman
committed
Porting to GlassFish
1 parent 1ce2c8a commit 4a73ca0

8 files changed

Lines changed: 33 additions & 59 deletions

File tree

README.md

Lines changed: 19 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,33 @@
1-
Testing Java EE Applications on WebLogic 12.1.3 Using Arquillian
1+
Testing Java EE Applications using Arquillian
22
================================================================
33
This application demonstrates how Java EE applications can be effectively
4-
tested using Arquillian on WebLogic 12.1.3. The application contains a
4+
tested using Arquillian. The application contains a
55
set of JUnit tests that you should examine. The tests will be run as part
6-
of the Maven build. The tests require a running instance of
7-
WebLogic (please see setup instructions). The WebLogic Maven plugin used as
8-
part of the build also requires a running instance of WebLogic to be present.
9-
10-
WebLogic 12.1.3 supports Java EE 6 and some key Java EE 7 APIs -
11-
WebSocket, JAX-RS 2, JSON-P and JPA 2.1. The application uses both
12-
these APIs as well as Java EE 6 features such as CDI, EJB 3.1 and JSF 2.
6+
of the Maven build. We used GlassFish 4.1 for the application (see setup
7+
instructions below) but it should be easy to port to any Java EE 7 application
8+
server such as JBoss, WildFly, WebLogic or WebSphere.
139

1410
Setup
1511
-----
16-
* Install WebLogic 12.1.3
17-
* The Java EE 7 APIs are not automatically enabled. This
18-
[Aquarium blog entry](https://blogs.oracle.com/theaquarium/entry/java_ee_7_support_comes)
19-
is invaluable in better understanding the Java EE 7 API support in
20-
WebLogic 12.1.3. The referenced white paper explains the steps necessary to
21-
enable the APIs.
22-
* The demo application requires a data source. WebLogic 12.1.3 supports the
23-
Java EE 6 standard @DataSourceDefinition and corresponding XML elements.
24-
However, this does not seem to work with JPA 2.1 so we could not use it. A bug
25-
has been filed to get this fixed. Yet another approach is to use WebLogic
26-
proprietary JDBC modules. This requires an EAR file and would significantly
27-
complicate an otherwise simple WAR build. For this reason, this was not an
28-
approach we used. As a result, however, you will need to manually create a
29-
data source for the demo application. The data source is expected to be bound
30-
to 'jdbc/ActionBazaarDB'. We used embedded Derby but any underlying database
31-
should work. If helpful, a sample WebLogic data source definition is provided
32-
[here](ActionBazaarDB-jdbc.xml).
33-
* The demo application uses the WebLogic Maven plugin to automatically deploy
34-
as part of the build. You will need to enable the plugin in your environment.
35-
The detailed instructions to do this can be found
36-
[here](http://docs.oracle.com/middleware/1213/wls/WLPRG/maven.htm). This
37-
resource also contains details on how to configure the Maven plugin, which
38-
you will need to do (see below).
12+
* Install GlassFish 4.1
3913
* Please download this repository. You can use Git or just the simple zip
4014
download.
4115
* The demo is just a simple Maven project under the [actionbazaar](actionbazaar)
4216
directory. You should be able to open it up in any Maven capable IDE, we used
4317
NetBeans.
44-
* If desired setup WebLogic in your IDE. This is what we tested.
45-
* The tests in the Maven build are executed against a running WebLogic instance.
18+
* If desired setup GlassFish in your IDE.
19+
* The tests in the Maven build are executed against an installed GlassFish instance.
4620
You will need to configure
4721
[this file] (actionbazaar/src/test/resources/arquillian.xml) with the details
48-
of your running WebLogic instance (you could run the instance via the IDE).
49-
For details on configuring WebLogic for Arquillian, look
50-
[here] (https://docs.jboss.org/author/display/ARQ/WLS+12.1+-+Remote).
51-
* The build also automatically undeploys and deploys the application to the
52-
running WebLogic instance using the WebLogic Maven plugin. Please configure
53-
the plugin in the [Maven POM](actionbazaar/pom.xml) with the details
54-
of your running WebLogic instance.
22+
of your GlassFish installation. For details on configuring GlassFish for
23+
Arquillian, look
24+
[here] (https://docs.jboss.org/author/display/ARQ/GlassFish+3.1+-+Managed).
25+
Note that in this case we are using GlassFish in managed mode. This means that
26+
Arquillian still automatically start and stop GlassFish as needed. You must
27+
set an admin password for GlassFish. Due to a GlassFish bug, Arquillian can't
28+
start GlassFish with an empty admin password. Also, GlassFish embedded is
29+
no longer supported as of GlassFish 4 and cannot be used. Similarly, we ran
30+
into GlassFish bugs trying to use remote mode (normally the fastest option
31+
with Arquillian).
5532
* If desired, you can deploy and run the application manually. We did this both
56-
via NetBeans and by using the plain Maven generated war file in addition to
57-
the automated build.
58-
* You can hook up the build to a continuous integration server such as Hudson.
59-
We tested such a setup.
33+
via NetBeans and by using the plain Maven generated war file.

actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
import com.actionbazaar.application.BidService;
4343
import com.actionbazaar.domain.Bid;
4444
import java.io.Serializable;
45-
import javax.enterprise.context.SessionScoped;
45+
import javax.enterprise.context.ApplicationScoped;
4646
import javax.enterprise.inject.Produces;
4747
import javax.inject.Inject;
4848
import javax.inject.Named;
4949

5050
@Named
51-
@SessionScoped
51+
@ApplicationScoped
5252
public class AddBid implements Serializable {
5353

5454
private static final long serialVersionUID = 1L;
@@ -58,7 +58,7 @@ public class AddBid implements Serializable {
5858

5959
@Produces
6060
@Named
61-
@SessionScoped
61+
@ApplicationScoped
6262
private final Bid bid = new Bid();
6363

6464
public String onAdd() {

actionbazaar/src/test/java/com/actionbazaar/application/BidServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class BidServiceTest {
6464
@Deployment
6565
public static WebArchive createDeployment() {
6666
return ShrinkWrap
67-
.create(WebArchive.class, "actionbazaar-test.war")
67+
.create(WebArchive.class, "actionbazaar-service-test.war")
6868
.addClasses(BidService.class, DefaultBidService.class,
6969
Profiled.class, ProfilingInterceptor.class,
7070
BidRepository.class, DefaultBidRepository.class, Bid.class)

actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class BidServiceUnitTest {
5858
@Deployment
5959
public static WebArchive createDeployment() {
6060
return ShrinkWrap
61-
.create(WebArchive.class, "actionbazaar-test.war")
61+
.create(WebArchive.class, "actionbazaar-service-unit-test.war")
6262
.addClasses(BidService.class, DefaultBidService.class,
6363
BidRepository.class, MockBidRepository.class, Bid.class)
6464
.addAsWebInfResource("test-beans.xml", "beans.xml");

actionbazaar/src/test/java/com/actionbazaar/interfaces/rest/BidRestServiceTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class BidRestServiceTest {
6666
@Deployment
6767
public static WebArchive createDeployment() {
6868
return ShrinkWrap
69-
.create(WebArchive.class, "actionbazaar-test.war")
69+
.create(WebArchive.class, "actionbazaar-rest-test.war")
7070
.addClasses(BidRestService.class, RestConfiguration.class,
7171
BidService.class, DefaultBidService.class,
7272
BidRepository.class, DefaultBidRepository.class, Bid.class)
@@ -80,7 +80,7 @@ public static WebArchive createDeployment() {
8080
@InSequence(1)
8181
public void testAddBid() {
8282
WebTarget target = ClientBuilder.newClient()
83-
.target("http://localhost:8080/actionbazaar-test/rest/bids");
83+
.target("http://localhost:8080/actionbazaar-rest-test/rest/bids");
8484
// Save a new bid.
8585
Bid bid = new Bid();
8686

@@ -105,7 +105,7 @@ public void testAddBid() {
105105
@InSequence(2)
106106
public void testUpdateBid() {
107107
WebTarget target = ClientBuilder.newClient()
108-
.target("http://localhost:8080/actionbazaar-test/rest/bids/{id}")
108+
.target("http://localhost:8080/actionbazaar-rest-test/rest/bids/{id}")
109109
.resolveTemplate("id", bidId);
110110

111111
// Update bid.
@@ -127,7 +127,7 @@ public void testUpdateBid() {
127127
@InSequence(3)
128128
public void testDeleteBid() {
129129
WebTarget target = ClientBuilder.newClient()
130-
.target("http://localhost:8080/actionbazaar-test/rest/bids/{id}")
130+
.target("http://localhost:8080/actionbazaar-rest-test/rest/bids/{id}")
131131
.resolveTemplate("id", bidId);
132132

133133
target.request().delete();

actionbazaar/src/test/java/com/actionbazaar/interfaces/socket/ChatServerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ public class ChatServerTest {
7777
@Deployment
7878
public static WebArchive createDeployment() {
7979
return ShrinkWrap
80-
.create(WebArchive.class, "actionbazaar-test.war")
80+
.create(WebArchive.class, "actionbazaar-websocket-test.war")
8181
.addClass(ChatMessage.class)
8282
.addClass(ChatServer.class);
8383
}
8484

8585
@Test
8686
public void testChat() throws URISyntaxException, DeploymentException, IOException, InterruptedException {
87-
URI uri = new URI("ws://localhost:8080/actionbazaar-test/chat");
87+
URI uri = new URI("ws://localhost:8080/actionbazaar-websocket-test/chat");
8888

8989
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
9090

actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class AddBidTest {
7070
@Deployment(testable = false)
7171
public static Archive<?> createDeployment() {
7272
return ShrinkWrap
73-
.create(WebArchive.class, "actionbazaar-test.war")
73+
.create(WebArchive.class, "actionbazaar-jsf-test.war")
7474
.addClasses(BidService.class, DefaultBidService.class,
7575
BidRepository.class, DefaultBidRepository.class, Bid.class,
7676
AddBid.class)

actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AlertServletTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class AlertServletTest {
5757
@Deployment
5858
public static WebArchive createDeployment() {
5959
return ShrinkWrap
60-
.create(WebArchive.class, "actionbazaar-test.war")
60+
.create(WebArchive.class, "actionbazaar-servlet-test.war")
6161
.addClass(AlertServlet.class);
6262
}
6363

@@ -67,7 +67,7 @@ public void testGetAlerts() {
6767

6868
// Get account balance
6969
JsonObject response = client
70-
.target("http://localhost:8080/actionbazaar-test/alerts")
70+
.target("http://localhost:8080/actionbazaar-servlet-test/alerts")
7171
.queryParam("user_id", "1111").request("application/json")
7272
.get(JsonObject.class);
7373
// TODO Assert more of the content.

0 commit comments

Comments
 (0)