This web version of Reminders is a large example I made for students taking my course on web application development using Java EE 7. It covers the following topics:
The front-end was built using jQuery and Twitter Bootstrap. It was originally built for an earlier version of the webservice that did not include any authentication. I've updated it to use the API of the new webservice and set it up to use the default administrator account that gets created when you first deploy the application. Other than that, the front-end hasn't been updated so don't take it as an example of best practices.
The source code is available on GitHub. Switch to the
openshift branch to see the version that is running on OpenShift. The differences in source code
are minor and mostly involve changes to URLs.
To run this example on a local GlassFish installation, you will need to:
sun-resources.xmlto point to an empty schema. Make sure you keep the name
jdbc/reminders. Also make sure GlassFish has the required driver installed in the
libfolder of the domain you're using.
Realmsand create a realm with the following settings:
IMAGES_BASE_DIRin the Utilities class to point to an existing directory on your machine.
default.pngimage (it's included in the files used for testing) to that directory.
The database schema will be created when you first deploy the application.
Once this is done, you can edit
persistence.xml to set the table generation strategy to
To enable the included tests, modify
pom.xml to set
The tests will connect to your database so make sure you modify
in the same way you modified
It's best to use a separate schema for your tests as every run of the tests will drop and create the generated tables.
The tests will run on an embedded GlassFish server. I did not change the ports so make sure GlassFish is not already running
or the embedded server will not be able to start. The test files include a
domain.xml configuration file for the embedded server.
This configuration file already includes the security realm so no setup is required. Upon running the tests, you should see 126 green lights.
This is a complete test suite for the Credentials and Users resources, testing every aspect from simple business logic to
validation, persistence and complete use case scenario's. The Lists and Reminders resources don't have test suites yet,
but as they are very similar to the Users resource, you might want to try writing these tests yourself, as an exercise.
To interact directly with the webservice, I recommend you use Postman.
If you've enjoyed my work or found it helpful, please consider becoming a patron. Your support helps me free up time to work on my books and projects.