...
org.codehaus.jackson
jackson-core-asl
1.8.1
provided
...
Note
Why do you need the Jackson annotations?
JAX-RS does not specify mediatype-agnostic annotations for certain use cases. You will encounter atleast one of them in the project. The object graph contains cyclic/bi-directional relationships among entities like Venue, Section, Show, Performance and TicketPrice. JSON representations for these objects will need tweaking to avoid stack oVerflow errors and the like, at runtime.
JBoss Enterprise Application 6 uses Jackson to perform serialization and dserialization of objects, thus requiring use of Jackson annotations to modify this behavior. @JsonIgnoreProperties from Jackson will be used to suppress serialization and deserialization of one of the fields involved in the cycle.
===== Enabling CDI =====
The next step is to enable CDI in the deployment by creating a beans.xml file in the WEB-INF folder of the web application.
src/main/webapp/WEB-INF/beans.xml
/**
*
* A number of RESTful services implement GET operations on a particular type of entity. For
* observing the DRY principle, the generic operations are implemented in the code>BaseEntityService/code>
* class, and the other services can inherit from here.
*
*
*
* Subclasses will declare a base path using the JAX-RS {@link Path} annotation, for example:
*
*
*
* code>
* @Path("/widgets")
* public class WidgetService extends BaseEntityService {
* ...
* }
* /code>
*
*
*
* will support the following methods:
*
*
*
* code>
* GET /widgets
* GET /widgets/:id
* GET /widgets/count
* /code>
*
*
*
* Subclasses may specify various criteria for filtering entities when retrieving a list of them, by supporting
* custom query parameters. Pagination is supported by default through the query parameters code>first/code>
* and code>maxResults/code>.
*
*
*
* The class is abstract because it is not intended to be used directly, but subclassed by actual JAX-RS
* endpoints.
*
*
*/
public abstract class BaseEntityService {
@Inject
private EntityManager entityManager;
private Class entityClass;
public BaseEntityService() {}
public BaseEntityService(Class entityClass) {
this.entityClass = entityClass;
}
public EntityManager getEntityManager() {
return entityManager;
}
}
===== Retrieving Auctions =====
===== Creating and deleting Auctions =====
====== Testing ======
* http://www.jboss.org/ticket-monster/BusinessLogic/
* Test Rest: http://blog.itcrowd.pl/2013/10/arquillian-rest-extension-client.html
* Setup and run arquilliant test: http://docs.jboss.org/arquillian/reference/1.0.0.Alpha1/en-US/html_single/#d0e395
*
===== Setup Test =====
Since Arquillian needs to perform JNDI lookups to get references to the components under test, we need to include a jndi.properties file on the test classpath. Create the file src/test/resources/jndi.properties and populate it with the following contents:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=jnp://localhost:1099
Next, we're going to return to pom.xml to add another dependency. Arquillian picks which container it's going to use to deploy the test archive and negotiate test execution using the service provider mechanism, meaning which implementation of the DeployableContainer SPI is on the classpath. We'll control that through the use of Maven profiles. Add the following profiles to pom.xml:
4.0.0
...
arq-jbossas-managed
org.jboss.as
jboss-as-arquillian-container-managed
test
arq-jbossas-remote
org.jboss.as
jboss-as-arquillian-container-remote
test
If you haven’t used the archetype, or the profiles don’t exist, create them.
Each profile defines a different Arquillian container. In both cases the tests execute in an application server instance. In one case (arq-jbossas-managed) the server instance is started and stopped by the test suite, while in the other (arq-jbossas-remote), the test suite expects an already started server instance.
Once these profiles are defined, we can execute the tests in two ways:
from the command-line build
from an IDE
Executing tests from the command line
You can now execute the test suite from the command line by running the Maven build with the appropriate target and profile, as in one of the following examples.
After ensuring that the JBOSS_HOME environment variable is set to a valid JBoss EAP 6.2 installation directory), you can run the following command:
mvn clean test -Parq-jbossas-managed
Or, after starting a JBoss EAP 6.2 instance, you can run the following command
mvn clean test -Parq-jbossas-remote
These tests execute as part of the Maven build and can be easily included in an automated build and test harness.
==== Test troubleshooting ====
* https://community.jboss.org/thread/237632
After fixing the bom.version as described above, start a clean system: kill old test, process, eclipse.
* http://logging.apache.org/log4j/1.2/manual.html
====== Deployment ======
mvn package
cp target/*.war JBOSS_HOME/standalone/deployments