javaee-samples / javaee8-samples

Java EE 8 Samples
Other
376 stars 238 forks source link
beanvalidation cdi glassfish javaee javaee8 jsf json-b payara servlet servlets tomcat

Java EE 8 Samples

This workspace consists of Java EE 8 Samples and unit tests. They are categorized in different directories, one for each Technology/JSR.

Some samples/tests have documentation, otherwise read the code.

How to run?

Samples are tested on Payara, GlassFish and Tomcat using Arquillian. Arquillian uses container profiles to start up and deploy tests to individual containers.

Only one container profile can be active at a given time, otherwise there will be dependency conflicts.

These are the available container profiles:

The containers that download and install a server (the *-ci-managed profiles) allow you to override the version used, e.g.:

To run them in the console do:

  1. In the terminal, mvn test -fae at the top-level directory to start the tests for the default profile.

When developing and runing them from IDE, remember to activate the profile before running the test.

To learn more about Arquillian please refer to the Arquillian Guides

To run only a subset of the tests do at the top-level directory:

  1. Install top level dependencies: mvn clean install -pl "test-utils" -am
  2. cd into desired module, e.g.: cd cdi
  3. Run tests against desired server, e.g.: mvn clean test -P glassfish-ci-managed

How to contribute

With your help we can improve this set of samples, learn from each other and grow the community full of passionate people who care about the technology, innovation and code quality. Every contribution matters!

There is just a bunch of things you should keep in mind before sending a pull request, so we can easily get all the new things incorporated into the master branch.

Standard tests are jUnit based. Test classes naming must comply with surefire naming standards **/*Test.java, **/*Test*.java or **/*TestCase.java.

For the sake of clarity and consistency, and to minimize the upfront complexity, we prefer standard jUnit tests using Java, with as additional helpers HtmlUnit, Hamcrest and of course Arquillian. Please don't use alternatives for these technologies. If any new dependency has to be introduced into this project it should provide something that's not covered by these existing dependencies.

Some coding principles

Small Git tips

That's it! Welcome in the community!

CI Job

CI jobs are executed by Travis. Note that by the very nature of the samples provided here it's perfectly normal that not all tests pass. This normally would indicate a bug in the server on which the samples are executed. If you think it's really the test that's faulty, then please submit an issue or provide a PR with a fix.

Run each sample in Docker