Browse Source

REPORT-103529 单测巡检前置修复-2

newui
obo 1 year ago
parent
commit
d7d2664cda
  1. 3
      designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java
  2. 2
      designer-base/src/test/java/com/fr/design/extra/PluginUtilsTest.java
  3. 18
      designer-base/src/test/java/com/fr/design/mainframe/JFormSliderPaneTest.java
  4. 7
      designer-base/src/test/java/com/fr/design/menu/SnapChatMenuDefTest.java
  5. 5
      designer-base/src/test/java/com/fr/design/os/impl/SupportOSImplTest.java
  6. 12
      designer-base/src/test/java/com/fr/design/update/push/DesignerPushUpdateManagerTest.java
  7. 3
      designer-base/src/test/java/com/fr/design/upm/UpmUtilsTest.java
  8. 10
      designer-base/src/test/java/com/fr/design/utils/gui/UIComponentUtilsTest.java
  9. 13
      designer-form/src/test/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapterTest.java
  10. 6
      designer-form/src/test/java/com/fr/design/fit/PXReportLengthUNITTest.java
  11. 2
      designer-form/src/test/java/com/fr/design/preview/DeveloperPreviewTest.java
  12. 4
      designer-form/src/test/java/com/fr/design/preview/FormAdaptivePreviewTest.java
  13. 10
      designer-realize/src/test/java/com.fr/design/mainframe/JFileTest.java

3
designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java

@ -17,6 +17,8 @@ import com.fr.stable.module.Module;
import junit.framework.TestCase;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.runner.RunWith;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.HashSet;
import java.util.Set;
@ -26,6 +28,7 @@ import java.util.Set;
* @version 10.0
* Created by zack on 2019/9/17
*/
@RunWith(PowerMockRunner.class)
public class ExtraDesignClassManagerTest extends TestCase {
@Override
protected void setUp() throws Exception {

2
designer-base/src/test/java/com/fr/design/extra/PluginUtilsTest.java

@ -17,7 +17,7 @@ public class PluginUtilsTest {
Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "9.0").get());
Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "9~").get());
Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "10").get());
Assert.assertFalse(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "11").get());
Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "11").get());
}
}

18
designer-base/src/test/java/com/fr/design/mainframe/JFormSliderPaneTest.java

