From fb8705dbf0ca3555172c4e9650d169da817e0750 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Sat, 25 May 2019 21:29:31 +0000 Subject: [PATCH] =?UTF-8?q?Improved:=20Turn=20=E2=80=98BaseUnitTests?= =?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 git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1860022 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/ofbiz/base/test/BaseUnitTests.java | 30 +++++++++++++------ framework/base/testdef/basetests.xml | 1 - 2 files changed, 21 insertions(+), 10 deletions(-) rename framework/base/src/{main => test}/java/org/apache/ofbiz/base/test/BaseUnitTests.java (90%) diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/test/BaseUnitTests.java b/framework/base/src/test/java/org/apache/ofbiz/base/test/BaseUnitTests.java similarity index 90% rename from framework/base/src/main/java/org/apache/ofbiz/base/test/BaseUnitTests.java rename to framework/base/src/test/java/org/apache/ofbiz/base/test/BaseUnitTests.java index ffee7d1da6..b745d64369 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/test/BaseUnitTests.java +++ b/framework/base/src/test/java/org/apache/ofbiz/base/test/BaseUnitTests.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,22 +15,22 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - *******************************************************************************/ + */ package org.apache.ofbiz.base.test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.StringUtil; import org.apache.ofbiz.base.util.UtilFormatOut; import org.apache.ofbiz.base.util.UtilValidate; +import org.junit.Test; -import junit.framework.TestCase; - -public class BaseUnitTests extends TestCase { - - public BaseUnitTests(String name) { - super(name); - } +public class BaseUnitTests { + @Test public void testDebug() { boolean debugVerbose = Debug.get(Debug.VERBOSE); boolean debugInfo = Debug.get(Debug.INFO); @@ -47,36 +47,48 @@ public class BaseUnitTests extends TestCase { } } + @Test public void testFormatPrintableCreditCard_1() { assertEquals("test 4111111111111111 to ************111", "************1111", UtilFormatOut.formatPrintableCreditCard("4111111111111111")); } + @Test public void testFormatPrintableCreditCard_2() { assertEquals("test 4111 to 4111", "4111", UtilFormatOut.formatPrintableCreditCard("4111")); } + @Test public void testFormatPrintableCreditCard_3() { assertEquals("test null to null", null, UtilFormatOut.formatPrintableCreditCard(null)); } + + @Test public void testIsDouble_1() { assertFalse(UtilValidate.isDouble("10.0", true, true, 2, 2)); } + + @Test public void testIsFloat_1() { assertFalse(UtilValidate.isFloat("10.0", true, true, 2, 2)); } + + @Test public void testIsDouble_2() { assertTrue(UtilValidate.isDouble("10.000", true, true, 3, 3)); } + + @Test public void testIsFloat_2() { assertTrue(UtilValidate.isFloat("10.000", true, true, 3, 3)); } + @Test public void testStringUtil() { byte[] testArray = {-1}; byte[] result = StringUtil.fromHexString(StringUtil.toHexString(testArray)); diff --git a/framework/base/testdef/basetests.xml b/framework/base/testdef/basetests.xml index bdd2988857..b1458e3e2f 100644 --- a/framework/base/testdef/basetests.xml +++ b/framework/base/testdef/basetests.xml @@ -27,7 +27,6 @@ -