Merge branch '1.2.x'

This commit is contained in:
Andy Wilkinson
2019-03-26 12:11:10 +00:00
42 changed files with 194 additions and 192 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2017 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,7 +68,8 @@ public class LinkExtractorsPayloadTests {
public void singleLink() throws IOException {
Map<String, List<Link>> links = this.linkExtractor
.extractLinks(createResponse("single-link"));
assertLinks(Arrays.asList(new Link("alpha", "http://alpha.example.com", "Alpha")),
assertLinks(
Arrays.asList(new Link("alpha", "https://alpha.example.com", "Alpha")),
links);
}
@@ -76,8 +77,8 @@ public class LinkExtractorsPayloadTests {
public void multipleLinksWithDifferentRels() throws IOException {
Map<String, List<Link>> links = this.linkExtractor
.extractLinks(createResponse("multiple-links-different-rels"));
assertLinks(Arrays.asList(new Link("alpha", "http://alpha.example.com", "Alpha"),
new Link("bravo", "http://bravo.example.com")), links);
assertLinks(Arrays.asList(new Link("alpha", "https://alpha.example.com", "Alpha"),
new Link("bravo", "https://bravo.example.com")), links);
}
@Test
@@ -85,8 +86,8 @@ public class LinkExtractorsPayloadTests {
Map<String, List<Link>> links = this.linkExtractor
.extractLinks(createResponse("multiple-links-same-rels"));
assertLinks(Arrays.asList(
new Link("alpha", "http://alpha.example.com/one", "Alpha one"),
new Link("alpha", "http://alpha.example.com/two")), links);
new Link("alpha", "https://alpha.example.com/one", "Alpha one"),
new Link("alpha", "https://alpha.example.com/two")), links);
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2018 the original author or authors.
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,9 +62,9 @@ public class UriModifyingOperationPreprocessorTests {
public void requestUriHostCanBeModified() {
this.preprocessor.host("api.example.com");
OperationRequest processed = this.preprocessor
.preprocess(createRequestWithUri("http://api.foo.com:12345"));
.preprocess(createRequestWithUri("https://api.foo.com:12345"));
assertThat(processed.getUri())
.isEqualTo(URI.create("http://api.example.com:12345"));
.isEqualTo(URI.create("https://api.example.com:12345"));
assertThat(processed.getHeaders().getFirst(HttpHeaders.HOST))
.isEqualTo("api.example.com:12345");
}
@@ -73,9 +73,9 @@ public class UriModifyingOperationPreprocessorTests {
public void requestUriPortCanBeModified() {
this.preprocessor.port(23456);
OperationRequest processed = this.preprocessor
.preprocess(createRequestWithUri("http://api.example.com:12345"));
.preprocess(createRequestWithUri("https://api.example.com:12345"));
assertThat(processed.getUri())
.isEqualTo(URI.create("http://api.example.com:23456"));
.isEqualTo(URI.create("https://api.example.com:23456"));
assertThat(processed.getHeaders().getFirst(HttpHeaders.HOST))
.isEqualTo("api.example.com:23456");
}
@@ -84,8 +84,8 @@ public class UriModifyingOperationPreprocessorTests {
public void requestUriPortCanBeRemoved() {
this.preprocessor.removePort();
OperationRequest processed = this.preprocessor
.preprocess(createRequestWithUri("http://api.example.com:12345"));
assertThat(processed.getUri()).isEqualTo(URI.create("http://api.example.com"));
.preprocess(createRequestWithUri("https://api.example.com:12345"));
assertThat(processed.getUri()).isEqualTo(URI.create("https://api.example.com"));
assertThat(processed.getHeaders().getFirst(HttpHeaders.HOST))
.isEqualTo("api.example.com");
}
@@ -93,28 +93,28 @@ public class UriModifyingOperationPreprocessorTests {
@Test
public void requestUriPathIsPreserved() {
this.preprocessor.removePort();
OperationRequest processed = this.preprocessor
.preprocess(createRequestWithUri("http://api.example.com:12345/foo/bar"));
OperationRequest processed = this.preprocessor.preprocess(
createRequestWithUri("https://api.example.com:12345/foo/bar"));
assertThat(processed.getUri())
.isEqualTo(URI.create("http://api.example.com/foo/bar"));
.isEqualTo(URI.create("https://api.example.com/foo/bar"));
}
@Test
public void requestUriQueryIsPreserved() {
this.preprocessor.removePort();
OperationRequest processed = this.preprocessor
.preprocess(createRequestWithUri("http://api.example.com:12345?foo=bar"));
OperationRequest processed = this.preprocessor.preprocess(
createRequestWithUri("https://api.example.com:12345?foo=bar"));
assertThat(processed.getUri())
.isEqualTo(URI.create("http://api.example.com?foo=bar"));
.isEqualTo(URI.create("https://api.example.com?foo=bar"));
}
@Test
public void requestUriAnchorIsPreserved() {
this.preprocessor.removePort();
OperationRequest processed = this.preprocessor
.preprocess(createRequestWithUri("http://api.example.com:12345#foo"));
.preprocess(createRequestWithUri("https://api.example.com:12345#foo"));
assertThat(processed.getUri())
.isEqualTo(URI.create("http://api.example.com#foo"));
.isEqualTo(URI.create("https://api.example.com#foo"));
}
@Test
@@ -132,9 +132,9 @@ public class UriModifyingOperationPreprocessorTests {
this.preprocessor.host("api.example.com");
OperationRequest processed = this.preprocessor
.preprocess(createRequestWithContent(
"The uri 'http://localhost:12345' should be used"));
"The uri 'https://localhost:12345' should be used"));
assertThat(new String(processed.getContent()))
.isEqualTo("The uri 'http://api.example.com:12345' should be used");
.isEqualTo("The uri 'https://api.example.com:12345' should be used");
}
@Test
@@ -212,9 +212,9 @@ public class UriModifyingOperationPreprocessorTests {
this.preprocessor.host("api.example.com");
OperationResponse processed = this.preprocessor
.preprocess(createResponseWithContent(
"The uri 'http://localhost:12345' should be used"));
"The uri 'https://localhost:12345' should be used"));
assertThat(new String(processed.getContent()))
.isEqualTo("The uri 'http://api.example.com:12345' should be used");
.isEqualTo("The uri 'https://api.example.com:12345' should be used");
}
@Test
@@ -280,35 +280,35 @@ public class UriModifyingOperationPreprocessorTests {
@Test
public void urisInRequestHeadersCanBeModified() {
OperationRequest processed = this.preprocessor.host("api.example.com")
.preprocess(createRequestWithHeader("Foo", "http://locahost:12345"));
.preprocess(createRequestWithHeader("Foo", "https://locahost:12345"));
assertThat(processed.getHeaders().getFirst("Foo"))
.isEqualTo("http://api.example.com:12345");
.isEqualTo("https://api.example.com:12345");
assertThat(processed.getHeaders().getFirst("Host")).isEqualTo("api.example.com");
}
@Test
public void urisInResponseHeadersCanBeModified() {
OperationResponse processed = this.preprocessor.host("api.example.com")
.preprocess(createResponseWithHeader("Foo", "http://locahost:12345"));
.preprocess(createResponseWithHeader("Foo", "https://locahost:12345"));
assertThat(processed.getHeaders().getFirst("Foo"))
.isEqualTo("http://api.example.com:12345");
.isEqualTo("https://api.example.com:12345");
}
@Test
public void urisInRequestPartHeadersCanBeModified() {
OperationRequest processed = this.preprocessor.host("api.example.com").preprocess(
createRequestWithPartWithHeader("Foo", "http://locahost:12345"));
createRequestWithPartWithHeader("Foo", "https://locahost:12345"));
assertThat(processed.getParts().iterator().next().getHeaders().getFirst("Foo"))
.isEqualTo("http://api.example.com:12345");
.isEqualTo("https://api.example.com:12345");
}
@Test
public void urisInRequestPartContentCanBeModified() {
OperationRequest processed = this.preprocessor.host("api.example.com")
.preprocess(createRequestWithPartWithContent(
"The uri 'http://localhost:12345' should be used"));
"The uri 'https://localhost:12345' should be used"));
assertThat(new String(processed.getParts().iterator().next().getContent()))
.isEqualTo("The uri 'http://api.example.com:12345' should be used");
.isEqualTo("The uri 'https://api.example.com:12345' should be used");
}
@Test

