Sample application demonstrates how a project can be structured with RESTful services and a Web UI.
This project can be cloned as a template.
Follow these commands to fetch the source and build:
- git clone https://github.com/BorderTech/sample-app.git my-dir (first time only)
- cd my-dir
- mvn clean install -Pquick-build (The profile quick-build has QA and Tests turned off)
Follow these commands to run a local instance of the REST Services:
- cd app-lde
- mvn lde-exec:run
- Access swagger ui at http://localhost:8082/lde/launchswagger
Follow these commands to run a local instance of the Web UI:
- cd web-lde
- mvn lde-exec:run
- Access web ui at http://localhost:8081/lde/app
By default the Web UI uses a Mocked version of the service layer. This can be overriden to use a REST Client implementation via a property file, environment variables or system properties.
Follow these steps to make the Web UI call the local instance of the REST Services via a property file:
- cd web-lde
- copy example_local_app.properties to local_app.properties
- Uncomment the BT_WEB_ENV=LOCAL
- Run Web UI
- Run REST Service
Environment Variables can also be used to make the Web UI use a REST client implementation.
To use the REST Client Implementation, set the following variable:
SET BT_WEB_ENV=LOCALTo use a different REST endpoint, set the following variable:
SET BT_APP_REST_URI=http://myhost:8082/myapp/apiThe configuration of the Web UI and REST Services can also be configured via System Properties.
Running the Web UI with the REST Client Implementation:
cd web-lde
mvn lde-exec:run -DBT_WEB_ENV=LOCALRunning the Web UI with the REST Client Implementation and different REST URI:
cd web-lde
mvn lde-exec:run -DBT_WEB_ENV=LOCAL -DBT_APP_REST_URI=http://localhost:8888/lde/apiRunning the REST Services on a different Port:
cd app-lde
mvn lde-exec:run -Dbordertech.lde.port.default=8888The app and web war artifact name defaults to maven generated value ${project.build.finalName}. This behaviour can be modified by setting property -Dapp.warName and/or -Dweb.warName. If supplied, then only war file in target dir is impacted, artifacts published to maven repository (local or remote) is as per maven default.
Advantage of setting custom war name is, when deployed to a web container, the application context becomes http://<host:port>/<custom-warName>. It avoid the need for container specific configuration.
The app and web war artifact names will be ${project.build.finalName}
mvn install
app war will be apple-war, and web war will be orange-war
mvn install -Dapp.warName=apple-war -Dweb.warName=orange-war
app and web war will be it's artifactId as defined in pom.xml
mvn install -Dapp.warName='${project.artifactId}' -Dweb.warName='${project.artifactId}'
Sample command lines for running smoke tests.
See Run REST Service, ensure localhost is running ahead of executing API Test
mvn test -Psmoke -pl rest-server-impl -Dserver.smoke.port=8086 -Dserver.smoke.host=http://localhost -Dserver.smoke.base=/lde/api/v1/
See Run Web UI, ensure localhost is running ahead of executing UI Test
mvn test -Psmoke -pl web-ui -Dbordertech.webfriends.selenium.launchServer=false -Dbordertech.webfriends.selenium.serverUrl=http://localhost:8081/lde