You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by je...@apache.org on 2009/11/10 04:06:30 UTC
svn commit: r834316 -
/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Streams.java
Author: jessewilson
Date: Tue Nov 10 03:06:30 2009
New Revision: 834316
URL: http://svn.apache.org/viewvc?rev=834316&view=rev
Log:
A helper class for writing I/O tests. I couldn't find a location for general purpose test utilities like this one, so I created a new one.
Added:
harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Streams.java
Added: harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Streams.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Streams.java?rev=834316&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Streams.java (added)
+++ harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Streams.java Tue Nov 10 03:06:30 2009
@@ -0,0 +1,41 @@
+/*
+ * 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 tests.support;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Utility methods for working with byte and character streams.
+ */
+public class Streams {
+
+ /**
+ * Drains the stream into a byte array and returns the result.
+ */
+ public static byte[] bytesFromStream(InputStream source) throws IOException {
+ byte[] buffer = new byte[1024];
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ int count;
+ while ((count = source.read(buffer)) != -1) {
+ out.write(buffer, 0, count);
+ }
+ return out.toByteArray();
+ }
+}
Re: svn commit: r834316 - /harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Streams.java
Posted by Tim Ellison <t....@gmail.com>.
On 10/Nov/2009 04:01, Nathan Beyer wrote:
> Jesse, Make sure to setup your SVN config to enable auto-props such
> that new files have 'svn:eol-style=native'.
Details are in here http://wiki.apache.org/harmony/NewCommitter
Regards,
Tim
Re: svn commit: r834316 - /harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Streams.java
Posted by Nathan Beyer <nd...@apache.org>.
Jesse, Make sure to setup your SVN config to enable auto-props such
that new files have 'svn:eol-style=native'.
Thanks
On Mon, Nov 9, 2009 at 9:06 PM, <je...@apache.org> wrote:
> Author: jessewilson
> Date: Tue Nov 10 03:06:30 2009
> New Revision: 834316
>
> URL: http://svn.apache.org/viewvc?rev=834316&view=rev
> Log:
> A helper class for writing I/O tests. I couldn't find a location for general purpose test utilities like this one, so I created a new one.
>
> Added:
> harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Streams.java
>
> Added: harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Streams.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Streams.java?rev=834316&view=auto
> ==============================================================================
> --- harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Streams.java (added)
> +++ harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Streams.java Tue Nov 10 03:06:30 2009
> @@ -0,0 +1,41 @@
> +/*
> + * 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 tests.support;
> +
> +import java.io.ByteArrayOutputStream;
> +import java.io.IOException;
> +import java.io.InputStream;
> +
> +/**
> + * Utility methods for working with byte and character streams.
> + */
> +public class Streams {
> +
> + /**
> + * Drains the stream into a byte array and returns the result.
> + */
> + public static byte[] bytesFromStream(InputStream source) throws IOException {
> + byte[] buffer = new byte[1024];
> + ByteArrayOutputStream out = new ByteArrayOutputStream();
> + int count;
> + while ((count = source.read(buffer)) != -1) {
> + out.write(buffer, 0, count);
> + }
> + return out.toByteArray();
> + }
> +}
>
>
>