Easymock mock 反常处理的模仿代码ITeye - 千亿集团

Easymock mock 反常处理的模仿代码ITeye

2019-01-12 09:24:51 | 作者: 昊英 | 标签: | 浏览: 2981

@Test(expected = ReferenceRetryException.class) public void testTryErrorsButHasReturn() throws Exception { String schema = "BPOS"; Map String, Object parameters = new HashMap String, Object parameters.put("REGION_FUND", "SRS1"); parameters.put("CLIENT_ACCT", "SLX1"); parameters.put("CUSIP", "007942006"); ReferenceMeta rm = new ReferenceMeta(); rm.setMetaKey("metaKey"); rm.setSchema(schema); rm.setRequestNumber("500011"); rm.setContext("osw"); rm.setOutputFields("Fieldname1,Fieldname2,Fieldname3"); rm.setRegion("UA1NA"); parameters.put(Constants.PARAM_META, rm); parameters.put(Constants.PARAM_COLUMNS_CACHED, true); String user = "user"; String password = "pass"; final Client client2 = mockControl.createMock(Client.class); client2.signOn(user, password); expectLastCall().times(3); ResultSet resultSet = null; try { resultSet = mockControl.createMock(ResultSet.class); Column[] columns = new Column[2]; columns[0] = createMockBuilder(Column.class).withConstructor("column1", "string").createMock(); columns[1] = createMockBuilder(Column.class).withConstructor("column2", "string").createMock(); expect(resultSet.getColumns()).andReturn(columns); String status = "INTERNAL ERROR [B061 ERROR: BRIHRC_INVALID_FACILITYTOKEN - Tran=ATNU, Compcode=001]"; expect(resultSet.getString("__status")).andReturn(status); expectLastCall().times(1); expect(resultSet.getString("__errorMsg")).andReturn(""); expectLastCall().times(1); expect(resultSet.getString("column1")).andReturn("value1"); expectLastCall().times(1); expect(resultSet.getString("column2")).andReturn("value2"); expectLastCall().times(1); expect(resultSet.next()).andReturn(true); expectLastCall().times(1); expect(resultSet.next()).andReturn(false); expectLastCall().times(1); } catch (Exception e1) { e1.printStackTrace(); expect(client2.process((String) anyObject())).andReturn(resultSet).times(2); custodyChannel = new CustodyReferenceChannel() { @Override protected Client createClient(String signUrl, String metaKey) { return client2; custodyChannel.setUser(user); custodyChannel.setPassword(password);
版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表千亿集团立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章