Initial Gradle commit with test properties, development properties, logging properties, lombok properties, and travis properties, and example Spring Boot classes and integration and unit tests

This commit is contained in:
2019-02-01 21:39:57 -07:00
parent bef3654a5c
commit 5e9ae19afb
21 changed files with 580 additions and 7 deletions
@@ -0,0 +1,36 @@
package integrationTest;
import hello.Application;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.net.URL;
import static org.junit.Assert.assertEquals;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class)
public class HelloControllerIntegrationTest {
@LocalServerPort private int port;
private URL base;
@Autowired private TestRestTemplate testRestTemplate;
@Before
public void setUp() throws Exception {
this.base = new URL("http://localhost:" + port + "/");
}
@Test
public void testGetHello() {
final ResponseEntity<String> response = testRestTemplate.getForEntity(base.toString(),
String.class);
assertEquals("Greetings from Spring Boot!", response.getBody());
}
}