Search in sources :

Example 11 with CodecService

use of org.onosproject.codec.CodecService 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 12 with CodecService

use of org.onosproject.codec.CodecService in project onos by opennetworkinglab.

the class OpenstackNetworkingCodecRegisterTest method testActivateDeactivate.

/**
 * Tests codec register activation and deactivation.
 */
@Test
public void testActivateDeactivate() {
    register = new OpenstackNetworkingCodecRegister();
    CodecService codecService = new TestCodecService();
    TestUtils.setField(register, "codecService", codecService);
    register.activate();
    assertEquals(InstancePortCodec.class.getName(), codecService.getCodec(InstancePort.class).getClass().getName());
    register.deactivate();
    assertNull(codecService.getCodec(InstancePort.class));
}
Also used : InstancePortCodec(org.onosproject.openstacknetworking.codec.InstancePortCodec) CodecService(org.onosproject.codec.CodecService) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) Test(org.junit.Test)

Example 13 with CodecService

use of org.onosproject.codec.CodecService in project onos by opennetworkinglab.

the class OpenstackRestCodecRegisterTest method testActivateDeactivate.

/**
 * Tests codec register activation and deactivation.
 */
@Test
public void testActivateDeactivate() {
    register = new OpenstackRestCodecRegister();
    CodecService codecService = new TestCodecService();
    TestUtils.setField(register, "codecService", codecService);
    register.activate();
    assertEquals(StatsInfoJsonCodec.class.getName(), codecService.getCodec(StatsInfo.class).getClass().getName());
    assertEquals(FlowInfoJsonCodec.class.getName(), codecService.getCodec(FlowInfo.class).getClass().getName());
    assertEquals(StatsFlowRuleJsonCodec.class.getName(), codecService.getCodec(StatsFlowRule.class).getClass().getName());
    assertEquals(TelemetryConfigJsonCodec.class.getName(), codecService.getCodec(TelemetryConfig.class).getClass().getName());
    register.deactivate();
    assertNull(codecService.getCodec(StatsInfo.class));
    assertNull(codecService.getCodec(FlowInfo.class));
    assertNull(codecService.getCodec(StatsFlowRule.class));
    assertNull(codecService.getCodec(TelemetryConfig.class));
}
Also used : FlowInfo(org.onosproject.openstacktelemetry.api.FlowInfo) StatsFlowRule(org.onosproject.openstacktelemetry.api.StatsFlowRule) StatsInfo(org.onosproject.openstacktelemetry.api.StatsInfo) CodecService(org.onosproject.codec.CodecService) TelemetryConfigJsonCodec(org.onosproject.openstacktelemetry.codec.rest.TelemetryConfigJsonCodec) StatsInfoJsonCodec(org.onosproject.openstacktelemetry.codec.rest.StatsInfoJsonCodec) StatsFlowRuleJsonCodec(org.onosproject.openstacktelemetry.codec.rest.StatsFlowRuleJsonCodec) FlowInfoJsonCodec(org.onosproject.openstacktelemetry.codec.rest.FlowInfoJsonCodec) TelemetryConfig(org.onosproject.openstacktelemetry.api.config.TelemetryConfig) Test(org.junit.Test)

Aggregations

CodecService (org.onosproject.codec.CodecService)13 Test (org.junit.Test)8 Before (org.junit.Before)5 ServiceDirectory (org.onlab.osgi.ServiceDirectory)5 TestServiceDirectory (org.onlab.osgi.TestServiceDirectory)5 CodecManager (org.onosproject.codec.impl.CodecManager)5 K8sNode (org.onosproject.k8snode.api.K8sNode)2 K8sNetwork (org.onosproject.k8snetworking.api.K8sNetwork)1 K8sPort (org.onosproject.k8snetworking.api.K8sPort)1 K8sNetworkCodec (org.onosproject.k8snetworking.codec.K8sNetworkCodec)1 K8sPortCodec (org.onosproject.k8snetworking.codec.K8sPortCodec)1 K8sNodeCodec (org.onosproject.k8snode.codec.K8sNodeCodec)1 KubevirtHostRoute (org.onosproject.kubevirtnetworking.api.KubevirtHostRoute)1 KubevirtIpPool (org.onosproject.kubevirtnetworking.api.KubevirtIpPool)1 KubevirtNetwork (org.onosproject.kubevirtnetworking.api.KubevirtNetwork)1 KubevirtHostRouteCodec (org.onosproject.kubevirtnetworking.codec.KubevirtHostRouteCodec)1 KubevirtIpPoolCodec (org.onosproject.kubevirtnetworking.codec.KubevirtIpPoolCodec)1 KubevirtNetworkCodec (org.onosproject.kubevirtnetworking.codec.KubevirtNetworkCodec)1 KubevirtNode (org.onosproject.kubevirtnode.api.KubevirtNode)1 KubevirtPhyInterface (org.onosproject.kubevirtnode.api.KubevirtPhyInterface)1