|
|
|
@ -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).<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()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|