Browse Source

REPORT-13402 【阻塞】【10.0.2回归】公式面板点不开=>调整代码

bugfix/10.0
plough 6 years ago
parent
commit
40f367e1d2
  1. 6
      designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java
  2. 36
      designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java

6
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) { private static boolean isCustomFormulaPath(String classFilePath) {
return !isJarPath(classFilePath) && isDebugMode(); return !isJarPath(classFilePath) && isNotDebugMode();
} }
private static boolean isDebugMode() { private static boolean isNotDebugMode() {
return !GeneralUtils.readBuildNO().contains("-"); return GeneralUtils.readBuildNO().contains("-");
} }
private static boolean isJarPath(String classFilePath) { private static boolean isJarPath(String classFilePath) {

36
designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java

@ -1,14 +1,24 @@
package com.fr.design.formula; 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.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.Assert.fail;
import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;
/** /**
* Created by plough on 2018/12/7. * Created by plough on 2018/12/7.
*/ */
@RunWith(PowerMockRunner.class)
@PrepareForTest(GeneralUtils.class)
public class FunctionConstantsTest { public class FunctionConstantsTest {
@Test @Test
public void testNewInstanceFail() throws Exception { public void testNewInstanceFail() throws Exception {
@ -37,4 +47,30 @@ public class FunctionConstantsTest {
NameAndFunctionList commonFunctionList = FunctionConstants.COMMON; NameAndFunctionList commonFunctionList = FunctionConstants.COMMON;
assertEquals(9, commonFunctionList.getDescriptions().length); 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).<Boolean>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).<Boolean>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).<Boolean>get());
classFilePath = "/Applications/FineReport_10.0_12_10/webapps/webroot/WEB-INF/classes/com/fr/function";
assertTrue(Reflect.on(FunctionConstants.class).call("isCustomFormulaPath", classFilePath).<Boolean>get());
}
} }

Loading…
Cancel
Save