View File

@@ -1,7 +1,7 @@
{
"_links": {
"alpha": "http://alpha.example.com",
"bravo": "http://bravo.example.com"
"alpha": "https://alpha.example.com",
"bravo": "https://bravo.example.com"
},
"_embedded": "embedded-test",
"beta": "beta-value",

View File

@@ -1,7 +1,7 @@
{
"_links": {
"alpha": "http://alpha.example.com",
"bravo": "http://bravo.example.com"
"alpha": "https://alpha.example.com",
"bravo": "https://bravo.example.com"
},
"beta": "beta-value",
"charlie": "charlie-value"

View File

@@ -1,10 +1,10 @@
{
"links": [ {
"rel": "alpha",
"href": "http://alpha.example.com",
"href": "https://alpha.example.com",
"title": "Alpha"
}, {
"rel": "bravo",
"href": "http://bravo.example.com"
"href": "https://bravo.example.com"
} ]
}

View File

@@ -1,10 +1,10 @@
{
"links": [ {
"rel": "alpha",
"href": "http://alpha.example.com/one",
"href": "https://alpha.example.com/one",
"title": "Alpha one"
}, {
"rel": "alpha",
"href": "http://alpha.example.com/two"
"href": "https://alpha.example.com/two"
} ]
}

View File

@@ -1,7 +1,7 @@
{
"links": [ {
"rel": "alpha",
"href": "http://alpha.example.com",
"href": "https://alpha.example.com",
"title": "Alpha"
} ]
}

View File

@@ -1,9 +1,9 @@
{
"links": {
"alpha": [{
"href": "http://alpha.example.com/one"
"href": "https://alpha.example.com/one"
}, {
"href": "http://alpha.example.com/two"
"href": "https://alpha.example.com/two"
}]
}
}

View File

@@ -1,11 +1,11 @@
{
"_links": {
"alpha": {
"href": "http://alpha.example.com",
"href": "https://alpha.example.com",
"title": "Alpha"
},
"bravo": {
"href": "http://bravo.example.com"
"href": "https://bravo.example.com"
}
}
}

View File

@@ -1,10 +1,10 @@
{
"_links": {
"alpha": [{
"href": "http://alpha.example.com/one",
"href": "https://alpha.example.com/one",
"title": "Alpha one"
}, {
"href": "http://alpha.example.com/two"
"href": "https://alpha.example.com/two"
}]
}
}

View File

@@ -1,7 +1,7 @@
{
"_links": {
"alpha": {
"href": "http://alpha.example.com",
"href": "https://alpha.example.com",
"title": "Alpha"
}
}

View File

@@ -1,9 +1,9 @@
{
"_links": [ {
"rel": "alpha",
"href": "http://alpha.example.com/one"
"href": "https://alpha.example.com/one"
}, {
"rel": "alpha",
"href": "http://alpha.example.com/two"
"href": "https://alpha.example.com/two"
} ]
}