Skip to content

callicoder/testing-spring-boot-applications

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Testing Spring Boot Applications

This is a sample application used for a talk that shows testing improvements in Spring Boot 1.4. Look at the talk script in combination with the commit history for a high level overview.

Running the application

If you want to run the application locally you’ll need to follow these steps:

MySQL

A local MySQL server is required and should be configured using the following commands:

Add a cars database and user:

CREATE DATABASE cars;
CREATE USER 'cars'@'localhost' IDENTIFIED BY 'cars';
GRANT ALL PRIVILEGES ON cars . * TO 'cars'@'localhost';
FLUSH PRIVILEGES;

Create a table:

USE cars;
CREATE TABLE user (id BIGINT NOT NULL AUTO_INCREMENT, username VARCHAR(255), vin VARCHAR(255), PRIMARY KEY (id));
ALTER TABLE user ADD CONSTRAINT UK_USERNAME UNIQUE (USERNAME);

Insert some data:

INSERT INTO user (username, vin) values ('mickey', '01234567890123456');

Mock remote service

The sample calls a remote REST service that must be running. The build includes a WireMock version that can be used. For some reason the second request to WireMock seems to hang, so make sure you curl it at least three times after starting:

mvn -Pwiremock
curl http://localhost:8081/vs/vehicle/01234567890123456/details
curl http://localhost:8081/vs/vehicle/01234567890123456/details (will fail, hit Ctrl^C)
curl http://localhost:8081/vs/vehicle/01234567890123456/details

Run the application

When MySQL and WireMock are running you can type:

mvn spring-boot:run

Test using

curl http://localhost:8080/mickey/vehicle

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%