diff --git a/designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java b/designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java index 466d28dab9..1377e39428 100644 --- a/designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java +++ b/designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java @@ -6,8 +6,8 @@ import com.fr.config.dao.impl.LocalEntityDao; import com.fr.config.dao.impl.LocalXmlEntityDao; import com.fr.design.fun.ToolbarItemProvider; import com.fr.design.gui.core.WidgetOption; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JTemplate; -import com.fr.design.mainframe.JVirtualTemplate; import com.fr.general.ModuleContext; import com.fr.report.restriction.CellCountRestriction; import com.fr.report.restriction.ReportRestrictionScene; @@ -18,6 +18,9 @@ import junit.framework.TestCase; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import java.util.HashSet; @@ -29,9 +32,14 @@ import java.util.Set; * Created by zack on 2019/9/17 */ @RunWith(PowerMockRunner.class) +@PrepareForTest({Toolkit.class}) +@PowerMockIgnore("javax.swing.*") public class ExtraDesignClassManagerTest extends TestCase { @Override protected void setUp() throws Exception { + PowerMock.mockStatic(Toolkit.class); + EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes(); + PowerMock.replayAll(); DaoContext.setEntityDao(new LocalEntityDao()); DaoContext.setClassHelperDao(new LocalClassHelperDao()); DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); @@ -41,7 +49,7 @@ public class ExtraDesignClassManagerTest extends TestCase { public void testGetWebOption() { try { - final JTemplate jTemplate = new JVirtualTemplate(null); + final JTemplate jTemplate = EasyMock.mock(JTemplate.class); ToolbarItemProvider item = EasyMock.mock(ToolbarItemProvider.class); ToolbarItemProvider item1 = EasyMock.mock(ToolbarItemProvider.class); EasyMock.expect(item.accept(jTemplate)).andReturn(false).anyTimes(); diff --git a/designer-base/src/test/java/com/fr/design/utils/gui/UIComponentUtilsTest.java b/designer-base/src/test/java/com/fr/design/utils/gui/UIComponentUtilsTest.java index c3a0448d7f..dcb21f7999 100644 --- a/designer-base/src/test/java/com/fr/design/utils/gui/UIComponentUtilsTest.java +++ b/designer-base/src/test/java/com/fr/design/utils/gui/UIComponentUtilsTest.java @@ -4,12 +4,14 @@ import com.fr.design.gui.core.UITextComponent; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; +import com.fr.general.GeneralContext; import com.fr.stable.StringUtils; import org.easymock.EasyMock; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -17,6 +19,7 @@ import javax.swing.Icon; import java.awt.Component; import java.awt.Graphics; +import java.util.Locale; import static org.junit.Assert.*; @@ -25,6 +28,7 @@ import static org.junit.Assert.*; */ @RunWith(PowerMockRunner.class) @PrepareForTest({Toolkit.class}) +@PowerMockIgnore("javax.swing.*") public class UIComponentUtilsTest { private static final String HTML_TAG_TPL = "
"; private static final String HTML_TAG = ""; @@ -40,6 +44,7 @@ public class UIComponentUtilsTest { public void setUp() { PowerMock.mockStatic(Toolkit.class); EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes(); + PowerMock.replayAll(); textButton = new UIButton("hello"); emptyTextButton = new UIButton(StringUtils.EMPTY); iconButton = new UIButton(createMockIcon()); @@ -47,13 +52,13 @@ public class UIComponentUtilsTest { textLabel = new UILabel("hello"); emptyTextLabel = new UILabel(StringUtils.EMPTY); iconLabel = new UILabel(createMockIcon()); + GeneralContext.setLocale(Locale.US); } @Test public void testSetLineWrap() { UITextComponent[] noWrapComps = {emptyTextButton, emptyTextLabel, iconButton, iconLabel}; UITextComponent[] wrapComps = {textLabel, textButton}; - for (UITextComponent comp : wrapComps) { UIComponentUtils.setLineWrap(comp); assertTrue(isLineWrapped(comp)); diff --git a/designer-form/src/test/java/com/fr/design/preview/FormAdaptivePreviewTest.java b/designer-form/src/test/java/com/fr/design/preview/FormAdaptivePreviewTest.java index 0dd76146fc..72ab19e6c0 100644 --- a/designer-form/src/test/java/com/fr/design/preview/FormAdaptivePreviewTest.java +++ b/designer-form/src/test/java/com/fr/design/preview/FormAdaptivePreviewTest.java @@ -12,14 +12,6 @@ import java.util.Map; * Created by kerry on 2020-04-24 */ public class FormAdaptivePreviewTest { - @Test - public void testParametersForPreview() { - FormAdaptivePreview formPreview = new FormAdaptivePreview(); - Map