You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by jo...@apache.org on 2017/12/20 19:18:37 UTC
[cxf] branch mp-client updated (d1336c7 -> df8c7cc)
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a change to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git.
omit d1336c7 [CXF-7579] Removing excluded test.
omit 86b97d5 ConfigFacade to handle cases where no MP Config exists
omit 281161d MP Rest Client interface validation tests
omit 743cdd3 [CXF-7579] Fixing POM dependencies.
omit 7cc9105 Ensure tests pass
omit 5b27f69 checkstyle fix
omit 4aa6f99 [CXF-7579] Simplify config lookup.
omit a039b34 [CXF-7579] Fixing parent path location.
omit 5e053e4 [CXF-7579] Mark the default mapper and json provider as non-custom.
omit 1a69ba8 [CXF-7579] Upgrading to final release, refactoring dependencies.
omit e3c1a4f [CXF-7579] Enable custom method test.
omit f0398b9 [CXF-7579] Fix sorting to take into account custom vs user.
omit 781acae [CXF-7579] Add the default Json provider to each client.
omit 37829a6 [CXF-7579] Adding handling for disabling mapper.
omit 6cefb7a [CXF-7579] Wrapping up exception mapper support.
omit 3924fcf [CXF-7579] Introduce a dedicated proxy for MicroProfile
omit 65bb8a5 [CXF-7579] Setup Systests to run the MicroProfile TCKs.
omit d34de7d [CXF-7579] More config impl.
omit 5461312 [CXF-7579] More config impl.
omit 6d8d9ee Config handling for MP rest client (#352)
omit 0679829 [CXF-7579] Begin the implementation of the MP Rest Client in CXF
omit d3dd6f4 [CXF-7593] Supporting the injection of Application into Feature
omit 4874891 [CXF-7592] Removing redundant parentheses
omit 2eec28a [CXF-7592] Mapping IOExceptions thrown from the container request filters
omit 352eda1 Don't hold onto thread Strongly so the WeakHashMap will work
omit 5886d18 [CXF-7589] Use just "spring-beans.xml" to avoid lock in to specific version
omit 176bb5e [CXF-7591] Allow getResponseContext().clear() to clear out everything to reduce memory usage
omit 8bab0fa CXF-7581: SwaggerUIResourceFilter doesn't allow call to service, fixing test cases
omit 5e31f30 CXF-7581: SwaggerUIResourceFilter doesn't allow call to service, fixing test cases
omit 53bc56a CXF-7581: SwaggerUIResourceFilter doesn't allow call to service endpoint. Adding more robust test cases
omit 52eac40 update Swagger-UI version
omit f87c74e Revert "CXF-7581: SwaggerUIResourceFilter doesn't allow call to service endpoint. Reverting the initial solution (not generic enough)"
omit 0b26fba CXF-7581: SwaggerUIResourceFilter doesn't allow call to service endpoint. Reverting the initial solution (not generic enough)
omit f3717d1 CXF-7581: SwaggerUIResourceFilter doesn't allow call to service endpoint
omit 6124110 CXF-7586: Remove @PersistenceContext
omit 230d345 CXF-7588 - SAML audience restriction validation is enabled by default for REST services
omit 0729975 [CXF-7587] use Jetty context path when setting HTTP handler name
omit 179e6c1 Fixing all Checkstyle errors for samples
omit e7f0cb9 CXF-7525: Add support for Swagger 2.0 (OpenApi Spec 3.0). Initial integration implementation. Fixing minor issues.
omit d4ac194 CXF-7525: Add support for Swagger 2.0 (OpenApi Spec 3.0). Initial integration implementation
omit eef84da Upgrade jetty version
omit cf7e2c4 Upgrade easymock version
omit 4c9197d Upgrade spring-ldap version
omit e1dda37 Update versions of httpcomponents that we use
omit c3edd6e Upgrade undertow version
omit ed1eaca Upgrade rxjava
omit 8691166 Update dropwizard metrics
omit 4fb4bcc [CXF-7584] Restricting the proxies (by default) from accidentally supplying empty path template values, an updated patch from Alexey Markevich applied, This closes #354
omit ad9f07c [CXF-7470] Cannot set target for recovered source sequence
omit f265fca [CXF-7585] Close InputStream in AttachmentSerializer when base64 encoding is used
omit 10c10f3 [CXF-7525] Adding the requestBodies conversion test
omit 11a0a29 [CXF-7525] More renaming
omit b892757 [CXF-7525] Renaming the test to avoid the future confusions
omit 056c627 [CXF-7525] Prototyping the code to support components/requestBodies instead of inlining into httpVerb/requestBody, tests to follow
omit e03ab40 [CXF-7525] Introducing OpenApiConfiguration to be able to customize the conversion process
omit a18cab5 [CXF-7525] Completing the system test
omit 9b03aec [CXF-7525] Changing the package for open api converters, starting with a system test to be completed shortly
omit 6d316c0 [CXF-7527] Completing the initial test of all of petShop v2 methods
omit acd0e36 CXF-7578 - Set the signature algorithm properly for the TransportBinding IssuedToken case (StAX)
omit 1c8b9fd [CXF-7525] More testing
omit 3cf7d8f [CXF-7573] Closing InputStream
add c6c66c4 [CXF-7573] Closing InputStream
add caf52cf [CXF-7525] More testing
add 60975c7 CXF-7578 - Set the signature algorithm properly for the TransportBinding IssuedToken case (StAX)
add b0b503d [CXF-7527] Completing the initial test of all of petShop v2 methods
add 2b9c671 [CXF-7525] Changing the package for open api converters, starting with a system test to be completed shortly
add 2705f4d [CXF-7525] Completing the system test
add 1503b42 [CXF-7525] Introducing OpenApiConfiguration to be able to customize the conversion process
add 8ffecb4 [CXF-7525] Prototyping the code to support components/requestBodies instead of inlining into httpVerb/requestBody, tests to follow
add 1f9601c [CXF-7525] Renaming the test to avoid the future confusions
add 58ead76 [CXF-7525] More renaming
add 27e3a63 [CXF-7525] Adding the requestBodies conversion test
add e48f902 [CXF-7585] Close InputStream in AttachmentSerializer when base64 encoding is used
add 3984faa Merge pull request #355 from gebhardt/CXF-7585
add 262b93c [CXF-7470] Cannot set target for recovered source sequence
add 9cda849 [CXF-7584] Restricting the proxies (by default) from accidentally supplying empty path template values, an updated patch from Alexey Markevich applied, This closes #354
add 8089b06 Update dropwizard metrics
add 57d7010 Upgrade rxjava
add 6827740 Upgrade undertow version
add 9a8215c Update versions of httpcomponents that we use
add 0877134 Upgrade spring-ldap version
add 12e767a Upgrade easymock version
add 53f738a Upgrade jetty version
add df4214a CXF-7525: Add support for Swagger 2.0 (OpenApi Spec 3.0). Initial integration implementation
add 564d36e CXF-7525: Add support for Swagger 2.0 (OpenApi Spec 3.0). Initial integration implementation. Fixing minor issues.
add eae819e Fixing all Checkstyle errors for samples
add 56d7f84 CXF-7588 - SAML audience restriction validation is enabled by default for REST services
add 97d813c CXF-7586: Remove @PersistenceContext
add ef562f6 CXF-7581: SwaggerUIResourceFilter doesn't allow call to service endpoint
add 7c2fef5 [CXF-7587] use Jetty context path when setting HTTP handler name
add 804addf Merge pull request #356 from johnpoth/CXF-7587
add 5b90271 CXF-7581: SwaggerUIResourceFilter doesn't allow call to service endpoint. Reverting the initial solution (not generic enough)
add 27057bc Revert "CXF-7581: SwaggerUIResourceFilter doesn't allow call to service endpoint. Reverting the initial solution (not generic enough)"
add 2831313 update Swagger-UI version
add df41960 CXF-7581: SwaggerUIResourceFilter doesn't allow call to service endpoint. Adding more robust test cases
add d53a7a3 CXF-7581: SwaggerUIResourceFilter doesn't allow call to service, fixing test cases
add 80783b9 CXF-7581: SwaggerUIResourceFilter doesn't allow call to service, fixing test cases
add 97cde56 [CXF-7591] Allow getResponseContext().clear() to clear out everything to reduce memory usage
add 3e26115 [CXF-7589] Use just "spring-beans.xml" to avoid lock in to specific version
add 7954121 Don't hold onto thread Strongly so the WeakHashMap will work
add 94bbc35 [CXF-7592] Mapping IOExceptions thrown from the container request filters
add 845f551 [CXF-7592] Removing redundant parentheses
add efa3c8a [CXF-7593] Supporting the injection of Application into Feature
add 201f4a6 Updating the Flowable test
new e21face [CXF-7579] Begin the implementation of the MP Rest Client in CXF
new eb705f4 Config handling for MP rest client (#352)
new 6353df0 [CXF-7579] More config impl.
new b4d0456 [CXF-7579] More config impl.
new ddac0a9 [CXF-7579] Setup Systests to run the MicroProfile TCKs.
new 4be2d95 [CXF-7579] Introduce a dedicated proxy for MicroProfile
new 358fd2d [CXF-7579] Wrapping up exception mapper support.
new fdde9bd [CXF-7579] Adding handling for disabling mapper.
new f33d4a0 [CXF-7579] Add the default Json provider to each client.
new 82832a8 [CXF-7579] Fix sorting to take into account custom vs user.
new 2281501 [CXF-7579] Enable custom method test.
new d76a926 [CXF-7579] Upgrading to final release, refactoring dependencies.
new c826d79 [CXF-7579] Mark the default mapper and json provider as non-custom.
new f232a9d [CXF-7579] Fixing parent path location.
new 8e86a5d [CXF-7579] Simplify config lookup.
new 05436bc checkstyle fix
new b5b242d Ensure tests pass
new a949c7f [CXF-7579] Fixing POM dependencies.
new 13a483f MP Rest Client interface validation tests
new 6e99bc4 ConfigFacade to handle cases where no MP Config exists
new df8c7cc [CXF-7579] Removing excluded test.
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (d1336c7)
\
N -- N -- N refs/heads/mp-client (df8c7cc)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 21 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../jaxrs/reactive/RxJava2FlowableService.java | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
--
To stop receiving notification emails like this one, please contact
['"commits@cxf.apache.org" <co...@cxf.apache.org>'].
[cxf] 06/21: [CXF-7579] Introduce a dedicated proxy for MicroProfile
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 4be2d953c58fcc0b4a05f4f41102e415e8edfd65
Author: John D. Ament <jo...@apache.org>
AuthorDate: Sat Dec 16 09:00:45 2017 -0500
[CXF-7579] Introduce a dedicated proxy for MicroProfile
Move exception handling into a protected method to be overridden
Move proxy creation into a method as well
Minor code clean up to use proper sorting
---
.../apache/cxf/jaxrs/provider/ProviderFactory.java | 8 +-
.../apache/cxf/jaxrs/client/ClientProxyImpl.java | 2 +-
.../cxf/jaxrs/client/JAXRSClientFactoryBean.java | 21 ++--
rt/rs/microprofile-client/pom.xml | 41 ++++---
.../microprofile/client/ContractComparator.java | 53 +++++++++
.../client/CxfTypeSafeClientBuilder.java | 14 ++-
.../client/MicroProfileClientFactoryBean.java | 94 +++++++++++-----
.../client/MicroProfileClientProviderFactory.java | 120 +++++++++++++++++++++
.../microprofile/client/cdi/RestClientBean.java | 11 +-
.../client/proxy/MicroProfileClientProxyImpl.java | 65 +++++++++++
.../client/CxfTypeSafeClientBuilderTest.java | 47 +++++++-
systests/microprofile/client/weld/pom.xml | 24 ++++-
12 files changed, 430 insertions(+), 70 deletions(-)
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
index e1af3fb..4fd6657 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
@@ -657,14 +657,14 @@ public abstract class ProviderFactory {
*/
private void sortReaders() {
if (!customComparatorAvailable(MessageBodyReader.class)) {
- Collections.sort(messageReaders, new MessageBodyReaderComparator());
+ messageReaders.sort(new MessageBodyReaderComparator());
} else {
doCustomSort(messageReaders);
}
}
private <T> void sortWriters() {
if (!customComparatorAvailable(MessageBodyWriter.class)) {
- Collections.sort(messageWriters, new MessageBodyWriterComparator());
+ messageWriters.sort(new MessageBodyWriterComparator());
} else {
doCustomSort(messageWriters);
}
@@ -703,11 +703,11 @@ public abstract class ProviderFactory {
}
List<T> theProviders = (List<T>)listOfProviders;
Comparator<? super T> theComparator = (Comparator<? super T>)theProviderComparator;
- Collections.sort(theProviders, theComparator);
+ theProviders.sort(theComparator);
}
private void sortContextResolvers() {
- Collections.sort(contextResolvers, new ContextResolverComparator());
+ contextResolvers.sort(new ContextResolverComparator());
}
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
index 508e430..d7aacb9 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
@@ -298,7 +298,7 @@ public class ClientProxyImpl extends AbstractClient implements
return index;
}
- private void checkResponse(Method m, Response r, Message inMessage) throws Throwable {
+ protected void checkResponse(Method m, Response r, Message inMessage) throws Throwable {
Throwable t = null;
int status = r.getStatus();
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
index a783bf9..f36f5a5 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
@@ -306,15 +306,7 @@ public class JAXRSClientFactoryBean extends AbstractJAXRSFactoryBean {
boolean isRoot = cri.getURITemplate() != null;
ClientProxyImpl proxyImpl = null;
ClientState actualState = getActualState();
- if (actualState == null) {
- proxyImpl =
- new ClientProxyImpl(URI.create(getAddress()), proxyLoader, cri, isRoot,
- inheritHeaders, varValues);
- } else {
- proxyImpl =
- new ClientProxyImpl(actualState, proxyLoader, cri, isRoot,
- inheritHeaders, varValues);
- }
+ proxyImpl = createClientProxy(cri, isRoot, actualState, varValues);
initClient(proxyImpl, ep, actualState == null);
ClassLoader theLoader = proxyLoader == null ? cri.getServiceClass().getClassLoader() : proxyLoader;
@@ -341,6 +333,17 @@ public class JAXRSClientFactoryBean extends AbstractJAXRSFactoryBean {
}
+ protected ClientProxyImpl createClientProxy(ClassResourceInfo cri, boolean isRoot,
+ ClientState actualState, Object[] varValues) {
+ if (actualState == null) {
+ return new ClientProxyImpl(URI.create(getAddress()), proxyLoader, cri, isRoot,
+ inheritHeaders, varValues);
+ } else {
+ return new ClientProxyImpl(actualState, proxyLoader, cri, isRoot,
+ inheritHeaders, varValues);
+ }
+ }
+
protected ConduitSelector getConduitSelector(Endpoint ep) {
ConduitSelector cs = getConduitSelector();
if (cs == null) {
diff --git a/rt/rs/microprofile-client/pom.xml b/rt/rs/microprofile-client/pom.xml
index a893fb9..402a528 100644
--- a/rt/rs/microprofile-client/pom.xml
+++ b/rt/rs/microprofile-client/pom.xml
@@ -100,6 +100,12 @@
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
+ <groupId>org.eclipse.microprofile.rest.client</groupId>
+ <artifactId>microprofile-rest-client-tck</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
<version>1.1</version>
@@ -121,23 +127,6 @@
<optional>true</optional>
</dependency>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<scope>test</scope>
@@ -179,6 +168,24 @@
</dependencies>
<profiles>
<profile>
+ <id>release-repo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>mp-rest-client</id>
+ <url>https://oss.sonatype.org/content/repositories/orgeclipsemicroprofile-1037/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ </repositories>
+ </profile>
+ <profile>
<id>java9</id>
<activation>
<jdk>9</jdk>
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/ContractComparator.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/ContractComparator.java
new file mode 100644
index 0000000..5ef4fb5
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/ContractComparator.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client;
+
+import java.util.Comparator;
+import java.util.Map;
+import org.apache.cxf.jaxrs.utils.AnnotationUtils;
+import static org.apache.cxf.microprofile.client.MicroProfileClientConfigurableImpl.CONTRACTS;
+
+class ContractComparator implements Comparator<Object> {
+ private MicroProfileClientFactoryBean microProfileClientFactoryBean;
+
+ ContractComparator(MicroProfileClientFactoryBean microProfileClientFactoryBean) {
+ this.microProfileClientFactoryBean = microProfileClientFactoryBean;
+ }
+
+ @Override
+ public int compare(Object oLeft, Object oRight) {
+ int left = getPriority(oLeft.getClass());
+ int right = getPriority(oRight.getClass());
+ return left - right;
+ }
+
+ private int getPriority(Class<?> clazz) {
+ Map<Class<?>, Integer> contracts = microProfileClientFactoryBean.getConfiguration()
+ .getContracts(clazz);
+ if (contracts != null && !contracts.isEmpty()) {
+ for (Class<?> providerClass : CONTRACTS) {
+ Integer priority = contracts.get(providerClass);
+ if (priority != null) {
+ return priority;
+ }
+ }
+ }
+ return AnnotationUtils.getBindingPriority(clazz);
+ }
+}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
index 904731c..40f5cc9 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
@@ -24,7 +24,7 @@ import java.util.Objects;
import javax.ws.rs.core.Configurable;
import javax.ws.rs.core.Configuration;
import org.eclipse.microprofile.rest.client.RestClientBuilder;
-import org.eclipse.microprofile.rest.client.annotation.RegisterProviders;
+import org.eclipse.microprofile.rest.client.annotation.RegisterProvider;
public class CxfTypeSafeClientBuilder implements RestClientBuilder, Configurable<RestClientBuilder> {
private String baseUri;
@@ -42,12 +42,16 @@ public class CxfTypeSafeClientBuilder implements RestClientBuilder, Configurable
if (baseUri == null) {
throw new IllegalStateException("baseUrl not set");
}
- RegisterProviders providers = aClass.getAnnotation(RegisterProviders.class);
+ RegisterProvider[] providers = aClass.getAnnotationsByType(RegisterProvider.class);
Configuration config = configImpl.getConfiguration();
if (providers != null) {
- for (Class<?> c : providers.value()) {
- if (!config.isRegistered(c)) {
- register(c);
+ for (RegisterProvider provider : providers) {
+ if (!config.isRegistered(provider.value())) {
+ if (provider.priority() == -1) {
+ register(provider.value());
+ } else {
+ register(provider.value(), provider.priority());
+ }
}
}
}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
index 3d89549..7f662ff 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
@@ -18,51 +18,91 @@
*/
package org.apache.cxf.microprofile.client;
+import java.net.URI;
import java.util.ArrayList;
-import java.util.Comparator;
+import java.util.LinkedHashSet;
import java.util.List;
-import java.util.Map;
+import java.util.Set;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.client.ClientResponseFilter;
import javax.ws.rs.core.Configuration;
+
+import org.apache.cxf.common.util.ClassHelper;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.jaxrs.client.AbstractClient;
+import org.apache.cxf.jaxrs.client.ClientProxyImpl;
+import org.apache.cxf.jaxrs.client.ClientState;
import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
-import org.apache.cxf.jaxrs.utils.AnnotationUtils;
-import static org.apache.cxf.microprofile.client.MicroProfileClientConfigurableImpl.CONTRACTS;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.model.FilterProviderInfo;
+import org.apache.cxf.microprofile.client.proxy.MicroProfileClientProxyImpl;
public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
+ private final ContractComparator comparator;
private Configuration configuration;
+ private ClassLoader proxyLoader;
+ private boolean inheritHeaders;
public MicroProfileClientFactoryBean(Configuration configuration, String baseUri, Class<?> aClass) {
super();
this.configuration = configuration;
+ this.comparator = new ContractComparator(this);
super.setAddress(baseUri);
super.setServiceClass(aClass);
- super.setProviderComparator(new ContractComparator());
- List<Object> providerClasses = new ArrayList<>();
- providerClasses.addAll(configuration.getClasses());
- providerClasses.addAll(configuration.getInstances());
- super.setProviders(providerClasses);
+ super.setProviderComparator(comparator);
+ List<Object> providers = new ArrayList<>();
+ providers.addAll(processProviders());
+ super.setProviders(providers);
+ }
+
+ @Override
+ public void setClassLoader(ClassLoader loader) {
+ super.setClassLoader(loader);
+ this.proxyLoader = loader;
}
- private class ContractComparator implements Comparator<Object> {
- @Override
- public int compare(Object o1, Object o2) {
- int left = getPriority(o1.getClass());
- int right = getPriority(o2.getClass());
- return left - right;
+ @Override
+ public void setInheritHeaders(boolean inheritHeaders) {
+ super.setInheritHeaders(inheritHeaders);
+ this.inheritHeaders = inheritHeaders;
+ }
+
+ @Override
+ protected void initClient(AbstractClient client, Endpoint ep, boolean addHeaders) {
+ super.initClient(client, ep, addHeaders);
+ MicroProfileClientProviderFactory factory = MicroProfileClientProviderFactory.createInstance(getBus(),
+ comparator);
+ ep.put(MicroProfileClientProviderFactory.CLIENT_FACTORY_NAME, factory);
+ }
+
+ @Override
+ protected ClientProxyImpl createClientProxy(ClassResourceInfo cri, boolean isRoot,
+ ClientState actualState, Object[] varValues) {
+ if (actualState == null) {
+ return new MicroProfileClientProxyImpl(URI.create(getAddress()), proxyLoader, cri, isRoot,
+ inheritHeaders, varValues);
+ } else {
+ return new MicroProfileClientProxyImpl(actualState, proxyLoader, cri, isRoot,
+ inheritHeaders, varValues);
}
+ }
- private int getPriority(Class<?> clazz) {
- for (Class<?> providerClass : CONTRACTS) {
- Map<Class<?>, Integer> contracts = MicroProfileClientFactoryBean.this.
- configuration.getContracts(providerClass);
- if (contracts != null) {
- Integer priority = contracts.get(clazz);
- if (priority != null) {
- return priority;
- }
- }
+ Configuration getConfiguration() {
+ return configuration;
+ }
+
+ private Set<Object> processProviders() {
+ Set<Object> providers = new LinkedHashSet<>();
+ for (Object provider : configuration.getInstances()) {
+ Class<?> providerCls = ClassHelper.getRealClass(bus, provider);
+ if (provider instanceof ClientRequestFilter || provider instanceof ClientResponseFilter) {
+ FilterProviderInfo<Object> filter = new FilterProviderInfo<>(providerCls, providerCls,
+ provider, bus, configuration.getContracts(providerCls));
+ providers.add(filter);
+ } else {
+ providers.add(provider);
}
- return AnnotationUtils.getBindingPriority(clazz);
}
+ return providers;
}
-
}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientProviderFactory.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientProviderFactory.java
new file mode 100644
index 0000000..ec24efc
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientProviderFactory.java
@@ -0,0 +1,120 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+import javax.ws.rs.core.Configuration;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.util.ClassHelper;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.jaxrs.model.ProviderInfo;
+import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.message.Message;
+import org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper;
+
+public final class MicroProfileClientProviderFactory extends ProviderFactory {
+ static final String CLIENT_FACTORY_NAME = MicroProfileClientProviderFactory.class.getName();
+ private List<ProviderInfo<ResponseExceptionMapper<?>>> responseExceptionMappers =
+ new ArrayList<ProviderInfo<ResponseExceptionMapper<?>>>(1);
+ private final ContractComparator comparator;
+
+ private MicroProfileClientProviderFactory(Bus bus, ContractComparator comparator) {
+ super(bus);
+ this.comparator = comparator;
+ }
+
+ public static MicroProfileClientProviderFactory createInstance(Bus bus, ContractComparator comparator) {
+ if (bus == null) {
+ bus = BusFactory.getThreadDefaultBus();
+ }
+ MicroProfileClientProviderFactory factory = new MicroProfileClientProviderFactory(bus, comparator);
+ ProviderFactory.initFactory(factory);
+ factory.setBusProviders();
+ return factory;
+ }
+
+ public static MicroProfileClientProviderFactory getInstance(Message m) {
+ Endpoint e = m.getExchange().getEndpoint();
+ return getInstance(e);
+ }
+
+ public static MicroProfileClientProviderFactory getInstance(Endpoint e) {
+ return (MicroProfileClientProviderFactory)e.get(CLIENT_FACTORY_NAME);
+ }
+
+ @Override
+ protected void setProviders(boolean custom, boolean busGlobal, Object... providers) {
+ List<ProviderInfo<?>> theProviders =
+ prepareProviders(custom, busGlobal, providers, null);
+ super.setCommonProviders(theProviders);
+ for (ProviderInfo<?> provider : theProviders) {
+ Class<?> providerCls = ClassHelper.getRealClass(getBus(), provider.getProvider());
+
+ if (ResponseExceptionMapper.class.isAssignableFrom(providerCls)) {
+ addProviderToList(responseExceptionMappers, provider);
+ }
+
+ }
+ responseExceptionMappers.sort(comparator);
+
+ injectContextProxies(responseExceptionMappers);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<ResponseExceptionMapper<?>> createResponseExceptionMapper(Message m, Class<?> paramType) {
+
+ List<ResponseExceptionMapper<?>> candidates = new LinkedList<>();
+
+ for (ProviderInfo<ResponseExceptionMapper<?>> em : responseExceptionMappers) {
+ if (handleMapper(em, paramType, m, ResponseExceptionMapper.class, true)) {
+ candidates.add(em.getProvider());
+ }
+ }
+ if (candidates.size() == 0) {
+ return Collections.emptyList();
+ }
+ candidates.sort(new ResponseExceptionMapperComparator());
+ return Collections.unmodifiableList(candidates);
+ }
+
+ @Override
+ public void clearProviders() {
+ super.clearProviders();
+ responseExceptionMappers.clear();
+ }
+
+ @Override
+ public Configuration getConfiguration(Message m) {
+ return (Configuration)m.getExchange().getOutMessage()
+ .getContextualProperty(Configuration.class.getName());
+ }
+
+ private class ResponseExceptionMapperComparator implements Comparator<ResponseExceptionMapper<?>> {
+
+ @Override
+ public int compare(ResponseExceptionMapper<?> oLeft, ResponseExceptionMapper<?> oRight) {
+ return oLeft.getPriority() - oRight.getPriority();
+ }
+ }
+}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java
index 83f7cde..7baec1c 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java
@@ -23,15 +23,19 @@ import java.lang.reflect.Type;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.enterprise.context.Dependent;
import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Default;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.PassivationCapable;
+import javax.enterprise.util.AnnotationLiteral;
import org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilder;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
@@ -40,6 +44,7 @@ import org.eclipse.microprofile.rest.client.inject.RestClient;
public class RestClientBean implements Bean<Object>, PassivationCapable {
public static final String REST_URL_FORMAT = "%s/mp-rest/url";
public static final String REST_SCOPE_FORMAT = "%s/mp-rest/scope";
+ private static final Default DEFAULT_LITERAL = new DefaultLiteral();
private final Class<?> clientInterface;
private final Class<? extends Annotation> scope;
private final BeanManager beanManager;
@@ -94,7 +99,7 @@ public class RestClientBean implements Bean<Object>, PassivationCapable {
@Override
public Set<Annotation> getQualifiers() {
- return Collections.singleton(RestClient.LITERAL);
+ return new HashSet<>(Arrays.asList(DEFAULT_LITERAL, RestClient.RestClientLiteral.LITERAL));
}
@Override
@@ -150,4 +155,8 @@ public class RestClientBean implements Bean<Object>, PassivationCapable {
+ " has multiple scopes defined " + possibleScopes);
}
}
+
+ private static final class DefaultLiteral extends AnnotationLiteral<Default> implements Default {
+
+ }
}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/proxy/MicroProfileClientProxyImpl.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/proxy/MicroProfileClientProxyImpl.java
new file mode 100644
index 0000000..17da4e1
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/proxy/MicroProfileClientProxyImpl.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client.proxy;
+
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.util.List;
+import javax.ws.rs.core.Response;
+import org.apache.cxf.jaxrs.client.ClientProxyImpl;
+import org.apache.cxf.jaxrs.client.ClientState;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.microprofile.client.MicroProfileClientProviderFactory;
+import org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper;
+
+public class MicroProfileClientProxyImpl extends ClientProxyImpl {
+ public MicroProfileClientProxyImpl(URI baseURI, ClassLoader loader, ClassResourceInfo cri,
+ boolean isRoot, boolean inheritHeaders, Object... varValues) {
+ super(baseURI, loader, cri, isRoot, inheritHeaders, varValues);
+ }
+
+ public MicroProfileClientProxyImpl(ClientState initialState, ClassLoader loader, ClassResourceInfo cri,
+ boolean isRoot, boolean inheritHeaders, Object... varValues) {
+ super(initialState, loader, cri, isRoot, inheritHeaders, varValues);
+ }
+
+ @Override
+ protected void checkResponse(Method m, Response r, Message inMessage) throws Throwable {
+ MicroProfileClientProviderFactory factory = MicroProfileClientProviderFactory.getInstance(inMessage);
+ List<ResponseExceptionMapper<?>> mappers = factory.createResponseExceptionMapper(inMessage,
+ Throwable.class);
+ for (ResponseExceptionMapper<?> mapper : mappers) {
+ if (mapper.handles(r.getStatus(), r.getHeaders())) {
+ Throwable t = mapper.toThrowable(r);
+ if (t instanceof RuntimeException) {
+ throw t;
+ } else if (t != null && m.getExceptionTypes() != null) {
+ // its a checked exception, make sure its declared
+ for (Class c : m.getExceptionTypes()) {
+ if (t.getClass().isAssignableFrom(c)) {
+ throw t;
+ }
+ }
+ // TODO Log the unhandled declarable
+ }
+ }
+ }
+ }
+}
diff --git a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
index e903f09..c6bfaf2 100644
--- a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
+++ b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
@@ -17,6 +17,7 @@
* under the License.
*/
package org.apache.cxf.microprofile.client;
+
import java.net.URL;
import javax.ws.rs.core.Response;
import org.apache.cxf.microprofile.client.mock.HighPriorityClientReqFilter;
@@ -24,9 +25,15 @@ import org.apache.cxf.microprofile.client.mock.HighPriorityMBW;
import org.apache.cxf.microprofile.client.mock.LowPriorityClientReqFilter;
import org.apache.cxf.microprofile.client.mock.MyClient;
import org.eclipse.microprofile.rest.client.RestClientBuilder;
-
+import org.eclipse.microprofile.rest.client.tck.interfaces.InterfaceWithoutProvidersDefined;
+import org.eclipse.microprofile.rest.client.tck.providers.TestClientRequestFilter;
+import org.eclipse.microprofile.rest.client.tck.providers.TestClientResponseFilter;
+import org.eclipse.microprofile.rest.client.tck.providers.TestMessageBodyReader;
+import org.eclipse.microprofile.rest.client.tck.providers.TestMessageBodyWriter;
+import org.eclipse.microprofile.rest.client.tck.providers.TestParamConverterProvider;
+import org.eclipse.microprofile.rest.client.tck.providers.TestReaderInterceptor;
+import org.eclipse.microprofile.rest.client.tck.providers.TestWriterInterceptor;
import org.junit.Assert;
-import org.junit.Ignore;
import org.junit.Test;
public class CxfTypeSafeClientBuilderTest extends Assert {
@@ -45,15 +52,47 @@ public class CxfTypeSafeClientBuilderTest extends Assert {
}
@Test
- @Ignore
public void testConfigPriorityOverrides() throws Exception {
RestClientBuilder builder = RestClientBuilder.newBuilder();
builder.register(HighPriorityClientReqFilter.class); // annotation priority of 10
- builder.register(LowPriorityClientReqFilter.class, 5); // overriding priority to be 5 (preferred)
+ builder.register(LowPriorityClientReqFilter.class, 5);
+ // overriding priority to be 5 (preferred)
+ assertTrue(builder.getConfiguration().isRegistered(LowPriorityClientReqFilter.class));
MyClient c = builder.baseUrl(new URL("http://localhost/null")).build(MyClient.class);
Response r = c.get();
assertEquals("low", r.readEntity(String.class));
}
+
+ @Test
+ public void testInvokesPostOperationWithRegisteredProviders() throws Exception {
+ String inputBody = "input body will be removed";
+ String expectedResponseBody = TestMessageBodyReader.REPLACED_BODY;
+
+ InterfaceWithoutProvidersDefined api = new CxfTypeSafeClientBuilder()
+ .register(TestClientRequestFilter.class)
+ .register(TestClientResponseFilter.class)
+ .register(TestMessageBodyReader.class, 4999)
+ .register(TestMessageBodyWriter.class)
+ .register(TestParamConverterProvider.class)
+ .register(TestReaderInterceptor.class)
+ .register(TestWriterInterceptor.class)
+ .baseUrl(new URL("http://localhost/null"))
+ .build(InterfaceWithoutProvidersDefined.class);
+
+ Response response = api.executePost(inputBody);
+
+ String body = response.readEntity(String.class);
+
+ response.close();
+
+ assertEquals(expectedResponseBody, body);
+
+ assertEquals(TestClientResponseFilter.getAndResetValue(), 1);
+ assertEquals(TestClientRequestFilter.getAndResetValue(), 1);
+ assertEquals(TestReaderInterceptor.getAndResetValue(), 1);
+ assertEquals(TestWriterInterceptor.getAndResetValue(), 1);
+ }
+
/** using for test coverage
@Override
public RestClientBuilder register(Class<?> componentClass, int priority) {
diff --git a/systests/microprofile/client/weld/pom.xml b/systests/microprofile/client/weld/pom.xml
index 7df726e..10f8ddf 100644
--- a/systests/microprofile/client/weld/pom.xml
+++ b/systests/microprofile/client/weld/pom.xml
@@ -120,14 +120,34 @@
<dependency>org.eclipse.microprofile.rest.client:microprofile-rest-client-tck</dependency>
</dependenciesToScan>
<excludes>
- <exclude>org.eclipse.microprofile.rest.client.tck.AdditionalRegistrationTest</exclude>
<exclude>org.eclipse.microprofile.rest.client.tck.CallMultipleMappersTest</exclude>
<exclude>org.eclipse.microprofile.rest.client.tck.DefaultExceptionMapperTest</exclude>
<exclude>org.eclipse.microprofile.rest.client.tck.ExceptionMapperTest</exclude>
<exclude>org.eclipse.microprofile.rest.client.tck.InvokeWithJsonPProviderTest</exclude>
+ <exclude>org.eclipse.microprofile.rest.client.tck.InvalidInterfaceTest</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+ <profiles>
+ <profile>
+ <id>release-repo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>mp-rest-client</id>
+ <url>https://oss.sonatype.org/content/repositories/orgeclipsemicroprofile-1037/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ </repositories>
+ </profile>
+ </profiles>
+</project>
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 08/21: [CXF-7579] Adding handling for disabling mapper.
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit fdde9bd103b24115ea41eb46f7e3444594f22013
Author: John D. Ament <jo...@apache.org>
AuthorDate: Sat Dec 16 15:26:29 2017 -0500
[CXF-7579] Adding handling for disabling mapper.
Re-enable unit tests since this is working again.
---
.../microprofile/client/CxfTypeSafeClientBuilder.java | 2 +-
.../client/MicroProfileClientConfigurableImpl.java | 19 +++++++++++++++++++
.../client/MicroProfileClientFactoryBean.java | 10 +++++++---
.../client/CxfTypeSafeClientBuilderTest.java | 4 ++--
systests/microprofile/client/weld/pom.xml | 3 ++-
5 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
index 40f5cc9..d895586 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
@@ -55,7 +55,7 @@ public class CxfTypeSafeClientBuilder implements RestClientBuilder, Configurable
}
}
}
- MicroProfileClientFactoryBean bean = new MicroProfileClientFactoryBean(getConfiguration(),
+ MicroProfileClientFactoryBean bean = new MicroProfileClientFactoryBean(configImpl,
baseUri, aClass);
return bean.create(aClass);
}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
index 9a6ccbc..ec28479 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
@@ -18,6 +18,7 @@
*/
package org.apache.cxf.microprofile.client;
+import java.util.Optional;
import javax.ws.rs.RuntimeType;
import javax.ws.rs.client.ClientRequestFilter;
import javax.ws.rs.client.ClientResponseFilter;
@@ -29,6 +30,8 @@ import javax.ws.rs.ext.ReaderInterceptor;
import javax.ws.rs.ext.WriterInterceptor;
import org.apache.cxf.jaxrs.impl.ConfigurableImpl;
import org.apache.cxf.jaxrs.impl.ConfigurationImpl;
+import org.eclipse.microprofile.config.Config;
+import org.eclipse.microprofile.config.ConfigProvider;
import org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper;
public class MicroProfileClientConfigurableImpl<C extends Configurable<C>>
@@ -37,6 +40,7 @@ public class MicroProfileClientConfigurableImpl<C extends Configurable<C>>
static final Class<?>[] CONTRACTS = new Class<?>[] {ClientRequestFilter.class,
ClientResponseFilter.class, ReaderInterceptor.class, WriterInterceptor.class,
MessageBodyWriter.class, MessageBodyReader.class, ResponseExceptionMapper.class};
+ private static final String CONFIG_KEY_DISABLE_MAPPER = "microprofile.rest.client.disable.default.mapper";
public MicroProfileClientConfigurableImpl(C configurable) {
this(configurable, null);
@@ -47,4 +51,19 @@ public class MicroProfileClientConfigurableImpl<C extends Configurable<C>>
CONTRACTS, config == null ? new ConfigurationImpl(RuntimeType.CLIENT)
: new ConfigurationImpl(config, CONTRACTS));
}
+
+ boolean isDefaultExceptionMapperDisabled() {
+ Object prop = getConfiguration().getProperty(CONFIG_KEY_DISABLE_MAPPER);
+ if (prop instanceof Boolean) {
+ return (Boolean)prop;
+ } else {
+ Config config = ConfigProvider.getConfig();
+ Optional<Boolean> optionalValue = config.getOptionalValue(CONFIG_KEY_DISABLE_MAPPER,
+ Boolean.class);
+ if (optionalValue.isPresent()) {
+ return optionalValue.get();
+ }
+ }
+ return false;
+ }
}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
index f01fea8..58cdfb3 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
@@ -36,6 +36,7 @@ import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
import org.apache.cxf.jaxrs.model.FilterProviderInfo;
import org.apache.cxf.microprofile.client.proxy.MicroProfileClientProxyImpl;
+import org.eclipse.microprofile.rest.client.RestClientBuilder;
public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
private final ContractComparator comparator;
@@ -44,16 +45,19 @@ public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
private ClassLoader proxyLoader;
private boolean inheritHeaders;
- public MicroProfileClientFactoryBean(Configuration configuration, String baseUri, Class<?> aClass) {
+ public MicroProfileClientFactoryBean(MicroProfileClientConfigurableImpl<RestClientBuilder> configuration,
+ String baseUri, Class<?> aClass) {
super();
- this.configuration = configuration;
+ this.configuration = configuration.getConfiguration();
this.comparator = new ContractComparator(this);
super.setAddress(baseUri);
super.setServiceClass(aClass);
super.setProviderComparator(comparator);
registeredProviders = new ArrayList<>();
registeredProviders.addAll(processProviders());
- registeredProviders.add(new DefaultResponseExceptionMapper());
+ if (!configuration.isDefaultExceptionMapperDisabled()) {
+ registeredProviders.add(new DefaultResponseExceptionMapper());
+ }
super.setProviders(registeredProviders);
}
diff --git a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
index be37b73..5ac4b79 100644
--- a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
+++ b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
@@ -34,10 +34,8 @@ import org.eclipse.microprofile.rest.client.tck.providers.TestParamConverterProv
import org.eclipse.microprofile.rest.client.tck.providers.TestReaderInterceptor;
import org.eclipse.microprofile.rest.client.tck.providers.TestWriterInterceptor;
import org.junit.Assert;
-import org.junit.Ignore;
import org.junit.Test;
-@Ignore
public class CxfTypeSafeClientBuilderTest extends Assert {
@Test
@@ -56,6 +54,7 @@ public class CxfTypeSafeClientBuilderTest extends Assert {
@Test
public void testConfigPriorityOverrides() throws Exception {
RestClientBuilder builder = RestClientBuilder.newBuilder();
+ builder.property("microprofile.rest.client.disable.default.mapper", true);
builder.register(HighPriorityClientReqFilter.class); // annotation priority of 10
builder.register(LowPriorityClientReqFilter.class, 5);
// overriding priority to be 5 (preferred)
@@ -78,6 +77,7 @@ public class CxfTypeSafeClientBuilderTest extends Assert {
.register(TestParamConverterProvider.class)
.register(TestReaderInterceptor.class)
.register(TestWriterInterceptor.class)
+ .property("microprofile.rest.client.disable.default.mapper", true)
.baseUrl(new URL("http://localhost/null"))
.build(InterfaceWithoutProvidersDefined.class);
diff --git a/systests/microprofile/client/weld/pom.xml b/systests/microprofile/client/weld/pom.xml
index 04c7c56..dff4f0d 100644
--- a/systests/microprofile/client/weld/pom.xml
+++ b/systests/microprofile/client/weld/pom.xml
@@ -53,7 +53,7 @@
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-weld-embedded</artifactId>
- <version>2.0.0.Beta5</version>
+ <version>2.0.0.Final</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -120,6 +120,7 @@
<dependency>org.eclipse.microprofile.rest.client:microprofile-rest-client-tck</dependency>
</dependenciesToScan>
<excludes>
+ <exclude>org.eclipse.microprofile.rest.client.tck.CustomHttpMethodTest</exclude>
<exclude>org.eclipse.microprofile.rest.client.tck.InvokeWithJsonPProviderTest</exclude>
<exclude>org.eclipse.microprofile.rest.client.tck.InvalidInterfaceTest</exclude>
</excludes>
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 10/21: [CXF-7579] Fix sorting to take into account custom vs
user.
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 82832a861072ddc8b5c9eafb373d3d85e097b05e
Author: John D. Ament <jo...@apache.org>
AuthorDate: Mon Dec 18 23:26:18 2017 -0500
[CXF-7579] Fix sorting to take into account custom vs user.
Remove verbose output from TCK
---
.../apache/cxf/jaxrs/provider/ProviderFactory.java | 2 +-
.../cxf/microprofile/client/ContractComparator.java | 21 +++++++++++++++------
.../client/MicroProfileClientFactoryBean.java | 6 ++++--
.../client/MicroProfileClientProviderFactory.java | 12 +++++++++---
systests/microprofile/client/weld/pom.xml | 3 ++-
5 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
index 4fd6657..ed4ce0a 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
@@ -846,7 +846,7 @@ public abstract class ProviderFactory {
}
}
- private static int compareCustomStatus(ProviderInfo<?> p1, ProviderInfo<?> p2) {
+ protected static int compareCustomStatus(ProviderInfo<?> p1, ProviderInfo<?> p2) {
Boolean custom1 = p1.isCustom();
Boolean custom2 = p2.isCustom();
int result = custom1.compareTo(custom2) * -1;
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/ContractComparator.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/ContractComparator.java
index 5ef4fb5..02bab65 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/ContractComparator.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/ContractComparator.java
@@ -20,20 +20,29 @@ package org.apache.cxf.microprofile.client;
import java.util.Comparator;
import java.util.Map;
+
+import org.apache.cxf.jaxrs.model.ProviderInfo;
import org.apache.cxf.jaxrs.utils.AnnotationUtils;
import static org.apache.cxf.microprofile.client.MicroProfileClientConfigurableImpl.CONTRACTS;
-class ContractComparator implements Comparator<Object> {
- private MicroProfileClientFactoryBean microProfileClientFactoryBean;
+class ContractComparator implements Comparator<ProviderInfo<?>> {
+ private final MicroProfileClientFactoryBean microProfileClientFactoryBean;
+ private final Comparator<ProviderInfo<?>> parent;
- ContractComparator(MicroProfileClientFactoryBean microProfileClientFactoryBean) {
+ ContractComparator(MicroProfileClientFactoryBean microProfileClientFactoryBean,
+ Comparator<ProviderInfo<?>> parent) {
this.microProfileClientFactoryBean = microProfileClientFactoryBean;
+ this.parent = parent;
}
@Override
- public int compare(Object oLeft, Object oRight) {
- int left = getPriority(oLeft.getClass());
- int right = getPriority(oRight.getClass());
+ public int compare(ProviderInfo<?> oLeft, ProviderInfo<?> oRight) {
+ int parentResult = parent.compare(oLeft, oRight);
+ if (parentResult != 0) {
+ return parentResult;
+ }
+ int left = getPriority(oLeft.getResourceClass());
+ int right = getPriority(oRight.getResourceClass());
return left - right;
}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
index 6855740..e9a1767 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
@@ -20,6 +20,7 @@ package org.apache.cxf.microprofile.client;
import java.net.URI;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -35,11 +36,12 @@ import org.apache.cxf.jaxrs.client.ClientState;
import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
import org.apache.cxf.jaxrs.model.FilterProviderInfo;
+import org.apache.cxf.jaxrs.model.ProviderInfo;
import org.apache.cxf.microprofile.client.proxy.MicroProfileClientProxyImpl;
import org.eclipse.microprofile.rest.client.RestClientBuilder;
public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
- private final ContractComparator comparator;
+ private final Comparator<ProviderInfo<?>> comparator;
private final List<Object> registeredProviders;
private Configuration configuration;
private ClassLoader proxyLoader;
@@ -49,7 +51,7 @@ public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
String baseUri, Class<?> aClass) {
super();
this.configuration = configuration.getConfiguration();
- this.comparator = new ContractComparator(this);
+ this.comparator = MicroProfileClientProviderFactory.createComparator(this);
super.setAddress(baseUri);
super.setServiceClass(aClass);
super.setProviderComparator(comparator);
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientProviderFactory.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientProviderFactory.java
index ec24efc..05a0457 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientProviderFactory.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientProviderFactory.java
@@ -37,14 +37,15 @@ public final class MicroProfileClientProviderFactory extends ProviderFactory {
static final String CLIENT_FACTORY_NAME = MicroProfileClientProviderFactory.class.getName();
private List<ProviderInfo<ResponseExceptionMapper<?>>> responseExceptionMappers =
new ArrayList<ProviderInfo<ResponseExceptionMapper<?>>>(1);
- private final ContractComparator comparator;
+ private final Comparator<ProviderInfo<?>> comparator;
- private MicroProfileClientProviderFactory(Bus bus, ContractComparator comparator) {
+ private MicroProfileClientProviderFactory(Bus bus, Comparator<ProviderInfo<?>> comparator) {
super(bus);
this.comparator = comparator;
}
- public static MicroProfileClientProviderFactory createInstance(Bus bus, ContractComparator comparator) {
+ public static MicroProfileClientProviderFactory createInstance(Bus bus,
+ Comparator<ProviderInfo<?>> comparator) {
if (bus == null) {
bus = BusFactory.getThreadDefaultBus();
}
@@ -63,6 +64,11 @@ public final class MicroProfileClientProviderFactory extends ProviderFactory {
return (MicroProfileClientProviderFactory)e.get(CLIENT_FACTORY_NAME);
}
+ static Comparator<ProviderInfo<?>> createComparator(MicroProfileClientFactoryBean bean) {
+ Comparator<ProviderInfo<?>> parent = ProviderFactory::compareCustomStatus;
+ return new ContractComparator(bean, parent);
+ }
+
@Override
protected void setProviders(boolean custom, boolean busGlobal, Object... providers) {
List<ProviderInfo<?>> theProviders =
diff --git a/systests/microprofile/client/weld/pom.xml b/systests/microprofile/client/weld/pom.xml
index 990d344..77628bd 100644
--- a/systests/microprofile/client/weld/pom.xml
+++ b/systests/microprofile/client/weld/pom.xml
@@ -31,6 +31,7 @@
<properties>
<microprofile.rest.client.version>1.0-SNAPSHOT</microprofile.rest.client.version>
<geronimo.config.version>1.0</geronimo.config.version>
+ <wiremock.params>--port=8765</wiremock.params>
</properties>
<dependencies>
<dependency>
@@ -119,7 +120,7 @@
</goals>
<configuration>
<dir>target/classes</dir>
- <params>--port=8765 --verbose</params>
+ <params>${wiremock.params}</params>
</configuration>
</execution>
</executions>
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 01/21: [CXF-7579] Begin the implementation of the MP Rest
Client in CXF
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit e21facebf107913fe817a607bb06e2ecd0bac421
Author: John D. Ament <jo...@apache.org>
AuthorDate: Tue Dec 5 20:42:48 2017 -0500
[CXF-7579] Begin the implementation of the MP Rest Client in CXF
---
rt/rs/microprofile-client/pom.xml | 218 +++++++++++++++++++++
.../client/CxfTypeSafeClientBuilder.java | 117 +++++++++++
.../microprofile/client/cdi/RestClientBean.java | 153 +++++++++++++++
.../client/cdi/RestClientExtension.java | 53 +++++
.../client/spi/CxfRestClientBuilderResolver.java | 31 +++
.../services/javax.enterprise.inject.spi.Extension | 1 +
...ofile.rest.client.spi.RestClientBuilderResolver | 1 +
rt/rs/pom.xml | 1 +
8 files changed, 575 insertions(+)
diff --git a/rt/rs/microprofile-client/pom.xml b/rt/rs/microprofile-client/pom.xml
new file mode 100644
index 0000000..a893fb9
--- /dev/null
+++ b/rt/rs/microprofile-client/pom.xml
@@ -0,0 +1,218 @@
+<?xml version="1.0"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cxf-rt-rs-mp-client</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache CXF MicroProfile Client</name>
+ <description>Apache CXF MicroProfile Client</description>
+ <url>http://cxf.apache.org</url>
+ <parent>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-parent</artifactId>
+ <version>3.2.2-SNAPSHOT</version>
+ <relativePath>../../../parent/pom.xml</relativePath>
+ </parent>
+ <properties>
+ <cxf.osgi.import>
+ org.apache.aries*;version="${cxf.aries.version.range}";resolution:=optional,
+ org.springframework*;resolution:="optional";version="${cxf.osgi.spring.version}"
+ </cxf.osgi.import>
+ <!-- keep in sync with services exported in activator -->
+ <cxf.export.service>
+ org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/blueprint/jaxrs-client"
+ </cxf.export.service>
+ <cxf.bundle.activator>org.apache.cxf.jaxrs.client.blueprint.Activator</cxf.bundle.activator>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.core</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>blueprint-parser</artifactId>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-local</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-features-logging</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.microprofile.rest.client</groupId>
+ <artifactId>microprofile-rest-client-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.microprofile.config</groupId>
+ <artifactId>microprofile-config-api</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <version>1.2</version>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jcache_1.0_spec</artifactId>
+ <version>1.0-alpha-1</version>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${cxf.servlet-api.group}</groupId>
+ <artifactId>${cxf.servlet-api.artifact}</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-databinding-jaxb</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-jcs-jcache</artifactId>
+ <version>2.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <profiles>
+ <profile>
+ <id>java9</id>
+ <activation>
+ <jdk>9</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ <type>jar</type>
+ <overWrite>false</overWrite>
+ <outputDirectory>${project.basedir}/target/java9</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
new file mode 100644
index 0000000..4e231aa
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
@@ -0,0 +1,117 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import javax.ws.rs.core.Configuration;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
+import org.eclipse.microprofile.rest.client.RestClientBuilder;
+import org.eclipse.microprofile.rest.client.annotation.RegisterProviders;
+
+public class CxfTypeSafeClientBuilder implements RestClientBuilder {
+ private String baseUri;
+ private Map<String, Object> properties;
+ private List<Object> jaxrsProviders;
+
+ public CxfTypeSafeClientBuilder() {
+ this.properties = new HashMap<>();
+ this.jaxrsProviders = new ArrayList<>();
+ }
+
+ @Override
+ public RestClientBuilder baseUrl(URL url) {
+ this.baseUri = Objects.requireNonNull(url).toExternalForm();
+ return this;
+ }
+
+ @Override
+ public <T> T build(Class<T> aClass) {
+ RegisterProviders providers = aClass.getAnnotation(RegisterProviders.class);
+ List<Object> providerClasses = new ArrayList<>();
+ providerClasses.addAll(this.jaxrsProviders);
+ if (providers != null) {
+ providerClasses.addAll(Arrays.asList(providers.value()));
+ }
+ JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
+ bean.setAddress(baseUri);
+ bean.setServiceClass(aClass);
+ bean.setProviders(providerClasses);
+ bean.setProperties(properties);
+ return bean.create(aClass);
+ }
+
+ @Override
+ public Configuration getConfiguration() {
+ return null;
+ }
+
+ @Override
+ public RestClientBuilder property(String s, Object o) {
+ this.properties.put(s, o);
+ return this;
+ }
+
+ @Override
+ public RestClientBuilder register(Class<?> providerClass) {
+ this.jaxrsProviders.add(providerClass);
+ return this;
+ }
+
+ @Override
+ public RestClientBuilder register(Class<?> aClass, int i) {
+ return this;
+ }
+
+ @Override
+ public RestClientBuilder register(Class<?> aClass, Class<?>... classes) {
+ return this;
+ }
+
+ @Override
+ public RestClientBuilder register(Class<?> aClass, Map<Class<?>, Integer> map) {
+ return this;
+ }
+
+ @Override
+ public RestClientBuilder register(Object o) {
+ this.jaxrsProviders.add(o);
+ return this;
+ }
+
+ @Override
+ public RestClientBuilder register(Object o, int i) {
+ return this;
+ }
+
+ @Override
+ public RestClientBuilder register(Object o, Class<?>... classes) {
+ return this;
+ }
+
+ @Override
+ public RestClientBuilder register(Object o, Map<Class<?>, Integer> map) {
+ return this;
+ }
+}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java
new file mode 100644
index 0000000..83f7cde
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java
@@ -0,0 +1,153 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client.cdi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.PassivationCapable;
+import org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilder;
+import org.eclipse.microprofile.config.Config;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.eclipse.microprofile.rest.client.inject.RestClient;
+
+public class RestClientBean implements Bean<Object>, PassivationCapable {
+ public static final String REST_URL_FORMAT = "%s/mp-rest/url";
+ public static final String REST_SCOPE_FORMAT = "%s/mp-rest/scope";
+ private final Class<?> clientInterface;
+ private final Class<? extends Annotation> scope;
+ private final BeanManager beanManager;
+ private final Config config;
+
+ RestClientBean(Class<?> clientInterface, BeanManager beanManager) {
+ this.clientInterface = clientInterface;
+ this.beanManager = beanManager;
+ this.config = ConfigProvider.getConfig();
+ this.scope = this.readScope();
+ }
+ @Override
+ public String getId() {
+ return clientInterface.getName();
+ }
+
+ @Override
+ public Class<?> getBeanClass() {
+ return clientInterface;
+ }
+
+ @Override
+ public Set<InjectionPoint> getInjectionPoints() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public boolean isNullable() {
+ return false;
+ }
+
+ @Override
+ public Object create(CreationalContext<Object> creationalContext) {
+ CxfTypeSafeClientBuilder builder = new CxfTypeSafeClientBuilder();
+ String baseUrl = getBaseUrl();
+ try {
+ return builder.baseUrl(new URL(baseUrl)).build(clientInterface);
+ } catch (MalformedURLException e) {
+ throw new IllegalArgumentException("The value of URL was invalid " + baseUrl);
+ }
+ }
+
+ @Override
+ public void destroy(Object instance, CreationalContext<Object> creationalContext) {
+
+ }
+
+ @Override
+ public Set<Type> getTypes() {
+ return Collections.singleton(clientInterface);
+ }
+
+ @Override
+ public Set<Annotation> getQualifiers() {
+ return Collections.singleton(RestClient.LITERAL);
+ }
+
+ @Override
+ public Class<? extends Annotation> getScope() {
+ return scope;
+ }
+
+ @Override
+ public String getName() {
+ return clientInterface.getName();
+ }
+
+ @Override
+ public Set<Class<? extends Annotation>> getStereotypes() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public boolean isAlternative() {
+ return false;
+ }
+
+ private String getBaseUrl() {
+ String property = String.format(REST_URL_FORMAT, clientInterface.getName());
+ return config.getValue(property, String.class);
+ }
+
+ private Class<? extends Annotation> readScope() {
+ // first check to see if the value is set
+ String property = String.format(REST_SCOPE_FORMAT, clientInterface.getName());
+ String configuredScope = config.getOptionalValue(property, String.class).orElse(null);
+ if (configuredScope != null) {
+ try {
+ return (Class<? extends Annotation>)Class.forName(configuredScope);
+ } catch (Exception e) {
+ throw new IllegalArgumentException("The scope " + configuredScope + " is invalid", e);
+ }
+ }
+
+ List<Annotation> possibleScopes = new ArrayList<>();
+ Annotation[] annotations = clientInterface.getDeclaredAnnotations();
+ for (Annotation annotation : annotations) {
+ if (beanManager.isScope(annotation.annotationType())) {
+ possibleScopes.add(annotation);
+ }
+ }
+ if (possibleScopes.isEmpty()) {
+ return Dependent.class;
+ } else if (possibleScopes.size() == 1) {
+ return possibleScopes.get(0).annotationType();
+ } else {
+ throw new IllegalArgumentException("The client interface " + clientInterface
+ + " has multiple scopes defined " + possibleScopes);
+ }
+ }
+}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientExtension.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientExtension.java
new file mode 100644
index 0000000..1d8f677
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientExtension.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client.cdi;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.AfterDeploymentValidation;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.enterprise.inject.spi.WithAnnotations;
+import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
+
+public class RestClientExtension implements Extension {
+ private static Set<Class<?>> restClientClasses = new LinkedHashSet<>();
+ private static Set<Throwable> errors = new LinkedHashSet<>();
+ public void findClients(@Observes @WithAnnotations({RegisterRestClient.class}) ProcessAnnotatedType<?> pat) {
+ Class<?> restClient = pat.getAnnotatedType().getJavaClass();
+ if (restClient.isInterface()) {
+ restClientClasses.add(restClient);
+ pat.veto();
+ } else {
+ errors.add(new IllegalArgumentException("The class " + restClient
+ + " is not an interface"));
+ }
+ }
+
+ public void registerClientBeans(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager) {
+ restClientClasses.stream().map(c -> new RestClientBean(c, beanManager)).forEach(afterBeanDiscovery::addBean);
+ }
+
+ public void registerErrors(@Observes AfterDeploymentValidation afterDeploymentValidation) {
+ errors.forEach(afterDeploymentValidation::addDeploymentProblem);
+ }
+}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/spi/CxfRestClientBuilderResolver.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/spi/CxfRestClientBuilderResolver.java
new file mode 100644
index 0000000..cf7f612
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/spi/CxfRestClientBuilderResolver.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client.spi;
+
+import javax.enterprise.inject.Vetoed;
+import org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilder;
+import org.eclipse.microprofile.rest.client.spi.RestClientBuilderResolver;
+
+@Vetoed
+public class CxfRestClientBuilderResolver extends RestClientBuilderResolver {
+ @Override
+ public CxfTypeSafeClientBuilder newBuilder() {
+ return new CxfTypeSafeClientBuilder();
+ }
+}
diff --git a/rt/rs/microprofile-client/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/rt/rs/microprofile-client/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
new file mode 100644
index 0000000..eadea9b
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
@@ -0,0 +1 @@
+org.apache.cxf.microprofile.client.cdi.RestClientExtension
\ No newline at end of file
diff --git a/rt/rs/microprofile-client/src/main/resources/META-INF/services/org.eclipse.microprofile.rest.client.spi.RestClientBuilderResolver b/rt/rs/microprofile-client/src/main/resources/META-INF/services/org.eclipse.microprofile.rest.client.spi.RestClientBuilderResolver
new file mode 100644
index 0000000..bd7696b
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/resources/META-INF/services/org.eclipse.microprofile.rest.client.spi.RestClientBuilderResolver
@@ -0,0 +1 @@
+org.apache.cxf.microprofile.client.spi.CxfRestClientBuilderResolver
\ No newline at end of file
diff --git a/rt/rs/pom.xml b/rt/rs/pom.xml
index 9edd71c..4578434 100644
--- a/rt/rs/pom.xml
+++ b/rt/rs/pom.xml
@@ -44,5 +44,6 @@
<module>sse</module>
<module>description-openapi-v3</module>
<module>description-swagger-ui</module>
+ <module>microprofile-client</module>
</modules>
</project>
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 21/21: [CXF-7579] Removing excluded test.
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit df8c7cc57efd953114499660ae28f609afbd1a73
Author: John D. Ament <jo...@apache.org>
AuthorDate: Wed Dec 20 07:08:30 2017 -0500
[CXF-7579] Removing excluded test.
---
systests/microprofile/client/weld/pom.xml | 3 ---
1 file changed, 3 deletions(-)
diff --git a/systests/microprofile/client/weld/pom.xml b/systests/microprofile/client/weld/pom.xml
index 91edf98..face317 100644
--- a/systests/microprofile/client/weld/pom.xml
+++ b/systests/microprofile/client/weld/pom.xml
@@ -109,9 +109,6 @@
<dependenciesToScan>
<dependency>org.eclipse.microprofile.rest.client:microprofile-rest-client-tck</dependency>
</dependenciesToScan>
- <excludes>
- <exclude>org.eclipse.microprofile.rest.client.tck.InvalidInterfaceTest</exclude>
- </excludes>
</configuration>
</plugin>
</plugins>
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 20/21: ConfigFacade to handle cases where no MP Config exists
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 6e99bc43a32812a6fe086f357eec50dd2ea47084
Author: Andy McCright <j....@gmail.com>
AuthorDate: Tue Dec 19 21:39:24 2017 -0600
ConfigFacade to handle cases where no MP Config exists
---
.../client/MicroProfileClientConfigurableImpl.java | 16 ++-----
.../microprofile/client/cdi/RestClientBean.java | 17 ++++---
.../microprofile/client/config/ConfigFacade.java | 53 ++++++++++++++++++++++
3 files changed, 67 insertions(+), 19 deletions(-)
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
index b27c47e..97e8c7d 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
@@ -27,10 +27,10 @@ import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.MessageBodyWriter;
import javax.ws.rs.ext.ReaderInterceptor;
import javax.ws.rs.ext.WriterInterceptor;
+
import org.apache.cxf.jaxrs.impl.ConfigurableImpl;
import org.apache.cxf.jaxrs.impl.ConfigurationImpl;
-import org.eclipse.microprofile.config.Config;
-import org.eclipse.microprofile.config.ConfigProvider;
+import org.apache.cxf.microprofile.client.config.ConfigFacade;
import org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper;
public class MicroProfileClientConfigurableImpl<C extends Configurable<C>>
@@ -55,16 +55,8 @@ public class MicroProfileClientConfigurableImpl<C extends Configurable<C>>
Object prop = getConfiguration().getProperty(CONFIG_KEY_DISABLE_MAPPER);
if (prop instanceof Boolean) {
return (Boolean)prop;
- } else {
- Config config;
- try {
- config = ConfigProvider.getConfig();
- } catch (ExceptionInInitializerError | NoClassDefFoundError | IllegalStateException ex) {
- // no config provider implementation
- return false;
- }
- return config.getOptionalValue(CONFIG_KEY_DISABLE_MAPPER,
- Boolean.class).orElse(false);
}
+ return ConfigFacade.getOptionalValue(CONFIG_KEY_DISABLE_MAPPER,
+ Boolean.class).orElse(false);
}
}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java
index 7baec1c..7524f0c 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/cdi/RestClientBean.java
@@ -28,6 +28,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
import javax.enterprise.context.Dependent;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.Default;
@@ -36,9 +37,9 @@ import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.PassivationCapable;
import javax.enterprise.util.AnnotationLiteral;
+
import org.apache.cxf.microprofile.client.CxfTypeSafeClientBuilder;
-import org.eclipse.microprofile.config.Config;
-import org.eclipse.microprofile.config.ConfigProvider;
+import org.apache.cxf.microprofile.client.config.ConfigFacade;
import org.eclipse.microprofile.rest.client.inject.RestClient;
public class RestClientBean implements Bean<Object>, PassivationCapable {
@@ -48,12 +49,10 @@ public class RestClientBean implements Bean<Object>, PassivationCapable {
private final Class<?> clientInterface;
private final Class<? extends Annotation> scope;
private final BeanManager beanManager;
- private final Config config;
RestClientBean(Class<?> clientInterface, BeanManager beanManager) {
this.clientInterface = clientInterface;
this.beanManager = beanManager;
- this.config = ConfigProvider.getConfig();
this.scope = this.readScope();
}
@Override
@@ -124,16 +123,20 @@ public class RestClientBean implements Bean<Object>, PassivationCapable {
private String getBaseUrl() {
String property = String.format(REST_URL_FORMAT, clientInterface.getName());
- return config.getValue(property, String.class);
+ String baseURL = ConfigFacade.getValue(property, String.class);
+ if (baseURL == null) {
+ throw new IllegalStateException("Unable to determine base URL from configuration");
+ }
+ return baseURL;
}
private Class<? extends Annotation> readScope() {
// first check to see if the value is set
String property = String.format(REST_SCOPE_FORMAT, clientInterface.getName());
- String configuredScope = config.getOptionalValue(property, String.class).orElse(null);
+ String configuredScope = ConfigFacade.getOptionalValue(property, String.class).orElse(null);
if (configuredScope != null) {
try {
- return (Class<? extends Annotation>)Class.forName(configuredScope);
+ return (Class<? extends Annotation>) Class.forName(configuredScope);
} catch (Exception e) {
throw new IllegalArgumentException("The scope " + configuredScope + " is invalid", e);
}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/config/ConfigFacade.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/config/ConfigFacade.java
new file mode 100644
index 0000000..e543d7c
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/config/ConfigFacade.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.microprofile.client.config;
+
+import java.util.Optional;
+
+import org.eclipse.microprofile.config.Config;
+import org.eclipse.microprofile.config.ConfigProvider;
+
+public final class ConfigFacade {
+
+ private ConfigFacade() {
+ }
+
+ private static Optional<Config> config() {
+ Config c;
+ try {
+ c = ConfigProvider.getConfig();
+ } catch (ExceptionInInitializerError | NoClassDefFoundError | IllegalStateException ex) {
+ // expected if no MP Config implementation is available
+ c = null;
+ }
+ return Optional.ofNullable(c);
+ }
+
+ public static <T> Optional<T> getOptionalValue(String propertyName, Class<T> clazz) {
+ Optional<Config> c = config();
+ return c.isPresent() ? c.get().getOptionalValue(propertyName, clazz) : Optional.empty();
+ }
+
+ public static <T> T getValue(String propertyName, Class<T> clazz) {
+ Optional<Config> c = config();
+ return c.isPresent() ? c.get().getValue(propertyName, clazz) : null;
+ }
+
+}
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 07/21: [CXF-7579] Wrapping up exception mapper support.
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 358fd2d25aba3d678b931e9519fe918215928405
Author: John D. Ament <jo...@apache.org>
AuthorDate: Sat Dec 16 10:21:26 2017 -0500
[CXF-7579] Wrapping up exception mapper support.
---
.../client/DefaultResponseExceptionMapper.java | 34 ++++++++++++++++++++++
.../client/MicroProfileClientFactoryBean.java | 9 ++++--
.../client/CxfTypeSafeClientBuilderTest.java | 2 ++
systests/microprofile/client/weld/pom.xml | 3 --
4 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/DefaultResponseExceptionMapper.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/DefaultResponseExceptionMapper.java
new file mode 100644
index 0000000..691de11
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/DefaultResponseExceptionMapper.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client;
+
+import javax.annotation.Priority;
+import javax.enterprise.inject.Vetoed;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper;
+
+@Priority(Integer.MAX_VALUE)
+@Vetoed
+public class DefaultResponseExceptionMapper implements ResponseExceptionMapper<Throwable> {
+ @Override
+ public Throwable toThrowable(Response response) {
+ throw new WebApplicationException(response);
+ }
+}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
index 7f662ff..f01fea8 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
@@ -39,6 +39,7 @@ import org.apache.cxf.microprofile.client.proxy.MicroProfileClientProxyImpl;
public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
private final ContractComparator comparator;
+ private final List<Object> registeredProviders;
private Configuration configuration;
private ClassLoader proxyLoader;
private boolean inheritHeaders;
@@ -50,9 +51,10 @@ public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
super.setAddress(baseUri);
super.setServiceClass(aClass);
super.setProviderComparator(comparator);
- List<Object> providers = new ArrayList<>();
- providers.addAll(processProviders());
- super.setProviders(providers);
+ registeredProviders = new ArrayList<>();
+ registeredProviders.addAll(processProviders());
+ registeredProviders.add(new DefaultResponseExceptionMapper());
+ super.setProviders(registeredProviders);
}
@Override
@@ -72,6 +74,7 @@ public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
super.initClient(client, ep, addHeaders);
MicroProfileClientProviderFactory factory = MicroProfileClientProviderFactory.createInstance(getBus(),
comparator);
+ factory.setUserProviders(registeredProviders);
ep.put(MicroProfileClientProviderFactory.CLIENT_FACTORY_NAME, factory);
}
diff --git a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
index c6bfaf2..be37b73 100644
--- a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
+++ b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
@@ -34,8 +34,10 @@ import org.eclipse.microprofile.rest.client.tck.providers.TestParamConverterProv
import org.eclipse.microprofile.rest.client.tck.providers.TestReaderInterceptor;
import org.eclipse.microprofile.rest.client.tck.providers.TestWriterInterceptor;
import org.junit.Assert;
+import org.junit.Ignore;
import org.junit.Test;
+@Ignore
public class CxfTypeSafeClientBuilderTest extends Assert {
@Test
diff --git a/systests/microprofile/client/weld/pom.xml b/systests/microprofile/client/weld/pom.xml
index 10f8ddf..04c7c56 100644
--- a/systests/microprofile/client/weld/pom.xml
+++ b/systests/microprofile/client/weld/pom.xml
@@ -120,9 +120,6 @@
<dependency>org.eclipse.microprofile.rest.client:microprofile-rest-client-tck</dependency>
</dependenciesToScan>
<excludes>
- <exclude>org.eclipse.microprofile.rest.client.tck.CallMultipleMappersTest</exclude>
- <exclude>org.eclipse.microprofile.rest.client.tck.DefaultExceptionMapperTest</exclude>
- <exclude>org.eclipse.microprofile.rest.client.tck.ExceptionMapperTest</exclude>
<exclude>org.eclipse.microprofile.rest.client.tck.InvokeWithJsonPProviderTest</exclude>
<exclude>org.eclipse.microprofile.rest.client.tck.InvalidInterfaceTest</exclude>
</excludes>
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 02/21: Config handling for MP rest client (#352)
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit eb705f4a09fb7cedd498e48ac442fa2610288fbb
Author: Andy McCright <j....@gmail.com>
AuthorDate: Wed Dec 6 19:05:08 2017 -0600
Config handling for MP rest client (#352)
---
.../client/CxfTypeSafeClientBuilder.java | 54 +++++++------
.../client/CxfTypeSafeClientBuilderTest.java | 94 ++++++++++++++++++++++
.../client/mock/HighPriorityClientReqFilter.java | 36 +++++++++
.../microprofile/client/mock/HighPriorityMBW.java | 69 ++++++++++++++++
.../client/mock/LowPriorityClientReqFilter.java | 36 +++++++++
.../cxf/microprofile/client/mock/MyClient.java | 29 +++++++
.../cxf/microprofile/client/mock/MyObject.java | 34 ++++++++
7 files changed, 329 insertions(+), 23 deletions(-)
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
index 4e231aa..8fc7b54 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
@@ -21,24 +21,20 @@ package org.apache.cxf.microprofile.client;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import javax.ws.rs.core.Configurable;
import javax.ws.rs.core.Configuration;
import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
+import org.apache.cxf.jaxrs.client.spec.ClientConfigurableImpl;
import org.eclipse.microprofile.rest.client.RestClientBuilder;
import org.eclipse.microprofile.rest.client.annotation.RegisterProviders;
public class CxfTypeSafeClientBuilder implements RestClientBuilder {
private String baseUri;
- private Map<String, Object> properties;
- private List<Object> jaxrsProviders;
-
- public CxfTypeSafeClientBuilder() {
- this.properties = new HashMap<>();
- this.jaxrsProviders = new ArrayList<>();
- }
+ private final Configurable<CxfTypeSafeClientBuilder> configImpl =
+ new ClientConfigurableImpl(this);
@Override
public RestClientBuilder baseUrl(URL url) {
@@ -48,9 +44,14 @@ public class CxfTypeSafeClientBuilder implements RestClientBuilder {
@Override
public <T> T build(Class<T> aClass) {
+ if (baseUri == null) {
+ throw new IllegalStateException("baseUrl not set");
+ }
RegisterProviders providers = aClass.getAnnotation(RegisterProviders.class);
List<Object> providerClasses = new ArrayList<>();
- providerClasses.addAll(this.jaxrsProviders);
+ Configuration config = configImpl.getConfiguration();
+ providerClasses.addAll(config.getClasses());
+ providerClasses.addAll(config.getInstances());
if (providers != null) {
providerClasses.addAll(Arrays.asList(providers.value()));
}
@@ -58,60 +59,67 @@ public class CxfTypeSafeClientBuilder implements RestClientBuilder {
bean.setAddress(baseUri);
bean.setServiceClass(aClass);
bean.setProviders(providerClasses);
- bean.setProperties(properties);
+ bean.setProperties(config.getProperties());
return bean.create(aClass);
}
@Override
public Configuration getConfiguration() {
- return null;
+ return configImpl.getConfiguration();
}
@Override
- public RestClientBuilder property(String s, Object o) {
- this.properties.put(s, o);
+ public RestClientBuilder property(String key, Object value) {
+ configImpl.property(key, value);
return this;
}
@Override
- public RestClientBuilder register(Class<?> providerClass) {
- this.jaxrsProviders.add(providerClass);
+ public RestClientBuilder register(Class<?> componentClass) {
+ configImpl.register(componentClass);
return this;
}
@Override
- public RestClientBuilder register(Class<?> aClass, int i) {
+ public RestClientBuilder register(Object component) {
+ configImpl.register(component);
return this;
}
@Override
- public RestClientBuilder register(Class<?> aClass, Class<?>... classes) {
+ public RestClientBuilder register(Class<?> componentClass, int priority) {
+ configImpl.register(componentClass, priority);
return this;
}
@Override
- public RestClientBuilder register(Class<?> aClass, Map<Class<?>, Integer> map) {
+ public RestClientBuilder register(Class<?> componentClass, Class<?>... contracts) {
+ configImpl.register(componentClass, contracts);
return this;
}
@Override
- public RestClientBuilder register(Object o) {
- this.jaxrsProviders.add(o);
+ public RestClientBuilder register(Class<?> componentClass, Map<Class<?>, Integer> contracts) {
+ configImpl.register(componentClass, contracts);
return this;
}
@Override
- public RestClientBuilder register(Object o, int i) {
+ public RestClientBuilder register(Object component, int priority) {
+ configImpl.register(component, priority);
return this;
}
@Override
- public RestClientBuilder register(Object o, Class<?>... classes) {
+ public RestClientBuilder register(Object component, Class<?>... contracts) {
+ configImpl.register(component, contracts);
return this;
}
@Override
- public RestClientBuilder register(Object o, Map<Class<?>, Integer> map) {
+ public RestClientBuilder register(Object component, Map<Class<?>, Integer> contracts) {
+ configImpl.register(component, contracts);
return this;
}
+
}
diff --git a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
new file mode 100644
index 0000000..8d6d1a0
--- /dev/null
+++ b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client;
+import java.net.URL;
+import javax.ws.rs.core.Response;
+import org.apache.cxf.microprofile.client.mock.HighPriorityClientReqFilter;
+import org.apache.cxf.microprofile.client.mock.HighPriorityMBW;
+import org.apache.cxf.microprofile.client.mock.LowPriorityClientReqFilter;
+import org.apache.cxf.microprofile.client.mock.MyClient;
+import org.eclipse.microprofile.rest.client.RestClientBuilder;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class CxfTypeSafeClientBuilderTest extends Assert {
+
+ @Test
+ public void testConfigMethods() {
+ RestClientBuilder builder = RestClientBuilder.newBuilder();
+
+ assertEquals("y", builder.property("x", "y").getConfiguration().getProperty("x"));
+
+ assertTrue(builder.register(HighPriorityMBW.class).getConfiguration().isRegistered(HighPriorityMBW.class));
+
+ HighPriorityMBW mbw = new HighPriorityMBW(1);
+ assertTrue(builder.register(mbw).getConfiguration().isRegistered(mbw));
+
+ }
+
+ @Ignore
+ @Test
+ public void testConfigPriorityOverrides() throws Exception {
+ RestClientBuilder builder = RestClientBuilder.newBuilder();
+ builder.register(HighPriorityClientReqFilter.class); // annotation priority of 10
+ builder.register(LowPriorityClientReqFilter.class, 5); // overriding priority to be 5 (preferred)
+ MyClient c = builder.baseUrl(new URL("http://localhost/null")).build(MyClient.class);
+ Response r = c.get();
+ assertEquals("low", r.readEntity(String.class));
+ }
+/** using for test coverage
+ @Override
+ public RestClientBuilder register(Class<?> componentClass, int priority) {
+ configImpl.register(componentClass, priority);
+ return this;
+ }
+
+ @Override
+ public RestClientBuilder register(Class<?> componentClass, Class<?>... contracts) {
+ configImpl.register(componentClass, contracts);
+ return this;
+ }
+
+ @Override
+ public RestClientBuilder register(Class<?> componentClass, Map<Class<?>, Integer> contracts) {
+ configImpl.register(componentClass, contracts);
+ return this;
+ }
+
+ @Override
+ public RestClientBuilder register(Object component, int priority) {
+ configImpl.register(component, priority);
+ return this;
+ }
+
+ @Override
+ public RestClientBuilder register(Object component, Class<?>... contracts) {
+ configImpl.register(component, contracts);
+ return this;
+ }
+
+ @Override
+ public RestClientBuilder register(Object component, Map<Class<?>, Integer> contracts) {
+ configImpl.register(component, contracts);
+ return this;
+ }
+**/
+}
diff --git a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/HighPriorityClientReqFilter.java b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/HighPriorityClientReqFilter.java
new file mode 100644
index 0000000..0f1ebf6
--- /dev/null
+++ b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/HighPriorityClientReqFilter.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client.mock;
+
+import java.io.IOException;
+
+import javax.annotation.Priority;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.core.Response;
+
+@Priority(10)
+public class HighPriorityClientReqFilter implements ClientRequestFilter {
+
+ @Override
+ public void filter(ClientRequestContext paramClientRequestContext) throws IOException {
+ paramClientRequestContext.abortWith(Response.ok("high").build());
+ }
+
+}
diff --git a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/HighPriorityMBW.java b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/HighPriorityMBW.java
new file mode 100644
index 0000000..65cc859
--- /dev/null
+++ b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/HighPriorityMBW.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client.mock;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.annotation.Priority;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+
+@Priority(10)
+public class HighPriorityMBW implements MessageBodyWriter<MyObject> {
+
+ private final int id;
+
+ public HighPriorityMBW() {
+ this(0);
+ }
+
+ public HighPriorityMBW(int id) {
+ this.id = id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof HighPriorityMBW && ((HighPriorityMBW)o).id == this.id;
+ }
+
+ @Override
+ public int hashCode() {
+ return id;
+ }
+
+ @Override
+ public boolean isWriteable(Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType) {
+ return true;
+ }
+
+ @Override
+ public void writeTo(MyObject t, Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType,
+ MultivaluedMap<String, Object> httpHeaders,
+ OutputStream entityStream) throws IOException,
+ WebApplicationException {
+ entityStream.write(t.toString().getBytes());
+ }
+}
diff --git a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/LowPriorityClientReqFilter.java b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/LowPriorityClientReqFilter.java
new file mode 100644
index 0000000..67a73b3
--- /dev/null
+++ b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/LowPriorityClientReqFilter.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client.mock;
+
+import java.io.IOException;
+
+import javax.annotation.Priority;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.core.Response;
+
+@Priority(6000)
+public class LowPriorityClientReqFilter implements ClientRequestFilter {
+
+ @Override
+ public void filter(ClientRequestContext paramClientRequestContext) throws IOException {
+ paramClientRequestContext.abortWith(Response.ok("low").build());
+ }
+
+}
diff --git a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/MyClient.java b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/MyClient.java
new file mode 100644
index 0000000..c380845
--- /dev/null
+++ b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/MyClient.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client.mock;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+
+@Path("/")
+public interface MyClient {
+ @GET
+ Response get();
+}
diff --git a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/MyObject.java b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/MyObject.java
new file mode 100644
index 0000000..5b56f7c
--- /dev/null
+++ b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/MyObject.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client.mock;
+
+public class MyObject {
+ private String name;
+ private int id;
+
+ public MyObject(String name, int id) {
+ this.name = name;
+ this.id = id;
+ }
+
+ @Override
+ public String toString() {
+ return "name=\"" + name + "\" : id=" + id;
+ }
+}
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 05/21: [CXF-7579] Setup Systests to run the MicroProfile TCKs.
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit ddac0a9d06422139c2c9e897b7886a63dc8c2c3a
Author: John D. Ament <jo...@apache.org>
AuthorDate: Sun Dec 10 20:17:49 2017 -0500
[CXF-7579] Setup Systests to run the MicroProfile TCKs.
---
systests/microprofile/client/weld/pom.xml | 133 ++++++++++++++++++++++++++++++
systests/microprofile/pom.xml | 35 ++++++++
systests/pom.xml | 1 +
3 files changed, 169 insertions(+)
diff --git a/systests/microprofile/client/weld/pom.xml b/systests/microprofile/client/weld/pom.xml
new file mode 100644
index 0000000..7df726e
--- /dev/null
+++ b/systests/microprofile/client/weld/pom.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>cxf-systests-cdi</artifactId>
+ <groupId>org.apache.cxf.systests</groupId>
+ <version>3.2.2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>cxf-systests-microprofile-weld</artifactId>
+ <name>Apache CXF System Tests - MicroProfile Rest Client TCK</name>
+ <properties>
+ <microprofile.rest.client.version>1.0-SNAPSHOT</microprofile.rest.client.version>
+ <geronimo.config.version>1.0</geronimo.config.version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.testng</groupId>
+ <artifactId>arquillian-testng-container</artifactId>
+ <version>1.1.14.Final</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld.se</groupId>
+ <artifactId>weld-se-core</artifactId>
+ <version>2.4.5.Final</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-weld-embedded</artifactId>
+ <version>2.0.0.Beta5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.microprofile.rest.client</groupId>
+ <artifactId>microprofile-rest-client-tck</artifactId>
+ <version>${microprofile.rest.client.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <version>1.1.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.json</groupId>
+ <artifactId>javax.json-api</artifactId>
+ <version>1.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <version>1.7.25</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.config</groupId>
+ <artifactId>geronimo-config-impl</artifactId>
+ <version>1.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-mp-client</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>uk.co.deliverymind</groupId>
+ <artifactId>wiremock-maven-plugin</artifactId>
+ <version>2.7.0</version>
+ <executions>
+ <execution>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <dir>target/classes</dir>
+ <params>--port=8765 --verbose</params>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.20</version>
+ <configuration>
+ <dependenciesToScan>
+ <dependency>org.eclipse.microprofile.rest.client:microprofile-rest-client-tck</dependency>
+ </dependenciesToScan>
+ <excludes>
+ <exclude>org.eclipse.microprofile.rest.client.tck.AdditionalRegistrationTest</exclude>
+ <exclude>org.eclipse.microprofile.rest.client.tck.CallMultipleMappersTest</exclude>
+ <exclude>org.eclipse.microprofile.rest.client.tck.DefaultExceptionMapperTest</exclude>
+ <exclude>org.eclipse.microprofile.rest.client.tck.ExceptionMapperTest</exclude>
+ <exclude>org.eclipse.microprofile.rest.client.tck.InvokeWithJsonPProviderTest</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/systests/microprofile/pom.xml b/systests/microprofile/pom.xml
new file mode 100644
index 0000000..f8ff337
--- /dev/null
+++ b/systests/microprofile/pom.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cxf-microprofile-tck</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache CXF MicroProfile TCKs</name>
+ <description>Apache CXF System Tests - MicroProfile TCKs</description>
+ <url>http://cxf.apache.org</url>
+ <parent>
+ <groupId>org.apache.cxf.systests</groupId>
+ <artifactId>cxf-systests</artifactId>
+ <version>3.2.2-SNAPSHOT</version>
+ </parent>
+ <modules>
+ <module>client/weld</module>
+ </modules>
+</project>
diff --git a/systests/pom.xml b/systests/pom.xml
index b87437d..e7847b9 100644
--- a/systests/pom.xml
+++ b/systests/pom.xml
@@ -52,5 +52,6 @@
<module>tracing</module>
<module>ws-transfer</module>
<module>rs-sse</module>
+ <module>microprofile</module>
</modules>
</project>
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 19/21: MP Rest Client interface validation tests
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 13a483f176de72a3b0297a8d777c5f80393665a9
Author: Andy McCright <j....@gmail.com>
AuthorDate: Tue Dec 19 15:26:45 2017 -0600
MP Rest Client interface validation tests
Checks:
- that the passed-in type is an interface
- that each method has, at most, one HTTP method annotation
- that URI template variables in @Path annotations are resolved by
@PathParam annotations
---
.../client/CxfTypeSafeClientBuilder.java | 1 +
.../cxf/microprofile/client/Messages.properties | 24 ++++
.../client/MicroProfileClientConfigurableImpl.java | 8 +-
.../apache/cxf/microprofile/client/Validator.java | 124 +++++++++++++++++++
.../cxf/microprofile/client/ValidatorTest.java | 134 +++++++++++++++++++++
5 files changed, 290 insertions(+), 1 deletion(-)
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
index d895586..2daf944 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
@@ -42,6 +42,7 @@ public class CxfTypeSafeClientBuilder implements RestClientBuilder, Configurable
if (baseUri == null) {
throw new IllegalStateException("baseUrl not set");
}
+ Validator.checkValid(aClass);
RegisterProvider[] providers = aClass.getAnnotationsByType(RegisterProvider.class);
Configuration config = configImpl.getConfiguration();
if (providers != null) {
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/Messages.properties b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/Messages.properties
new file mode 100644
index 0000000..d2d5363
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/Messages.properties
@@ -0,0 +1,24 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+VALIDATION_NOT_AN_INTERFACE=The type, {0}, passed in to the build method is not an interface.
+VALIDATION_METHOD_WITH_MULTIPLE_VERBS=The client interface contains a method, {0} annotated with more than one HTTP method: {1}
+VALIDATION_UNRESOLVED_PATH_PARAMS=The client interface, {0} has one or more methods with unresolved path template variables: {1}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
index 3df4246..b27c47e 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
@@ -56,7 +56,13 @@ public class MicroProfileClientConfigurableImpl<C extends Configurable<C>>
if (prop instanceof Boolean) {
return (Boolean)prop;
} else {
- Config config = ConfigProvider.getConfig();
+ Config config;
+ try {
+ config = ConfigProvider.getConfig();
+ } catch (ExceptionInInitializerError | NoClassDefFoundError | IllegalStateException ex) {
+ // no config provider implementation
+ return false;
+ }
return config.getOptionalValue(CONFIG_KEY_DISABLE_MAPPER,
Boolean.class).orElse(false);
}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/Validator.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/Validator.java
new file mode 100644
index 0000000..8d77e02
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/Validator.java
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.jaxrs.model.URITemplate;
+import org.eclipse.microprofile.rest.client.RestClientDefinitionException;
+
+final class Validator {
+ private static final ResourceBundle BUNDLE = BundleUtils.getBundle(Validator.class);
+
+ private Validator() {
+ }
+
+
+ public static void checkValid(Class<?> userType) throws RestClientDefinitionException {
+ if (!userType.isInterface()) {
+ throwException("VALIDATION_NOT_AN_INTERFACE", userType);
+ }
+ Method[] methods = userType.getMethods();
+ checkMethodsForMultipleHTTPMethodAnnotations(methods);
+ checkMethodsForInvalidURITemplates(userType, methods);
+ }
+
+ private static void checkMethodsForMultipleHTTPMethodAnnotations(Method[] clientMethods)
+ throws RestClientDefinitionException {
+
+ Map<String, Class<? extends Annotation>> httpMethods = new HashMap<>();
+ for (Method method : clientMethods) {
+
+ for (Annotation anno : method.getAnnotations()) {
+ Class<? extends Annotation> annoClass = anno.annotationType();
+ HttpMethod verb = annoClass.getAnnotation(HttpMethod.class);
+ if (verb != null) {
+ httpMethods.put(verb.value(), annoClass);
+ }
+ }
+ if (httpMethods.size() > 1) {
+ throwException("VALIDATION_METHOD_WITH_MULTIPLE_VERBS", method, httpMethods.values());
+ }
+ httpMethods.clear();
+ }
+
+ }
+
+ private static void checkMethodsForInvalidURITemplates(Class<?> userType, Method[] methods)
+ throws RestClientDefinitionException {
+
+ Path classPathAnno = userType.getAnnotation(Path.class);
+
+ final Set<String> classLevelVariables = new HashSet<>();
+ URITemplate classTemplate = null;
+ if (classPathAnno != null) {
+ classTemplate = new URITemplate(classPathAnno.value());
+ classLevelVariables.addAll(classTemplate.getVariables());
+ }
+ URITemplate template;
+ for (Method method : methods) {
+
+ Path methodPathAnno = method.getAnnotation(Path.class);
+ if (methodPathAnno != null) {
+ template = classPathAnno == null ? new URITemplate(methodPathAnno.value())
+ : new URITemplate(classPathAnno.value() + "/" + methodPathAnno.value());
+ } else {
+ template = classTemplate;
+ }
+ if (template == null) {
+ continue;
+ }
+ Set<String> allVariables = new HashSet<>(template.getVariables());
+ if (!allVariables.isEmpty()) {
+ Map<String, String> paramMap = new HashMap<>();
+ for (Parameter p : method.getParameters()) {
+ PathParam pathParam = p.getAnnotation(PathParam.class);
+ if (pathParam != null) {
+ paramMap.put(pathParam.value(), "x");
+ }
+ }
+ try {
+ template.substitute(paramMap, Collections.<String>emptySet(), false);
+ } catch (IllegalArgumentException ex) {
+ throwException("VALIDATION_UNRESOLVED_PATH_PARAMS", userType, method);
+ }
+ }
+ }
+ }
+
+ private static void throwException(String msgKey, Object...msgParams) throws RestClientDefinitionException {
+ Message msg = new Message(msgKey, BUNDLE, msgParams);
+ throw new RestClientDefinitionException(msg.toString());
+ }
+
+}
diff --git a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/ValidatorTest.java b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/ValidatorTest.java
new file mode 100644
index 0000000..7877574
--- /dev/null
+++ b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/ValidatorTest.java
@@ -0,0 +1,134 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+
+import org.eclipse.microprofile.rest.client.RestClientBuilder;
+import org.eclipse.microprofile.rest.client.RestClientDefinitionException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ValidatorTest extends Assert {
+
+ public abstract static class NotAnInterface {
+ @GET
+ public abstract Response get();
+ }
+
+ public interface MultiVerbMethod {
+ @GET
+ Response get();
+ @PUT
+ Response put(String x);
+ @POST
+ @DELETE
+ Response postAndDelete();
+ }
+
+ @Path("/rest/{class}")
+ public interface UnresolvedClassUriTemplate {
+ @GET
+ Response myUnresolvedMethod();
+ }
+
+ @Path("/rest")
+ public interface UnresolvedMethodUriTemplate {
+ @Path("/{method}")
+ @GET
+ Response myOtherUnresolvedMethod();
+ }
+
+ @Path("/rest/{class}")
+ public interface PartiallyResolvedUriTemplate {
+ @GET
+ Response get(@PathParam("class")String className);
+
+ @PUT
+ @Path("/{method}")
+ Response put(@PathParam("method")String methodName);
+ }
+
+ @Path("/rest/{class}")
+ public interface PartiallyResolvedUriTemplate2 {
+ @DELETE
+ Response delete(@PathParam("class")String className);
+
+ @POST
+ @Path("/{method}")
+ Response post(@PathParam("class")String className);
+ }
+
+ private static RestClientBuilder newBuilder() {
+ RestClientBuilder builder = RestClientBuilder.newBuilder();
+ try {
+ builder = builder.baseUrl(new URL("http://localhost:8080/test"));
+ } catch (MalformedURLException e) {
+ fail("MalformedURL - bad testcase");
+ }
+ return builder;
+ }
+
+ @Test
+ public void testNotAnInterface() {
+ test(NotAnInterface.class, "is not an interface", "NotAnInterface");
+ }
+
+ @Test
+ public void testMethodWithMultipleVerbs() {
+ test(MultiVerbMethod.class, "more than one HTTP method", "postAndDelete", "javax.ws.rs.POST",
+ "javax.ws.rs.DELETE");
+ }
+
+ @Test
+ public void testUnresolvedUriTemplates() {
+ test(UnresolvedClassUriTemplate.class, "unresolved path template variables", "UnresolvedClassUriTemplate",
+ "myUnresolvedMethod");
+ test(UnresolvedMethodUriTemplate.class, "unresolved path template variables", "UnresolvedMethodUriTemplate",
+ "myOtherUnresolvedMethod");
+ test(PartiallyResolvedUriTemplate.class, "unresolved path template variables", "PartiallyResolvedUriTemplate",
+ "put");
+ test(PartiallyResolvedUriTemplate2.class, "unresolved path template variables", "PartiallyResolvedUriTemplate2",
+ "post");
+ }
+
+ private void test(Class<?> clientInterface, String...expectedMessageTexts) {
+ try {
+ newBuilder().build(clientInterface);
+ fail("Expected RestClientDefinitionException");
+ } catch (RestClientDefinitionException ex) {
+ String msgText = ex.getMessage();
+ assertNotNull("No message text in RestClientDefinitionException", msgText);
+ for (String expectedMessageText : expectedMessageTexts) {
+ assertTrue("Exception text does not contain expected message: " + expectedMessageText,
+ msgText.contains(expectedMessageText));
+ }
+ }
+ }
+}
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 03/21: [CXF-7579] More config impl.
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 6353df0e8f2f198688627cccaee545b555e8e9a8
Author: John D. Ament <jo...@apache.org>
AuthorDate: Thu Dec 7 06:35:47 2017 -0500
[CXF-7579] More config impl.
---
.../client/CxfTypeSafeClientBuilder.java | 27 ++++------
.../client/MicroProfileClientConfigurableImpl.java | 50 +++++++++++++++++
.../client/MicroProfileClientFactoryBean.java | 62 ++++++++++++++++++++++
.../client/CxfTypeSafeClientBuilderTest.java | 2 +-
4 files changed, 123 insertions(+), 18 deletions(-)
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
index 8fc7b54..904731c 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilder.java
@@ -19,22 +19,17 @@
package org.apache.cxf.microprofile.client;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.ws.rs.core.Configurable;
import javax.ws.rs.core.Configuration;
-import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
-import org.apache.cxf.jaxrs.client.spec.ClientConfigurableImpl;
import org.eclipse.microprofile.rest.client.RestClientBuilder;
import org.eclipse.microprofile.rest.client.annotation.RegisterProviders;
-public class CxfTypeSafeClientBuilder implements RestClientBuilder {
+public class CxfTypeSafeClientBuilder implements RestClientBuilder, Configurable<RestClientBuilder> {
private String baseUri;
- private final Configurable<CxfTypeSafeClientBuilder> configImpl =
- new ClientConfigurableImpl(this);
+ private final MicroProfileClientConfigurableImpl<RestClientBuilder> configImpl =
+ new MicroProfileClientConfigurableImpl<>(this);
@Override
public RestClientBuilder baseUrl(URL url) {
@@ -48,18 +43,16 @@ public class CxfTypeSafeClientBuilder implements RestClientBuilder {
throw new IllegalStateException("baseUrl not set");
}
RegisterProviders providers = aClass.getAnnotation(RegisterProviders.class);
- List<Object> providerClasses = new ArrayList<>();
Configuration config = configImpl.getConfiguration();
- providerClasses.addAll(config.getClasses());
- providerClasses.addAll(config.getInstances());
if (providers != null) {
- providerClasses.addAll(Arrays.asList(providers.value()));
+ for (Class<?> c : providers.value()) {
+ if (!config.isRegistered(c)) {
+ register(c);
+ }
+ }
}
- JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
- bean.setAddress(baseUri);
- bean.setServiceClass(aClass);
- bean.setProviders(providerClasses);
- bean.setProperties(config.getProperties());
+ MicroProfileClientFactoryBean bean = new MicroProfileClientFactoryBean(getConfiguration(),
+ baseUri, aClass);
return bean.create(aClass);
}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
new file mode 100644
index 0000000..9a6ccbc
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client;
+
+import javax.ws.rs.RuntimeType;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.core.Configurable;
+import javax.ws.rs.core.Configuration;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.ReaderInterceptor;
+import javax.ws.rs.ext.WriterInterceptor;
+import org.apache.cxf.jaxrs.impl.ConfigurableImpl;
+import org.apache.cxf.jaxrs.impl.ConfigurationImpl;
+import org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper;
+
+public class MicroProfileClientConfigurableImpl<C extends Configurable<C>>
+ extends ConfigurableImpl<C>
+ implements Configurable<C> {
+ static final Class<?>[] CONTRACTS = new Class<?>[] {ClientRequestFilter.class,
+ ClientResponseFilter.class, ReaderInterceptor.class, WriterInterceptor.class,
+ MessageBodyWriter.class, MessageBodyReader.class, ResponseExceptionMapper.class};
+
+ public MicroProfileClientConfigurableImpl(C configurable) {
+ this(configurable, null);
+ }
+
+ public MicroProfileClientConfigurableImpl(C configurable, Configuration config) {
+ super(configurable,
+ CONTRACTS, config == null ? new ConfigurationImpl(RuntimeType.CLIENT)
+ : new ConfigurationImpl(config, CONTRACTS));
+ }
+}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
new file mode 100644
index 0000000..4499807
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client;
+
+import java.util.Comparator;
+import java.util.Map;
+import javax.ws.rs.core.Configuration;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
+import org.apache.cxf.jaxrs.utils.AnnotationUtils;
+import static org.apache.cxf.microprofile.client.MicroProfileClientConfigurableImpl.CONTRACTS;
+
+public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
+ private Configuration configuration;
+
+ public MicroProfileClientFactoryBean(Configuration configuration, String baseUri, Class<?> aClass) {
+ super();
+ this.configuration = configuration;
+ super.setAddress(baseUri);
+ super.setServiceClass(aClass);
+ super.setProviderComparator(new ContractComparator());
+ }
+
+ private class ContractComparator implements Comparator<Object> {
+ @Override
+ public int compare(Object o1, Object o2) {
+ int left = getPriority(o1.getClass());
+ int right = getPriority(o2.getClass());
+ return right - left;
+ }
+
+ private int getPriority(Class<?> clazz) {
+ for (Class<?> providerClass : CONTRACTS) {
+ Map<Class<?>, Integer> contracts = MicroProfileClientFactoryBean.this.
+ configuration.getContracts(providerClass);
+ if (contracts != null) {
+ Integer priority = contracts.get(clazz);
+ if (priority != null) {
+ return priority;
+ }
+ }
+ }
+ return AnnotationUtils.getBindingPriority(clazz);
+ }
+ }
+
+}
diff --git a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
index 8d6d1a0..e903f09 100644
--- a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
+++ b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
@@ -44,8 +44,8 @@ public class CxfTypeSafeClientBuilderTest extends Assert {
}
- @Ignore
@Test
+ @Ignore
public void testConfigPriorityOverrides() throws Exception {
RestClientBuilder builder = RestClientBuilder.newBuilder();
builder.register(HighPriorityClientReqFilter.class); // annotation priority of 10
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 13/21: [CXF-7579] Mark the default mapper and json provider
as non-custom.
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit c826d79029e020abee797084f92f476719368b94
Author: John D. Ament <jo...@apache.org>
AuthorDate: Tue Dec 19 15:03:50 2017 -0500
[CXF-7579] Mark the default mapper and json provider as non-custom.
---
.../cxf/microprofile/client/JsonPProvider.java | 26 ----------------------
.../client/MicroProfileClientFactoryBean.java | 25 +++++++++++----------
2 files changed, 13 insertions(+), 38 deletions(-)
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/JsonPProvider.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/JsonPProvider.java
deleted file mode 100644
index 09bd122..0000000
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/JsonPProvider.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.microprofile.client;
-
-import javax.annotation.Priority;
-import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider;
-
-@Priority(Integer.MAX_VALUE)
-public class JsonPProvider extends JsrJsonpProvider {
-}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
index e9a1767..eee6b74 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
@@ -18,16 +18,6 @@
*/
package org.apache.cxf.microprofile.client;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import javax.ws.rs.client.ClientRequestFilter;
-import javax.ws.rs.client.ClientResponseFilter;
-import javax.ws.rs.core.Configuration;
-
import org.apache.cxf.common.util.ClassHelper;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.jaxrs.client.AbstractClient;
@@ -37,9 +27,20 @@ import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
import org.apache.cxf.jaxrs.model.FilterProviderInfo;
import org.apache.cxf.jaxrs.model.ProviderInfo;
+import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider;
import org.apache.cxf.microprofile.client.proxy.MicroProfileClientProxyImpl;
import org.eclipse.microprofile.rest.client.RestClientBuilder;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.core.Configuration;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
private final Comparator<ProviderInfo<?>> comparator;
private final List<Object> registeredProviders;
@@ -58,9 +59,9 @@ public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
registeredProviders = new ArrayList<>();
registeredProviders.addAll(processProviders());
if (!configuration.isDefaultExceptionMapperDisabled()) {
- registeredProviders.add(new DefaultResponseExceptionMapper());
+ registeredProviders.add(new ProviderInfo<>(new DefaultResponseExceptionMapper(),getBus(),false));
}
- registeredProviders.add(new JsonPProvider());
+ registeredProviders.add(new ProviderInfo<>(new JsrJsonpProvider(),getBus(),false));
super.setProviders(registeredProviders);
}
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 04/21: [CXF-7579] More config impl.
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit b4d0456439f148fe08f9fe10ed50ee35bcdbb281
Author: John D. Ament <jo...@apache.org>
AuthorDate: Thu Dec 7 06:50:02 2017 -0500
[CXF-7579] More config impl.
---
.../cxf/microprofile/client/MicroProfileClientFactoryBean.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
index 4499807..3d89549 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
@@ -18,7 +18,9 @@
*/
package org.apache.cxf.microprofile.client;
+import java.util.ArrayList;
import java.util.Comparator;
+import java.util.List;
import java.util.Map;
import javax.ws.rs.core.Configuration;
import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
@@ -34,6 +36,10 @@ public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
super.setAddress(baseUri);
super.setServiceClass(aClass);
super.setProviderComparator(new ContractComparator());
+ List<Object> providerClasses = new ArrayList<>();
+ providerClasses.addAll(configuration.getClasses());
+ providerClasses.addAll(configuration.getInstances());
+ super.setProviders(providerClasses);
}
private class ContractComparator implements Comparator<Object> {
@@ -41,7 +47,7 @@ public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
public int compare(Object o1, Object o2) {
int left = getPriority(o1.getClass());
int right = getPriority(o2.getClass());
- return right - left;
+ return left - right;
}
private int getPriority(Class<?> clazz) {
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 11/21: [CXF-7579] Enable custom method test.
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 22815013334de1dcb7b4aaddbe1703ce6a6c0a2a
Author: John D. Ament <jo...@apache.org>
AuthorDate: Mon Dec 18 23:27:30 2017 -0500
[CXF-7579] Enable custom method test.
---
systests/microprofile/client/weld/pom.xml | 1 -
1 file changed, 1 deletion(-)
diff --git a/systests/microprofile/client/weld/pom.xml b/systests/microprofile/client/weld/pom.xml
index 77628bd..5e22ae4 100644
--- a/systests/microprofile/client/weld/pom.xml
+++ b/systests/microprofile/client/weld/pom.xml
@@ -133,7 +133,6 @@
<dependency>org.eclipse.microprofile.rest.client:microprofile-rest-client-tck</dependency>
</dependenciesToScan>
<excludes>
- <exclude>org.eclipse.microprofile.rest.client.tck.CustomHttpMethodTest</exclude>
<exclude>org.eclipse.microprofile.rest.client.tck.InvalidInterfaceTest</exclude>
</excludes>
</configuration>
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 17/21: Ensure tests pass
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit b5b242dd5ab4456d38e2f9b3558957da8d045188
Author: Andy McCright <j....@gmail.com>
AuthorDate: Tue Dec 19 16:06:22 2017 -0600
Ensure tests pass
Using an Echo client request filter to avoid sending the request to the
network. This ensures that the other filters and reader interceptors
are invoked, but not the writer interceptor.
---
.../client/CxfTypeSafeClientBuilderTest.java | 8 ++++-
.../client/mock/EchoClientReqFilter.java | 36 ++++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
index 5ac4b79..aafd1a2 100644
--- a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
+++ b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/CxfTypeSafeClientBuilderTest.java
@@ -20,6 +20,8 @@ package org.apache.cxf.microprofile.client;
import java.net.URL;
import javax.ws.rs.core.Response;
+
+import org.apache.cxf.microprofile.client.mock.EchoClientReqFilter;
import org.apache.cxf.microprofile.client.mock.HighPriorityClientReqFilter;
import org.apache.cxf.microprofile.client.mock.HighPriorityMBW;
import org.apache.cxf.microprofile.client.mock.LowPriorityClientReqFilter;
@@ -77,6 +79,7 @@ public class CxfTypeSafeClientBuilderTest extends Assert {
.register(TestParamConverterProvider.class)
.register(TestReaderInterceptor.class)
.register(TestWriterInterceptor.class)
+ .register(EchoClientReqFilter.class)
.property("microprofile.rest.client.disable.default.mapper", true)
.baseUrl(new URL("http://localhost/null"))
.build(InterfaceWithoutProvidersDefined.class);
@@ -92,7 +95,10 @@ public class CxfTypeSafeClientBuilderTest extends Assert {
assertEquals(TestClientResponseFilter.getAndResetValue(), 1);
assertEquals(TestClientRequestFilter.getAndResetValue(), 1);
assertEquals(TestReaderInterceptor.getAndResetValue(), 1);
- assertEquals(TestWriterInterceptor.getAndResetValue(), 1);
+ // If we use the EchoClientReqFilter, it will be executed before the TestWriterInterceptor,
+ // so that interceptor won't be called in this test.
+ // TODO: add a test for writer interceptors - possibly in systests
+ //assertEquals(TestWriterInterceptor.getAndResetValue(), 1);
}
/** using for test coverage
diff --git a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/EchoClientReqFilter.java b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/EchoClientReqFilter.java
new file mode 100644
index 0000000..7496989
--- /dev/null
+++ b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/mock/EchoClientReqFilter.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client.mock;
+
+import java.io.IOException;
+
+import javax.annotation.Priority;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.core.Response;
+
+@Priority(Integer.MAX_VALUE)
+public class EchoClientReqFilter implements ClientRequestFilter {
+
+ @Override
+ public void filter(ClientRequestContext crc) throws IOException {
+ crc.abortWith(Response.ok(crc.getEntity()).build());
+ }
+
+}
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 12/21: [CXF-7579] Upgrading to final release,
refactoring dependencies.
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit d76a926b4c6085ad42718bee828114cbc24fbd97
Author: John D. Ament <jo...@apache.org>
AuthorDate: Tue Dec 19 14:49:22 2017 -0500
[CXF-7579] Upgrading to final release, refactoring dependencies.
---
parent/pom.xml | 19 +++++++++++
rt/rs/microprofile-client/pom.xml | 33 -------------------
systests/microprofile/client/weld/pom.xml | 55 +++++++++----------------------
3 files changed, 34 insertions(+), 73 deletions(-)
diff --git a/parent/pom.xml b/parent/pom.xml
index e27c8a5..5a674eb 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -237,6 +237,8 @@
<cxf.pmd.eclipse.ruleset.ext />
<cxf.resources.base.path />
<cxf.reactor.version>3.1.0.RELEASE</cxf.reactor.version>
+ <cxf.microprofile.rest.client.version>1.0</cxf.microprofile.rest.client.version>
+ <cxf.microprofile.config.version>1.1</cxf.microprofile.config.version>
</properties>
<build>
<resources>
@@ -1029,6 +1031,23 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.eclipse.microprofile.rest.client</groupId>
+ <artifactId>microprofile-rest-client-api</artifactId>
+ <version>${cxf.microprofile.rest.client.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.microprofile.rest.client</groupId>
+ <artifactId>microprofile-rest-client-tck</artifactId>
+ <version>${cxf.microprofile.rest.client.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.microprofile.config</groupId>
+ <artifactId>microprofile-config-api</artifactId>
+ <version>${cxf.microprofile.config.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>${cxf.slf4j.version}</version>
diff --git a/rt/rs/microprofile-client/pom.xml b/rt/rs/microprofile-client/pom.xml
index fa7644a..beb8514 100644
--- a/rt/rs/microprofile-client/pom.xml
+++ b/rt/rs/microprofile-client/pom.xml
@@ -97,7 +97,6 @@
<dependency>
<groupId>org.eclipse.microprofile.rest.client</groupId>
<artifactId>microprofile-rest-client-api</artifactId>
- <version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
@@ -112,29 +111,15 @@
<dependency>
<groupId>org.eclipse.microprofile.rest.client</groupId>
<artifactId>microprofile-rest-client-tck</artifactId>
- <version>1.0-SNAPSHOT</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
- <version>1.1</version>
- <scope>provided</scope>
- <optional>true</optional>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
- <version>1.2</version>
<scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jcache_1.0_spec</artifactId>
- <version>1.0-alpha-1</version>
- <scope>provided</scope>
- <optional>true</optional>
</dependency>
<dependency>
<groupId>cglib</groupId>
@@ -173,24 +158,6 @@
</dependencies>
<profiles>
<profile>
- <id>release-repo</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <repositories>
- <repository>
- <id>mp-rest-client</id>
- <url>https://oss.sonatype.org/content/repositories/orgeclipsemicroprofile-1037/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- </releases>
- </repository>
- </repositories>
- </profile>
- <profile>
<id>java9</id>
<activation>
<jdk>9</jdk>
diff --git a/systests/microprofile/client/weld/pom.xml b/systests/microprofile/client/weld/pom.xml
index 5e22ae4..ee731b2 100644
--- a/systests/microprofile/client/weld/pom.xml
+++ b/systests/microprofile/client/weld/pom.xml
@@ -29,15 +29,19 @@
<artifactId>cxf-systests-microprofile-weld</artifactId>
<name>Apache CXF System Tests - MicroProfile Rest Client TCK</name>
<properties>
- <microprofile.rest.client.version>1.0-SNAPSHOT</microprofile.rest.client.version>
- <geronimo.config.version>1.0</geronimo.config.version>
- <wiremock.params>--port=8765</wiremock.params>
+ <cxf.geronimo.config.version>1.0</cxf.geronimo.config.version>
+ <cxf.wiremock.params>--port=8765</cxf.wiremock.params>
+ <cxf.weld.se.version>2.4.5.Final</cxf.weld.se.version>
+ <cxf.arquillian.weld.container.version>2.0.0.Final</cxf.arquillian.weld.container.version>
+ <cxf.johnzon.tck.version>1.1.3</cxf.johnzon.tck.version>
+ <cxf.json.api.1.1.version>1.1</cxf.json.api.1.1.version>
+ <cxf.arquillian.version>1.1.14.Final</cxf.arquillian.version>
</properties>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.testng</groupId>
<artifactId>arquillian-testng-container</artifactId>
- <version>1.1.14.Final</version>
+ <version>${cxf.arquillian.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -48,49 +52,40 @@
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
- <version>2.4.5.Final</version>
+ <version>${cxf.weld.se.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-weld-embedded</artifactId>
- <version>2.0.0.Final</version>
+ <version>${cxf.arquillian.weld.container.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.rest.client</groupId>
<artifactId>microprofile-rest-client-tck</artifactId>
- <version>${microprofile.rest.client.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.johnzon</groupId>
- <artifactId>johnzon-core</artifactId>
- <version>1.1.3</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.johnzon</groupId>
<artifactId>johnzon-core</artifactId>
- <version>1.1.3</version>
+ <version>${cxf.johnzon.tck.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
- <version>1.1</version>
+ <version>${cxf.json.api.1.1.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
- <version>1.7.25</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.config</groupId>
<artifactId>geronimo-config-impl</artifactId>
- <version>1.0</version>
+ <version>${cxf.geronimo.config.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -102,7 +97,7 @@
<dependency>
<groupId>org.apache.johnzon</groupId>
<artifactId>johnzon-jsonb</artifactId>
- <version>1.1.3</version>
+ <version>${cxf.johnzon.tck.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -120,7 +115,7 @@
</goals>
<configuration>
<dir>target/classes</dir>
- <params>${wiremock.params}</params>
+ <params>${cxf.wiremock.params}</params>
</configuration>
</execution>
</executions>
@@ -139,24 +134,4 @@
</plugin>
</plugins>
</build>
- <profiles>
- <profile>
- <id>release-repo</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <repositories>
- <repository>
- <id>mp-rest-client</id>
- <url>https://oss.sonatype.org/content/repositories/orgeclipsemicroprofile-1037/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- </releases>
- </repository>
- </repositories>
- </profile>
- </profiles>
</project>
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 16/21: checkstyle fix
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 05436bc5bc43399aae5809a7d20f8065dcbcd829
Author: Andy McCright <j....@gmail.com>
AuthorDate: Tue Dec 19 15:38:40 2017 -0600
checkstyle fix
---
.../client/MicroProfileClientFactoryBean.java | 25 +++++++++++-----------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
index eee6b74..a94af36 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
@@ -18,6 +18,17 @@
*/
package org.apache.cxf.microprofile.client;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.core.Configuration;
+
import org.apache.cxf.common.util.ClassHelper;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.jaxrs.client.AbstractClient;
@@ -31,16 +42,6 @@ import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider;
import org.apache.cxf.microprofile.client.proxy.MicroProfileClientProxyImpl;
import org.eclipse.microprofile.rest.client.RestClientBuilder;
-import javax.ws.rs.client.ClientRequestFilter;
-import javax.ws.rs.client.ClientResponseFilter;
-import javax.ws.rs.core.Configuration;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
private final Comparator<ProviderInfo<?>> comparator;
private final List<Object> registeredProviders;
@@ -59,9 +60,9 @@ public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
registeredProviders = new ArrayList<>();
registeredProviders.addAll(processProviders());
if (!configuration.isDefaultExceptionMapperDisabled()) {
- registeredProviders.add(new ProviderInfo<>(new DefaultResponseExceptionMapper(),getBus(),false));
+ registeredProviders.add(new ProviderInfo<>(new DefaultResponseExceptionMapper(), getBus(), false));
}
- registeredProviders.add(new ProviderInfo<>(new JsrJsonpProvider(),getBus(),false));
+ registeredProviders.add(new ProviderInfo<>(new JsrJsonpProvider(), getBus(), false));
super.setProviders(registeredProviders);
}
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 14/21: [CXF-7579] Fixing parent path location.
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit f232a9d2335a06c4cb6d5603c1fa140c33c0b24a
Author: John D. Ament <jo...@apache.org>
AuthorDate: Tue Dec 19 15:05:35 2017 -0500
[CXF-7579] Fixing parent path location.
---
systests/microprofile/client/weld/pom.xml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/systests/microprofile/client/weld/pom.xml b/systests/microprofile/client/weld/pom.xml
index ee731b2..0235119 100644
--- a/systests/microprofile/client/weld/pom.xml
+++ b/systests/microprofile/client/weld/pom.xml
@@ -20,9 +20,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <artifactId>cxf-systests-cdi</artifactId>
+ <artifactId>cxf-microprofile-tck</artifactId>
<groupId>org.apache.cxf.systests</groupId>
<version>3.2.2-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 09/21: [CXF-7579] Add the default Json provider to each
client.
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit f33d4a0afdf794bfdbe5d96d655f41fdb90a1113
Author: John D. Ament <jo...@apache.org>
AuthorDate: Sat Dec 16 16:55:24 2017 -0500
[CXF-7579] Add the default Json provider to each client.
---
rt/rs/microprofile-client/pom.xml | 15 ++++++++-----
.../cxf/microprofile/client/JsonPProvider.java | 26 ++++++++++++++++++++++
.../client/MicroProfileClientFactoryBean.java | 1 +
systests/microprofile/client/weld/pom.xml | 15 +++++++++++--
4 files changed, 50 insertions(+), 7 deletions(-)
diff --git a/rt/rs/microprofile-client/pom.xml b/rt/rs/microprofile-client/pom.xml
index 402a528..fa7644a 100644
--- a/rt/rs/microprofile-client/pom.xml
+++ b/rt/rs/microprofile-client/pom.xml
@@ -100,6 +100,16 @@
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-extension-providers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.json</groupId>
+ <artifactId>javax.json-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
<groupId>org.eclipse.microprofile.rest.client</groupId>
<artifactId>microprofile-rest-client-tck</artifactId>
<version>1.0-SNAPSHOT</version>
@@ -160,11 +170,6 @@
<version>2.1</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.awaitility</groupId>
- <artifactId>awaitility</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<profiles>
<profile>
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/JsonPProvider.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/JsonPProvider.java
new file mode 100644
index 0000000..09bd122
--- /dev/null
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/JsonPProvider.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.microprofile.client;
+
+import javax.annotation.Priority;
+import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider;
+
+@Priority(Integer.MAX_VALUE)
+public class JsonPProvider extends JsrJsonpProvider {
+}
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
index 58cdfb3..6855740 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientFactoryBean.java
@@ -58,6 +58,7 @@ public class MicroProfileClientFactoryBean extends JAXRSClientFactoryBean {
if (!configuration.isDefaultExceptionMapperDisabled()) {
registeredProviders.add(new DefaultResponseExceptionMapper());
}
+ registeredProviders.add(new JsonPProvider());
super.setProviders(registeredProviders);
}
diff --git a/systests/microprofile/client/weld/pom.xml b/systests/microprofile/client/weld/pom.xml
index dff4f0d..990d344 100644
--- a/systests/microprofile/client/weld/pom.xml
+++ b/systests/microprofile/client/weld/pom.xml
@@ -69,9 +69,15 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <version>1.1.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
- <version>1.0</version>
+ <version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -92,6 +98,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-jsonb</artifactId>
+ <version>1.1.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
@@ -121,7 +133,6 @@
</dependenciesToScan>
<excludes>
<exclude>org.eclipse.microprofile.rest.client.tck.CustomHttpMethodTest</exclude>
- <exclude>org.eclipse.microprofile.rest.client.tck.InvokeWithJsonPProviderTest</exclude>
<exclude>org.eclipse.microprofile.rest.client.tck.InvalidInterfaceTest</exclude>
</excludes>
</configuration>
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 18/21: [CXF-7579] Fixing POM dependencies.
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit a949c7fed84637a8bf2396b4ebed93e2018a7aaf
Author: John D. Ament <jo...@apache.org>
AuthorDate: Tue Dec 19 20:11:28 2017 -0500
[CXF-7579] Fixing POM dependencies.
---
systests/microprofile/client/weld/pom.xml | 39 ++++---------
systests/microprofile/pom.xml | 94 +++++++++++++++++++++++++++++++
2 files changed, 104 insertions(+), 29 deletions(-)
diff --git a/systests/microprofile/client/weld/pom.xml b/systests/microprofile/client/weld/pom.xml
index 0235119..91edf98 100644
--- a/systests/microprofile/client/weld/pom.xml
+++ b/systests/microprofile/client/weld/pom.xml
@@ -28,78 +28,59 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>cxf-systests-microprofile-weld</artifactId>
- <name>Apache CXF System Tests - MicroProfile Rest Client TCK</name>
- <properties>
- <cxf.geronimo.config.version>1.0</cxf.geronimo.config.version>
- <cxf.wiremock.params>--port=8765</cxf.wiremock.params>
- <cxf.weld.se.version>2.4.5.Final</cxf.weld.se.version>
- <cxf.arquillian.weld.container.version>2.0.0.Final</cxf.arquillian.weld.container.version>
- <cxf.johnzon.tck.version>1.1.3</cxf.johnzon.tck.version>
- <cxf.json.api.1.1.version>1.1</cxf.json.api.1.1.version>
- <cxf.arquillian.version>1.1.14.Final</cxf.arquillian.version>
- </properties>
+ <name>Apache CXF System Tests - MicroProfile Rest Client TCK on Weld</name>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.testng</groupId>
<artifactId>arquillian-testng-container</artifactId>
- <version>${cxf.arquillian.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
- <version>${cxf.weld.se.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-weld-embedded</artifactId>
- <version>${cxf.arquillian.weld.container.version}</version>
- <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.rest.client</groupId>
- <artifactId>microprofile-rest-client-tck</artifactId>
+ <artifactId>microprofile-rest-client-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.johnzon</groupId>
<artifactId>johnzon-core</artifactId>
- <version>${cxf.johnzon.tck.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
- <version>${cxf.json.api.1.1.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.config</groupId>
<artifactId>geronimo-config-impl</artifactId>
- <version>${cxf.geronimo.config.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-mp-client</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.johnzon</groupId>
<artifactId>johnzon-jsonb</artifactId>
- <version>${cxf.johnzon.tck.version}</version>
- <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.microprofile.rest.client</groupId>
+ <artifactId>microprofile-rest-client-tck</artifactId>
</dependency>
</dependencies>
<build>
diff --git a/systests/microprofile/pom.xml b/systests/microprofile/pom.xml
index f8ff337..c35fe4b 100644
--- a/systests/microprofile/pom.xml
+++ b/systests/microprofile/pom.xml
@@ -29,6 +29,100 @@
<artifactId>cxf-systests</artifactId>
<version>3.2.2-SNAPSHOT</version>
</parent>
+ <properties>
+ <cxf.geronimo.config.version>1.0</cxf.geronimo.config.version>
+ <cxf.microprofile.rest.client.version>1.0</cxf.microprofile.rest.client.version>
+ <cxf.wiremock.params>--port=8765</cxf.wiremock.params>
+ <cxf.weld.se.version>2.4.5.Final</cxf.weld.se.version>
+ <cxf.arquillian.weld.container.version>2.0.0.Final</cxf.arquillian.weld.container.version>
+ <cxf.johnzon.tck.version>1.1.3</cxf.johnzon.tck.version>
+ <cxf.json.api.1.1.version>1.1</cxf.json.api.1.1.version>
+ <cxf.arquillian.version>1.1.14.Final</cxf.arquillian.version>
+ <cxf.slf4j.version>1.7.25</cxf.slf4j.version>
+ <cxf.commons.logging.version>1.2</cxf.commons.logging.version>
+ <cxf.javax.ws.rs.version>2.1</cxf.javax.ws.rs.version>
+ </properties>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.arquillian.testng</groupId>
+ <artifactId>arquillian-testng-container</artifactId>
+ <version>${cxf.arquillian.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>${cxf.commons.logging.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>${cxf.javax.ws.rs.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld.se</groupId>
+ <artifactId>weld-se-core</artifactId>
+ <version>${cxf.weld.se.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.container</groupId>
+ <artifactId>arquillian-weld-embedded</artifactId>
+ <version>${cxf.arquillian.weld.container.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.microprofile.rest.client</groupId>
+ <artifactId>microprofile-rest-client-api</artifactId>
+ <version>${cxf.microprofile.rest.client.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <version>${cxf.johnzon.tck.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.json</groupId>
+ <artifactId>javax.json-api</artifactId>
+ <version>${cxf.json.api.1.1.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <version>${cxf.slf4j.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.config</groupId>
+ <artifactId>geronimo-config-impl</artifactId>
+ <version>${cxf.geronimo.config.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-mp-client</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-jsonb</artifactId>
+ <version>${cxf.johnzon.tck.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.microprofile.rest.client</groupId>
+ <artifactId>microprofile-rest-client-tck</artifactId>
+ <version>${cxf.microprofile.rest.client.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
<modules>
<module>client/weld</module>
</modules>
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.
[cxf] 15/21: [CXF-7579] Simplify config lookup.
Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
johndament pushed a commit to branch mp-client
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 8e86a5d5369c4938874005b826bf2b90fcd6262c
Author: John D. Ament <jo...@apache.org>
AuthorDate: Tue Dec 19 16:32:50 2017 -0500
[CXF-7579] Simplify config lookup.
---
.../microprofile/client/MicroProfileClientConfigurableImpl.java | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
index ec28479..3df4246 100644
--- a/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
+++ b/rt/rs/microprofile-client/src/main/java/org/apache/cxf/microprofile/client/MicroProfileClientConfigurableImpl.java
@@ -18,7 +18,6 @@
*/
package org.apache.cxf.microprofile.client;
-import java.util.Optional;
import javax.ws.rs.RuntimeType;
import javax.ws.rs.client.ClientRequestFilter;
import javax.ws.rs.client.ClientResponseFilter;
@@ -58,12 +57,8 @@ public class MicroProfileClientConfigurableImpl<C extends Configurable<C>>
return (Boolean)prop;
} else {
Config config = ConfigProvider.getConfig();
- Optional<Boolean> optionalValue = config.getOptionalValue(CONFIG_KEY_DISABLE_MAPPER,
- Boolean.class);
- if (optionalValue.isPresent()) {
- return optionalValue.get();
- }
+ return config.getOptionalValue(CONFIG_KEY_DISABLE_MAPPER,
+ Boolean.class).orElse(false);
}
- return false;
}
}
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.