Browse Source

Pull request #12256: REPORT-94637 单元测试修复

Merge in DESIGN/design from ~OBO/design1:release/11.0 to release/11.0

* commit 'bb5cd7e6ef77c4aff5c6aa84ab737be4ad53d0f9':
  REPORT-94637 单元测试修复
newui
Obo-王学仁 1 year ago
parent
commit
1dadab24f5
  1. 19
      designer-base/src/test/java/com/fr/design/mainframe/loghandler/DesignerLogHandlerTest.java
  2. 2
      designer-base/src/test/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfoTest.java
  3. 21
      designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java
  4. 18
      designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java

19
designer-base/src/test/java/com/fr/design/mainframe/loghandler/DesignerLogHandlerTest.java

@ -1,7 +1,16 @@
package com.fr.design.mainframe.loghandler;
import com.fr.design.i18n.Toolkit;
import junit.framework.TestCase;
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;
import static org.junit.Assert.*;
@ -10,8 +19,18 @@ import static org.junit.Assert.*;
* @version 10.0
* Created by vito on 2022/1/25
*/
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"javax.management.*", "javax.swing.*"})
@PrepareForTest(Toolkit.class)
public class DesignerLogHandlerTest {
@Before
public void setUp() {
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
PowerMock.replayAll();
}
@Test
public void findTplLink() {
Assert.assertArrayEquals(

2
designer-base/src/test/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfoTest.java

@ -37,7 +37,7 @@ public class ComponentReuseNotificationInfoTest {
writer.flush();
writer.close();
Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<ComponentReuseNotificationInfo xmlVersion=\"20170720\" releaseVersion=\"\" clickedWidgetLib=\"false\" hasCompleteEmbedFilter=\"false\" firstDrag=\"true\" widgetLibHasRefreshed=\"false\" firstDragEndTime=\"0\" historyCreatedReuses=\"[]\"/>\n", sw.toString());
"<ComponentReuseNotificationInfo xmlVersion=\"20211223\" releaseVersion=\"\" clickedWidgetLib=\"false\" completeEmbedFilter=\"false\" completeFirstShowComponentLib=\"false\" firstDrag=\"true\" widgetLibHasRefreshed=\"false\" firstDragEndTime=\"0\" historyCreatedReuses=\"[]\"/>\n", sw.toString());
}
}

21
designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java

@ -1,20 +1,33 @@
package com.fr.file;
import com.fr.base.extension.FileExtension;
import com.fr.design.i18n.Toolkit;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.invoke.Reflect;
import com.fr.stable.StringUtils;
import org.easymock.EasyMock;
import org.junit.Assert;
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 2019-10-15
*/
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"javax.management.*", "javax.swing.*"})
@PrepareForTest({Toolkit.class, FileNodeFILE.class})
public class FILEChooserPaneTest {
@Test
public void testAddChooseFileFilter() {
FILEChooserPane chooserPane = Reflect.on(FILEChooserPane.class).field("INSTANCE").get();
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
PowerMock.replayAll();
FILEChooserPane chooserPane = EasyMock.mock(FILEChooserPane.class);
Reflect.on(chooserPane).set("suffix", ".cpt");
String result1 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", null).get();
Assert.assertEquals("WorkBook1.cpt", result1);
@ -25,11 +38,11 @@ public class FILEChooserPaneTest {
ChooseFileFilter chooseFileFilter2 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY);
String result3 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", chooseFileFilter2).get();
Assert.assertEquals("WorkBook1.cpt.cptx", result3);
Assert.assertEquals("WorkBook1.cptx", result3);
ChooseFileFilter chooseFileFilter3 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY);
String result4 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter3).get();
Assert.assertEquals("WorkBook1.cptx.cpt", result4);
Assert.assertEquals("WorkBook1.cpt", result4);
ChooseFileFilter chooseFileFilter5 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY);
String result5 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter5).get();

18
designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.template.info;
import com.fr.design.i18n.Toolkit;
import com.fr.form.ui.CardAddButton;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.ChartEditor;
@ -16,16 +17,33 @@ import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONObject;
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;
import java.awt.Rectangle;
/**
* Created by kerry on 2020-05-08
*/
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"javax.management.*", "javax.swing.*"})
@PrepareForTest(Toolkit.class)
public class ComponentCreateOperateTest {
@Before
public void setUp() {
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
PowerMock.replayAll();
}
@Test
public void testConstructor() {
ElementCaseEditor caseEditor = new ElementCaseEditor();

Loading…
Cancel
Save