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