You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by em...@apache.org on 2016/04/11 08:49:51 UTC
[1/2] cxf git commit: Revert previous wrong commit "Change test to
demostrate the real issue" (This reverts commit
9505a3c7c82691da2bad94459702a665b14420fa).
Repository: cxf
Updated Branches:
refs/heads/master 9505a3c7c -> e37c00d5c
Revert previous wrong commit "Change test to demostrate the real issue"
(This reverts commit 9505a3c7c82691da2bad94459702a665b14420fa).
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/aed1b1d4
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/aed1b1d4
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/aed1b1d4
Branch: refs/heads/master
Commit: aed1b1d45ea12b1b1a7f083f756c27ed914ad9b7
Parents: 9505a3c
Author: Jim Ma <em...@apache.org>
Authored: Mon Apr 11 14:42:51 2016 +0800
Committer: Jim Ma <em...@apache.org>
Committed: Mon Apr 11 14:45:12 2016 +0800
----------------------------------------------------------------------
.../java/org/apache/cxf/systest/jaxrs/BookApplication2.java | 2 +-
.../cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/aed1b1d4/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookApplication2.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookApplication2.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookApplication2.java
index c77e636..b424f7d 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookApplication2.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookApplication2.java
@@ -22,7 +22,7 @@ import javax.servlet.ServletContext;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Context;
-@ApplicationPath("/thebooks2%21")
+@ApplicationPath("/the%20books2")
public class BookApplication2 extends BookApplication {
public BookApplication2(@Context ServletContext sc) {
super(sc);
http://git-wip-us.apache.org/repos/asf/cxf/blob/aed1b1d4/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
index 9bb5760..75e966e 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
@@ -39,7 +39,6 @@ import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
public class JAXRSClientServerNonSpringBookTest extends AbstractBusClientServerTestBase {
@@ -181,10 +180,10 @@ public class JAXRSClientServerNonSpringBookTest extends AbstractBusClientServerT
assertEquals("TheBook", r.getHeaderString("BookWriter"));
}
- @Ignore
+ @Test
public void testGetBook123TwoApplications() throws Exception {
doTestPerRequest("http://localhost:" + PORT + "/application6/thebooks/bookstore2/bookheaders");
- doTestPerRequest("http://localhost:" + PORT + "/application6/thebooks2!/bookstore2/book%20headers");
+ doTestPerRequest("http://localhost:" + PORT + "/application6/the%20books2/bookstore2/book%20headers");
}
private Response doTestPerRequest(String address) throws Exception {
[2/2] cxf git commit: [CXF-6861]:Add JAXBProviderTest
Posted by em...@apache.org.
[CXF-6861]:Add JAXBProviderTest
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/e37c00d5
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e37c00d5
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e37c00d5
Branch: refs/heads/master
Commit: e37c00d5cc8cf17d6875090654caef6162b363f1
Parents: aed1b1d
Author: Jim Ma <em...@apache.org>
Authored: Mon Apr 11 14:48:38 2016 +0800
Committer: Jim Ma <em...@apache.org>
Committed: Mon Apr 11 14:48:38 2016 +0800
----------------------------------------------------------------------
.../systest/jaxrs/provider/CXFJaxbProvider.java | 69 +++++++++++++++
.../cxf/systest/jaxrs/provider/CXFResource.java | 33 ++++++++
.../jaxrs/provider/JAXBProviderTest.java | 89 ++++++++++++++++++++
3 files changed, 191 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/e37c00d5/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/CXFJaxbProvider.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/CXFJaxbProvider.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/CXFJaxbProvider.java
new file mode 100644
index 0000000..b4bd527
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/CXFJaxbProvider.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.systest.jaxrs.provider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import javax.xml.bind.JAXBElement;
+
+@Provider
+public class CXFJaxbProvider implements MessageBodyReader<JAXBElement<?>>, MessageBodyWriter<JAXBElement<?>> {
+
+ @Override
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return JAXBElement.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public long getSize(JAXBElement<?> t, Class<?> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType) {
+ return t.getValue().toString().length() + 2;
+ }
+
+ @Override
+ public void writeTo(JAXBElement<?> t, Class<?> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType, MultivaluedMap<String, Object> httpHeaders,
+ OutputStream entityStream) throws IOException, WebApplicationException {
+ entityStream.write("WriteInCXFJaxbProvider".getBytes());
+ }
+
+ @Override
+ public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+ return isWriteable(type, genericType, annotations, mediaType);
+ }
+
+ @Override
+ public JAXBElement<String> readFrom(Class<JAXBElement<?>> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType,
+ MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
+ throws IOException, WebApplicationException {
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/e37c00d5/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/CXFResource.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/CXFResource.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/CXFResource.java
new file mode 100644
index 0000000..5f3a7d0
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/CXFResource.java
@@ -0,0 +1,33 @@
+/**
+ * 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.systest.jaxrs.provider;
+
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.xml.bind.JAXBElement;
+
+@Path("resource")
+public class CXFResource {
+
+ @Path("jaxb")
+ @POST
+ public JAXBElement<String> jaxb(JAXBElement<String> jaxb) {
+ return jaxb;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/e37c00d5/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/JAXBProviderTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/JAXBProviderTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/JAXBProviderTest.java
new file mode 100644
index 0000000..a6d6a52
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/provider/JAXBProviderTest.java
@@ -0,0 +1,89 @@
+/**
+ * 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.systest.jaxrs.provider;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class JAXBProviderTest extends AbstractBusClientServerTestBase {
+ public static final String PORT = allocatePort(JAXBProviderTest.class);
+
+ @Ignore
+ public static class Server extends AbstractBusTestServerBase {
+ protected void run() {
+ final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
+ sf.setResourceClasses(CXFResource.class);
+ sf.setProvider(new CXFJaxbProvider());
+ sf.setAddress("http://localhost:" + PORT + "/");
+ sf.create();
+ }
+
+ public static void main(String[] args) {
+ try {
+ Server s = new Server();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+ }
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ AbstractResourceInfo.clearAllMaps();
+ // keep out of process due to stack traces testing failures
+ assertTrue("server did not launch correctly", launchServer(Server.class, true));
+ createStaticBus();
+ }
+
+ @Test
+ public void testNoResultsAreReturned() throws Exception {
+ WebClient client = WebClient.create("http://localhost:" + PORT + "/resource/jaxb");
+ WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(3000000);
+
+ List<String> values = new ArrayList<String>();
+ values.add(MediaType.APPLICATION_XML);
+ client.getHeaders().put("content-type", values);
+ JAXBElement<String> test = new JAXBElement<String>(new QName("org.apache.cxf", "jaxbelement"),
+ String.class, "test");
+ Response response = client.post(test);
+ String result = response.readEntity(String.class);
+ Assert.assertTrue(result.contains("<jaxbelement xmlns=\"org.apache.cxf\">test</jaxbelement>"));
+ Assert.assertFalse(result.contains("WriteInCXFJaxbProvider"));
+ }
+}