commit c13117a7c87ef3c9c5ad3d2f8475348d084087b3
Author: Ghislain Nadeau <[email protected]>
AuthorDate: Thu, 20 Jun 2013 22:33:41 -0400
Commit: Mauro Talevi <[email protected]>
CommitDate: Sun, 21 Jul 2013 18:45:28 +0200
JBEHAVE-930: Ensure unit tests pass without default encoding set to UTF-8.
diff --git a/jbehave-core/src/main/java/org/jbehave/core/io/IOUtils.java
b/jbehave-core/src/main/java/org/jbehave/core/io/IOUtils.java
index 08e84cf..1c8bebb 100644
--- a/jbehave-core/src/main/java/org/jbehave/core/io/IOUtils.java
+++ b/jbehave-core/src/main/java/org/jbehave/core/io/IOUtils.java
@@ -21,7 +21,7 @@ public class IOUtils {
*/
public static String toString(InputStream input, boolean close) throws
IOException {
try {
- return org.apache.commons.io.IOUtils.toString(input);
+ return org.apache.commons.io.IOUtils.toString(input, "UTF-8");
}
finally {
if ( close ) {
diff --git
a/jbehave-core/src/test/java/org/jbehave/core/io/IOUtilsBehaviour.java
b/jbehave-core/src/test/java/org/jbehave/core/io/IOUtilsBehaviour.java
index 301beb7..0135071 100644
--- a/jbehave-core/src/test/java/org/jbehave/core/io/IOUtilsBehaviour.java
+++ b/jbehave-core/src/test/java/org/jbehave/core/io/IOUtilsBehaviour.java
@@ -79,17 +79,17 @@ public class IOUtilsBehaviour {
// same for InputStream
@Test
public void shouldProcessInputStream() throws IOException {
- assertEquals("", IOUtils.toString(new
ByteArrayInputStream("".getBytes()), true));
- assertEquals("a", IOUtils.toString(new
ByteArrayInputStream("a".getBytes()), true));
- assertEquals("asdf", IOUtils.toString(new
ByteArrayInputStream("asdf".getBytes()), true));
- assertEquals("äöü", IOUtils.toString(new
ByteArrayInputStream("äöü".getBytes()), true));
+ assertEquals("", IOUtils.toString(new
ByteArrayInputStream("".getBytes("UTF-8")), true));
+ assertEquals("a", IOUtils.toString(new
ByteArrayInputStream("a".getBytes("UTF-8")), true));
+ assertEquals("asdf", IOUtils.toString(new
ByteArrayInputStream("asdf".getBytes("UTF-8")), true));
+ assertEquals("äöü", IOUtils.toString(new
ByteArrayInputStream("äöü".getBytes("UTF-8")), true));
- ByteArrayInputStream input = new
ByteArrayInputStream("asdf".getBytes());
+ ByteArrayInputStream input = new
ByteArrayInputStream("asdf".getBytes("UTF-8"));
assertEquals("asdf", IOUtils.toString(input, false));
input.close();
String longString=createLongString();
- assertEquals(longString, IOUtils.toString(new
ByteArrayInputStream(longString.getBytes()), true));
+ assertEquals(longString, IOUtils.toString(new
ByteArrayInputStream(longString.getBytes("UTF-8")), true));
assertEquals("##########", IOUtils.toString(new
FileInputStream("src/test/resources/testfile"), true));