This project requires at least Java 8. If you want to run it from the command line then you'll
need Maven 3 on your PATH
as well.
You'll need MySQL server and MySQL workbench, this can be downloaded from here if you don't already have it. When running through the installer you can keep all the default options.
Open mysql workbench, choose the local mysql instance.
Create a database called agentdiscoveries
. Later, when you start the application it will create the necessary tables itself.
- Copy
AgentDiscoveries-Backend/src/main/resources/template_config.properties
and rename the new copyconfig.properties
. Update thedatabase.username
anddatabase.password
fields in your new file. - Copy
AgentDiscoveries-Backend/src/main/resources/META-INF/template_persistence.xml
and rename the new copypersistence.xml
. Update thejavax.persistence.jdbc.user
andjavax.persistence.jdbc.password
fields in your new file.
You will notice that there are 2 modules in this project - AgentDiscoveries-Backend
and AgentDiscoveries-Frontend
.
The main build will build them both.
There are instructions for running them separately at the bottom of this section.
To build the project, you will need to run mvn clean package
.
The jar generated in the backend project will contain everything required for the website.
To start the application from the command line, run
java -jar AgentDiscoveries-Backend/target/agentdiscoveries-backend-1.0-SNAPSHOT.jar
The application homepage can be found at http://localhost:8080
.
There is also a health-check at http://localhost:8080/healthcheck
.
If there are any problems starting the application take a look at the logs first, it is probably a database or port already in use issue.
The app comes with some test users added by the migrations:
Username | Password | Role |
---|---|---|
test_user | password | User |
test_agent | password | Agent |
test_corrupt | N/A | User with a corrupt password |
test_admin | password | Admin |
These should be deleted in the production environment.
In order to run your application directly using IntelliJ, you should first make sure the frontend project has been built (or else it can't serve the website!). You can ensure this is automatically done by adding a 'build step' to the run configuration: Either mvn build
or npm run build
in the frontend project.
Then, in the run configuration, set the main class to be AgentDiscoveriesApplication
and you'll be able to use IntelliJ to run your project.
Alternatively, you can serve the frontend using a development server:
To speed up front end development, there is a dev server you can run instead.
NB: You will still need to have the backend server running on port 8080!
To use this from the command line, run mvn clean package -Ddev
To use this from IntelliJ, set up a Maven
build configuration with the working directory set to the AgentDiscoveries-Frontend
project and the command Line option to clean package -Ddev
.
This will set up a server at http://localhost:8081
(Note the difference!).
The browser will automatically reload whenever you change any javascript or SASS.
Both the backend and frontend tests can be run with mvn test
in the root directory.
These can be found in AgentDiscoveries-Frontend/app/test
To run the frontend unit tests in IntelliJ, follow the instructions for Mocha
From command line navigate to AgentDiscoveries-Frontend
and then run npm test
(or mvn test
, but this may give less pretty output).
These can be found in AgentDiscoveries-Backend/src/test/java
These can be found in AgentDiscoveries-Backend/src/test/java/org/softwire/training/api/unit
N.B. Unit test files must have names ending with "Test.java"
To run in IntelliJ, right click on any test to run it individually, or the entire directory to 'Run tests in org.softwire.training.api.unit'.
These can be found in AgentDiscoveries-Backend/src/test/java/org/softwire/training/api/integration
N.B. Integration test files must have names ending with "IT.java"
To run in IntelliJ:
- Make sure the app is already running
- Right click on any test to run it individually, or the entire directory to 'Run tests in org.softwire.training.api.integration'.
Changing WebDriverHelper.HEADLESS
to false
will cause a visible Chrome window to pop up, which is sometimes much easier to debug!