1
2
3
4
5 package org.neo.swarm.services.binding;
6
7 import junit.framework.TestCase;
8
9 import org.easymock.MockControl;
10 import org.neo.swarm.ApplicationContext;
11 import org.neo.swarm.SwarmContainer;
12 import org.neo.swarm.core.aop.silc.comp.Perspective;
13 import org.neo.swarm.util.network.multicast.Sender;
14 import org.neo.swarm.util.serialize.Serializer;
15 import org.neo.swarm.util.threads.ThreadPool;
16
17 /***
18 * @author navery
19 *
20 */
21 public class BindingRunnablesTest extends TestCase {
22
23 public void testDynamicBindingService() throws Exception {
24 MockControl appContextControl = MockControl.createControl(ApplicationContext.class);
25 ApplicationContext appContext = (ApplicationContext) appContextControl.getMock();
26
27 MockControl senderControl = MockControl.createControl(Sender.class);
28 Sender sender = (Sender) senderControl.getMock();
29
30 MockControl serializerControl = MockControl.createControl(Serializer.class);
31 Serializer serializer = (Serializer) serializerControl.getMock();
32
33 appContextControl.expectAndReturn(appContext.getURI(),"blahURI");
34 appContextControl.expectAndReturn(appContext.retrieveComponent(Perspective.REMOTE, "blahURI"), appContext);
35
36 serializer.serialize(null);
37 serializerControl.setMatcher(MockControl.ALWAYS_MATCHER);
38 serializerControl.setReturnValue("blah".getBytes());
39
40 appContextControl.replay();
41 senderControl.replay();
42 serializerControl.replay();
43
44 DynamicRunnable dynamicRunnable = new DynamicRunnable(appContext, sender, serializer, 100);
45 dynamicRunnable.start();
46 dynamicRunnable.stop();
47
48 appContextControl.verify();
49 senderControl.verify();
50 serializerControl.verify();
51 }
52 }