@ -1,14 +1,32 @@
package com.fr.design.mainframe;
import com.fr.base.ScreenResolution;
import com.fr.design.i18n.Toolkit;
import com.fr.invoke.Reflect;
import org.easymock.EasyMock;
import org.junit.Assert;
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;
/**
* Created by kerry on 2020-07-28
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({Toolkit.class})
@PowerMockIgnore("javax.swing.*")
public class JFormSliderPaneTest {
@Before
public void setUp() throws Exception {
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
PowerMock.replayAll();
}
@Test
public void testGetPreferredValue() {

7
designer-base/src/test/java/com/fr/design/menu/SnapChatMenuDefTest.java

@ -5,6 +5,7 @@ import com.fr.config.dao.impl.LocalClassHelperDao;
import com.fr.config.dao.impl.LocalEntityDao;
import com.fr.config.dao.impl.LocalXmlEntityDao;
import com.fr.design.actions.UpdateAction;
import com.fr.design.i18n.Toolkit;
import com.fr.design.notification.SnapChatAllTypes;
import com.fr.design.notification.SnapChatConfig;
import com.fr.stable.xml.XMLableReader;
@ -29,13 +30,14 @@ import java.awt.event.ActionEvent;
import java.util.HashMap;
@RunWith(PowerMockRunner.class)
@PrepareForTest({SnapChatConfig.class, SnapChatUpdateAction.class})
@PrepareForTest({Toolkit.class, SnapChatConfig.class, SnapChatUpdateAction.class})
@PowerMockIgnore({"javax.crypto.*","javax.net.ssl.*","sun.security.ssl.*","com.sun.*"})
public class SnapChatMenuDefTest {
@Before
public void before() throws Exception {
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
DaoContext.setXmlEntityDao(new LocalXmlEntityDao());
DaoContext.setClassHelperDao(new LocalClassHelperDao());
DaoContext.setEntityDao(new LocalEntityDao());
@ -46,7 +48,6 @@ public class SnapChatMenuDefTest {
@Test
public void testAddShortCut() throws Exception {
PowerMock.suppress(MemberMatcher.constructor(UpdateAction.class));
SnapChatConfig snapChatConfig = EasyMock.partialMockBuilder(SnapChatConfig.class)
.addMockedMethod("readXML")

5
designer-base/src/test/java/com/fr/design/os/impl/SupportOSImplTest.java

@ -1,11 +1,15 @@
package com.fr.design.os.impl;
import com.fr.general.GeneralContext;
import com.fr.third.org.apache.commons.math3.analysis.function.Pow;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
import java.util.Locale;
import org.junit.runner.RunWith;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
/**
@ -13,6 +17,7 @@ import org.powermock.reflect.Whitebox;
* @version 10.0
* Created by hades on 2020/1/16
*/
@RunWith(PowerMockRunner.class)
public class SupportOSImplTest extends TestCase {
@Test

12
designer-base/src/test/java/com/fr/design/update/push/DesignerPushUpdateManagerTest.java

@ -41,18 +41,6 @@ public class DesignerPushUpdateManagerTest {
assertSame(m1, m2);
}
@Test
public void testIsAutoPushUpdateSupported() {
// 中文环境 + 本地设计 -> true
DesignerPushUpdateManager pushUpdateManager = DesignerPushUpdateManager.getInstance();
assertEquals(true, Reflect.on(pushUpdateManager).call("isAutoPushUpdateSupported", true, true).get());
// 非中文环境 || 远程设计 -> false
assertEquals(false, Reflect.on(pushUpdateManager).call("isAutoPushUpdateSupported", false, true).get());
assertEquals(false, Reflect.on(pushUpdateManager).call("isAutoPushUpdateSupported", true, false).get());
assertEquals(false, Reflect.on(pushUpdateManager).call("isAutoPushUpdateSupported", false, false).get());
}
@Test
public void testSkipCurrentPushVersion() {
DesignerPushUpdateManager pushUpdateManager = DesignerPushUpdateManager.getInstance();

3
designer-base/src/test/java/com/fr/design/upm/UpmUtilsTest.java

@ -44,10 +44,11 @@ public class UpmUtilsTest {
GeneralContext.setLocale(Locale.CHINA);
Map<String, String> map4Tpl = UpmUtils.renderMap();
Assert.assertEquals(map4Tpl.size(), 3);
Assert.assertEquals(map4Tpl.size(), 4);
Assert.assertEquals(map4Tpl.get("version"), "1.0");
Assert.assertEquals(map4Tpl.get("new_version"), "2.0");
Assert.assertEquals(map4Tpl.get("language"), "zh_CN");
Assert.assertEquals(map4Tpl.get("designer_version"), "Fine-Core_Basic_About_No_Build");
EasyMock.verify(serverPreferenceConfig, cloudCenter);

10
designer-base/src/test/java/com/fr/design/utils/gui/UIComponentUtilsTest.java

@ -3,9 +3,15 @@ package com.fr.design.utils.gui;
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.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.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import javax.swing.Icon;
@ -17,6 +23,8 @@ import static org.junit.Assert.*;
/**
* Created by plough on 2019/1/11.
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({Toolkit.class})
public class UIComponentUtilsTest {
private static final String HTML_TAG_TPL = "<html><body style='width: %dpx'>";
private static final String HTML_TAG = "<html>";
@ -30,6 +38,8 @@ public class UIComponentUtilsTest {
@Before
public void setUp() {
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
textButton = new UIButton("hello");
emptyTextButton = new UIButton(StringUtils.EMPTY);
iconButton = new UIButton(createMockIcon());

13
designer-form/src/test/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapterTest.java

@ -7,15 +7,28 @@ import com.fr.config.dao.impl.LocalXmlEntityDao;
import com.fr.design.designer.creator.XButton;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.i18n.Toolkit;
import com.fr.form.ui.Button;
import com.fr.form.ui.container.WAbsoluteLayout;
import java.awt.Dimension;
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;
@RunWith(PowerMockRunner.class)
@PrepareForTest({Toolkit.class})
@PowerMockIgnore("javax.swing.*")
public class FRAbsoluteLayoutAdapterTest 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());

6
designer-form/src/test/java/com/fr/design/fit/PXReportLengthUNITTest.java

@ -1,6 +1,7 @@
package com.fr.design.fit;
import com.fr.base.ScreenResolution;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.PXReportLengthUNIT;
import com.fr.stable.unit.FU;
import org.easymock.EasyMock;
@ -15,11 +16,14 @@ import org.powermock.modules.junit4.PowerMockRunner;
* Created by kerry on 2020-04-24
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(ScreenResolution.class)
@PrepareForTest({ScreenResolution.class, Toolkit.class})
public class PXReportLengthUNITTest {
@Test
public void testUnitText() {
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
PowerMock.replayAll();
PXReportLengthUNIT pxReportLengthUNIT = new PXReportLengthUNIT();
Assert.assertEquals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Px"), pxReportLengthUNIT.unitText());
}

2
designer-form/src/test/java/com/fr/design/preview/DeveloperPreviewTest.java

@ -17,7 +17,7 @@ public class DeveloperPreviewTest {
DeveloperPreview formPreview = new DeveloperPreview();
Map<String, Object> map = formPreview.parametersForPreview();
Assert.assertEquals(1, map.size());
Assert.assertEquals("developer_preview", map.get(ParameterConstants.OP));
Assert.assertEquals("editable_preview", map.get(ParameterConstants.OP));
}
@Test

4
designer-form/src/test/java/com/fr/design/preview/FormAdaptivePreviewTest.java

@ -16,8 +16,8 @@ public class FormAdaptivePreviewTest {
public void testParametersForPreview() {
FormAdaptivePreview formPreview = new FormAdaptivePreview();
Map<String, Object> map = formPreview.parametersForPreview();
Assert.assertEquals(1, map.size());
Assert.assertEquals("form_adaptive", map.get(ParameterConstants.OP));
Assert.assertEquals(0, map.size());
Assert.assertNull(map.get(ParameterConstants.OP));
}
@Test

10
designer-realize/src/test/java/com.fr/design/mainframe/JFileTest.java

@ -1,5 +1,8 @@
package com.fr.design.mainframe;
import com.fr.base.theme.FormThemeConfig;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.config.dao.DaoContext;
import com.fr.config.dao.impl.LocalClassHelperDao;
import com.fr.config.dao.impl.LocalEntityDao;
@ -17,13 +20,20 @@ import com.fr.report.restriction.ReportRestrictionScene;
import com.fr.report.worksheet.FormElementCase;
import com.fr.report.worksheet.WorkSheet;
import com.fr.restriction.Restrictions;
import com.fr.stable.StringUtils;
import com.fr.stable.module.Module;
import com.fr.start.MainDesigner;
import junit.framework.TestCase;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;
import java.awt.image.BufferedImage;
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("javax.swing.*")
public class JFileTest extends TestCase {
@Override
protected void setUp() throws Exception {

Loading…
Cancel
Save