blob: 709082d30e7a36dd36fb0570125cef336df92fa9 [file] [log] [blame]
= SimpleApp
This is a simple link:[Apache Isis] application, but structured so it can be used as a starting point for developing your own applications.
== Quick start
* install prereqs:
** Java 8 LTS (eg link:[Adopt OpenJDK] distribution)
** Maven 3.6 or later ([download])
* download and unzip
curl "$REPO/zip/$BRANCH" > $REPO-$
unzip $REPO-$
cd $REPO
* Build using Maven:
mvn clean install
* Run using Maven:
mvn -pl webapp spring-boot:run
* Login using:
** username: `sven`
** password: `pass`
The app runs with H2 running in-memory, with sample data set up using link:[fixture scripts].
== Application Structure
The following table explains the contents of each of the directories:
|Holds the "simple" module, consisting of the `SimpleObject` entity and supporting services.
It also contains module-specific unit- and integration tests.
Larger applications should consist of multiple modules; each such module can be copied from this starter module.
|Holds the bootstrapping classes, along with application-level scoped services and home page.
It also contains application-wide integration tests/BDD specs, and lockdown tests.
The `pom.xml` also provides goals to run the app from the command line, or to be assembled into a Docker image.
== Development
Apache Isis uses DataNucleus as its ORM, which requires that any entities are "enhanced", a post-compile process.
Normally this is done as part of a "mvn clean install", but the entities can also be enhanced explicity using:
mvn -pl module-simple datanucleus:enhance -o
This is useful to know if the application or integration test fails to bootstrap, complaining of "unenhanced entities".
TIP: You can also use ``
== Testing
The application has three types of tests.
Each of these generates its own set of tests, and each can be disabled through a system property.
.Testing types
[cols="5a,12m,6m,3m", options="header"]
| Test type
| Report
| Phase
| Skip using
| Unit test
| target/surefire-unittest-reports
| test
| -DskipUTs
| Integ test
| target/surefire-integtest-reports
| integration-test
| -DskipITs
| BDD (Cucumber) specs
| target/surefire-integbddspecs-reports
| integration-test
| -DskipBS
The test reports format are in XML and basic HTML format.
In addition:
BDD (Cucumber) specification reports, as an interactive website
These outputs can for example be processed within/published by a continuous pipeline pipeline.
=== Lockdown Tests
Lockdown tests capture the state of the system, so that changes to that system can be captured and confirmed.
There are two lockdown tests:
* the metamodel (serialized as XML)
This is expected to change whenever the domain logic is changed, but generally should _not_ change when the Apache Isis framework is upgraded.
* Maven dependencies (serialized as flat files)
This should only change when dependencies are bumped or new dependencies added.
The lockdown tests are implemented as link:[approval test]s, meaning that the current state is compared to an "approved" state.
If there are no differences then the test passes.
If there are differences then the test fails, and a diff is shown using any available `diff` tool.
The lockdown tests are disabled by default, and are enabled with system properties.
* to compare the current metamodel with the previously approved metamodel:
mvn integration-test -Dmetamodel.lockdown
* to compare the current Maven dependencies with the previously approved dependencies:
mvn test -Dmavendeps.lockdown
When there are differences, the current state is written to the `current` subdirectory.
If the current state is approved, it should be copied over to the corresponding `approved` subdirectory.
== Docker
To package up the application as a docker image and push to a Docker registry:
* modify the `to/image` configuration property for the link:[jib-maven-plugin] in the `pom.xml`
The default value is ``:
** change `` prefix to push to a registry other than Docker hub
** change `apacheisis/simpleapp` to the name of your app.
* package up the app with the `docker` profile:
mvn -pl webapp -DskipTests -Ddocker package
* to specify Docker registry credentials through some other mechanism, configure the `pom.xml` for `maven-jib-plugin` (it supports a link:[variety of ways] to specify credentials)
* to override the image at the command line, use `-Dimage=...`.
To run a docker image previously packaged:
docker pull apacheisis/simpleapp:latest
docker container run -d -p 8080:8080 apacheisis/simpleapp:latest
This can then be accessed at link:http://localhost:8080[localhost:8080].
=== Externalized Configuration
The Docker image is configured to run in the `/run/secrets` directory.
Configuration can be therefore be externalized by defining an `` secret for the Kubernetes or Docker Swarm cluster.
Spring Boot will use these settings in preference to the configuration properties defined in `classpath:config/`, see link:[Spring docs].
== Translations
Apache Isis supports i18n using link:[GNU .po file]s.
The `WEB-INF/translations.po` is the fallback (an empty value means that the key is used "as-is"), while `WEB-INF/translations-XX.po` files provide translations for each "XX" locale.
Translations are required for all domain classes and all members (actions, properties and collections) of all classes.
This information is available from the metamodel, and so a new template `translations.po` is generated as a side-effect of running the integration tests (through a log4j2 logger).
A good integration test to run is `ValidateDomainModel_IntegTest`.
In addition, translations are required for any validation messages triggered by the test.
Running an integration tests that trigger validations will result in these messages being captured as keys, for example `Smoke_IntegTest`.
The generated file should be merged with any existing translations in `WEB-INF/translations.po`, and translations obtained for any new keys (there are numerous online services that support the format).