Search in sources :

Example 1 with LispRouterAdapter

use of org.onosproject.lisp.ctl.LispRouterAdapter in project onos by opennetworkinglab.

the class LispControllerImplTest method setUp.

/**
 * Sets up routers to use as data, mocks and launches a controller instance.
 */
@Before
public void setUp() {
    try {
        router1 = new LispRouterAdapter();
        routerId1 = LispRouterId.routerId(new URI("lisp:10.1.1.1"));
        router2 = new LispRouterAdapter();
        routerId2 = LispRouterId.routerId(new URI("lisp:10.1.1.2"));
        router3 = new LispRouterAdapter();
        routerId3 = LispRouterId.routerId(new URI("lisp:10.1.1.3"));
    } catch (URISyntaxException e) {
        // this will never happen...
        fail();
    }
    controller = new LispControllerImpl();
    agent = controller.agent;
    routerListener = new TestRouterListener();
    controller.addRouterListener(routerListener);
    messageListener = new TestMessageListener();
    controller.addMessageListener(messageListener);
    controller.coreService = createMock(CoreService.class);
    ComponentConfigService mockConfigService = createMock(ComponentConfigService.class);
    expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    mockConfigService.registerProperties(controller.getClass());
    expectLastCall();
    mockConfigService.unregisterProperties(controller.getClass(), false);
    expectLastCall();
    expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    controller.cfgService = mockConfigService;
    replay(mockConfigService);
    ComponentContext mockContext = createMock(ComponentContext.class);
    Dictionary<String, Object> properties = new Hashtable<>();
    properties.put("lispAuthKey", "onos");
    properties.put("lispAuthKeyId", 1);
    expect(mockContext.getProperties()).andReturn(properties);
    replay(mockContext);
    LispControllerBootstrap bootstrap = createMock(LispControllerBootstrap.class);
    bootstrap.start();
    expectLastCall();
    controller.bootstrap = bootstrap;
    replay(bootstrap);
    controller.activate(mockContext);
}
Also used : ComponentConfigService(org.onosproject.cfg.ComponentConfigService) ComponentContext(org.osgi.service.component.ComponentContext) Hashtable(java.util.Hashtable) CoreService(org.onosproject.core.CoreService) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) EasyMock.anyObject(org.easymock.EasyMock.anyObject) LispRouterAdapter(org.onosproject.lisp.ctl.LispRouterAdapter) Before(org.junit.Before)

Aggregations

URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Hashtable (java.util.Hashtable)1 EasyMock.anyObject (org.easymock.EasyMock.anyObject)1 Before (org.junit.Before)1 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)1 CoreService (org.onosproject.core.CoreService)1 LispRouterAdapter (org.onosproject.lisp.ctl.LispRouterAdapter)1 ComponentContext (org.osgi.service.component.ComponentContext)1