package com.henry.jewellery;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = HenryJewelleryApplication.class)
@WebAppConfiguration
public class HenryJewelleryApplicationTests {

	@Test
	public void contextLoads() {
	}

}

@@ -23,16 +23,62 @@
 llery;%0A%0A
+import static org.junit.Assert.assertEquals;%0A%0A
 import o
@@ -156,113 +156,311 @@
 ork.
-test.context.web.WebAppConfiguration;%0Aimport org.springframework.boot.test.SpringApplicationConfiguration
+beans.factory.annotation.Value;%0Aimport org.springframework.boot.test.SpringApplicationConfiguration;%0Aimport org.springframework.boot.test.TestRestTemplate;%0Aimport org.springframework.boot.test.WebIntegrationTest;%0Aimport org.springframework.http.HttpStatus;%0Aimport org.springframework.http.ResponseEntity
 ;%0Aim
@@ -528,16 +528,68 @@
 sRunner;
+%0Aimport org.springframework.web.client.RestTemplate;
 %0A%0A@RunWi
@@ -705,24 +705,42 @@
 @Web
-AppConfiguration
+IntegrationTest(randomPort = true)
 %0Apub
@@ -786,17 +786,141 @@
 s %7B%0A
-%0A%09
+    @Value(%22$%7Blocal.server.port%7D%22)%0A    private int port;%0A%0A    private RestTemplate template = new TestRestTemplate();%0A%0A    
 @Test%0A
-%09
+    
 publ
@@ -948,10 +948,801 @@
 ) %7B%0A
-%09%7D%0A
+    %7D%0A%0A    @Test%0A    public void homePageLoads() %7B%0A        ResponseEntity%3CString%3E response = template.getForEntity(%22http://localhost:%22 + port + %22/%22, String.class);%0A        assertEquals(HttpStatus.OK, response.getStatusCode());%0A    %7D%0A%0A    @Test%0A    public void loginEndpointProtected() %7B%0A        ResponseEntity%3CString%3E response = template.getForEntity(%22http://localhost:%22 + port + %22/accounts/me%22, String.class);%0A        assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode());%0A    %7D%0A%0A    @Test%0A    public void loginSucceeds() %7B%0A        RestTemplate template = new TestRestTemplate(%22user%22, %22p%22);%0A        ResponseEntity%3CString%3E response = template.getForEntity(%22http://localhost:%22 + port + %22/accounts/me%22, String.class);%0A        assertEquals(HttpStatus.OK, response.getStatusCode());%0A    %7D
 %0A%7D%0A

add test cases