Search in sources :

Example 51 with Src

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.Src in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testSvecObject.

@Test
public void testSvecObject() throws IOException, PCEPDeserializerException {
    final PCEPSvecObjectParser parser = new PCEPSvecObjectParser();
    ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject2.bin"));
    final SvecBuilder builder = new SvecBuilder();
    builder.setProcessingRule(false);
    builder.setIgnore(false);
    builder.setLinkDiverse(false);
    builder.setNodeDiverse(false);
    builder.setSrlgDiverse(false);
    builder.setRequestsIds(Lists.newArrayList(new RequestId(0xFFL)));
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
    ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject1_10ReqIDs.bin"));
    builder.setProcessingRule(true);
    builder.setLinkDiverse(true);
    builder.setSrlgDiverse(true);
    final List<RequestId> requestIDs = Lists.newArrayList();
    requestIDs.add(new RequestId(0xFFFFFFFFL));
    requestIDs.add(new RequestId(0x00000001L));
    requestIDs.add(new RequestId(0x01234567L));
    requestIDs.add(new RequestId(0x89ABCDEFL));
    requestIDs.add(new RequestId(0xFEDCBA98L));
    requestIDs.add(new RequestId(0x76543210L));
    requestIDs.add(new RequestId(0x15825266L));
    requestIDs.add(new RequestId(0x48120BBEL));
    requestIDs.add(new RequestId(0x25FB7E52L));
    requestIDs.add(new RequestId(0xB2F2546BL));
    builder.setRequestsIds(requestIDs);
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
    buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) PCEPSvecObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPSvecObjectParser) SvecBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.svec.object.SvecBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 52 with Src

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.Src in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testOpenObjectWOTLV.

@Test
public void testOpenObjectWOTLV() throws PCEPDeserializerException, IOException {
    final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(this.tlvRegistry, this.viTlvRegistry);
    final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
    final OpenBuilder builder = new OpenBuilder();
    builder.setProcessingRule(false);
    builder.setIgnore(false);
    builder.setVersion(new ProtocolVersion((short) 1));
    builder.setKeepalive((short) 30);
    builder.setDeadTimer((short) 120);
    builder.setSessionId((short) 1);
    builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().build());
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
    final ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) ByteBuf(io.netty.buffer.ByteBuf) ProtocolVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.error.object.TlvsBuilder) PCEPOpenObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPOpenObjectParser) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject) Test(org.junit.Test)

Example 53 with Src

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.Src in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testRPObjectWithTlv.

@Test
public void testRPObjectWithTlv() throws PCEPDeserializerException, IOException {
    final PCEPRequestParameterObjectParser parser = new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
    ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject1.bin"));
    final RpBuilder builder = new RpBuilder();
    builder.setProcessingRule(true);
    builder.setIgnore(true);
    builder.setReoptimization(true);
    builder.setBiDirectional(false);
    builder.setLoose(true);
    builder.setMakeBeforeBreak(true);
    builder.setOrder(false);
    builder.setPathKey(false);
    builder.setSupplyOf(false);
    builder.setFragmentation(false);
    builder.setP2mp(false);
    builder.setEroCompression(false);
    builder.setPriority((short) 5);
    builder.setRequestId(new RequestId(0xdeadbeefL));
    builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder().build());
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject2.bin"));
    builder.setReoptimization(false);
    builder.setFragmentation(true);
    builder.setEroCompression(true);
    final OrderBuilder b = new OrderBuilder();
    b.setDelete(0xffffffffL);
    b.setSetup(1L);
    builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder().setOrder(b.build()).build());
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) ByteBuf(io.netty.buffer.ByteBuf) PCEPRequestParameterObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser) OrderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.OrderBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.error.object.TlvsBuilder) RpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.RpBuilder) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject) Test(org.junit.Test)

Example 54 with Src

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.Src in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testLspaObjectSerializerDefence.

@Test
public void testLspaObjectSerializerDefence() throws IOException, PCEPDeserializerException {
    final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
    final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
    final LspaBuilder builder = new LspaBuilder();
    builder.setProcessingRule(true);
    builder.setIgnore(true);
    builder.setLocalProtectionDesired(false);
    final ByteBuf buf = Unpooled.buffer(result.readableBytes());
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
Also used : LspaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.LspaBuilder) PCEPLspaObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPLspaObjectParser) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 55 with Src

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.Src in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testMetricObject.

@Test
public void testMetricObject() throws IOException, PCEPDeserializerException {
    final PCEPMetricObjectParser parser = new PCEPMetricObjectParser();
    ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPMetricObject1LowerBounds.bin"));
    final MetricBuilder builder = new MetricBuilder();
    builder.setProcessingRule(true);
    builder.setIgnore(true);
    builder.setComputed(false);
    builder.setBound(false);
    builder.setMetricType((short) 1);
    builder.setValue(new Float32(new byte[] { 0, 0, 0, 0 }));
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPMetricObject2UpperBounds.bin"));
    builder.setComputed(true);
    builder.setBound(false);
    builder.setMetricType((short) 2);
    builder.setValue(new Float32(new byte[] { (byte) 0x4f, (byte) 0x70, (byte) 0x00, (byte) 0x00 }));
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : Float32(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) PCEPMetricObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPMetricObjectParser) ByteBuf(io.netty.buffer.ByteBuf) MetricBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.metric.object.MetricBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)85 ByteBuf (io.netty.buffer.ByteBuf)51 BigInteger (java.math.BigInteger)32 ArrayList (java.util.ArrayList)29 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)25 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)23 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)20 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)20 Ipv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)18 UdpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch)18 TcpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch)17 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)16 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)15 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder)15 Ipv6Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match)14 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)13 SctpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch)13 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match)12 ArpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch)12 FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)12