Search in sources :

Example 11 with CodecManager

use of org.onosproject.codec.impl.CodecManager in project onos by opennetworkinglab.

the class StatisticsResourceTest method setUpTest.

/**
 * Initializes test mocks and environment.
 */
@Before
public void setUpTest() {
    mockLinkService = createMock(LinkService.class);
    expect(mockLinkService.getLinks()).andReturn(ImmutableList.of(link1, link2, link3));
    expect(mockLinkService.getLinks(connectPoint("0000000000000001", 2))).andReturn(ImmutableSet.of(link3));
    mockStatisticService = createMock(StatisticService.class);
    expect(mockStatisticService.load(link1)).andReturn(new DefaultLoad(2, 1, 1));
    expect(mockStatisticService.load(link2)).andReturn(new DefaultLoad(22, 11, 1));
    expect(mockStatisticService.load(link3)).andReturn(new DefaultLoad(222, 111, 1));
    replay(mockLinkService, mockStatisticService);
    // Register the services needed for the test
    CodecManager codecService = new CodecManager();
    codecService.activate();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(LinkService.class, mockLinkService).add(StatisticService.class, mockStatisticService).add(CodecService.class, codecService);
    setServiceDirectory(testDirectory);
}
Also used : ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) StatisticService(org.onosproject.net.statistic.StatisticService) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CodecManager(org.onosproject.codec.impl.CodecManager) LinkService(org.onosproject.net.link.LinkService) DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Before(org.junit.Before)

Example 12 with CodecManager

use of org.onosproject.codec.impl.CodecManager in project onos by opennetworkinglab.

the class TopologyResourceTest method setUpTest.

/**
 * Initializes the test harness.
 */
@Before
public void setUpTest() {
    TopologyService topologyService = new MockTopologyService();
    DeviceService mockDeviceService = new MockDeviceService();
    CodecManager codecService = new CodecManager();
    codecService.activate();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(DeviceService.class, mockDeviceService).add(TopologyService.class, topologyService).add(CodecService.class, codecService);
    setServiceDirectory(testDirectory);
}
Also used : ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) DeviceService(org.onosproject.net.device.DeviceService) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CodecManager(org.onosproject.codec.impl.CodecManager) TopologyService(org.onosproject.net.topology.TopologyService) Before(org.junit.Before)

Example 13 with CodecManager

use of org.onosproject.codec.impl.CodecManager in project onos by opennetworkinglab.

the class ApplicationsResourceTest method setUpMocks.

/**
 * Initializes test mocks and environment.
 */
@Before
public void setUpMocks() {
    appService = createMock(ApplicationAdminService.class);
    coreService = createMock(CoreService.class);
    expect(appService.getId("one")).andReturn(id1).anyTimes();
    expect(appService.getId("two")).andReturn(id2).anyTimes();
    expect(appService.getId("three")).andReturn(id3).anyTimes();
    expect(appService.getId("four")).andReturn(id4).anyTimes();
    expect(appService.getApplication(id3)).andReturn(app3).anyTimes();
    expect(appService.getState(isA(ApplicationId.class))).andReturn(ApplicationState.ACTIVE).anyTimes();
    // Register the services needed for the test
    CodecManager codecService = new CodecManager();
    codecService.activate();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(ApplicationAdminService.class, appService).add(ApplicationService.class, appService).add(CoreService.class, coreService).add(CodecService.class, codecService);
    setServiceDirectory(testDirectory);
}
Also used : ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CoreService(org.onosproject.core.CoreService) CodecManager(org.onosproject.codec.impl.CodecManager) ApplicationAdminService(org.onosproject.app.ApplicationAdminService) Before(org.junit.Before)

Example 14 with CodecManager

use of org.onosproject.codec.impl.CodecManager in project onos by opennetworkinglab.

the class FlowsResourceTest method setUpTest.

/**
 * Sets up the global values for all the tests.
 */
@Before
public void setUpTest() {
    // Mock device service
    expect(mockDeviceService.getDevice(deviceId1)).andReturn(device1);
    expect(mockDeviceService.getDevice(deviceId2)).andReturn(device2);
    expect(mockDeviceService.getDevices()).andReturn(ImmutableSet.of(device1, device2));
    // Mock Core Service
    expect(mockCoreService.getAppId(anyShort())).andReturn(NetTestTools.APP_ID).anyTimes();
    expect(mockCoreService.getAppId(anyString())).andReturn(NetTestTools.APP_ID).anyTimes();
    expect(mockCoreService.registerApplication(FlowRuleCodec.REST_APP_ID)).andReturn(APP_ID).anyTimes();
    replay(mockCoreService);
    // Register the services needed for the test
    final CodecManager codecService = new CodecManager();
    codecService.activate();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(FlowRuleService.class, mockFlowService).add(DeviceService.class, mockDeviceService).add(CodecService.class, codecService).add(CoreService.class, mockCoreService).add(ApplicationService.class, mockApplicationService);
    setServiceDirectory(testDirectory);
}
Also used : ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) DeviceService(org.onosproject.net.device.DeviceService) CoreService(org.onosproject.core.CoreService) CodecManager(org.onosproject.codec.impl.CodecManager) Before(org.junit.Before)

Example 15 with CodecManager

use of org.onosproject.codec.impl.CodecManager in project onos by opennetworkinglab.

the class BaseConfigTestHelper method setUpBaseConfigClass.

@BeforeClass
public static void setUpBaseConfigClass() throws TestUtilsException {
    directory = new TestServiceDirectory();
    CodecManager codecService = new CodecManager();
    codecService.activate();
    directory.add(CodecService.class, codecService);
    // replace service directory used by BaseConfig
    original = TestUtils.getField(BaseConfig.class, "services");
    TestUtils.setField(BaseConfig.class, "services", directory);
}
Also used : TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CodecManager(org.onosproject.codec.impl.CodecManager) BaseConfig(org.onosproject.net.config.BaseConfig) BeforeClass(org.junit.BeforeClass)

Aggregations

CodecManager (org.onosproject.codec.impl.CodecManager)53 Before (org.junit.Before)48 TestServiceDirectory (org.onlab.osgi.TestServiceDirectory)35 ServiceDirectory (org.onlab.osgi.ServiceDirectory)30 LispMappingExtensionCodecRegistrator (org.onosproject.drivers.lisp.extensions.LispMappingExtensionCodecRegistrator)10 MappingCodecRegistrator (org.onosproject.mapping.MappingCodecRegistrator)7 BeforeClass (org.junit.BeforeClass)5 CodecService (org.onosproject.codec.CodecService)5 BaseConfig (org.onosproject.net.config.BaseConfig)5 DeviceService (org.onosproject.net.device.DeviceService)5 CoreService (org.onosproject.core.CoreService)2 K8sNetworkAdminService (org.onosproject.k8snetworking.api.K8sNetworkAdminService)2 MetricsService (org.onlab.metrics.MetricsService)1 ApplicationAdminService (org.onosproject.app.ApplicationAdminService)1 ClusterService (org.onosproject.cluster.ClusterService)1 ControllerNode (org.onosproject.cluster.ControllerNode)1 NodeId (org.onosproject.cluster.NodeId)1 ControlLoadSnapshotCodec (org.onosproject.cpman.codec.ControlLoadSnapshotCodec)1 LispAppDataAddress (org.onosproject.drivers.lisp.extensions.LispAppDataAddress)1 LispAsAddress (org.onosproject.drivers.lisp.extensions.LispAsAddress)1