Search in sources :

Example 46 with CodecManager

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

the class DevicesResourceTest method setUpMocks.

/**
 * Initializes test mocks and environment.
 */
@Before
public void setUpMocks() {
    mockDeviceService = createMock(DeviceService.class);
    mockDriverService = createMock(DriverService.class);
    expect(mockDeviceService.isAvailable(isA(DeviceId.class))).andReturn(true).anyTimes();
    expect(mockDeviceService.getRole(isA(DeviceId.class))).andReturn(MastershipRole.MASTER).anyTimes();
    expect(mockDeviceService.getLastUpdatedInstant(isA(DeviceId.class))).andReturn(0L).anyTimes();
    expect(mockDeviceService.localStatus(isA(DeviceId.class))).andReturn("").anyTimes();
    // Register the services needed for the test
    CodecManager codecService = new CodecManager();
    codecService.activate();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(DeviceService.class, mockDeviceService).add(DriverService.class, mockDriverService).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) DriverService(org.onosproject.net.driver.DriverService) Before(org.junit.Before)

Example 47 with CodecManager

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

the class GroupsResourceTest 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.registerApplication(GroupCodec.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(GroupService.class, mockGroupService).add(DeviceService.class, mockDeviceService).add(CodecService.class, codecService).add(CoreService.class, mockCoreService);
    setServiceDirectory(testDirectory);
}
Also used : ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CodecService(org.onosproject.codec.CodecService) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CodecManager(org.onosproject.codec.impl.CodecManager) GroupService(org.onosproject.net.group.GroupService) Before(org.junit.Before)

Example 48 with CodecManager

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

the class HostResourceTest method setUpTest.

/**
 * Initializes test mocks and environment.
 */
@Before
public void setUpTest() {
    expect(mockHostService.getHosts()).andReturn(hosts).anyTimes();
    // Register the services needed for the test
    final CodecManager codecService = new CodecManager();
    codecService.activate();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(HostService.class, mockHostService).add(HostAdminService.class, mockHostService).add(CodecService.class, codecService).add(HostProviderRegistry.class, mockHostProviderRegistry);
    setServiceDirectory(testDirectory);
}
Also used : HostService(org.onosproject.net.host.HostService) ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CodecService(org.onosproject.codec.CodecService) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CodecManager(org.onosproject.codec.impl.CodecManager) Before(org.junit.Before)

Example 49 with CodecManager

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

the class KubevirtNetworkWebResourceTest method setUpTest.

/**
 * Sets up the global values for all the tests.
 */
@Before
public void setUpTest() {
    final CodecManager codecService = new CodecManager();
    codecService.activate();
    codecService.registerCodec(KubevirtHostRoute.class, new KubevirtHostRouteCodec());
    codecService.registerCodec(KubevirtIpPool.class, new KubevirtIpPoolCodec());
    codecService.registerCodec(KubevirtNetwork.class, new KubevirtNetworkCodec());
    ServiceDirectory testDirectory = new TestServiceDirectory().add(KubevirtNetworkAdminService.class, mockAdminService).add(CodecService.class, codecService);
    setServiceDirectory(testDirectory);
    network = DefaultKubevirtNetwork.builder().networkId("network").name("network").type(KubevirtNetwork.Type.FLAT).cidr("10.10.10.0/24").mtu(1500).gatewayIp(IpAddress.valueOf("10.10.10.1")).defaultRoute(true).ipPool(new KubevirtIpPool(IpAddress.valueOf("10.10.10.100"), IpAddress.valueOf("10.10.10.200"))).build();
}
Also used : KubevirtNetworkCodec(org.onosproject.kubevirtnetworking.codec.KubevirtNetworkCodec) ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) KubevirtNetworkAdminService(org.onosproject.kubevirtnetworking.api.KubevirtNetworkAdminService) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CodecManager(org.onosproject.codec.impl.CodecManager) KubevirtIpPool(org.onosproject.kubevirtnetworking.api.KubevirtIpPool) KubevirtIpPoolCodec(org.onosproject.kubevirtnetworking.codec.KubevirtIpPoolCodec) KubevirtHostRouteCodec(org.onosproject.kubevirtnetworking.codec.KubevirtHostRouteCodec) Before(org.junit.Before)

Example 50 with CodecManager

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

the class KubevirtNodeWebResourceTest method setUpTest.

/**
 * Sets up the global values for all the tests.
 */
@Before
public void setUpTest() {
    final CodecManager codecService = new CodecManager();
    codecService.activate();
    codecService.registerCodec(KubevirtNode.class, new KubevirtNodeCodec());
    ServiceDirectory testDirectory = new TestServiceDirectory().add(KubevirtNodeAdminService.class, mockKubevirtNodeAdminService).add(CodecService.class, codecService);
    setServiceDirectory(testDirectory);
    kubevirtNode = DefaultKubevirtNode.builder().hostname("worker-node").type(KubevirtNode.Type.WORKER).dataIp(IpAddress.valueOf("10.134.34.222")).managementIp(IpAddress.valueOf("10.134.231.30")).intgBridge(DeviceId.deviceId("of:00000000000000a1")).tunBridge(DeviceId.deviceId("of:00000000000000a2")).state(KubevirtNodeState.INIT).build();
}
Also used : KubevirtNodeCodec(org.onosproject.kubevirtnode.codec.KubevirtNodeCodec) ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) KubevirtNodeAdminService(org.onosproject.kubevirtnode.api.KubevirtNodeAdminService) CodecManager(org.onosproject.codec.impl.CodecManager) Before(org.junit.Before)

Aggregations

CodecManager (org.onosproject.codec.impl.CodecManager)55 Before (org.junit.Before)50 TestServiceDirectory (org.onlab.osgi.TestServiceDirectory)37 ServiceDirectory (org.onlab.osgi.ServiceDirectory)32 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 KubevirtHostRouteCodec (org.onosproject.kubevirtnetworking.codec.KubevirtHostRouteCodec)2 KubevirtIpPoolCodec (org.onosproject.kubevirtnetworking.codec.KubevirtIpPoolCodec)2 KubevirtNetworkCodec (org.onosproject.kubevirtnetworking.codec.KubevirtNetworkCodec)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