Here are the examples of the java api org.springframework.http.ResponseEntity.getHeaders() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
441 Examples
19
View Source File : IIIFImageApiControllerTest.java
License : MIT License
Project Creator : dbmdz
License : MIT License
Project Creator : dbmdz
@Test
public void testImageInfoContentType() throws Exception {
ResponseEnreplacedy<String> response = restTemplate.getForEnreplacedy("/image/" + IIIFImageApiController.VERSION + "/file-zoom/info.json", String.clreplaced);
// replacedertThat(response.getHeaders().get("Referer")).isEqualTo("http://localhost/foobar"); //
// referer is null...
//
// replacedertThat(response.getHeaders().getAccept()).contains(MediaType.parseMediaType("application/ld+json")); // accept is null
replacedertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
replacedertThat(response.getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_JSON);
}
19
View Source File : IIIFImageApiControllerTest.java
License : MIT License
Project Creator : dbmdz
License : MIT License
Project Creator : dbmdz
@Test
public void testInfoRedirect() throws Exception {
ResponseEnreplacedy<String> response = restTemplate.getForEnreplacedy("/image/" + IIIFImageApiController.VERSION + "/abcdef", String.clreplaced);
replacedertThat(response.getStatusCode().series()).isEqualTo(HttpStatus.Series.REDIRECTION);
replacedertThat(response.getHeaders().getLocation().getPath()).isEqualTo("/image/" + IIIFImageApiController.VERSION + "/abcdef/info.json");
}
19
View Source File : IIIFImageApiControllerTest.java
License : MIT License
Project Creator : dbmdz
License : MIT License
Project Creator : dbmdz
@Test
public void testNoRedirectIfDisabled() throws Exception {
iiifController.setCanonicalRedirectEnabled(false);
ResponseEnreplacedy<String> response = restTemplate.getForEnreplacedy("/image/" + IIIFImageApiController.VERSION + "/file-zoom/pct:10,20,20,20/pct:84/0/default.jpg", String.clreplaced);
iiifController.setCanonicalRedirectEnabled(true);
replacedertThat(response.getStatusCode().series()).isEqualTo(HttpStatus.Series.SUCCESSFUL);
String link = response.getHeaders().getFirst("Link").toString();
replacedertThat(link).isEqualTo("<http://localhost:" + randomServerPort + "/image/" + IIIFImageApiController.VERSION + "/file-zoom/206,511,413,511/346,/0/default.jpg>;rel=\"canonical\"");
}
19
View Source File : IIIFImageApiControllerTest.java
License : MIT License
Project Creator : dbmdz
License : MIT License
Project Creator : dbmdz
@Test
public void testCanonicalRedirectWithRelativeCropAndScale() throws Exception {
ResponseEnreplacedy<String> response = restTemplate.getForEnreplacedy("/image/" + IIIFImageApiController.VERSION + "/file-zoom/pct:10,20,20,20/pct:84/0/default.jpg", String.clreplaced);
replacedertThat(response.getStatusCode().series()).isEqualTo(HttpStatus.Series.REDIRECTION);
String location = response.getHeaders().getLocation().getPath();
replacedertThat(location).isEqualTo("/image/" + IIIFImageApiController.VERSION + "/file-zoom/206,511,413,511/346,/0/default.jpg");
}
18
View Source File : SessionRestApi.java
License : MIT License
Project Creator : ergon
License : MIT License
Project Creator : ergon
public String create() {
ResponseEnreplacedy<Void> response = restTemplate().exchange(uri("session", "create"), POST, new HttpEnreplacedy<>(defaultHttpHeaders()), new ParameterizedTypeReference<Void>() {
});
return response.getHeaders().get("Set-Cookie").get(0);
}
18
View Source File : IIIFImageApiControllerTest.java
License : MIT License
Project Creator : dbmdz
License : MIT License
Project Creator : dbmdz
@Test
public void testNonExisting() {
ResponseEnreplacedy<String> response = restTemplate.getForEnreplacedy("/image/" + IIIFImageApiController.VERSION + "/idontexist/full/full/0/default.png", String.clreplaced);
replacedertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
replacedertThat(response.getHeaders().getContentType()).isNotEqualTo(MediaType.IMAGE_PNG);
}
17
View Source File : UpdateChecker.java
License : MIT License
Project Creator : WulfMarius
License : MIT License
Project Creator : WulfMarius
public void findLatestVersion() {
if (!this.canCheckForNewVersion()) {
return;
}
ResponseEnreplacedy<String> response = this.restClient.fetch(LATEST_RELEASE_URL, this.state.getEtag());
if (response.getStatusCode().is2xxSuccessful()) {
GithubRelease latestRelease = this.restClient.deserialize(response, GithubRelease.clreplaced, GithubRelease::new);
this.state.setLatestVersion(latestRelease.getName());
Githubreplacedet[] replacedets = latestRelease.getreplacedets();
if (replacedets != null && replacedets.length == 1) {
this.state.setreplacedet(replacedets[0]);
} else {
this.state.setreplacedet(null);
}
this.state.setReleaseUrl(latestRelease.getUrl());
}
this.state.setEtag(response.getHeaders().getETag());
this.state.setChecked(new Date());
}
17
View Source File : AbstractSourceFactory.java
License : MIT License
Project Creator : WulfMarius
License : MIT License
Project Creator : WulfMarius
protected SourceDescription getSourceDescription(String sourceDefinition, Map<String, String> parameters) {
String url = this.getDefinitionsUrl(sourceDefinition);
ResponseEnreplacedy<String> response = this.restClient.fetch(url, parameters.get(PARAMETER_ETAG));
if (!response.getStatusCode().isError()) {
SourceDescription result = this.restClient.deserialize(response, SourceDescription.clreplaced, this::createUnmodifiedSourceDescription);
result.setParameter(PARAMETER_ETAG, response.getHeaders().getETag());
result.setParameter(PARAMETER_VERSION, Source.VERSION);
return result;
}
throw new SourceException("Could not read source description: " + response.getStatusCodeValue() + ", " + response.getBody());
}
17
View Source File : CompatibilityChecker.java
License : MIT License
Project Creator : WulfMarius
License : MIT License
Project Creator : WulfMarius
private void fetchTldVersions() {
try {
ResponseEnreplacedy<String> response = this.restClient.fetch(TLD_VERSIONS_URL, this.state.getEtag());
if (response.getStatusCode().is2xxSuccessful()) {
this.state.setCompatibilityVersions(this.restClient.deserialize(response, CompatibilityVersions.clreplaced, null));
this.state.setEtag(response.getHeaders().getETag());
this.currentCompatibilityVersion = this.state.getCompatibilityVersions().floor(this.parsedCurrentVersion);
}
this.state.setChecked(new Date());
this.writeState();
} catch (AbortException e) {
// ignore
}
}
17
View Source File : FeignOkHttpTests.java
License : Apache License 2.0
Project Creator : spring-cloud
License : Apache License 2.0
Project Creator : spring-cloud
@Test
void testPatch() {
ResponseEnreplacedy<Void> response = testClient.patchHello(new Hello("foo"));
replacedertThat(response).isNotNull();
String header = response.getHeaders().getFirst("x-hello");
replacedertThat(header).isEqualTo("hello world patch");
}
17
View Source File : WebStaticApplicationTests.java
License : GNU Affero General Public License v3.0
Project Creator : romeoblog
License : GNU Affero General Public License v3.0
Project Creator : romeoblog
private void resources(String path, String type) {
ResponseEnreplacedy<String> enreplacedy = this.restTemplate.getForEnreplacedy(path, String.clreplaced);
replacedertThat(enreplacedy.getHeaders().getContentType()).isEqualTo(MediaType.valueOf(type));
}
17
View Source File : ApplicationIT.java
License : MIT License
Project Creator : rieckpil
License : MIT License
Project Creator : rieckpil
@Test
void shouldCreateUserAndPerformReporting() {
ResponseEnreplacedy<Void> result = this.testRestTemplate.postForEnreplacedy("/api/users", "duke", Void.clreplaced);
replacedertEquals(201, result.getStatusCodeValue());
replacedertTrue(result.getHeaders().containsKey("Location"), "Response doesn't contain Location header");
// additional replacedertion to verify the counter was incremented
// additional replacedertion that a new message is part of the queue
}
17
View Source File : FlowableUiApplicationSecurityTest.java
License : Apache License 2.0
Project Creator : flowable
License : Apache License 2.0
Project Creator : flowable
@Test
public void nonAuthenticatedUserShouldBeRedirectedToLogin() {
String rootUrl = "http://localhost:" + serverPort + "/flowable-ui/";
ResponseEnreplacedy<String> result = restTemplate.getForEnreplacedy(rootUrl, String.clreplaced);
replacedertThat(result.getStatusCode()).as("GET app definitions").isEqualTo(HttpStatus.FOUND);
replacedertThat(result.getHeaders().getFirst(HttpHeaders.LOCATION)).as("redirect location").isEqualTo("http://localhost:" + serverPort + "/flowable-ui/idm/#/login");
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void personResponseBodyWithSingle() throws Exception {
Person expected = new Person("Robert");
ResponseEnreplacedy<Person> enreplacedy = performGet("/person-response/single", JSON, Person.clreplaced);
replacedertEquals(17, enreplacedy.getHeaders().getContentLength());
replacedertEquals(expected, enreplacedy.getBody());
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void personResponseBodyWithMonoDeclaredAsObject() throws Exception {
Person expected = new Person("Robert");
ResponseEnreplacedy<Person> enreplacedy = performGet("/person-response/mono-declared-as-object", JSON, Person.clreplaced);
replacedertEquals(17, enreplacedy.getHeaders().getContentLength());
replacedertEquals(expected, enreplacedy.getBody());
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void personResponseBodyWithMono() throws Exception {
Person expected = new Person("Robert");
ResponseEnreplacedy<Person> responseEnreplacedy = performGet("/person-response/mono", JSON, Person.clreplaced);
replacedertEquals(17, responseEnreplacedy.getHeaders().getContentLength());
replacedertEquals(expected, responseEnreplacedy.getBody());
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void personResponseBodyWithCompletableFuture() throws Exception {
Person expected = new Person("Robert");
ResponseEnreplacedy<Person> responseEnreplacedy = performGet("/person-response/completable-future", JSON, Person.clreplaced);
replacedertEquals(17, responseEnreplacedy.getHeaders().getContentLength());
replacedertEquals(expected, responseEnreplacedy.getBody());
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void personResponseBody() throws Exception {
Person expected = new Person("Robert");
ResponseEnreplacedy<Person> responseEnreplacedy = performGet("/person-response/person", JSON, Person.clreplaced);
replacedertEquals(17, responseEnreplacedy.getHeaders().getContentLength());
replacedertEquals(expected, responseEnreplacedy.getBody());
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void personResponseBodyWithMonoResponseEnreplacedy() throws Exception {
Person expected = new Person("Robert");
ResponseEnreplacedy<Person> enreplacedy = performGet("/person-response/mono-response-enreplacedy", JSON, Person.clreplaced);
replacedertEquals(17, enreplacedy.getHeaders().getContentLength());
replacedertEquals(expected, enreplacedy.getBody());
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void byteBufferResponseBodyWithMono() throws Exception {
String expected = "Hello!";
ResponseEnreplacedy<String> responseEnreplacedy = performGet("/raw-response/mono", new HttpHeaders(), String.clreplaced);
replacedertEquals(6, responseEnreplacedy.getHeaders().getContentLength());
replacedertEquals(expected, responseEnreplacedy.getBody());
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
// SPR-16172
@Test
public void personResponseBodyWithMonoResponseEnreplacedyXml() throws Exception {
String url = "/person-response/mono-response-enreplacedy-xml";
ResponseEnreplacedy<String> enreplacedy = performGet(url, new HttpHeaders(), String.clreplaced);
String actual = enreplacedy.getBody();
replacedertEquals(91, enreplacedy.getHeaders().getContentLength());
replacedertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<person><name>Robert</name></person>", actual);
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
// SPR-17506
@Test
public void personResponseBodyWithEmptyMono() throws Exception {
ResponseEnreplacedy<Person> responseEnreplacedy = performGet("/person-response/mono-empty", JSON, Person.clreplaced);
replacedertEquals(0, responseEnreplacedy.getHeaders().getContentLength());
replacedertNull(responseEnreplacedy.getBody());
// As we're on the same connection, the 2nd request proves server response handling
// did complete after the 1st request..
responseEnreplacedy = performGet("/person-response/mono-empty", JSON, Person.clreplaced);
replacedertEquals(0, responseEnreplacedy.getHeaders().getContentLength());
replacedertNull(responseEnreplacedy.getBody());
}
16
View Source File : RequestHandler.java
License : MIT License
Project Creator : ssssssss-team
License : MIT License
Project Creator : ssssssss-team
/**
* 转换请求结果
*/
private Object convertResult(Object result, long requestTime, HttpServletResponse response) throws IOException {
if (result instanceof ResponseEnreplacedy) {
ResponseEnreplacedy enreplacedy = (ResponseEnreplacedy) result;
List<String> headers = new ArrayList<>();
for (Map.Entry<String, List<String>> entry : enreplacedy.getHeaders().entrySet()) {
String key = entry.getKey();
for (String value : entry.getValue()) {
headers.add("MA-" + key);
response.addHeader("MA-" + key, value);
}
}
headers.add(HEADER_RESPONSE_WITH_MAGIC_API);
response.setHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, String.join(",", headers));
if (enreplacedy.getHeaders().isEmpty()) {
return ResponseEnreplacedy.ok(new JsonBean<>(enreplacedy.getBody()));
}
return ResponseEnreplacedy.ok(new JsonBean<>(convertToBase64(enreplacedy.getBody())));
} else if (result instanceof ResponseModule.NullValue) {
return new JsonBean<>(1, "empty.");
}
return new JsonBean<>(resultProvider.buildResult(result, requestTime));
}
16
View Source File : SpringDecoderTests.java
License : Apache License 2.0
Project Creator : spring-cloud
License : Apache License 2.0
Project Creator : spring-cloud
@Test
public // Issue: https://github.com/spring-cloud/spring-cloud-openfeign/issues/456
void testResponseEnreplacedyHeaders() {
ResponseEnreplacedy<String> response = testClient().getContentType();
replacedertThat(response.getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_JSON);
}
16
View Source File : MessageControllerTest.java
License : Apache License 2.0
Project Creator : SpartaSystems
License : Apache License 2.0
Project Creator : SpartaSystems
@Test
public void shouldNotSetFilenameDispositionWhenFilenameNull() {
final InputStream streamMock = mock(InputStream.clreplaced);
setupForFetchAttachment(streamMock, null);
ResponseEnreplacedy response = messageControllerSpy.getMessageContentByAttachmentId(MSG_ID, ATTACH_ID);
replacedertThat(response.getHeaders().get("Content-Disposition")).hreplacedize(1).contains("attachment;");
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@ParameterizedHttpServerTest
public void personResponseBodyWithMonoResponseEnreplacedy(HttpServer httpServer) throws Exception {
startServer(httpServer);
Person expected = new Person("Robert");
ResponseEnreplacedy<Person> enreplacedy = performGet("/person-response/mono-response-enreplacedy", JSON, Person.clreplaced);
replacedertThat(enreplacedy.getHeaders().getContentLength()).isEqualTo(17);
replacedertThat(enreplacedy.getBody()).isEqualTo(expected);
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@ParameterizedHttpServerTest
public void byteBufferResponseBodyWithMono(HttpServer httpServer) throws Exception {
startServer(httpServer);
String expected = "Hello!";
ResponseEnreplacedy<String> responseEnreplacedy = performGet("/raw-response/mono", new HttpHeaders(), String.clreplaced);
replacedertThat(responseEnreplacedy.getHeaders().getContentLength()).isEqualTo(6);
replacedertThat(responseEnreplacedy.getBody()).isEqualTo(expected);
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
// SPR-17506
@ParameterizedHttpServerTest
public void personResponseBodyWithEmptyMono(HttpServer httpServer) throws Exception {
startServer(httpServer);
ResponseEnreplacedy<Person> responseEnreplacedy = performGet("/person-response/mono-empty", JSON, Person.clreplaced);
replacedertThat(responseEnreplacedy.getHeaders().getContentLength()).isEqualTo(0);
replacedertThat(responseEnreplacedy.getBody()).isNull();
// As we're on the same connection, the 2nd request proves server response handling
// did complete after the 1st request..
responseEnreplacedy = performGet("/person-response/mono-empty", JSON, Person.clreplaced);
replacedertThat(responseEnreplacedy.getHeaders().getContentLength()).isEqualTo(0);
replacedertThat(responseEnreplacedy.getBody()).isNull();
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@ParameterizedHttpServerTest
public void personResponseBody(HttpServer httpServer) throws Exception {
startServer(httpServer);
Person expected = new Person("Robert");
ResponseEnreplacedy<Person> responseEnreplacedy = performGet("/person-response/person", JSON, Person.clreplaced);
replacedertThat(responseEnreplacedy.getHeaders().getContentLength()).isEqualTo(17);
replacedertThat(responseEnreplacedy.getBody()).isEqualTo(expected);
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@ParameterizedHttpServerTest
public void personResponseBodyWithMonoDeclaredAsObject(HttpServer httpServer) throws Exception {
startServer(httpServer);
Person expected = new Person("Robert");
ResponseEnreplacedy<Person> enreplacedy = performGet("/person-response/mono-declared-as-object", JSON, Person.clreplaced);
replacedertThat(enreplacedy.getHeaders().getContentLength()).isEqualTo(17);
replacedertThat(enreplacedy.getBody()).isEqualTo(expected);
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
// SPR-16172
@ParameterizedHttpServerTest
public void personResponseBodyWithMonoResponseEnreplacedyXml(HttpServer httpServer) throws Exception {
startServer(httpServer);
String url = "/person-response/mono-response-enreplacedy-xml";
ResponseEnreplacedy<String> enreplacedy = performGet(url, new HttpHeaders(), String.clreplaced);
String actual = enreplacedy.getBody();
replacedertThat(enreplacedy.getHeaders().getContentLength()).isEqualTo(91);
replacedertThat(actual).isEqualTo(("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<person><name>Robert</name></person>"));
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@ParameterizedHttpServerTest
public void personResponseBodyWithSingle(HttpServer httpServer) throws Exception {
startServer(httpServer);
Person expected = new Person("Robert");
ResponseEnreplacedy<Person> enreplacedy = performGet("/person-response/single", JSON, Person.clreplaced);
replacedertThat(enreplacedy.getHeaders().getContentLength()).isEqualTo(17);
replacedertThat(enreplacedy.getBody()).isEqualTo(expected);
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@ParameterizedHttpServerTest
public void personResponseBodyWithMono(HttpServer httpServer) throws Exception {
startServer(httpServer);
Person expected = new Person("Robert");
ResponseEnreplacedy<Person> responseEnreplacedy = performGet("/person-response/mono", JSON, Person.clreplaced);
replacedertThat(responseEnreplacedy.getHeaders().getContentLength()).isEqualTo(17);
replacedertThat(responseEnreplacedy.getBody()).isEqualTo(expected);
}
16
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
@ParameterizedHttpServerTest
public void personResponseBodyWithCompletableFuture(HttpServer httpServer) throws Exception {
startServer(httpServer);
Person expected = new Person("Robert");
ResponseEnreplacedy<Person> responseEnreplacedy = performGet("/person-response/completable-future", JSON, Person.clreplaced);
replacedertThat(responseEnreplacedy.getHeaders().getContentLength()).isEqualTo(17);
replacedertThat(responseEnreplacedy.getBody()).isEqualTo(expected);
}
16
View Source File : StubbyMock.java
License : MIT License
Project Creator : osvaldjr
License : MIT License
Project Creator : osvaldjr
private static String getStubbyId(ResponseEnreplacedy response) {
String location = response.getHeaders().getFirst("location");
Matcher matcher = Pattern.compile(".*?\\/(\\d+)").matcher(location);
return matcher.find() ? matcher.group(1) : null;
}
16
View Source File : DataSetDownloadControllerTest.java
License : Apache License 2.0
Project Creator : kiegroup
License : Apache License 2.0
Project Creator : kiegroup
@Test
void content_length_should_be_number_of_bytes() throws IOException {
// Nice illustration of the problem: https://sankhs.com/2016/03/17/content-length-http-headers/
// If the content-length header is less than number of bytes, part of the response body thrown away!
// So if we sent "অhello" with content-length: 6, the client (browser) would only present "অhel".
// arrange
String msg = "অ";
when(demoService.exportDataSet()).thenReturn(msg);
// act
ResponseEnreplacedy<Resource> responseEnreplacedy = controller.exportDataSet();
// replacedert
replacedertThat(responseEnreplacedy.getHeaders().getContentLength()).isEqualTo(3);
}
16
View Source File : Auth0ApplicationTests.java
License : Apache License 2.0
Project Creator : jzheaux
License : Apache License 2.0
Project Creator : jzheaux
@Test
public void writeWhenBadAuthorizationHeaderThenRequestIsForbidden() {
Message toSave = new Message("New");
ResponseEnreplacedy<Message> response = postForMessage("/messages", this.messageReadAuthority, toSave);
replacedertThat(response.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
replacedertThat(response.getHeaders().get("WWW-Authenticate")).isNotNull().contains("Bearer error=\"insufficient_scope\", " + "error_description=\"Resource requires any or all of these scopes [message.write]\", " + "error_uri=\"https://tools.ietf.org/html/rfc6750#section-3.1\", " + "scope=\"message.write\"");
}
16
View Source File : Auth0ApplicationTests.java
License : Apache License 2.0
Project Creator : jzheaux
License : Apache License 2.0
Project Creator : jzheaux
@Test
public void writeWhenNoAuthorizationHeaderThenRequestIsForbiddenByCsrf() {
Message toSave = new Message("New");
ResponseEnreplacedy<Message> response = postForMessage("/messages", null, toSave);
replacedertThat(response.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
replacedertThat(response.getHeaders().get("WWW-Authenticate")).isNotNull().contains("Bearer");
}
16
View Source File : Auth0ApplicationTests.java
License : Apache License 2.0
Project Creator : jzheaux
License : Apache License 2.0
Project Creator : jzheaux
@Test
public void readWhenBadAuthorizationHeaderThenRequestIsForbidden() {
ResponseEnreplacedy<Message> response = getForMessage("/messages/{id}", this.messageWriteAuthority, 1L);
replacedertThat(response.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
replacedertThat(response.getHeaders().get("WWW-Authenticate")).isNotNull().contains("Bearer error=\"insufficient_scope\", " + "error_description=\"Resource requires any or all of these scopes [message.read]\", " + "error_uri=\"https://tools.ietf.org/html/rfc6750#section-3.1\", " + "scope=\"message.read\"");
}
16
View Source File : LegacyAuth0ApplicationTests.java
License : Apache License 2.0
Project Creator : jzheaux
License : Apache License 2.0
Project Creator : jzheaux
@Test
public void readWhenBadAuthorizationHeaderThenRequestIsForbidden() {
ResponseEnreplacedy<Message> response = getForMessage("/messages/{id}", this.messageWriteAuthority, 1L);
replacedertThat(response.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
replacedertThat(response.getHeaders().get("WWW-Authenticate")).isNotNull().contains("Bearer error=\"insufficient_scope\", " + "error_description=\"Insufficient scope for this resource\", " + "scope=\"message.read\"");
}
16
View Source File : LegacyAuth0ApplicationTests.java
License : Apache License 2.0
Project Creator : jzheaux
License : Apache License 2.0
Project Creator : jzheaux
@Test
public void writeWhenBadAuthorizationHeaderThenRequestIsForbidden() {
Message toSave = new Message("New");
ResponseEnreplacedy<Message> response = postForMessage("/messages", this.messageReadAuthority, toSave);
replacedertThat(response.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
replacedertThat(response.getHeaders().get("WWW-Authenticate")).isNotNull().contains("Bearer error=\"insufficient_scope\", " + "error_description=\"Insufficient scope for this resource\", " + "scope=\"message.write\"");
}
16
View Source File : IIIFPresentationApiControllerTest.java
License : MIT License
Project Creator : dbmdz
License : MIT License
Project Creator : dbmdz
@Test
public void testManifest() {
ResponseEnreplacedy<String> response = restTemplate.getForEnreplacedy("/presentation/" + IIIFPresentationApiController.VERSION + "/manifest-valid-data/manifest", String.clreplaced);
replacedertThat(response.getHeaders().get("mani1")).containsExactly("mani-value1");
replacedertThat(response.getHeaders().get("mani2")).containsExactly("mani-value2");
}
16
View Source File : IIIFImageApiControllerTest.java
License : MIT License
Project Creator : dbmdz
License : MIT License
Project Creator : dbmdz
@Test
public void testContentDispositionHeader() throws Exception {
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.add("Referer", "http://localhost/foobar");
ResponseEnreplacedy<byte[]> response = restTemplate.exchange("/image/" + IIIFImageApiController.VERSION + "/http-google/full/full/0/default.png", HttpMethod.GET, new HttpEnreplacedy<>(requestHeaders), byte[].clreplaced);
replacedertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
replacedertThat(response.getHeaders().getLastModified()).isNotNull();
replacedertThat(response.getHeaders().getContentType()).isEqualTo(MediaType.IMAGE_PNG);
replacedertThat(response.getHeaders().getContentDisposition().getType()).isEqualTo("inline");
replacedertThat(response.getHeaders().getContentDisposition().getFilename()).isEqualTo(IIIFImageApiController.VERSION + "_http-google_full_full_0_default.png");
replacedertThat(response.getHeaders().get("cache-control")).containsExactly("max-age=86400");
}
16
View Source File : IIIFImageApiControllerTest.java
License : MIT License
Project Creator : dbmdz
License : MIT License
Project Creator : dbmdz
/* Other */
@Test
public void testCorsHeader() throws Exception {
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setOrigin("http://im.a.foreign.er");
ResponseEnreplacedy<String> response = restTemplate.exchange("/image/" + IIIFImageApiController.VERSION + "/http-google/info.json", HttpMethod.GET, new HttpEnreplacedy<>(requestHeaders), String.clreplaced);
replacedertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
replacedertThat(response.getHeaders().getAccessControlAllowOrigin()).isEqualTo("*");
}
16
View Source File : IIIFImageApiControllerTest.java
License : MIT License
Project Creator : dbmdz
License : MIT License
Project Creator : dbmdz
@Test
public void testImageInfoSizes() throws Exception {
ResponseEnreplacedy<String> response = restTemplate.getForEnreplacedy("/image/" + IIIFImageApiController.VERSION + "/file-zoom/info.json", String.clreplaced);
replacedertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
replacedertThat(response.getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_JSON);
DoreplacedentContext ctx = JsonPath.parse(response.getBody());
replacedertThat(ctx).jsonPathAsInteger("$.width").isEqualTo(2064);
replacedertThat(ctx).jsonPathAsInteger("$.height").isEqualTo(2553);
}
15
View Source File : SampleOAuth2ClientApplicationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void everythingShouldRedirectToLogin() {
ResponseEnreplacedy<String> enreplacedy = this.restTemplate.getForEnreplacedy("/", String.clreplaced);
replacedertThat(enreplacedy.getStatusCode()).isEqualTo(HttpStatus.FOUND);
replacedertThat(enreplacedy.getHeaders().getLocation()).isEqualTo(URI.create("http://localhost:" + this.port + "/login"));
}
15
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void personResponseBodyWithPublisher() throws Exception {
List<?> expected = asList(new Person("Robert"), new Person("Marie"));
ResponseEnreplacedy<List<Person>> enreplacedy = performGet("/person-response/publisher", JSON, PERSON_LIST);
replacedertEquals(-1, enreplacedy.getHeaders().getContentLength());
replacedertEquals(expected, enreplacedy.getBody());
}
15
View Source File : RequestMappingMessageConversionIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void personResponseBodyWithList() throws Exception {
List<?> expected = asList(new Person("Robert"), new Person("Marie"));
ResponseEnreplacedy<List<Person>> enreplacedy = performGet("/person-response/list", JSON, PERSON_LIST);
replacedertEquals(36, enreplacedy.getHeaders().getContentLength());
replacedertEquals(expected, enreplacedy.getBody());
}
15
View Source File : RestTemplateTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void postForEnreplacedy() throws Exception {
mockTextPlainHttpMessageConverter();
HttpHeaders requestHeaders = new HttpHeaders();
mockSentRequest(POST, "https://example.com", requestHeaders);
mockResponseStatus(HttpStatus.OK);
String expected = "42";
mockResponseBody(expected, MediaType.TEXT_PLAIN);
ResponseEnreplacedy<String> result = template.postForEnreplacedy("https://example.com", "Hello World", String.clreplaced);
replacedertEquals("Invalid POST result", expected, result.getBody());
replacedertEquals("Invalid Content-Type", MediaType.TEXT_PLAIN, result.getHeaders().getContentType());
replacedertEquals("Invalid Accept header", MediaType.TEXT_PLAIN_VALUE, requestHeaders.getFirst("Accept"));
replacedertEquals("Invalid status code", HttpStatus.OK, result.getStatusCode());
verify(response).close();
}
15
View Source File : RestTemplateTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void getForEnreplacedy() throws Exception {
HttpHeaders requestHeaders = new HttpHeaders();
mockSentRequest(GET, "https://example.com", requestHeaders);
mockTextPlainHttpMessageConverter();
mockResponseStatus(HttpStatus.OK);
String expected = "Hello World";
mockTextResponseBody(expected);
ResponseEnreplacedy<String> result = template.getForEnreplacedy("https://example.com", String.clreplaced);
replacedertEquals("Invalid GET result", expected, result.getBody());
replacedertEquals("Invalid Accept header", MediaType.TEXT_PLAIN_VALUE, requestHeaders.getFirst("Accept"));
replacedertEquals("Invalid Content-Type header", MediaType.TEXT_PLAIN, result.getHeaders().getContentType());
replacedertEquals("Invalid status code", HttpStatus.OK, result.getStatusCode());
verify(response).close();
}
See More Examples