|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2017 the original author or authors.
|
|
|
|
* Copyright 2012-2018 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -16,6 +16,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
package sample.jsp;
|
|
|
|
package sample.jsp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.net.URI;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
|
|
|
|
|
|
|
@ -23,7 +26,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
|
|
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
|
|
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
|
|
|
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
|
|
|
import org.springframework.http.HttpMethod;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
|
|
|
import org.springframework.http.RequestEntity;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
|
|
|
|
|
@ -48,4 +55,15 @@ public class SampleWebJspApplicationTests {
|
|
|
|
assertThat(entity.getBody()).contains("/resources/text.txt");
|
|
|
|
assertThat(entity.getBody()).contains("/resources/text.txt");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void customErrorPage() throws Exception {
|
|
|
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
|
|
|
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
|
|
|
|
|
|
|
RequestEntity<Void> request = new RequestEntity<>(headers, HttpMethod.GET,
|
|
|
|
|
|
|
|
URI.create("/foo"));
|
|
|
|
|
|
|
|
ResponseEntity<String> entity = this.restTemplate.exchange(request, String.class);
|
|
|
|
|
|
|
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
|
|
|
|
|
assertThat(entity.getBody()).contains("Something went wrong");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|