Browse Source
* commit '0506d68d934830a0ef86663e0abc03825bb2c0b8': REPORT-19083 设计器内删除当前模板时,未自动退回到最后一张已打开的模板 无JIRA任务 数据收集,为了规避获取username要在启动之后,写了个中转文件 REPORT-18422 图片控件插件问题 设计器部分漏提交 CHART-9783 地图相关操作慢 REPORT-18570 fr连接bi 数据分析预览单元格没有过滤设置 限制文件大小 REPORT-19059 环境切换同名程序数据集还是使用上一个环境的sql 换个名字 REPORT-18855 加下单元测试 REPORT-19058 环境切换暂存文件为保存提示 REPORT-18855 & REPORT-18857 jpg图片持久化遗漏了一些场景 CHART-9576 远程设计 设计器中用实时的 内存配置推荐:设计器安装插件随lic显示状态不对 REPORT-18955 填报属性配置,提交条件的删除按钮没有灰色化research/10.0
neil
5 years ago
17 changed files with 243 additions and 48 deletions
@ -0,0 +1,102 @@
|
||||
package com.fr.design.data; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.data.impl.storeproc.StoreProcedure; |
||||
import com.fr.design.data.tabledata.wrapper.TableDataFactory; |
||||
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||
import com.fr.file.ProcedureConfig; |
||||
import com.fr.file.TableDataConfig; |
||||
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.PrepareForTest; |
||||
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; |
||||
import org.powermock.modules.junit4.PowerMockRunner; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest({TableDataFactory.class, StoreProcedure.class, TableDataConfig.class, ProcedureConfig.class}) |
||||
@SuppressStaticInitializationFor({"com.fr.design.data.tabledata.wrapper.TableDataFactory"}) |
||||
public class DesignTableDataManagerTest { |
||||
|
||||
@Test |
||||
public void testFireDataChange() { |
||||
|
||||
DesignTableDataManager.envChange(); |
||||
|
||||
|
||||
PowerMock.mockStatic(TableDataConfig.class); |
||||
|
||||
TableDataConfig config = EasyMock.mock(TableDataConfig.class); |
||||
TableDataConfig config2 = EasyMock.mock(TableDataConfig.class); |
||||
|
||||
TableData td1 = EasyMock.mock(TableData.class); |
||||
TableData td2 = EasyMock.mock(TableData.class); |
||||
TableData td3 = EasyMock.mock(TableData.class); |
||||
TableData td4 = EasyMock.mock(TableData.class); |
||||
EasyMock.expect(config.getTableData("firstData")).andReturn(td1).once(); |
||||
EasyMock.expect(config.getTableData("secondData")).andReturn(td2).once(); |
||||
EasyMock.expect(config2.getTableData("firstData")).andReturn(td3).once(); |
||||
EasyMock.expect(config2.getTableData("secondData")).andReturn(td4).once(); |
||||
|
||||
EasyMock.expect(TableDataConfig.getInstance()).andReturn(config).once().andReturn(config2).once(); |
||||
|
||||
PowerMock.mockStatic(TableDataFactory.class); |
||||
EasyMock.expect(TableDataFactory.getSortOfChineseNameOfServerData(config)) |
||||
.andReturn(new String[]{"firstData", "secondData"}).once(); |
||||
EasyMock.expect(TableDataFactory.getSortOfChineseNameOfServerData(config2)) |
||||
.andReturn(new String[]{"firstData", "secondData"}).once(); |
||||
|
||||
|
||||
ProcedureConfig proConfig = EasyMock.mock(ProcedureConfig.class); |
||||
StoreProcedure pc1 = PowerMock.createMock(StoreProcedure.class); |
||||
StoreProcedure pc2 = PowerMock.createMock(StoreProcedure.class); |
||||
ProcedureConfig proConfig2 = EasyMock.mock(ProcedureConfig.class); |
||||
StoreProcedure pc3 = PowerMock.createMock(StoreProcedure.class); |
||||
StoreProcedure pc4 = PowerMock.createMock(StoreProcedure.class); |
||||
|
||||
Map<String, StoreProcedure> procedureMap = new HashMap<>(); |
||||
procedureMap.put("firstPRO", pc1); |
||||
procedureMap.put("secondPRO", pc2); |
||||
EasyMock.expect(proConfig.getProcedure("firstPRO")).andReturn(pc1).once(); |
||||
EasyMock.expect(proConfig.getProcedure("secondPRO")).andReturn(pc2).once(); |
||||
|
||||
Map<String, StoreProcedure> procedureMap2 = new HashMap<>(); |
||||
procedureMap2.put("firstPRO", pc3); |
||||
procedureMap2.put("secondPRO", pc4); |
||||
EasyMock.expect(proConfig2.getProcedure("firstPRO")).andReturn(pc3).once(); |
||||
EasyMock.expect(proConfig2.getProcedure("secondPRO")).andReturn(pc4).once(); |
||||
|
||||
EasyMock.expect(proConfig.getProcedures()).andReturn(procedureMap).once(); |
||||
EasyMock.expect(proConfig2.getProcedures()).andReturn(procedureMap2).once(); |
||||
|
||||
PowerMock.mockStatic(ProcedureConfig.class); |
||||
EasyMock.expect(ProcedureConfig.getInstance()).andReturn(proConfig).once().andReturn(proConfig2).once(); |
||||
|
||||
EasyMock.replay(proConfig, config, config2, proConfig2); |
||||
PowerMock.replay(TableDataFactory.class, TableDataConfig.class, ProcedureConfig.class); |
||||
|
||||
|
||||
Map<String, TableDataWrapper> map = DesignTableDataManager.getAllEditingDataSet(null); |
||||
Assert.assertEquals(4, map.size()); |
||||
Assert.assertSame(pc1, map.get("firstPRO").getTableData()); |
||||
Assert.assertSame(pc2, map.get("secondPRO").getTableData()); |
||||
Assert.assertSame(td1, map.get("firstData").getTableData()); |
||||
Assert.assertSame(td2, map.get("secondData").getTableData()); |
||||
|
||||
DesignTableDataManager.fireDSChanged(new HashMap<String, String>()); |
||||
|
||||
Map<String, TableDataWrapper> map2 = DesignTableDataManager.getAllEditingDataSet(null); |
||||
Assert.assertEquals(4, map2.size()); |
||||
Assert.assertSame(pc3, map2.get("firstPRO").getTableData()); |
||||
Assert.assertSame(pc4, map2.get("secondPRO").getTableData()); |
||||
Assert.assertSame(td3, map2.get("firstData").getTableData()); |
||||
Assert.assertSame(td4, map2.get("secondData").getTableData()); |
||||
|
||||
|
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.fr.file; |
||||
|
||||
import org.easymock.EasyMock; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
public class StashedFILETest { |
||||
|
||||
/** |
||||
* 用于测试暂存文件未保存时的提示 |
||||
*/ |
||||
@Test |
||||
public void testToString() { |
||||
FILE file = EasyMock.mock(FILE.class); |
||||
String name = "getA.cpt"; |
||||
EasyMock.expect(file.getName()).andReturn(name).once(); |
||||
EasyMock.replay(file); |
||||
FILE stashedFILE = new StashedFILE(file, new byte[0]); |
||||
String expectString = FILEFactory.MEM_PREFIX + name; |
||||
Assert.assertEquals(expectString, stashedFILE + ""); |
||||
EasyMock.verify(file); |
||||
} |
||||
} |
@ -0,0 +1,69 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.config.dao.DaoContext; |
||||
import com.fr.config.dao.impl.LocalClassHelperDao; |
||||
import com.fr.config.dao.impl.LocalEntityDao; |
||||
import com.fr.config.dao.impl.LocalXmlEntityDao; |
||||
import com.fr.form.main.Form; |
||||
import com.fr.form.ui.ElementCaseEditor; |
||||
import com.fr.general.ImageWithSuffix; |
||||
import com.fr.general.ModuleContext; |
||||
import com.fr.main.impl.WorkBook; |
||||
import com.fr.report.cell.DefaultTemplateCellElement; |
||||
import com.fr.report.cell.TemplateCellElement; |
||||
import com.fr.report.cell.cellattr.CellImage; |
||||
import com.fr.report.restriction.CellCountRestriction; |
||||
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.module.Module; |
||||
import com.fr.start.Designer; |
||||
import junit.framework.TestCase; |
||||
import org.junit.Assert; |
||||
|
||||
import java.awt.image.BufferedImage; |
||||
|
||||
public class JFileTest extends TestCase { |
||||
@Override |
||||
protected void setUp() throws Exception { |
||||
DaoContext.setEntityDao(new LocalEntityDao()); |
||||
DaoContext.setClassHelperDao(new LocalClassHelperDao()); |
||||
DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); |
||||
Restrictions.register(ReportRestrictionScene.CELL_COUNT, new CellCountRestriction()); |
||||
ModuleContext.startModule(Module.PAGE_MODULE); |
||||
ModuleContext.startModule(Module.VIEW_MODULE); |
||||
Designer designer = new Designer(new String[0]); |
||||
} |
||||
|
||||
public void testJWorkBookSetPicture() { |
||||
WorkBook workBook = new WorkBook(); |
||||
WorkSheet workSheet = new WorkSheet(); |
||||
workBook.addReport("sheet1", workSheet); |
||||
TemplateCellElement cellElement = new DefaultTemplateCellElement(); |
||||
workSheet.addCellElement(cellElement); |
||||
ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg"); |
||||
CellImage cellImage = new CellImage(); |
||||
cellImage.setImage(imageWithSuffix); |
||||
JWorkBook jWorkBook = new JWorkBook(workBook, "text"); |
||||
jWorkBook.setPictureElem(cellElement, cellImage); |
||||
Assert.assertEquals(imageWithSuffix, cellElement.getValue()); |
||||
} |
||||
|
||||
public void testJFormSetPicture() { |
||||
Form form = new Form(); |
||||
ElementCaseEditor editor = new ElementCaseEditor(); |
||||
FormElementCase elementCase = new FormElementCase(); |
||||
TemplateCellElement cellElement = new DefaultTemplateCellElement(); |
||||
elementCase.addCellElement(cellElement); |
||||
editor.setElementCase(elementCase); |
||||
form.getContainer().addWidget(editor); |
||||
ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg"); |
||||
CellImage cellImage = new CellImage(); |
||||
cellImage.setImage(imageWithSuffix); |
||||
JForm jForm = new JForm(); |
||||
jForm.setTarget(form); |
||||
jForm.setPictureElem(cellElement, cellImage); |
||||
Assert.assertEquals(imageWithSuffix, cellElement.getValue()); |
||||
} |
||||
} |
Loading…
Reference in new issue