From e59a460525eccf36cc1e592bfb1947ae84d78724 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Sat, 25 May 2019 21:24:02 +0000 Subject: [PATCH] =?UTF-8?q?Improved:=20Turn=20=E2=80=98UtilIOTests?= =?UTF-8?q?=E2=80=99=20into=20a=20unit=20test=20class=20(OFBIZ-11067)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously this test was disabled, however since it now seems to work now we enable it. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1860019 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/ofbiz/base/util}/UtilIOTests.java | 37 +++++++------------ framework/base/testdef/basetests.xml | 1 - 2 files changed, 13 insertions(+), 25 deletions(-) rename framework/base/src/{main/java/org/apache/ofbiz/base/util/test => test/java/org/apache/ofbiz/base/util}/UtilIOTests.java (84%) diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/test/UtilIOTests.java b/framework/base/src/test/java/org/apache/ofbiz/base/util/UtilIOTests.java similarity index 84% rename from framework/base/src/main/java/org/apache/ofbiz/base/util/test/UtilIOTests.java rename to framework/base/src/test/java/org/apache/ofbiz/base/util/UtilIOTests.java index 784bfe28db..2a6a906d3d 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/test/UtilIOTests.java +++ b/framework/base/src/test/java/org/apache/ofbiz/base/util/UtilIOTests.java @@ -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 java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -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; -@SourceMonitored -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) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } + @Test 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 @@ public class UtilIOTests extends GenericTestCaseBase { assertEquals("readString stream UTF8:" + label, wanted, UtilIO.readString(new ByteArrayInputStream(toRead), UtilIO.getUtf8())); } + @Test 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 @@ public class UtilIOTests extends GenericTestCaseBase { 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()); } } diff --git a/framework/base/testdef/basetests.xml b/framework/base/testdef/basetests.xml index 99234287ca..0bebbaaebf 100644 --- a/framework/base/testdef/basetests.xml +++ b/framework/base/testdef/basetests.xml @@ -29,7 +29,6 @@ -