use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Src in project netvirt by opendaylight.
the class ElanServiceTestModule method configureBindings.
@Override
protected void configureBindings() {
DataBroker dataBroker = DataBrokerTestModule.dataBroker();
bind(EntityOwnershipService.class).toInstance(Mockito.mock(EntityOwnershipService.class));
bind(INeutronVpnManager.class).toInstance(Mockito.mock(NeutronvpnManagerImpl.class));
IVpnManager ivpnManager = Mockito.mock(VpnManagerTestImpl.class, CALLS_REAL_METHODS);
bind(IMdsalApiManager.class).toInstance(new MDSALManager(dataBroker, Mockito.mock(PacketProcessingService.class)));
// Bindings for external services to "real" implementations
bind(LockManagerService.class).to(LockManagerServiceImpl.class);
bind(ElanConfig.class).toInstance(new ElanConfigBuilder().setIntBridgeGenMac(true).setTempSmacLearnTimeout(10).build());
// Bindings of all listeners (which are not directly referenced in the code)
// This is required to be explicit here, because these are referenced neither from src/main nor src/test
// and we, intentionally, don't use "classpath scanning for auto-discovery"
// so this list must kept, manually, in line with the rc/main/resources/org/opendaylight/blueprint/*.xml
// and target/generated-resources/org/opendaylight/blueprint/autowire.xml
// bind(ElanGroupListener.class);
// TODO complete this list!!! after Gerrit which adds @Inject to all listeners
// Bindings to test infra (fakes & mocks)
TestInterfaceManager obj = TestInterfaceManager.newInstance(dataBroker);
ItmRpcService itmRpcService = new ItmRpcTestImpl();
bind(DataBroker.class).toInstance(dataBroker);
bind(DataBroker.class).annotatedWith(OsgiService.class).toInstance(dataBroker);
bind(IdManagerService.class).toInstance(Mockito.mock(IdHelper.class, CALLS_REAL_METHODS));
bind(IInterfaceManager.class).toInstance(obj);
bind(TestInterfaceManager.class).toInstance(obj);
InterfaceMetaUtils interfaceMetaUtils = new InterfaceMetaUtils(dataBroker, Mockito.mock(IdHelper.class, CALLS_REAL_METHODS), Mockito.mock(BatchingUtils.class));
InterfaceManagerCommonUtils interfaceManagerCommonUtils = new InterfaceManagerCommonUtils(dataBroker, new MDSALManager(dataBroker, Mockito.mock(PacketProcessingService.class)), Mockito.mock(IdHelper.class, CALLS_REAL_METHODS), interfaceMetaUtils, Mockito.mock(BatchingUtils.class));
bind(OdlInterfaceRpcService.class).toInstance(ElanEgressActionsHelper.newInstance(interfaceManagerCommonUtils));
SingleTransactionDataBroker singleTransactionDataBroker = new SingleTransactionDataBroker(dataBroker);
bind(SingleTransactionDataBroker.class).toInstance(singleTransactionDataBroker);
IBgpManager ibgpManager = BgpManagerTestImpl.newInstance(singleTransactionDataBroker);
bind(ItmRpcService.class).toInstance(itmRpcService);
bind(ItmRpcTestImpl.class).toInstance((ItmRpcTestImpl) itmRpcService);
bind(DataImportBootReady.class).annotatedWith(OsgiService.class).toInstance(new DataImportBootReady() {
});
bind(DiagStatusService.class).toInstance(Mockito.mock(DiagStatusService.class));
bind(IVpnManager.class).toInstance(ivpnManager);
bind(IBgpManager.class).toInstance(ibgpManager);
bind(DataImportBootReady.class).toInstance(new DataImportBootReady() {
});
bind(IElanService.class).to(ElanServiceProvider.class);
MdsalUtils mdsalUtils = new MdsalUtils(dataBroker);
bind(MdsalUtils.class).toInstance(mdsalUtils);
bind(SouthboundUtils.class).toInstance(new SouthboundUtils(mdsalUtils));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Src in project bgpcep by opendaylight.
the class PCEPValidatorTest method testRepMsgWithVendorInforObjects.
@Test
public void testRepMsgWithVendorInforObjects() throws IOException, PCEPDeserializerException {
final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
final PcrepMessageBuilder builder = new PcrepMessageBuilder();
RepliesBuilder rBuilder = new RepliesBuilder();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.6.bin"));
final List<Replies> replies = Lists.newArrayList();
rBuilder = new RepliesBuilder();
rBuilder.setRp(this.rpTrue);
rBuilder.setVendorInformationObject(this.viObjects);
final List<Paths> paths = Lists.newArrayList();
final PathsBuilder paBuilder = new PathsBuilder();
paBuilder.setEro(this.ero);
paths.add(paBuilder.build());
rBuilder.setResult(new SuccessCaseBuilder().setSuccess(new SuccessBuilder().setPaths(paths).setVendorInformationObject(this.viObjects).build()).build()).build();
replies.add(rBuilder.build());
builder.setReplies(replies);
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Src in project bgpcep by opendaylight.
the class PCEPValidatorTest method testMonReqMsg.
@Test
public void testMonReqMsg() throws PCEPDeserializerException, IOException {
final PCEPMonitoringRequestMessageParser parser = new PCEPMonitoringRequestMessageParser(this.objectRegistry);
final PcreqMessageBuilder builder = new PcreqMessageBuilder();
final MonitoringRequestBuilder monReqBuilder = new MonitoringRequestBuilder();
monReqBuilder.setMonitoring(this.monitoring);
monReqBuilder.setPceIdList(Lists.newArrayList(new PceIdListBuilder().setPceId(this.pceId).build()));
builder.setMonitoringRequest(monReqBuilder.build());
final byte[] msgBytes = { 0x20, 0x08, 0x00, 0x18, /* monitoring object */
0x13, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, /* pce-id object */
0x19, 0x10, 0x00, 0x08, 0x7f, 0x00, 0x00, 0x02 };
ByteBuf result = Unpooled.wrappedBuffer(msgBytes);
assertEquals(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCMonReq.bin"));
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Requests> reqs2 = Lists.newArrayList();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.RequestsBuilder rBuilder1 = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.RequestsBuilder();
rBuilder1.setRp(this.rpTrue);
final P2pBuilder p2pBuilder = new P2pBuilder();
p2pBuilder.setEndpointsObj(this.endpoints);
p2pBuilder.setMetrics(Lists.newArrayList(this.metrics));
p2pBuilder.setIro(this.iro);
rBuilder1.setSegmentComputation(new SegmentComputationBuilder().setP2p(p2pBuilder.build()).build());
reqs2.add(rBuilder1.build());
builder.setRequests(reqs2);
builder.setSvec(Lists.newArrayList(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.SvecBuilder().setSvec(this.svec).build()));
monReqBuilder.setMonitoring(this.monitoring);
monReqBuilder.setPccIdReq(this.pccIdReq);
final PceIdList pceIdList = new PceIdListBuilder().setPceId(this.pceId).build();
monReqBuilder.setPceIdList(Lists.newArrayList(pceIdList, pceIdList));
builder.setMonitoringRequest(monReqBuilder.build());
assertEquals(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Src in project bgpcep by opendaylight.
the class PCEPValidatorTest method testReplyMsg.
@Test
public void testReplyMsg() throws IOException, PCEPDeserializerException {
// only RP
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.1.bin"));
final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
final PcrepMessageBuilder builder = new PcrepMessageBuilder();
RepliesBuilder rBuilder = new RepliesBuilder();
final List<Replies> replies1 = Lists.newArrayList();
rBuilder.setRp(this.rpTrue);
replies1.add(rBuilder.build());
builder.setReplies(replies1);
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
// simple Failure
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.2.bin"));
final List<Replies> replies2 = Lists.newArrayList();
rBuilder = new RepliesBuilder();
rBuilder.setRp(this.rpTrue);
replies2.add(rBuilder.build());
final RepliesBuilder rBuilder2 = new RepliesBuilder();
rBuilder2.setRp(this.rpTrue);
rBuilder2.setResult(new FailureCaseBuilder().setNoPath(this.noPath).build());
replies2.add(rBuilder2.build());
builder.setReplies(replies2);
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
// Failure with attributes
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.3.bin"));
final List<Replies> replies3 = Lists.newArrayList();
rBuilder = new RepliesBuilder();
rBuilder.setRp(this.rpTrue);
rBuilder.setResult(new FailureCaseBuilder().setNoPath(this.noPath).setLspa(this.lspa).setMetrics(Lists.newArrayList(this.metrics)).setIro(this.iro).build());
replies3.add(rBuilder.build());
builder.setReplies(replies3);
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
// Success
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.5.bin"));
final List<Replies> replies4 = Lists.newArrayList();
rBuilder = new RepliesBuilder();
rBuilder.setRp(this.rpTrue);
final List<Paths> paths = Lists.newArrayList();
final PathsBuilder paBuilder = new PathsBuilder();
paBuilder.setEro(this.ero);
paBuilder.setLspa(this.lspa);
paBuilder.setMetrics(Lists.newArrayList(this.metrics));
paBuilder.setIro(this.iro);
paBuilder.setOf(this.of);
paths.add(paBuilder.build());
rBuilder.setResult(new SuccessCaseBuilder().setSuccess(new SuccessBuilder().setPaths(paths).build()).build()).build();
replies4.add(rBuilder.build());
builder.setReplies(replies4);
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
try {
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(new PcrepMessageBuilder().build()).build(), null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Replies cannot be null or empty.", e.getMessage());
}
try {
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(new PcrepMessageBuilder().setReplies(Collections.emptyList()).build()).build(), null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Replies cannot be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Src in project bgpcep by opendaylight.
the class PCEPValidatorTest method testReqWithMonitoring.
@Test
public void testReqWithMonitoring() throws IOException, PCEPDeserializerException {
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCReq.8.bin"));
final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(this.objectRegistry);
final PcreqMessageBuilder builder = new PcreqMessageBuilder();
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Requests> reqs1 = Lists.newArrayList();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.RequestsBuilder rBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.RequestsBuilder();
rBuilder.setRp(this.rpTrue);
rBuilder.setSegmentComputation(new SegmentComputationBuilder().setP2p(new P2pBuilder().setEndpointsObj(this.endpoints).build()).build());
reqs1.add(rBuilder.build());
final MonitoringRequestBuilder monReqBuilder = new MonitoringRequestBuilder();
monReqBuilder.setMonitoring(this.monitoring);
monReqBuilder.setPccIdReq(this.pccIdReq);
monReqBuilder.setPceIdList(Lists.newArrayList(new PceIdListBuilder().setPceId(this.pceId).build()));
builder.setMonitoringRequest(monReqBuilder.build());
builder.setRequests(reqs1);
assertEquals(new PcreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcreqBuilder().setPcreqMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
Aggregations