Search in sources :

Example 1 with LispAppDataAddress

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));
}
Also used : LispAppDataAddress(org.onosproject.drivers.lisp.extensions.LispAppDataAddress) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Test(org.junit.Test)

Example 2 with LispAppDataAddress

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());
}
Also used : LispAppDataAddress(org.onosproject.drivers.lisp.extensions.LispAppDataAddress) CodecManager(org.onosproject.codec.impl.CodecManager) LispMappingExtensionCodecRegistrator(org.onosproject.drivers.lisp.extensions.LispMappingExtensionCodecRegistrator) Before(org.junit.Before)

Example 3 with LispAppDataAddress

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)));
}
Also used : LispAppDataAddress(org.onosproject.drivers.lisp.extensions.LispAppDataAddress) Test(org.junit.Test)

Example 4 with LispAppDataAddress

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;
}
Also used : LispAppDataAddress(org.onosproject.drivers.lisp.extensions.LispAppDataAddress) InputStream(java.io.InputStream) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Aggregations

LispAppDataAddress (org.onosproject.drivers.lisp.extensions.LispAppDataAddress)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