BundleContext bc = c.createMock(BundleContext.class);
ServiceReference sref = c.createMock(ServiceReference.class);
ExportRegistration exReg = c.createMock(ExportRegistration.class);
ExportRegistration exReg2 = c.createMock(ExportRegistration.class);
EndpointListener epl = EasyMock.createMock(EndpointListener.class);
EndpointDescription epd = c.createMock(EndpointDescription.class);
EndpointDescription epd2 = c.createMock(EndpointDescription.class);
ExportReference exRef = c.createMock(ExportReference.class);
ExportReference exRef2 = c.createMock(ExportReference.class);
Map props = new HashMap();
String[] oc = new String[1];
oc[0] = "myClass";
props.put("objectClass", oc);
Map props2 = new HashMap();
oc = new String[1];
oc[0] = "notMyClass";
props2.put("objectClass", oc);
EasyMock.expect(bc.getService(EasyMock.eq(sref))).andReturn(epl).anyTimes();
EasyMock.expect(bc.createFilter((String)EasyMock.anyObject())).andAnswer(new IAnswer<Filter>() {
public Filter answer() throws Throwable {
return FrameworkUtil.createFilter((String)EasyMock.getCurrentArguments()[0]);
}
}).anyTimes();
EasyMock.expect(sref.getProperty(EasyMock.eq(EndpointListener.ENDPOINT_LISTENER_SCOPE)))
.andReturn("(objectClass=myClass)").anyTimes();
EasyMock.expect(exReg.getExportReference()).andReturn(exRef).anyTimes();
EasyMock.expect(exRef.getExportedEndpoint()).andReturn(epd).anyTimes();
EasyMock.expect(epd.getProperties()).andReturn(props).anyTimes();
EasyMock.expect(exReg2.getExportReference()).andReturn(exRef2).anyTimes();
EasyMock.expect(exRef2.getExportedEndpoint()).andReturn(epd2).anyTimes();
EasyMock.expect(epd2.getProperties()).andReturn(props2).anyTimes();
// must only be called for the first EndpointDestription !
epl.endpointRemoved(EasyMock.eq(epd), EasyMock.eq("(objectClass=myClass)"));
EasyMock.expectLastCall().once();