From 40f367e1d2b3fff16568dd4cdaa18dffb7edc9a8 Mon Sep 17 00:00:00 2001 From: plough Date: Tue, 11 Dec 2018 11:22:49 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-13402=20=E3=80=90=E9=98=BB=E5=A1=9E?= =?UTF-8?q?=E3=80=91=E3=80=9010.0.2=E5=9B=9E=E5=BD=92=E3=80=91=E5=85=AC?= =?UTF-8?q?=E5=BC=8F=E9=9D=A2=E6=9D=BF=E7=82=B9=E4=B8=8D=E5=BC=80=3D>?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/formula/FunctionConstants.java | 6 ++-- .../design/formula/FunctionConstantsTest.java | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java b/designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java index 0166c269b..eee75a222 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java +++ b/designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java @@ -102,11 +102,11 @@ public final class FunctionConstants { } private static boolean isCustomFormulaPath(String classFilePath) { - return !isJarPath(classFilePath) && isDebugMode(); + return !isJarPath(classFilePath) && isNotDebugMode(); } - private static boolean isDebugMode() { - return !GeneralUtils.readBuildNO().contains("-"); + private static boolean isNotDebugMode() { + return GeneralUtils.readBuildNO().contains("-"); } private static boolean isJarPath(String classFilePath) { diff --git a/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java b/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java index 33cfd577d..75c9c9e5b 100644 --- a/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java +++ b/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java @@ -1,14 +1,24 @@ package com.fr.design.formula; +import com.fr.general.GeneralUtils; +import com.fr.invoke.Reflect; +import org.easymock.EasyMock; import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import static junit.framework.Assert.fail; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertTrue; +import static org.junit.Assert.assertFalse; /** * Created by plough on 2018/12/7. */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(GeneralUtils.class) public class FunctionConstantsTest { @Test public void testNewInstanceFail() throws Exception { @@ -37,4 +47,30 @@ public class FunctionConstantsTest { NameAndFunctionList commonFunctionList = FunctionConstants.COMMON; assertEquals(9, commonFunctionList.getDescriptions().length); } + + @Test + public void testIsCustomFormulaPathRunWithCode() { + PowerMock.mockStatic(GeneralUtils.class); + EasyMock.expect(GeneralUtils.readBuildNO()).andReturn("不是安装版本").anyTimes(); + PowerMock.replayAll(); + + String classFilePath = "/Users/plough/.m2/repository/com/fr/core/fine-core/10.0-RELEASE-SNAPSHOT/fine-core-10.0-RELEASE-20181211.024527-499.jar!/com/fr/function"; + assertFalse(Reflect.on(FunctionConstants.class).call("isCustomFormulaPath", classFilePath).get()); + + classFilePath = "/Users/plough/work/new_10_release_finereport/engine-settings/env/webroot/WEB-INF/classes/com/fr/function"; + assertFalse(Reflect.on(FunctionConstants.class).call("isCustomFormulaPath", classFilePath).get()); + } + + @Test + public void testIsCustomFormulaPathRunWithJar() { + PowerMock.mockStatic(GeneralUtils.class); + EasyMock.expect(GeneralUtils.readBuildNO()).andReturn("Build#release-2018.12.10.12.11.09.95").anyTimes(); + PowerMock.replayAll(); + + String classFilePath = "file:/Applications/FineReport_10.0_12_10/webapps/webroot/WEB-INF/lib/fine-report-engine-10.0.jar!/com/fr/function"; + assertFalse(Reflect.on(FunctionConstants.class).call("isCustomFormulaPath", classFilePath).get()); + + classFilePath = "/Applications/FineReport_10.0_12_10/webapps/webroot/WEB-INF/classes/com/fr/function"; + assertTrue(Reflect.on(FunctionConstants.class).call("isCustomFormulaPath", classFilePath).get()); + } }