diff --git a/README.md b/README.md
index f1a03ae..e0c3b68 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,29 @@
-Testing Java EE Applications Using Arquillian
-==========
+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 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 GlassFish, WildFly, WebLogic or WebSphere.
-This application demonstrates how Java EE applications can be effectively tested using Arquillian.
\ No newline at end of file
+Setup
+-----
+* 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 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 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/.gitignore b/actionbazaar/.gitignore
index 4585d1c..9069bbe 100644
--- a/actionbazaar/.gitignore
+++ b/actionbazaar/.gitignore
@@ -1,4 +1,6 @@
/target
log.txt
test-faces-config.NavData
-faces-config.NavData
\ No newline at end of file
+faces-config.NavData
+.gradle/
+.idea/
diff --git a/actionbazaar/build.gradle b/actionbazaar/build.gradle
new file mode 100644
index 0000000..dd08c86
--- /dev/null
+++ b/actionbazaar/build.gradle
@@ -0,0 +1,73 @@
+
+plugins {
+ id 'war'
+}
+
+repositories {
+ mavenCentral()
+}
+
+sourceCompatibility = 1.7
+targetCompatibility = 1.7
+
+group = 'com.actionbazaar'
+version = '1.0-SNAPSHOT'
+
+ext {
+ glassfish4Home = project.findProperty('glassfish4.home')
+ jbossEap7Home = project.findProperty('jbosseap70.home')
+ wildfly11Home = project.findProperty('wildfly11.home')
+}
+
+sourceSets {
+ test {
+ resources {
+ srcDir('src/main/webapp')
+ }
+ }
+}
+
+dependencies {
+ providedCompile group: 'javax', name: 'javaee-api', version: '7.0'
+
+ testCompile group: 'junit', name: 'junit', version: '4.12'
+ testCompile group: 'org.jboss.arquillian.junit', name: 'arquillian-junit-container', version: '1.2.0.Final'
+ testCompile group: 'org.jboss.shrinkwrap.resolver', name: 'shrinkwrap-resolver-depchain', version: '3.1.2'
+ testCompile group: 'org.jboss.arquillian.extension', name: 'arquillian-drone-webdriver-depchain', version: '2.5.0'
+ testCompile group: 'org.arquillian.container', name: 'arquillian-container-chameleon', version: '1.0.0.Beta3'
+}
+
+war {
+ archiveName 'actionbazaar.war'
+}
+
+task testGlassFish41(type: Test, dependsOn: testClasses) {
+ description = 'Runs the tests using GlassFish 4.1'
+ group = 'verification'
+
+ classpath += files('src/test/resources-glassfish')
+
+ environment 'JAVA_HOME', System.properties['java.home']
+ systemProperty 'arquillian.launch', 'glassfish41'
+ systemProperty 'glassfish.home', glassfish4Home
+}
+
+task testJBossEAP7(type: Test, dependsOn: testClasses) {
+ description = 'Runs the tests using JBoss EAP 7.0'
+ group = 'verification'
+
+ classpath += files('src/test/resources-jboss')
+
+ systemProperty 'arquillian.launch', 'jbosseap70'
+ systemProperty 'jboss.home', jbossEap7Home
+}
+
+task testWildFly11(type: Test, dependsOn: testClasses) {
+ description = 'Runs the tests using WildFly 11.0'
+ group = 'verification'
+
+ classpath += files('src/test/resources-jboss')
+
+ systemProperty 'arquillian.launch', 'wildfly11'
+ systemProperty 'jboss.home', wildfly11Home
+}
diff --git a/actionbazaar/gradle/wrapper/gradle-wrapper.jar b/actionbazaar/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..01b8bf6
Binary files /dev/null and b/actionbazaar/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/actionbazaar/gradle/wrapper/gradle-wrapper.properties b/actionbazaar/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..45a4d68
--- /dev/null
+++ b/actionbazaar/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
diff --git a/actionbazaar/gradlew b/actionbazaar/gradlew
new file mode 100755
index 0000000..cccdd3d
--- /dev/null
+++ b/actionbazaar/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/actionbazaar/gradlew.bat b/actionbazaar/gradlew.bat
new file mode 100644
index 0000000..f955316
--- /dev/null
+++ b/actionbazaar/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/actionbazaar/nb-configuration.xml b/actionbazaar/nb-configuration.xml
index b00b5e1..39882f4 100644
--- a/actionbazaar/nb-configuration.xml
+++ b/actionbazaar/nb-configuration.xml
@@ -14,14 +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
- WebLogic9
- Facelets
-
- /less:/css
- false
- /scss:/css
- false
-
- js/libs
+ WildFly
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/pom.xml b/actionbazaar/pom.xml
index c4ec329..b4cbe29 100644
--- a/actionbazaar/pom.xml
+++ b/actionbazaar/pom.xml
@@ -47,19 +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
- 2.0
- jar
- provided
-
junit
junit
@@ -84,21 +71,9 @@
test
- org.jboss.arquillian.container
- arquillian-wls-remote-12.1
- 1.0.0.Alpha2
- test
-
-
- org.glassfish.tyrus
- tyrus-server
- 1.7
- test
-
-
- org.glassfish.tyrus
- tyrus-container-grizzly-server
- 1.7
+ org.arquillian.container
+ arquillian-container-chameleon
+ 1.0.0.Alpha6
test
diff --git a/actionbazaar/settings.gradle b/actionbazaar/settings.gradle
new file mode 100644
index 0000000..a19a470
--- /dev/null
+++ b/actionbazaar/settings.gradle
@@ -0,0 +1,2 @@
+
+rootProject.name = 'testing-javaee'
diff --git a/actionbazaar/src/main/java/com/actionbazaar/application/DefaultBidService.java b/actionbazaar/src/main/java/com/actionbazaar/application/DefaultBidService.java
index 54e6098..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);
}
-}
\ 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..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()}); // removed.
+ @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/socket/ChatMessage.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/socket/ChatMessage.java
index fd01b02..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)
@@ -111,4 +120,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/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/main/java/com/actionbazaar/interfaces/web/AddBid.java b/actionbazaar/src/main/java/com/actionbazaar/interfaces/web/AddBid.java
index e411568..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,54 +1,15 @@
-/*
- * 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;
import com.actionbazaar.domain.Bid;
import java.io.Serializable;
-import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
@Named
-@RequestScoped
+@ApplicationScoped // TODO Change this to flow scoped.
public class AddBid implements Serializable {
private static final long serialVersionUID = 1L;
@@ -58,7 +19,7 @@ public class AddBid implements Serializable {
@Produces
@Named
- @RequestScoped
+ @ApplicationScoped
private final Bid bid = new Bid();
public String onAdd() {
@@ -66,4 +27,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..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();
@@ -85,11 +89,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..80c589f 100644
--- a/actionbazaar/src/main/resources/META-INF/persistence.xml
+++ b/actionbazaar/src/main/resources/META-INF/persistence.xml
@@ -1,15 +1,13 @@
-
-
- jdbc/ActionBazaarDB
+
+
+ java:global/jdbc/ActionBazaarDB
-
+ value="drop-and-create"/>
+
-
\ No newline at end of file
+
diff --git a/actionbazaar/src/main/webapp/WEB-INF/beans.xml b/actionbazaar/src/main/webapp/WEB-INF/beans.xml
index 5a535b3..0af1b98 100644
--- a/actionbazaar/src/main/webapp/WEB-INF/beans.xml
+++ b/actionbazaar/src/main/webapp/WEB-INF/beans.xml
@@ -1,5 +1,6 @@
-
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_2.xsd"
+ version="1.2" bean-discovery-mode="all">
\ No newline at end of file
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 ea9d986..7dc30dd 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
@@ -19,8 +18,13 @@
30
-
+
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/main/webapp/WEB-INF/weblogic.xml b/actionbazaar/src/main/webapp/WEB-INF/weblogic.xml
deleted file mode 100644
index 51fdd77..0000000
--- a/actionbazaar/src/main/webapp/WEB-INF/weblogic.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
- /actionbazaar
-
- jax-rs
- 2.0
- false
-
-
\ No newline at end of file
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..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;
@@ -64,13 +25,14 @@ 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)
- .addAsWebInfResource("test-beans.xml", "beans.xml")
- .addAsResource("test-persistence.xml",
- "META-INF/persistence.xml");
+ .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");
}
@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..72bd16e 100644
--- a/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java
+++ b/actionbazaar/src/test/java/com/actionbazaar/application/BidServiceUnitTest.java
@@ -1,71 +1,28 @@
-/*
- * 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;
-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 {
@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(EmptyAsset.INSTANCE, "beans.xml");
+ .addAsWebInfResource("test-beans.xml", "beans.xml");
}
@EJB
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 30bf50e..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;
@@ -51,15 +12,15 @@
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;
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;
@@ -67,12 +28,13 @@ 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)
- .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
- .addAsWebInfResource("test-weblogic.xml", "weblogic.xml")
+ .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");
}
@@ -81,7 +43,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-rest-test/rest/bids");
// Save a new bid.
Bid bid = new Bid();
@@ -106,7 +68,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-rest-test/rest/bids/{id}")
.resolveTemplate("id", bidId);
// Update bid.
@@ -128,7 +90,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-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 aefafcb..7e1509c 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,13 +58,14 @@
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;
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)
public class ChatServerTest {
@@ -75,73 +75,69 @@ 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")
+ .create(WebArchive.class, "actionbazaar-websocket-test.war")
.addClass(ChatMessage.class)
.addClass(ChatServer.class);
}
@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-websocket-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/java/com/actionbazaar/interfaces/web/AddBidTest.java b/actionbazaar/src/test/java/com/actionbazaar/interfaces/web/AddBidTest.java
index 25b4998..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;
@@ -51,7 +12,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;
@@ -71,14 +31,15 @@ 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)
.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(EmptyAsset.INSTANCE, "beans.xml")
+ .addAsWebInfResource("test-beans.xml", "beans.xml")
.addAsResource("test-persistence.xml",
"META-INF/persistence.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 b039040..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,77 +1,26 @@
-/*
- * 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 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;
+// 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
public static WebArchive createDeployment() {
- WebArchive archive = 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;
+ return ShrinkWrap
+ .create(WebArchive.class, "actionbazaar-servlet-test.war")
+ .addClass(AlertServlet.class);
}
@Test
@@ -80,7 +29,7 @@ public void testGetAlerts() {
// Get account balance
JsonObject response = client
- .target("http://localhost:7001/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.
diff --git a/actionbazaar/src/test/resources-glassfish/test-persistence-web.xml b/actionbazaar/src/test/resources-glassfish/test-persistence-web.xml
new file mode 100644
index 0000000..1ae3bbf
--- /dev/null
+++ b/actionbazaar/src/test/resources-glassfish/test-persistence-web.xml
@@ -0,0 +1,11 @@
+
+
+
+ java:global/jdbc/ActionBazaarDB
+ org.apache.derby.jdbc.EmbeddedDriver
+ jdbc:derby:/tmp/actionbazaar-development-database;create=true
+
+
\ No newline at end of file
diff --git a/actionbazaar/src/test/resources-glassfish/test-web.xml b/actionbazaar/src/test/resources-glassfish/test-web.xml
new file mode 100644
index 0000000..a349050
--- /dev/null
+++ b/actionbazaar/src/test/resources-glassfish/test-web.xml
@@ -0,0 +1,27 @@
+
+
+
+ javax.faces.PROJECT_STAGE
+ UnitTest
+
+
+ Faces Servlet
+ javax.faces.webapp.FacesServlet
+ 1
+
+
+ Faces Servlet
+ *.jsf
+
+
+ add_bid.jsf
+
+
+ java:global/jdbc/ActionBazaarDB
+ org.apache.derby.jdbc.EmbeddedDriver
+ jdbc:derby:/tmp/actionbazaar-development-database;create=true
+
+
\ No newline at end of file
diff --git a/actionbazaar/src/test/resources-jboss/test-persistence-web.xml b/actionbazaar/src/test/resources-jboss/test-persistence-web.xml
new file mode 100644
index 0000000..5b8d245
--- /dev/null
+++ b/actionbazaar/src/test/resources-jboss/test-persistence-web.xml
@@ -0,0 +1,11 @@
+
+
+
+ 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-web.xml b/actionbazaar/src/test/resources-jboss/test-web.xml
similarity index 57%
rename from actionbazaar/src/test/resources/test-web.xml
rename to actionbazaar/src/test/resources-jboss/test-web.xml
index 4bf2f9a..b0a1d82 100644
--- a/actionbazaar/src/test/resources/test-web.xml
+++ b/actionbazaar/src/test/resources-jboss/test-web.xml
@@ -1,8 +1,8 @@
-
+
javax.faces.PROJECT_STAGE
UnitTest
@@ -19,4 +19,9 @@
add_bid.jsf
+
+ 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/arquillian.xml b/actionbazaar/src/test/resources/arquillian.xml
index e98d17e..afd9d58 100644
--- a/actionbazaar/src/test/resources/arquillian.xml
+++ b/actionbazaar/src/test/resources/arquillian.xml
@@ -1,19 +1,40 @@
-
- target/
+ build/deployments
-
+
+
- t3://localhost:7001
- weblogic
- welcome123
- C:\Oracle\Middleware\Oracle_Home\wlserver
- AdminServer
+ jboss eap:7.0.0.Final:remote
+ localhost
+ admin
+ YOUR_JBOSSEAP_PASSWORD
-
+
+
+
+ glassfish:4.1:managed
+ ${glassfish.home}
+ true
+
+
+
+
+
+ jboss eap:7.0.0.Final:managed
+ ${jboss.home}
+
+
+
+
+
+ wildfly:11.0.0.Final:managed
+ ${jboss.home}
+
+
+
\ 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-beans.xml b/actionbazaar/src/test/resources/test-beans.xml
index 2bf376f..0af1b98 100644
--- a/actionbazaar/src/test/resources/test-beans.xml
+++ b/actionbazaar/src/test/resources/test-beans.xml
@@ -1,8 +1,6 @@
-
-
- com.actionbazaar.application.ProfilingInterceptor
-
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_2.xsd"
+ version="1.2" bean-discovery-mode="all">
\ 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.xml b/actionbazaar/src/test/resources/test-persistence.xml
index d86e9f3..16918a5 100644
--- a/actionbazaar/src/test/resources/test-persistence.xml
+++ b/actionbazaar/src/test/resources/test-persistence.xml
@@ -1,9 +1,11 @@
-
+
- jdbc/ActionBazaarDB
+ java:global/jdbc/ActionBazaarDB
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