Search in sources :

Example 1 with LispMulticastAddress

use of org.onosproject.drivers.lisp.extensions.LispMulticastAddress in project onos by opennetworkinglab.

the class LispMulticastAddressCodecTest method testLispMulticastAddressEncode.

/**
 * Tests encoding of a LispMulticastAddress object.
 */
@Test
public void testLispMulticastAddressEncode() {
    LispMulticastAddress address = new LispMulticastAddress.Builder().withInstanceId(INSTANCE_ID).withSrcMaskLength(SRC_MASK_LENGTH).withGrpMaskLength(GRP_MASK_LENGTH).withSrcAddress(MappingAddresses.ipv4MappingAddress(SRC_ADDRESS_PREFIX)).withGrpAddress(MappingAddresses.ipv4MappingAddress(GRP_ADDRESS_PREFIX)).build();
    ObjectNode addressJson = multicastAddressCodec.encode(address, context);
    assertThat("errors in encoding Multicast address JSON", addressJson, LispMulticastAddressJsonMatcher.matchesMulticastAddress(address));
}
Also used : LispMulticastAddress(org.onosproject.drivers.lisp.extensions.LispMulticastAddress) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Test(org.junit.Test)

Example 2 with LispMulticastAddress

use of org.onosproject.drivers.lisp.extensions.LispMulticastAddress in project onos by opennetworkinglab.

the class LispMulticastAddressCodecTest method getLispMulticastAddress.

/**
 * Reads in a LispMulticastAddress from the given resource and decodes it.
 *
 * @param resourceName resource to use to read the JSON for the rule
 * @return decoded LispMulticastAddress
 * @throws IOException if processing the resource fails
 */
private LispMulticastAddress getLispMulticastAddress(String resourceName) throws IOException {
    InputStream jsonStream = LispMulticastAddressCodecTest.class.getResourceAsStream(resourceName);
    JsonNode json = context.mapper().readTree(jsonStream);
    assertThat("JSON string should not be null", json, notNullValue());
    LispMulticastAddress multicastAddress = multicastAddressCodec.decode((ObjectNode) json, context);
    assertThat("decoded address should not be null", multicastAddress, notNullValue());
    return multicastAddress;
}
Also used : LispMulticastAddress(org.onosproject.drivers.lisp.extensions.LispMulticastAddress) InputStream(java.io.InputStream) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 3 with LispMulticastAddress

use of org.onosproject.drivers.lisp.extensions.LispMulticastAddress in project onos by opennetworkinglab.

the class LispMulticastAddressCodecTest method testLispMulticastAddressDecode.

/**
 * Tests decoding of a LispMulticastAddress JSON object.
 */
@Test
public void testLispMulticastAddressDecode() throws IOException {
    LispMulticastAddress address = getLispMulticastAddress("LispMulticastAddress.json");
    assertThat("incorrect instance id", address.getInstanceId(), is(INSTANCE_ID));
    assertThat("incorrect srcMaskLength", address.getSrcMaskLength(), is(SRC_MASK_LENGTH));
    assertThat("incorrect srcAddress", address.getSrcAddress(), is(MappingAddresses.ipv4MappingAddress(SRC_ADDRESS_PREFIX)));
    assertThat("incorrect grpMaskLength", address.getGrpMaskLength(), is(GRP_MASK_LENGTH));
    assertThat("incorrect grpAddress", address.getGrpAddress(), is(MappingAddresses.ipv4MappingAddress(GRP_ADDRESS_PREFIX)));
}
Also used : LispMulticastAddress(org.onosproject.drivers.lisp.extensions.LispMulticastAddress) Test(org.junit.Test)

Example 4 with LispMulticastAddress

use of org.onosproject.drivers.lisp.extensions.LispMulticastAddress in project onos by opennetworkinglab.

the class LispMulticastAddressCodecTest method setUp.

/**
 * Sets up for each test.
 * Creates a context and fetches the LispMulticastAddress codec.
 */
@Before
public void setUp() {
    CodecManager manager = new CodecManager();
    registrator = new LispMappingExtensionCodecRegistrator();
    registrator.codecService = manager;
    registrator.activate();
    context = new LispMappingExtensionCodecContextAdapter(registrator.codecService);
    multicastAddressCodec = context.codec(LispMulticastAddress.class);
    assertThat("Multicast address codec should not be null", multicastAddressCodec, notNullValue());
}
Also used : LispMulticastAddress(org.onosproject.drivers.lisp.extensions.LispMulticastAddress) CodecManager(org.onosproject.codec.impl.CodecManager) LispMappingExtensionCodecRegistrator(org.onosproject.drivers.lisp.extensions.LispMappingExtensionCodecRegistrator) Before(org.junit.Before)

Aggregations

LispMulticastAddress (org.onosproject.drivers.lisp.extensions.LispMulticastAddress)4 Test (org.junit.Test)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 InputStream (java.io.InputStream)1 Before (org.junit.Before)1 CodecManager (org.onosproject.codec.impl.CodecManager)1 LispMappingExtensionCodecRegistrator (org.onosproject.drivers.lisp.extensions.LispMappingExtensionCodecRegistrator)1