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()));
}
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());
}
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);
}
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);
}
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");
}
}
Aggregations