Author: mthl
Date: Sat May 25 21:29:31 2019
New Revision: 1860022

URL: http://svn.apache.org/viewvc?rev=1860022&view=rev
Log:
Improved: Turn ‘BaseUnitTests’ into a unit test class
(OFBIZ-11067)

Added:
    
ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/test/
    
ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/test/BaseUnitTests.java
   (with props)
Removed:
    
ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/test/BaseUnitTests.java
Modified:
    ofbiz/ofbiz-framework/trunk/framework/base/testdef/basetests.xml

Added: 
ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/test/BaseUnitTests.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/test/BaseUnitTests.java?rev=1860022&view=auto
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/test/BaseUnitTests.java
 (added)
+++ 
ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/test/BaseUnitTests.java
 Sat May 25 21:29:31 2019
@@ -0,0 +1,98 @@
+/*
+ * 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 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;
+
+public class BaseUnitTests {
+
+    @Test
+    public void testDebug() {
+        boolean debugVerbose = Debug.get(Debug.VERBOSE);
+        boolean debugInfo = Debug.get(Debug.INFO);
+        try {
+            Debug.set(Debug.VERBOSE, true);
+            assertTrue(Debug.verboseOn());
+            Debug.set(Debug.VERBOSE, false);
+            assertFalse(Debug.verboseOn());
+            Debug.set(Debug.INFO, true);
+            assertTrue(Debug.infoOn());
+        } finally {
+            Debug.set(Debug.VERBOSE, debugVerbose);
+            Debug.set(Debug.INFO, debugInfo);
+        }
+    }
+
+    @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));
+        assertEquals("Hex conversions", testArray[0], result[0]);
+    }
+
+}

Propchange: 
ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/test/BaseUnitTests.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/test/BaseUnitTests.java
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: 
ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/test/BaseUnitTests.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/ofbiz-framework/trunk/framework/base/testdef/basetests.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/testdef/basetests.xml?rev=1860022&r1=1860021&r2=1860022&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/testdef/basetests.xml (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/testdef/basetests.xml Sat May 25 
21:29:31 2019
@@ -27,7 +27,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.test.BaseUnitTests"/>
         <groovy-test-suite name="simple" 
location="component://base/groovyScripts/test/SimpleTests.groovy"/>
     </test-group>
 </test-suite>


Reply via email to