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:43:50 UTC

cxf git commit: [CXF-6891] Adding the missing test resources

Repository: cxf
Updated Branches:
  refs/heads/master 702f83d5c -> 71d825cf7


[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/71d825cf
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/71d825cf
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/71d825cf

Branch: refs/heads/master
Commit: 71d825cf78b4a6c4329fa0ea8c6262359217193a
Parents: 702f83d
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:43:32 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/71d825cf/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/71d825cf/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;
+    }
+}