A simple banking application demonstrating Test-Driven Development (TDD) with the Spring Framework. It models accounts and transfers, exposes lightweight HTTP endpoints, and includes comprehensive unit and integration tests.
- Implements core domain types:
Account,TransferReceipt, and exceptions for business rules. - Service layer handles transfers and fees with pluggable
FeePolicyimplementations. - Repository layer provides in-memory and JDBC-style implementations.
- Web layer uses Spring MVC to expose account lookup and transfer operations.
- In-memory HSQLDB is used for integration tests; schema and test data are provisioned via Spring.
- Java 21 (Temurin)
- Maven (WAR packaging)
- Spring Framework 5.3.x (MVC, JDBC, OXM)
- SLF4J logging
- HSQLDB (embedded, test-only)
- JUnit 4, Mockito
src/main/java/com/bank/...— Controllers, services, repositories, domainsrc/main/resources/META-INF/spring— Spring XML config, schema and test datasrc/test/java/com/bank/...— Unit and integration testssrc/webapp— Minimal JSP and web descriptors
- Java 21
- Maven 3.9+
# Run full test suite
mvn clean test
# Build WAR artifact
mvn clean packageThis project packages as a WAR (target/odtBank.war). Deploy to a compliant Servlet container or use Docker.
Build and run the application in a containerized environment:
# Build Docker image
docker build -t odtbank:latest .
# Run container (port 8080)
docker run -d -p 8080:8080 --name odtbank odtbank:latest
# View logs
docker logs -f odtbank
# Stop container
docker stop odtbankStack: Java 21 (Temurin), Tomcat 9.0.89, Spring 5.3.36
Deploy target/odtBank.war to a compliant Servlet container (e.g., Tomcat 9 with Servlet 4 support). The legacy Jetty Maven plugin defined in pom.xml is not guaranteed to work on modern JDKs.
Note: Tomcat 10+ requires Jakarta Servlet API; this project uses javax.servlet, so Tomcat 9 is recommended.
Controller: AccountController
- GET
/odtBank/account/{id}— Retrieve an account by ID - GET
/odtBank/account/{srcId}/transfer/{amount}/to/{destId}— TransferamountfromsrcIdtodestId
Responses are simple JSON/XML depending on the configured message converters.
# List account (replace {id} with actual ID from test-data.sql)
curl http://localhost:8080/odtBank/account/1
# Transfer funds
curl http://localhost:8080/odtBank/account/1/transfer/50/to/2- Spring context and beans are defined in
src/main/resources/META-INF/spring/spring-context.xml. - Test data and schema are defined in
schema.sqlandtest-data.sqlunder the same folder.
The project includes 22 tests covering services, policies, controller behavior, and an integration test that provisions an embedded database:
DefaultTransferServiceTest,DefaultTimeServiceTest,FlatFeePolicyTest,VariableFeePolicyTest,CheckingTimeAdviceTestAccountControllerTestIntegrationITCase(XML config-driven)
- Critical and high-severity CVEs have been remediated by upgrading Spring and migrating Jackson to FasterXML.
- See CVE details and actions in CVE_FIX_SUMMARY.md.
- Keep Spring 5.3.x and Jackson 2.17.x up to date with latest patch releases.
- Default development branch:
main(rename frommaster).
This repository does not declare a license. If you plan to distribute, add an appropriate LICENSE file.