use of org.onosproject.drivers.lisp.extensions.LispAppDataAddress in project onos by opennetworkinglab.
the class LispAppDataAddressCodecTest method testLispAppDataAddressEncode.
/**
* Tests encoding of a LispAppDataAddress object.
*/
@Test
public void testLispAppDataAddressEncode() {
LispAppDataAddress address = new LispAppDataAddress.Builder().withProtocol(PROTOCOL).withIpTos(IP_TOS).withLocalPortLow(LOCAL_PORT_LOW).withLocalPortHigh(LOCAL_PORT_HIGH).withRemotePortLow(REMOTE_PORT_LOW).withRemotePortHigh(REMOTE_PORT_HIGH).withAddress(MappingAddresses.ipv4MappingAddress(IPV4_PREFIX)).build();
ObjectNode addressJson = appDataAddressCodec.encode(address, context);
assertThat(addressJson, LispAppDataAddressJsonMatcher.matchesAppDataAddress(address));
}
use of org.onosproject.drivers.lisp.extensions.LispAppDataAddress in project onos by opennetworkinglab.
the class LispAppDataAddressCodecTest method setUp.
/**
* Sets up for each test.
* Creates a context and fetches the LispAppDataAddress codec.
*/
@Before
public void setUp() {
CodecManager manager = new CodecManager();
registrator = new LispMappingExtensionCodecRegistrator();
registrator.codecService = manager;
registrator.activate();
context = new LispMappingExtensionCodecContextAdapter(registrator.codecService);
appDataAddressCodec = context.codec(LispAppDataAddress.class);
assertThat(appDataAddressCodec, notNullValue());
}
use of org.onosproject.drivers.lisp.extensions.LispAppDataAddress in project onos by opennetworkinglab.
the class LispAppDataAddressCodecTest method testLispAppDataAddressDecode.
/**
* Tests decoding of a LispAppDataAddress JSON object.
*/
@Test
public void testLispAppDataAddressDecode() throws IOException {
LispAppDataAddress appDataAddress = getLispAppDataAddress("LispAppDataAddress.json");
assertThat("incorrect protocol value", appDataAddress.getProtocol(), is(PROTOCOL));
assertThat("incorrect IP ToS value", appDataAddress.getIpTos(), is(IP_TOS));
assertThat("incorrect local port low value", appDataAddress.getLocalPortLow(), is(LOCAL_PORT_LOW));
assertThat("incorrect local port high value", appDataAddress.getLocalPortHigh(), is(LOCAL_PORT_HIGH));
assertThat("incorrect remote port low value", appDataAddress.getRemotePortLow(), is(REMOTE_PORT_LOW));
assertThat("incorrect remote port high value", appDataAddress.getRemotePortHigh(), is(REMOTE_PORT_HIGH));
assertThat("incorrect mapping address", appDataAddress.getAddress(), is(MappingAddresses.ipv4MappingAddress(IPV4_PREFIX)));
}
use of org.onosproject.drivers.lisp.extensions.LispAppDataAddress in project onos by opennetworkinglab.
the class LispAppDataAddressCodecTest method getLispAppDataAddress.
/**
* Reads in a LispAppDataAddress from the given resource and decodes it.
*
* @param resourceName resource to use to read the JSON for the rule
* @return decoded LispAppDataAddress
* @throws IOException if processing the resource fails
*/
private LispAppDataAddress getLispAppDataAddress(String resourceName) throws IOException {
InputStream jsonStream = LispAppDataAddressCodecTest.class.getResourceAsStream(resourceName);
JsonNode json = context.mapper().readTree(jsonStream);
assertThat(json, notNullValue());
LispAppDataAddress appDataAddress = appDataAddressCodec.decode((ObjectNode) json, context);
assertThat(appDataAddress, notNullValue());
return appDataAddress;
}
Aggregations