Java Code Examples for org.easymock.EasyMock#expect()

The following examples show how to use org.easymock.EasyMock#expect() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CorbaConduitTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testBuildRequest() throws Exception {
    CorbaConduit conduit = setupCorbaConduit(false);
    CorbaMessage message = control.createMock(CorbaMessage.class);
    Exchange exchange = control.createMock(Exchange.class);
    EasyMock.expect(message.getExchange());
    EasyMock.expectLastCall().andReturn(exchange);
    ServiceInfo service = control.createMock(ServiceInfo.class);
    EasyMock.expect(exchange.get(ServiceInfo.class)).andReturn(service);
    List<CorbaTypeMap> list = control.createMock(List.class);
    CorbaTypeMap typeMap = control.createMock(CorbaTypeMap.class);
    EasyMock.expect(service.getExtensors(CorbaTypeMap.class)).andReturn(list);

    OperationType opType = control.createMock(OperationType.class);
    conduit.getArguments(message);
    EasyMock.expectLastCall().andReturn(null);
    conduit.getReturn(message);
    EasyMock.expectLastCall().andReturn(null);
    conduit.getExceptionList(conduit.getOperationExceptions(opType, typeMap),
                             message,
                             opType);
    EasyMock.expectLastCall().andReturn(null);

    conduit.getRequest(message, "Hello", null, null, null);
    EasyMock.expectLastCall();
}
 
Example 2
Source File: TestDeviceServiceUpgradeDriver.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
private IExpectationSetters<DeviceDriver> expectFindByProtocolAttributes() {
   AttributeMap protocolAttributes = AttributeMap.mapOf(
         DeviceService.DEVICE_ADV_PROTCOL_KEY.valueOf(device.getProtocol()),
         DeviceService.DEVICE_ADV_SUBPROTCOL_KEY.valueOf(device.getSubprotocol()),
         DeviceService.DEVICE_ADV_PROTOCOLID_KEY.valueOf(device.getProtocolid())
   );
   return
      EasyMock
         .expect(mockRegistry.findDriverFor("general", protocolAttributes, 0));
}
 
Example 3
Source File: BaseAlarmSubsystemTestCase.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
protected IExpectationSetters<AlarmIncidentModel> expectCurrentIncident() {
	return EasyMock.expect(incidentService.getCurrentIncident(context));
}
 
Example 4
Source File: TestAlarmIncidentServiceImpl.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
protected IExpectationSetters<Optional<SubsystemExecutor>> expectGetSubsystem() {
	return
		EasyMock
			.expect(registry.loadByPlace(placeId));
}
 
Example 5
Source File: TestAlarmIncidentServiceImpl.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
protected IExpectationSetters<AlarmIncident> expectFindAlarmIncidentById() {
	return
		EasyMock
			.expect(alarmIncidentDao.findById(placeId, incident.getId()));
}
 
Example 6
Source File: CorbaConduitTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testInvoke() throws Exception {
    CorbaConduit conduit = setupCorbaConduit(false);
    //CorbaMessage message = new CorbaMessage(msg);
    CorbaMessage message = control.createMock(CorbaMessage.class);
    /*String opName = "GreetMe";
    NVList nvlist = (NVList)orb.create_list(0);

    Request request = conduit.getRequest(message, "GreetMe", nvlist, null, null);
    request.invoke();
    */

    org.omg.CORBA.Object obj = control.createMock(org.omg.CORBA.Object.class);
    EasyMock.expect(message.get(CorbaConstants.CORBA_ENDPOINT_OBJECT)).andReturn(obj);

    //msg.put(CorbaConstants.CORBA_ENDPOINT_OBJECT, obj);
    Request r = control.createMock(Request.class);
    NVList nvList = orb.create_list(0);
    NamedValue ret = control.createMock(NamedValue.class);
    ExceptionList exList = control.createMock(ExceptionList.class);

    EasyMock.expect(obj._create_request((Context)EasyMock.anyObject(),
                        EasyMock.eq("greetMe"),
                        EasyMock.isA(NVList.class),
                        EasyMock.isA(NamedValue.class),
                        EasyMock.isA(ExceptionList.class),
                        EasyMock.isA(ContextList.class)));
    EasyMock.expectLastCall().andReturn(r);
    r.invoke();
    EasyMock.expectLastCall();

    control.replay();
    Request request = conduit.getRequest(message, "greetMe", nvList, ret, exList);
    request.invoke();
    control.verify();

      /* try {
            ContextList ctxList = orb.create_context_list();
            Context ctx = orb.get_default_context();
            org.omg.CORBA.Object targetObj = (org.omg.CORBA.Object)message
                .get(CorbaConstants.CORBA_ENDPOINT_OBJECT);
            Request request = targetObj._create_request(ctx, opName, list, ret, exList, ctxList);
            request.invoke();

        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
        }*/
}