Java Code Examples for org.onosproject.cfg.ComponentConfigService#unregisterProperties()

The following examples show how to use org.onosproject.cfg.ComponentConfigService#unregisterProperties() . 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: OpticalCircuitIntentCompilerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    sut = new OpticalCircuitIntentCompiler();
    coreService = createMock(CoreService.class);
    expect(coreService.registerApplication("org.onosproject.net.intent"))
            .andReturn(appId);
    sut.coreService = coreService;
    sut.deviceService = new MockDeviceService();
    sut.resourceService = new MockResourceService();
    sut.intentService = new TestIntentService();
    sut.intentSetMultimap = new MockIntentSetMultimap();

    super.setUp();

    intentExtensionService = createMock(IntentExtensionService.class);
    intentExtensionService.registerCompiler(OpticalCircuitIntent.class, sut);
    intentExtensionService.unregisterCompiler(OpticalCircuitIntent.class);
    sut.intentManager = intentExtensionService;
    replay(coreService, intentExtensionService);

    // mocking ComponentConfigService
    ComponentConfigService mockConfigService =
            EasyMock.createMock(ComponentConfigService.class);
    expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    mockConfigService.registerProperties(sut.getClass());
    expectLastCall();
    mockConfigService.unregisterProperties(sut.getClass(), false);
    expectLastCall();
    expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    sut.cfgService = mockConfigService;
    replay(mockConfigService);

}
 
Example 2
Source File: MastershipManagerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    mgr = new MastershipManager();
    service = mgr;
    injectEventDispatcher(mgr, new TestEventDispatcher());
    testClusterService = new TestClusterService();
    mgr.clusterService = testClusterService;
    mgr.upgradeService = new UpgradeServiceAdapter();
    mgr.store = new TestSimpleMastershipStore(mgr.clusterService);
    regionStore = new DistributedRegionStore();
    TestUtils.setField(regionStore, "storageService", new TestStorageService());
    TestUtils.callMethod(regionStore, "activate",
                         new Class<?>[] {});
    regionManager = new TestRegionManager();
    TestUtils.setField(regionManager, "store", regionStore);
    regionManager.activate();
    mgr.regionService = regionManager;

    ComponentConfigService mockConfigService =
            EasyMock.createMock(ComponentConfigService.class);
    expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    mockConfigService.registerProperties(mgr.getClass());
    expectLastCall();
    mockConfigService.unregisterProperties(mgr.getClass(), false);
    expectLastCall();
    expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    mgr.cfgService = mockConfigService;
    replay(mockConfigService);

    mgr.activate();
}
 
Example 3
Source File: OpenFlowControllerImplTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Sets up switches to use as data, mocks and launches a controller instance.
 */
@Before
public void setUp() {
    try {
        switch1 = new OpenflowSwitchDriverAdapter();
        dpid1 = Dpid.dpid(new URI("of:0000000000000111"));
        switch2 = new OpenflowSwitchDriverAdapter();
        dpid2 = Dpid.dpid(new URI("of:0000000000000222"));
        switch3 = new OpenflowSwitchDriverAdapter();
        dpid3 = Dpid.dpid(new URI("of:0000000000000333"));
    } catch (URISyntaxException ex) {
        //  Does not happen
        fail();
    }

    controller = new OpenFlowControllerImpl();
    agent = controller.agent;

    switchListener = new TestSwitchListener();
    controller.addListener(switchListener);

    CoreService mockCoreService =
            EasyMock.createMock(CoreService.class);
    controller.coreService = mockCoreService;

    OpenFlowService mockOpenFlowService =
            EasyMock.createMock(OpenFlowService.class);
    controller.openFlowManager = mockOpenFlowService;

    ComponentConfigService mockConfigService =
            EasyMock.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);

    NetworkConfigRegistry netConfigService = EasyMock.createMock(NetworkConfigRegistry.class);
    controller.netCfgService = netConfigService;

    ComponentContext mockContext = EasyMock.createMock(ComponentContext.class);
    Dictionary<String, Object> properties = new Hashtable<>();
    properties.put("openflowPorts",
                   Integer.toString(EPHEMERAL_PORT));
    expect(mockContext.getProperties()).andReturn(properties);
    replay(mockContext);
    controller.activate(mockContext);
}
 
Example 4
Source File: LispControllerImplTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 5
Source File: XmppControllerImplTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * Sets up devices to use as data, mocks and launches a controller instance.
 */
@Before
public void setUp() {
    device1 = new XmppDeviceAdapter();
    jid1 = new XmppDeviceId(new JID("[email protected]"));
    device2 = new XmppDeviceAdapter();
    jid2 = new XmppDeviceId(new JID("[email protected]"));
    device3 = new XmppDeviceAdapter();
    jid3 = new XmppDeviceId(new JID("[email protected]"));

    controller = new XmppControllerImpl();
    agent = controller.agent;

    testXmppDeviceListener = new TestXmppDeviceListener();
    controller.addXmppDeviceListener(testXmppDeviceListener);
    testXmppIqListener = new TestXmppIqListener();
    controller.addXmppIqListener(testXmppIqListener, testNamespace);
    testXmppMessageListener = new TestXmppMessageListener();
    controller.addXmppMessageListener(testXmppMessageListener);
    testXmppPresenceListener = new TestXmppPresenceListener();
    controller.addXmppPresenceListener(testXmppPresenceListener);

    CoreService mockCoreService =
            EasyMock.createMock(CoreService.class);
    controller.coreService = mockCoreService;

    ComponentConfigService mockCfgService =
            EasyMock.createMock(ComponentConfigService.class);
    expect(mockCfgService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    mockCfgService.registerProperties(controller.getClass());
    expectLastCall();
    mockCfgService.unregisterProperties(controller.getClass(), false);
    expectLastCall();
    expect(mockCfgService.getProperties(anyObject())).andReturn(ImmutableSet.of());
    controller.cfgService = mockCfgService;
    replay(mockCfgService);

    ComponentContext mockContext = EasyMock.createMock(ComponentContext.class);
    Dictionary<String, Object> properties = new Hashtable<>();
    properties.put("xmppPort",
                   "5269");
    expect(mockContext.getProperties()).andReturn(properties);
    replay(mockContext);
    controller.activate(mockContext);
}