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 2016/05/05 15:47:44 UTC
[1/2] cxf git commit: [CXF-6891] Adding the missing test resources
Repository: cxf
Updated Branches:
refs/heads/3.1.x-fixes 986231dea -> 4d7d3257d
[CXF-6891] Adding the missing test resources
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/4d7d3257
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/4d7d3257
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/4d7d3257
Branch: refs/heads/3.1.x-fixes
Commit: 4d7d3257d74ef1f7c74b65a802bf61ea4c9c2ea2
Parents: ebf80b5
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Thu May 5 16:43:32 2016 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Thu May 5 16:47:25 2016 +0100
----------------------------------------------------------------------
.../org/apache/cxf/helpers/IOUtilsTest.java | 57 ++++++++++++++++++++
.../apache/cxf/helpers/UnMarkedInputStream.java | 38 +++++++++++++
2 files changed, 95 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/4d7d3257/core/src/test/java/org/apache/cxf/helpers/IOUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/helpers/IOUtilsTest.java b/core/src/test/java/org/apache/cxf/helpers/IOUtilsTest.java
new file mode 100644
index 0000000..c0c8cc0
--- /dev/null
+++ b/core/src/test/java/org/apache/cxf/helpers/IOUtilsTest.java
@@ -0,0 +1,57 @@
+/**
+ * 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.helpers;
+
+
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class IOUtilsTest extends Assert {
+
+
+ @Test
+ public void testIsEmpty() throws Exception {
+ assertTrue(IOUtils.isEmpty(new ByteArrayInputStream(new byte[]{})));
+ }
+ @Test
+ public void testNonEmpty() throws Exception {
+ InputStream is = new ByteArrayInputStream("Hello".getBytes());
+ assertFalse(IOUtils.isEmpty(is));
+ assertEquals("Hello", IOUtils.toString(is));
+ }
+ @Test
+ public void testNonEmptyWithPushBack() throws Exception {
+ InputStream is = new PushbackInputStream(
+ new ByteArrayInputStream("Hello".getBytes()));
+ assertFalse(IOUtils.isEmpty(is));
+ assertEquals("Hello", IOUtils.toString(is));
+ }
+ @Test
+ public void testInputStreamWithNoMark() throws Exception {
+ String data = "this is some data";
+ InputStream is = new UnMarkedInputStream(data.getBytes());
+ assertFalse(IOUtils.isEmpty(is));
+ assertEquals(data, IOUtils.toString(is));
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/4d7d3257/core/src/test/java/org/apache/cxf/helpers/UnMarkedInputStream.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/helpers/UnMarkedInputStream.java b/core/src/test/java/org/apache/cxf/helpers/UnMarkedInputStream.java
new file mode 100644
index 0000000..39cc7a9
--- /dev/null
+++ b/core/src/test/java/org/apache/cxf/helpers/UnMarkedInputStream.java
@@ -0,0 +1,38 @@
+/**
+ * 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.helpers;
+
+import java.io.ByteArrayInputStream;
+
+public class UnMarkedInputStream extends ByteArrayInputStream {
+
+ public UnMarkedInputStream(byte[] buf) {
+ super(buf);
+ }
+
+ @Override
+ public boolean markSupported() {
+ return false;
+ }
+
+ @Override
+ public int available() {
+ return 0;
+ }
+}
[2/2] cxf git commit: Making it easier to reuse JAXRS
FeatureContextImpl
Posted by se...@apache.org.
Making it easier to reuse JAXRS FeatureContextImpl
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/ebf80b59
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ebf80b59
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ebf80b59
Branch: refs/heads/3.1.x-fixes
Commit: ebf80b597e06f26e681ca70464fe9f3135706280
Parents: 986231d
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Thu May 5 16:41:17 2016 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Thu May 5 16:47:25 2016 +0100
----------------------------------------------------------------------
.../apache/cxf/jaxrs/impl/ConfigurableImpl.java | 68 ---------------
.../cxf/jaxrs/impl/FeatureContextImpl.java | 91 ++++++++++++++++++++
.../jaxrs/JAXRS20ClientServerBookTest.java | 22 +++++
3 files changed, 113 insertions(+), 68 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/ebf80b59/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurableImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurableImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurableImpl.java
index e9c2cac..6d5c9dc 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurableImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurableImpl.java
@@ -26,7 +26,6 @@ import javax.ws.rs.RuntimeType;
import javax.ws.rs.core.Configurable;
import javax.ws.rs.core.Configuration;
import javax.ws.rs.core.Feature;
-import javax.ws.rs.core.FeatureContext;
import org.apache.cxf.jaxrs.utils.AnnotationUtils;
@@ -116,71 +115,4 @@ public class ConfigurableImpl<C extends Configurable<C>> implements Configurable
private C doRegister(Object provider, int bindingPriority, Class<?>... contracts) {
return register(provider, ConfigurationImpl.initContractsMap(bindingPriority, contracts));
}
-
- public static class FeatureContextImpl implements FeatureContext {
- private Configurable<?> cfg;
- public FeatureContextImpl(Configurable<?> cfg) {
- this.cfg = cfg;
- }
-
- @Override
- public Configuration getConfiguration() {
- return cfg.getConfiguration();
- }
-
- @Override
- public FeatureContext property(String name, Object value) {
- cfg.property(name, value);
- return this;
- }
-
- @Override
- public FeatureContext register(Class<?> cls) {
- cfg.register(cls);
- return this;
- }
-
- @Override
- public FeatureContext register(Object obj) {
- cfg.register(obj);
- return this;
- }
-
- @Override
- public FeatureContext register(Class<?> cls, int priority) {
- cfg.register(cls, priority);
- return this;
- }
-
- @Override
- public FeatureContext register(Class<?> cls, Class<?>... contract) {
- cfg.register(cls, contract);
- return this;
- }
-
- @Override
- public FeatureContext register(Class<?> cls, Map<Class<?>, Integer> map) {
- cfg.register(cls, map);
- return this;
- }
-
- @Override
- public FeatureContext register(Object obj, int priority) {
- cfg.register(obj, priority);
- return this;
- }
-
- @Override
- public FeatureContext register(Object obj, Class<?>... contract) {
- cfg.register(obj, contract);
- return this;
- }
-
- @Override
- public FeatureContext register(Object obj, Map<Class<?>, Integer> map) {
- cfg.register(obj, map);
- return this;
- }
-
- }
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/ebf80b59/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/FeatureContextImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/FeatureContextImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/FeatureContextImpl.java
new file mode 100644
index 0000000..47fadf0
--- /dev/null
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/FeatureContextImpl.java
@@ -0,0 +1,91 @@
+/**
+ * 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.jaxrs.impl;
+
+import java.util.Map;
+
+import javax.ws.rs.core.Configurable;
+import javax.ws.rs.core.Configuration;
+import javax.ws.rs.core.FeatureContext;
+
+public class FeatureContextImpl implements FeatureContext {
+ private Configurable<?> cfg;
+ public FeatureContextImpl(Configurable<?> cfg) {
+ this.cfg = cfg;
+ }
+
+ @Override
+ public Configuration getConfiguration() {
+ return cfg.getConfiguration();
+ }
+
+ @Override
+ public FeatureContext property(String name, Object value) {
+ cfg.property(name, value);
+ return this;
+ }
+
+ @Override
+ public FeatureContext register(Class<?> cls) {
+ cfg.register(cls);
+ return this;
+ }
+
+ @Override
+ public FeatureContext register(Object obj) {
+ cfg.register(obj);
+ return this;
+ }
+
+ @Override
+ public FeatureContext register(Class<?> cls, int priority) {
+ cfg.register(cls, priority);
+ return this;
+ }
+
+ @Override
+ public FeatureContext register(Class<?> cls, Class<?>... contract) {
+ cfg.register(cls, contract);
+ return this;
+ }
+
+ @Override
+ public FeatureContext register(Class<?> cls, Map<Class<?>, Integer> map) {
+ cfg.register(cls, map);
+ return this;
+ }
+
+ @Override
+ public FeatureContext register(Object obj, int priority) {
+ cfg.register(obj, priority);
+ return this;
+ }
+
+ @Override
+ public FeatureContext register(Object obj, Class<?>... contract) {
+ cfg.register(obj, contract);
+ return this;
+ }
+
+ @Override
+ public FeatureContext register(Object obj, Map<Class<?>, Integer> map) {
+ cfg.register(obj, map);
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/ebf80b59/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
index f1838f9..09815e0 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
@@ -40,6 +40,8 @@ import javax.ws.rs.client.ClientResponseFilter;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.InvocationCallback;
import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Feature;
+import javax.ws.rs.core.FeatureContext;
import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.HttpHeaders;
@@ -162,6 +164,17 @@ public class JAXRS20ClientServerBookTest extends AbstractBusClientServerTestBase
book = target.request("application/xml").get(BookInfo.class);
assertEquals(124L, book.getId());
}
+ @Test
+ public void testGetBookSpecProviderWithFeature() {
+ String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple";
+ Client client = ClientBuilder.newClient();
+ client.register(new ClientTestFeature());
+ WebTarget target = client.target(address);
+ BookInfo book = target.request("application/xml").get(BookInfo.class);
+ assertEquals(124L, book.getId());
+ book = target.request("application/xml").get(BookInfo.class);
+ assertEquals(124L, book.getId());
+ }
@Test
public void testGetBookWebTargetProvider() {
@@ -855,4 +868,13 @@ public class JAXRS20ClientServerBookTest extends AbstractBusClientServerTestBase
}
}
+ private static class ClientTestFeature implements Feature {
+
+ @Override
+ public boolean configure(FeatureContext context) {
+ context.register(new BookInfoReader());
+ return true;
+ }
+
+ }
}