Search in sources :

Example 36 with OfHeader

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.

the class PacketProcessingServiceImplTest method testBuildRequest.

@Test
public void testBuildRequest() throws Exception {
    TransmitPacketInput transmitPacketInput = buildTransmitPacketInput();
    final OfHeader request = packetProcessingService.buildRequest(new Xid(DUMMY_XID_VALUE), transmitPacketInput);
    assertEquals(DUMMY_XID_VALUE, request.getXid());
    assertTrue(request instanceof PacketOutInput);
    final PacketOutInput input = (PacketOutInput) request;
    assertEquals(OFConstants.OFP_NO_BUFFER, input.getBufferId());
    assertEquals(1, input.getAction().size());
    assertEquals(OutputActionCase.class, input.getAction().get(0).getActionChoice().getImplementedInterface());
    final OutputActionCase actionChoice = (OutputActionCase) input.getAction().get(0).getActionChoice();
    assertEquals(1, actionChoice.getOutputAction().getPort().getValue().intValue());
    assertEquals(ULTIMATE_PAYLOAD, new String(input.getData()));
}
Also used : Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) TransmitPacketInput(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput) OutputActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase) PacketOutInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput) Test(org.junit.Test)

Example 37 with OfHeader

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.

the class OpendaylightFlowTableStatisticsServiceImplTest method testBuildRequest.

@Test
public void testBuildRequest() throws Exception {
    Xid xid = new Xid(42L);
    GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder().setNode(createNodeRef("unitProt:123"));
    final OfHeader request = flowTableStatisticsService.buildRequest(xid, input.build());
    Assert.assertTrue(request instanceof MultipartRequestInput);
    final MultipartRequestInput mpRequest = (MultipartRequestInput) request;
    Assert.assertEquals(MultipartType.OFPMPTABLE, mpRequest.getType());
    Assert.assertTrue(mpRequest.getMultipartRequestBody() instanceof MultipartRequestTableCase);
    final MultipartRequestTableCase mpRequestBody = (MultipartRequestTableCase) (mpRequest.getMultipartRequestBody());
    Assert.assertTrue(mpRequestBody.getMultipartRequestTable().isEmpty());
}
Also used : MultipartRequestTableCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCase) Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) GetFlowTablesStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 38 with OfHeader

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.

the class StatisticsGatheringOnTheFlyServiceTest method testBuildRequest.

@Test
public void testBuildRequest() throws Exception {
    final long xidValue = 21L;
    Xid xid = new Xid(xidValue);
    final OfHeader request = statisticsGatheringService.buildRequest(xid, MultipartType.OFPMPFLOW);
    Assert.assertEquals(MultipartRequestInput.class, request.getImplementedInterface());
    Assert.assertEquals(xidValue, request.getXid().longValue());
    Assert.assertNotNull(request);
}
Also used : Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) Test(org.junit.Test)

Example 39 with OfHeader

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.

the class StackedSegment method completeEntry.

private static boolean completeEntry(final OutboundQueueEntry entry, final OfHeader response) {
    if (response instanceof Error) {
        final Error err = (Error) response;
        LOG.debug("Device-reported request XID {} failed {}:{}", response.getXid(), err.getTypeString(), err.getCodeString());
        entry.fail(new DeviceRequestFailedException("Device-side failure", err));
        return true;
    }
    return entry.complete(response);
}
Also used : Error(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error) DeviceRequestFailedException(org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException)

Example 40 with OfHeader

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.

the class ResponseExpectedRpcListenerTest method testCompleted.

/**
 * Test object creation.
 */
@Test
public void testCompleted() {
    RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName());
    ResponseExpectedRpcListener<OfHeader> listener = new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key);
    BarrierInputBuilder barrierBuilder = new BarrierInputBuilder();
    BarrierInput barrierInput = barrierBuilder.build();
    listener.completed(barrierInput);
    SettableFuture<RpcResult<?>> result = SettableFuture.create();
    result.set(RpcResultBuilder.success(barrierInput).build());
    try {
        Assert.assertEquals("Wrong result", result.get().getErrors(), listener.getResult().get().getErrors());
        Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult());
        Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful());
    } catch (InterruptedException | ExecutionException e) {
        fail("Problem accessing result");
    }
}
Also used : BarrierInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) BarrierInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException) BarrierOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput) Test(org.junit.Test)

Aggregations

OfHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader)30 Test (org.junit.Test)23 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)17 Xid (org.opendaylight.openflowplugin.api.openflow.device.Xid)10 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)5 ExecutionException (java.util.concurrent.ExecutionException)3 ServiceException (org.opendaylight.openflowplugin.impl.services.util.ServiceException)3 GroupMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupMessage)3 MultipartType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType)3 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 List (java.util.List)2 Future (java.util.concurrent.Future)2 Function (java.util.function.Function)2 OFDeserializer (org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer)2 TypeVersionKey (org.opendaylight.openflowplugin.extension.api.TypeVersionKey)2 ConversionException (org.opendaylight.openflowplugin.extension.api.exception.ConversionException)2 ConverterNotFoundException (org.opendaylight.openflowplugin.extension.api.exception.ConverterNotFoundException)2 ConvertorExecutor (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor)2 PortMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortMessage)2 FlowMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowMessage)2