Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E9254200AC0 for ; Tue, 10 May 2016 01:38:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E79B9160A16; Mon, 9 May 2016 23:38:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 35132160A0F for ; Tue, 10 May 2016 01:38:09 +0200 (CEST) Received: (qmail 24082 invoked by uid 500); 9 May 2016 23:38:08 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 24065 invoked by uid 99); 9 May 2016 23:38:08 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 May 2016 23:38:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 21338DFDE3; Mon, 9 May 2016 23:38:08 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: reta@apache.org To: commits@cxf.apache.org Date: Mon, 09 May 2016 23:38:09 -0000 Message-Id: <0460a95dd1a94f4196597300f1367613@git.apache.org> In-Reply-To: <26606cf77214469789cf76e7c667d5eb@git.apache.org> References: <26606cf77214469789cf76e7c667d5eb@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [02/16] cxf git commit: [CXF-6891] Adding the missing test resources archived-at: Mon, 09 May 2016 23:38:10 -0000 [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-jaxrs-2.1 Commit: 71d825cf78b4a6c4329fa0ea8c6262359217193a Parents: 702f83d Author: Sergey Beryozkin Authored: Thu May 5 16:43:32 2016 +0100 Committer: Sergey Beryozkin 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; + } +}