svn commit: r1799417 - /ofbiz/ofbiz-framework/trunk/framework/entity/src/test/java/org/apache/ofbiz/entity/util/EntitySaxReaderTests.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1799417 - /ofbiz/ofbiz-framework/trunk/framework/entity/src/test/java/org/apache/ofbiz/entity/util/EntitySaxReaderTests.java

jacopoc
Author: jacopoc
Date: Wed Jun 21 09:41:38 2017
New Revision: 1799417

URL: http://svn.apache.org/viewvc?rev=1799417&view=rev
Log:
Fixed: unit test failure when "verbose" logging was on.
(OFBIZ-9305)

When print.verbose was set to true in debug.properties, the unit test
EntitySaxReaderTests.parse was failing because it is using some mock objects;
fixed by temporarily disabling the verbose logging during the test.

Thanks: William Wang for the report.

Modified:
    ofbiz/ofbiz-framework/trunk/framework/entity/src/test/java/org/apache/ofbiz/entity/util/EntitySaxReaderTests.java

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/test/java/org/apache/ofbiz/entity/util/EntitySaxReaderTests.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/test/java/org/apache/ofbiz/entity/util/EntitySaxReaderTests.java?rev=1799417&r1=1799416&r2=1799417&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/test/java/org/apache/ofbiz/entity/util/EntitySaxReaderTests.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/test/java/org/apache/ofbiz/entity/util/EntitySaxReaderTests.java Wed Jun 21 09:41:38 2017
@@ -18,15 +18,32 @@
  *******************************************************************************/
 package org.apache.ofbiz.entity.util;
 
+import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.entity.Delegator;
 import org.apache.ofbiz.entity.GenericValue;
 import org.apache.ofbiz.entity.model.ModelEntity;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
 public class EntitySaxReaderTests {
+    private boolean logVerboseOn;
+
+    @Before
+    public void initialize() {
+        logVerboseOn = Debug.isOn(Debug.VERBOSE); // save the current setting (to be restored after the tests)
+        Debug.set(Debug.VERBOSE, false); // disable verbose logging: this is necessary to avoid a test error in the "parse" unit test
+    }
+
+    @After
+    public void restore() {
+        Debug.set(Debug.VERBOSE, logVerboseOn); // restore the verbose log setting
+    }
+
+
     @Test
     public void constructorWithDefaultTimeout() {
         Delegator delegator = mock(Delegator.class);