You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2020/09/09 23:35:37 UTC
[cxf] 01/01: Addressing review comments
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch CXF-8227
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 4e73867cc862983e64cc50dd1650ae031588090b
Author: reta <dr...@gmail.com>
AuthorDate: Wed Sep 9 19:34:52 2020 -0400
Addressing review comments
---
.../cxf/jaxrs/impl/PropertyHolderFactory.java | 2 +-
.../apache/cxf/systest/jaxrs/BookApplication.java | 10 +++++-----
.../jaxrs/JAXRSClientServerNonSpringBookTest.java | 23 +++++++++++-----------
3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java
index 0a771e8..052eb48 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java
@@ -49,7 +49,7 @@ public final class PropertyHolderFactory {
private static class ServletRequestPropertyHolder extends MessagePropertyHolder {
private static final String ENDPOINT_ADDRESS_PROPERTY = "org.apache.cxf.transport.endpoint.address";
- private HttpServletRequest request;
+ private final HttpServletRequest request;
ServletRequestPropertyHolder(Message m) {
super(m);
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookApplication.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookApplication.java
index 4039940..0465916 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookApplication.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookApplication.java
@@ -107,9 +107,9 @@ public class BookApplication extends Application {
WebApplicationException {
context.getHeaders().putSingle("BookWriter", "TheBook");
- final Object property = context.getProperty("x-book");
+ final Object property = context.getProperty("property");
if (property != null) {
- context.getHeaders().putSingle("X-Book-Header", property);
+ context.getHeaders().putSingle("X-Property-WriterInterceptor", property);
}
context.proceed();
@@ -138,9 +138,9 @@ public class BookApplication extends Application {
context.getHeaders().put("BOOK", Arrays.asList("1", "2"));
}
- final String header = context.getHeaderString("X-Book-Header");
- if (header != null) {
- context.setProperty("x-book", header);
+ final String value = context.getUriInfo().getQueryParameters().getFirst("property");
+ if (value != null) {
+ context.setProperty("property", value);
}
}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
index f456ba3..6192000 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
@@ -20,8 +20,10 @@
package org.apache.cxf.systest.jaxrs;
import java.io.InputStream;
+import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.WebApplicationException;
@@ -188,11 +190,11 @@ public class JAXRSClientServerNonSpringBookTest extends AbstractBusClientServerT
}
@Test
- public void testGetBook123Application11PerRequestWithHeader() throws Exception {
+ public void testGetBook123PropagatingContextPropertyToWriterInterceptor() throws Exception {
Response r =
- doTestPerRequest("http://localhost:" + PORT + "/application11/thebooks/bookstore2/bookheaders",
- "PropValue");
- assertEquals("PropValue", r.getHeaderString("X-Book-Header"));
+ doTestPerRequest("http://localhost:" + PORT + "/application6/thebooks/bookstore2/bookheaders",
+ new SimpleEntry<>("property", "PropValue"));
+ assertEquals("PropValue", r.getHeaderString("X-Property-WriterInterceptor"));
}
@@ -201,18 +203,17 @@ public class JAXRSClientServerNonSpringBookTest extends AbstractBusClientServerT
doTestPerRequest("http://localhost:" + PORT + "/application6/thebooks/bookstore2/bookheaders");
doTestPerRequest("http://localhost:" + PORT + "/application6/the%20books2/bookstore2/book%20headers");
}
-
- private Response doTestPerRequest(String address) throws Exception {
- return doTestPerRequest(address, null);
- }
- private Response doTestPerRequest(String address, String header) throws Exception {
+ @SafeVarargs
+ private final Response doTestPerRequest(String address, Map.Entry<String, String> ... params) throws Exception {
WebClient wc = WebClient.create(address);
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(100000000L);
wc.accept("application/xml");
- if (header != null) {
- wc.header("X-Book-Header", header);
+
+ for (Map.Entry<String, String> param: params) {
+ wc.query(param.getKey(), param.getValue());
}
+
Response r = wc.get();
Book book = r.readEntity(Book.class);
assertEquals("CXF in Action", book.getName());