From 07361237d8467de77e3d2c86046090433f041b92 Mon Sep 17 00:00:00 2001 From: "Levy.Xie" Date: Mon, 19 Jun 2023 17:04:07 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-94637=20=E5=8D=95=E6=B5=8B=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 + .../com/fr/design/formula/FormulaPaneTest.java | 2 +- .../design/formula/FunctionConstantsTest.java | 12 +++++++++++- .../icombocheckbox/UICheckListPopupTest.java | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 73aede69a1..68e9681694 100644 --- a/build.gradle +++ b/build.gradle @@ -90,6 +90,7 @@ allprojects { testImplementation 'org.easymock:easymock:3.5.1' testImplementation 'org.powermock:powermock-module-junit4:1.7.1' testImplementation 'org.powermock:powermock-api-easymock:1.7.1' + testImplementation 'org.powermock:powermock-api-mockito2:1.7.4' testImplementation 'junit:junit:4.12' } diff --git a/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java b/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java index 4ac71b5ac0..d804ec532b 100644 --- a/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java +++ b/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java @@ -17,7 +17,7 @@ public class FormulaPaneTest extends TestCase { @Test public void testSimilarComparator() { String[] strs = new String[] {"ScriptEval", "SPLIT", "SUMPRECISE"}; - String[] result = new String[] {"SPLIT", "ScriptEval", "SUMPRECISE"}; + String[] result = new String[] {"SPLIT", "SUMPRECISE", "ScriptEval",}; Arrays.sort(strs, new FormulaPane.SimilarComparator("sp")); Assert.assertArrayEquals(result, strs); } 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 b53d47780c..1c00f5bdc1 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,12 +1,16 @@ package com.fr.design.formula; +import com.fr.design.i18n.Toolkit; import com.fr.general.GeneralUtils; import com.fr.invoke.Reflect; import com.fr.log.FineLoggerFactory; import org.easymock.EasyMock; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mockito; import org.powermock.api.easymock.PowerMock; +import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -19,9 +23,15 @@ import static org.junit.Assert.fail; * Created by plough on 2018/12/7. */ @RunWith(PowerMockRunner.class) -@PrepareForTest(GeneralUtils.class) +@PrepareForTest({GeneralUtils.class, Toolkit.class}) public class FunctionConstantsTest { + @Before + public void setUp() { + PowerMockito.mockStatic(Toolkit.class); + PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test"); + } + @Test public void testNewInstanceFail() throws Exception { try { diff --git a/designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java b/designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java index 33a98e078d..a35055c2fd 100644 --- a/designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java +++ b/designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java @@ -1,8 +1,16 @@ package com.fr.design.gui.icombocheckbox; +import com.fr.design.i18n.Toolkit; import junit.framework.TestCase; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import java.util.ArrayList; import java.util.List; @@ -14,8 +22,17 @@ import java.util.TreeMap; * @version 10.0 * Created by hades on 2020/4/3 */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(Toolkit.class) +@PowerMockIgnore("javax.swing.*") public class UICheckListPopupTest extends TestCase { + @Before + public void setUp() { + PowerMockito.mockStatic(Toolkit.class); + PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test"); + } + @Test public void testGetSelectedValues() { Object[] values = new Object[]{"a", "b", "c"};