From 6e16d4fc08a29b49f67839a9ffa73f54f13fce24 Mon Sep 17 00:00:00 2001 From: Fabio Busatto Date: Wed, 18 Apr 2018 17:29:49 +0000 Subject: [PATCH] Update to Spring Boot 2 --- .gitignore | 15 ++++++++------- .mvn/wrapper/maven-wrapper.properties | 2 +- README.md | 8 ++++---- pom.xml | 2 +- .../com/example/demo/DemoApplicationTests.java | 14 +++++++++++++- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 2af7cef..d5dba20 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -target/ +/target/ !.mvn/wrapper/maven-wrapper.jar ### STS ### @@ -8,6 +8,7 @@ target/ .project .settings .springBeans +.sts4-cache ### IntelliJ IDEA ### .idea @@ -16,9 +17,9 @@ target/ *.ipr ### NetBeans ### -nbproject/private/ -build/ -nbbuild/ -dist/ -nbdist/ -.nb-gradle/ \ No newline at end of file +/nbproject/private/ +/build/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index c315043..b573bb5 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip diff --git a/README.md b/README.md index 251c844..8a61388 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ ### Java Spring template project -This project is based on a GitLab [Project Template](https://docs.gitlab.com/ee/gitlab-basics/create-project.html) +This project is based on a GitLab [Project Template](https://docs.gitlab.com/ee/gitlab-basics/create-project.html). -Additions and changes to the project can be proposed in the [original project](https://gitlab.com/gitlab-org/project-templates/spring) +Additions and changes to the project can be proposed in the [original project](https://gitlab.com/gitlab-org/project-templates/spring). ### CI/CD with Auto DevOps This template is compatible with [Auto DevOps](https://docs.gitlab.com/ee/topics/autodevops/). -If Auto DevOps is not already enabled for this project, you can [turn it on](https://docs.gitlab.com/ee/topics/autodevops/#enabling-auto-devops) -in the project settings. Otherwise, you can create a custom `.gitlab-ci.yml` file and customize it. +If Auto DevOps is not already enabled for this project, you can [turn it on](https://docs.gitlab.com/ee/topics/autodevops/#enabling-auto-devops) in the project settings. +Otherwise, you can create a custom `.gitlab-ci.yml` file and customize it. diff --git a/pom.xml b/pom.xml index 16ab646..2d1e8c8 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.6.RELEASE + 2.0.1.RELEASE diff --git a/src/test/java/com/example/demo/DemoApplicationTests.java b/src/test/java/com/example/demo/DemoApplicationTests.java index b76e7f2..8595e84 100644 --- a/src/test/java/com/example/demo/DemoApplicationTests.java +++ b/src/test/java/com/example/demo/DemoApplicationTests.java @@ -3,14 +3,26 @@ package com.example.demo; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.junit4.SpringRunner; +import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) -@SpringBootTest +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) public class DemoApplicationTests { @Test public void contextLoads() { } + @Autowired + private TestRestTemplate restTemplate; + + @Test + public void homeResponse() { + String body = this.restTemplate.getForObject("/", String.class); + assertThat(body).isEqualTo("Spring is here!"); + } } -- GitLab