You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2014/07/02 14:13:17 UTC
git commit: [CXF-5785] Applying a patch with the disabled test
Repository: cxf
Updated Branches:
refs/heads/master b6d3e1531 -> f0bb4ac2e
[CXF-5785] Applying a patch with the disabled test
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/f0bb4ac2
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f0bb4ac2
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f0bb4ac2
Branch: refs/heads/master
Commit: f0bb4ac2ee01d1c7696f1b281124d2bac9d222ea
Parents: b6d3e15
Author: Sergey Beryozkin <sb...@talend.com>
Authored: Wed Jul 2 13:12:59 2014 +0100
Committer: Sergey Beryozkin <sb...@talend.com>
Committed: Wed Jul 2 13:12:59 2014 +0100
----------------------------------------------------------------------
.../spring/MappingBeanDefinitionParser.java | 59 ++++++++++++++++++++
.../staxutils/transform/OutTransformWriter.java | 5 ++
.../cxf/jaxrs/spring/NamespaceHandler.java | 6 ++
.../jaxrs/security/JAXRSHttpsBookTest.java | 28 +++++++++-
.../jaxrs/security/jaxrs-https-client_old.xml | 57 +++++++++++++++++++
5 files changed, 153 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/f0bb4ac2/core/src/main/java/org/apache/cxf/configuration/spring/MappingBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/MappingBeanDefinitionParser.java b/core/src/main/java/org/apache/cxf/configuration/spring/MappingBeanDefinitionParser.java
new file mode 100644
index 0000000..776edc5
--- /dev/null
+++ b/core/src/main/java/org/apache/cxf/configuration/spring/MappingBeanDefinitionParser.java
@@ -0,0 +1,59 @@
+/**
+ * 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.configuration.spring;
+
+import java.util.Collections;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.staxutils.W3CDOMStreamWriter;
+import org.apache.cxf.staxutils.transform.OutTransformWriter;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.xml.ParserContext;
+
+public class MappingBeanDefinitionParser
+ extends org.springframework.beans.factory.xml.AbstractBeanDefinitionParser {
+
+ private final Map<String, String> transformMap;
+ public MappingBeanDefinitionParser(String oldns, String newns) {
+ transformMap = Collections.singletonMap("{" + oldns + "}*", "{" + newns + "}*");
+ }
+
+ @Override
+ protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
+ element = transformElement(element);
+ return (AbstractBeanDefinition)parserContext.getDelegate().parseCustomElement(element);
+ }
+ private Element transformElement(Element element) {
+
+ W3CDOMStreamWriter domWriter = new W3CDOMStreamWriter();
+ OutTransformWriter transformWriter = new OutTransformWriter(domWriter, transformMap);
+ try {
+ StaxUtils.copy(element, transformWriter);
+ } catch (XMLStreamException e) {
+ throw new RuntimeException(e);
+ }
+ return domWriter.getDocument().getDocumentElement();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/f0bb4ac2/core/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java b/core/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
index faf7a52..88bc7bb 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
@@ -56,6 +56,11 @@ public class OutTransformWriter extends DelegatingXMLStreamWriter {
private DelegatingNamespaceContext namespaceContext;
public OutTransformWriter(XMLStreamWriter writer,
+ Map<String, String> outMap) {
+ this(writer, outMap, null, null, null, false, null);
+ }
+
+ public OutTransformWriter(XMLStreamWriter writer,
Map<String, String> outMap,
Map<String, String> append,
List<String> dropEls,
http://git-wip-us.apache.org/repos/asf/cxf/blob/f0bb4ac2/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/NamespaceHandler.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/NamespaceHandler.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/NamespaceHandler.java
index b50fbab..1762514 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/NamespaceHandler.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/NamespaceHandler.java
@@ -18,6 +18,7 @@
*/
package org.apache.cxf.jaxrs.spring;
+import org.apache.cxf.configuration.spring.MappingBeanDefinitionParser;
import org.apache.cxf.configuration.spring.StringBeanDefinitionParser;
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
@@ -25,5 +26,10 @@ public class NamespaceHandler extends NamespaceHandlerSupport {
public void init() {
registerBeanDefinitionParser("server", new JAXRSServerFactoryBeanDefinitionParser());
registerBeanDefinitionParser("schemaLocation", new StringBeanDefinitionParser());
+
+ //for 2.x client object parsing
+ MappingBeanDefinitionParser mapping =
+ new MappingBeanDefinitionParser("http://cxf.apache.org/jaxrs", "http://cxf.apache.org/jaxrs-client");
+ registerBeanDefinitionParser("client", mapping);
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/f0bb4ac2/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSHttpsBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSHttpsBookTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSHttpsBookTest.java
index 7fd3be9..0ebdcc6 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSHttpsBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSHttpsBookTest.java
@@ -33,12 +33,12 @@ import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.systest.jaxrs.Book;
import org.apache.cxf.systest.jaxrs.BookStore;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
public class JAXRSHttpsBookTest extends AbstractBusClientServerTestBase {
public static final String PORT = BookHttpsServer.PORT;
@@ -52,6 +52,8 @@ public class JAXRSHttpsBookTest extends AbstractBusClientServerTestBase {
"org/apache/cxf/systest/jaxrs/security/jaxrs-https-client4.xml";
private static final String CLIENT_CONFIG_FILE5 =
"org/apache/cxf/systest/jaxrs/security/jaxrs-https-client5.xml";
+ private static final String CLIENT_CONFIG_FILE_OLD =
+ "org/apache/cxf/systest/jaxrs/security/jaxrs-https-client_old.xml";
@BeforeClass
public static void startServers() throws Exception {
createStaticBus("org/apache/cxf/systest/jaxrs/security/jaxrs-https-server.xml");
@@ -128,6 +130,28 @@ public class JAXRSHttpsBookTest extends AbstractBusClientServerTestBase {
ctx.close();
}
+ @Test
+ @Ignore("Works in the studio only if local jaxrs.xsd is updated to have jaxrs:client")
+ public void testGetBook123WebClientFromSpringWildcardOldJaxrsClient() throws Exception {
+ ClassPathXmlApplicationContext ctx =
+ new ClassPathXmlApplicationContext(new String[] {CLIENT_CONFIG_FILE_OLD});
+ Object bean = ctx.getBean("bookService.proxyFactory");
+ assertNotNull(bean);
+ JAXRSClientFactoryBean cfb = (JAXRSClientFactoryBean) bean;
+
+ WebClient wc = (WebClient)cfb.create();
+ assertEquals("https://localhost:" + PORT, wc.getBaseURI().toString());
+
+ wc.accept("application/xml");
+ wc.path("bookstore/securebooks/123");
+ TheBook b = wc.get(TheBook.class);
+
+ assertEquals(b.getId(), 123);
+ b = wc.get(TheBook.class);
+ assertEquals(b.getId(), 123);
+ ctx.close();
+ }
+
private void doTestGetBook123ProxyFromSpring(String cfgFile) throws Exception {
ClassPathXmlApplicationContext ctx =
http://git-wip-us.apache.org/repos/asf/cxf/blob/f0bb4ac2/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https-client_old.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https-client_old.xml b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https-client_old.xml
new file mode 100644
index 0000000..373a1d2
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/jaxrs-https-client_old.xml
@@ -0,0 +1,57 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:http="http://cxf.apache.org/transports/http/configuration"
+ xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+ xmlns:cxf="http://cxf.apache.org/core"
+ xmlns:sec="http://cxf.apache.org/configuration/security"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+ http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
+ http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd">
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+ <!-- -->
+ <!-- HTTP/S configuration for proxy & web clients -->
+ <!-- -->
+ <http:conduit name="*.http-conduit">
+ <http:client ConnectionTimeout="3000000" ReceiveTimeout="3000000"/>
+ <http:tlsClientParameters disableCNCheck="true">
+ <sec:keyManagers keyPassword="password">
+ <sec:keyStore type="JKS" password="password" file="src/test/java/org/apache/cxf/systest/http/resources/Morpit.jks"/>
+ </sec:keyManagers>
+ <sec:trustManagers>
+ <sec:keyStore type="JKS" password="password" file="src/test/java/org/apache/cxf/systest/http/resources/Truststore.jks"/>
+ </sec:trustManagers>
+ </http:tlsClientParameters>
+ </http:conduit>
+ <jaxrs:client id="bookService" address="https://localhost:${testutil.ports.jaxrs-https}" serviceClass="org.apache.cxf.jaxrs.client.WebClient">
+ <jaxrs:providers>
+ <bean class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
+ <property name="inTransformElements">
+ <map>
+ <entry key="Book" value="TheBook"/>
+ </map>
+ </property>
+ </bean>
+ </jaxrs:providers>
+ </jaxrs:client>
+</beans>