public class EndpointListenerTrackerCustomizerTest extends TestCase{
public void testEndpointListenerTrackerCustomizer(){
IMocksControl c = EasyMock.createNiceControl();
BundleContext ctx = c.createMock(BundleContext.class);
ZooKeeperDiscovery zkd = c.createMock(ZooKeeperDiscovery.class);
ServiceReference sref = c.createMock(ServiceReference.class);
ServiceReference sref2 = c.createMock(ServiceReference.class);
final Properties p = new Properties();
EasyMock.expect(sref.getPropertyKeys()).andAnswer(new IAnswer<String[]>() {
public String[] answer() throws Throwable {
return p.keySet().toArray(new String[p.keySet().size()]);
}
}).anyTimes();
EasyMock.expect(sref.getProperty((String)EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
public Object answer() throws Throwable {
String key = (String)(EasyMock.getCurrentArguments()[0]);
return p.getProperty(key);
}
}).anyTimes();
EasyMock.expect(sref2.getPropertyKeys()).andAnswer(new IAnswer<String[]>() {
public String[] answer() throws Throwable {
return p.keySet().toArray(new String[p.keySet().size()]);
}
}).anyTimes();
EasyMock.expect(sref2.getProperty((String)EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
public Object answer() throws Throwable {
String key = (String)(EasyMock.getCurrentArguments()[0]);
return p.getProperty(key);
}
}).anyTimes();
final ArrayList<IMocksControl> controls = new ArrayList<IMocksControl>();
EndpointListenerTrackerCustomizer eltc = new EndpointListenerTrackerCustomizer(zkd,ctx){
protected InterfaceMonitor createInterfaceMonitor(String scope, String objClass, Interest interest){
IMocksControl lc = EasyMock.createNiceControl();
InterfaceMonitor im = lc.createMock(InterfaceMonitor.class);
im.start();
EasyMock.expectLastCall().once();
im.close();
EasyMock.expectLastCall().once();
lc.replay();
controls.add(lc);
return im;
}
};