Skip to content
Browse files
Improved: Turn ‘UtilIOTests’ into a unit test class

Previously this test was disabled, however since it now seems to work
now we enable it.

git-svn-id: 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed May 25, 2019
1 parent 2d5e81c commit e59a460525eccf36cc1e592bfb1947ae84d78724
@@ -1,4 +1,4 @@
* 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
@@ -15,36 +15,24 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
package org.apache.ofbiz.base.util.test;
package org.apache.ofbiz.base.util;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;


import org.apache.ofbiz.base.lang.SourceMonitored;
import org.apache.ofbiz.base.test.GenericTestCaseBase;
import org.apache.ofbiz.base.util.UtilIO;
import org.junit.Test;

public class UtilIOTests extends GenericTestCaseBase {
public class UtilIOTests {
private static final byte[] trademarkBytes = new byte[] {
(byte) 0xE2, (byte) 0x84, (byte) 0xA2
public UtilIOTests(String name) {

protected void setUp() throws Exception {

protected void tearDown() throws Exception {

public void testReadString() throws Exception {
readStringTest_0("unix line ending", "\n", new byte[] { 0x0A });
readStringTest_0("mac line ending", "\r", new byte[] { 0x0D });
@@ -89,6 +77,7 @@ private static void readStringTest_1(String label, String wanted, byte[] toRead)
assertEquals("readString stream UTF8:" + label, wanted, UtilIO.readString(new ByteArrayInputStream(toRead), UtilIO.getUtf8()));

public void testWriteString() throws Exception {
writeStringTest_0("unix line ending", "\n", new byte[] { 0x0A });
writeStringTest_0("mac line ending", "\r", new byte[] { 0x0D });
@@ -110,12 +99,12 @@ private static void writeStringTest_0(String label, String lineSeparator, byte[]
private static void writeStringTest_1(String label, byte[] wanted, String toWrite) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
UtilIO.writeString(baos, toWrite);
assertEquals("writeString default:" + label, wanted, baos.toByteArray());
assertArrayEquals("writeString default:" + label, wanted, baos.toByteArray());
baos = new ByteArrayOutputStream();
UtilIO.writeString(baos, "UTF-8", toWrite);
assertEquals("writeString UTF-8:" + label, wanted, baos.toByteArray());
assertArrayEquals("writeString UTF-8:" + label, wanted, baos.toByteArray());
baos = new ByteArrayOutputStream();
UtilIO.writeString(baos, UtilIO.getUtf8(), toWrite);
assertEquals("writeString UTF8:" + label, wanted, baos.toByteArray());
assertArrayEquals("writeString UTF8:" + label, wanted, baos.toByteArray());
@@ -29,7 +29,6 @@
<junit-test-suite class-name="org.apache.ofbiz.base.util.collections.test.FlexibleMapAccessorTests"/>
<junit-test-suite class-name="org.apache.ofbiz.base.conversion.test.TestBooleanConverters"/>
<junit-test-suite class-name="org.apache.ofbiz.base.conversion.test.TestJSONConverters"/>
<!--junit-test-suite class-name="org.apache.ofbiz.base.util.test.UtilIOTests"/-->
<junit-test-suite class-name="org.apache.ofbiz.base.test.BaseUnitTests"/>
<groovy-test-suite name="simple" location="component://base/groovyScripts/test/SimpleTests.groovy"/>

0 comments on commit e59a460

Please sign in to comment.