Search in sources :

Example 56 with MappingAddress

use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.

the class MappingAddressCodecTest method ethMappingAddressTest.

/**
 * Tests Ethernet mapping address.
 */
@Test
public void ethMappingAddressTest() {
    MappingAddress address = MappingAddresses.ethMappingAddress(MAC);
    ObjectNode result = addressCodec.encode(address, context);
    assertThat(result, matchesMappingAddress(address));
}
Also used : MappingAddressJsonMatcher.matchesMappingAddress(org.onosproject.mapping.codec.MappingAddressJsonMatcher.matchesMappingAddress) MappingAddress(org.onosproject.mapping.addresses.MappingAddress) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Test(org.junit.Test)

Example 57 with MappingAddress

use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.

the class MappingAddressCodecTest method dnMappingAddressTest.

/**
 * Tests DN mapping address.
 */
@Test
public void dnMappingAddressTest() {
    MappingAddress address = MappingAddresses.dnMappingAddress(DN);
    ObjectNode result = addressCodec.encode(address, context);
    assertThat(result, matchesMappingAddress(address));
}
Also used : MappingAddressJsonMatcher.matchesMappingAddress(org.onosproject.mapping.codec.MappingAddressJsonMatcher.matchesMappingAddress) MappingAddress(org.onosproject.mapping.addresses.MappingAddress) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Test(org.junit.Test)

Example 58 with MappingAddress

use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.

the class MappingAddressCodecTest method testMappingAddressDecode.

/**
 * Tests the decoding of mapping address from JSON object.
 *
 * @throws IOException if processing the resource fails
 */
@Test
public void testMappingAddressDecode() throws IOException {
    MappingAddress address = getAddress("MappingAddress.json");
    assertThat(address.toString(), is("IPV4:" + IPV4_STRING + "/" + PORT_STRING));
}
Also used : MappingAddressJsonMatcher.matchesMappingAddress(org.onosproject.mapping.codec.MappingAddressJsonMatcher.matchesMappingAddress) MappingAddress(org.onosproject.mapping.addresses.MappingAddress) Test(org.junit.Test)

Example 59 with MappingAddress

use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.

the class MappingAddressCodecTest method asMappingAddressTest.

/**
 * Tests AS mapping address.
 */
@Test
public void asMappingAddressTest() {
    MappingAddress address = MappingAddresses.asMappingAddress(AS);
    ObjectNode result = addressCodec.encode(address, context);
    assertThat(result, matchesMappingAddress(address));
}
Also used : MappingAddressJsonMatcher.matchesMappingAddress(org.onosproject.mapping.codec.MappingAddressJsonMatcher.matchesMappingAddress) MappingAddress(org.onosproject.mapping.addresses.MappingAddress) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Test(org.junit.Test)

Example 60 with MappingAddress

use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.

the class MappingEntryCodecTest method testMappingEntryEncode.

/**
 * Tests encoding of a mapping entry object.
 */
@Test
public void testMappingEntryEncode() {
    MappingAddress address = MappingAddresses.ipv4MappingAddress(IPV4_PREFIX);
    MappingInstruction unicastWeight = MappingInstructions.unicastWeight(UNICAST_WEIGHT);
    MappingInstruction unicastPriority = MappingInstructions.unicastPriority(UNICAST_PRIORITY);
    MappingInstruction multicastWeight = MappingInstructions.multicastWeight(MULTICAST_WEIGHT);
    MappingInstruction multicastPriority = MappingInstructions.multicastPriority(MULTICAST_PRIORITY);
    MappingKey key = DefaultMappingKey.builder().withAddress(address).build();
    MappingTreatment treatment = DefaultMappingTreatment.builder().add(unicastWeight).add(unicastPriority).add(multicastWeight).add(multicastPriority).withAddress(address).build();
    MappingAction action = MappingActions.noAction();
    MappingValue value = DefaultMappingValue.builder().add(treatment).withAction(action).build();
    Mapping mapping = DefaultMapping.builder().withId(ID).forDevice(DEVICE_ID).withKey(key).withValue(value).build();
    MappingEntry entry = new DefaultMappingEntry(mapping, STATE);
    ObjectNode entryJson = entryCodec.encode(entry, context);
    assertThat(entryJson, MappingEntryJsonMatcher.matchesMappingEntry(entry));
}
Also used : MappingEntry(org.onosproject.mapping.MappingEntry) DefaultMappingEntry(org.onosproject.mapping.DefaultMappingEntry) MappingAddress(org.onosproject.mapping.addresses.MappingAddress) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) MappingAction(org.onosproject.mapping.actions.MappingAction) DefaultMapping(org.onosproject.mapping.DefaultMapping) Mapping(org.onosproject.mapping.Mapping) DefaultMappingEntry(org.onosproject.mapping.DefaultMappingEntry) DefaultMappingKey(org.onosproject.mapping.DefaultMappingKey) MappingKey(org.onosproject.mapping.MappingKey) MappingTreatment(org.onosproject.mapping.MappingTreatment) DefaultMappingTreatment(org.onosproject.mapping.DefaultMappingTreatment) DefaultMappingValue(org.onosproject.mapping.DefaultMappingValue) MappingValue(org.onosproject.mapping.MappingValue) MappingInstruction(org.onosproject.mapping.instructions.MappingInstruction) Test(org.junit.Test)

Aggregations

MappingAddress (org.onosproject.mapping.addresses.MappingAddress)66 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)34 Test (org.junit.Test)26 Before (org.junit.Before)11 DefaultMappingTreatment (org.onosproject.mapping.DefaultMappingTreatment)7 MappingTreatment (org.onosproject.mapping.MappingTreatment)7 MappingAddressJsonMatcher.matchesMappingAddress (org.onosproject.mapping.codec.MappingAddressJsonMatcher.matchesMappingAddress)7 IpPrefix (org.onlab.packet.IpPrefix)6 MappingInstruction (org.onosproject.mapping.instructions.MappingInstruction)6 DefaultMappingKey (org.onosproject.mapping.DefaultMappingKey)5 MappingKey (org.onosproject.mapping.MappingKey)5 DefaultMappingValue (org.onosproject.mapping.DefaultMappingValue)4 MappingValue (org.onosproject.mapping.MappingValue)4 MappingAction (org.onosproject.mapping.actions.MappingAction)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 EqualsTester (com.google.common.testing.EqualsTester)2 LispNatAddress (org.onosproject.drivers.lisp.extensions.LispNatAddress)2 LispTeRecord (org.onosproject.lisp.msg.types.lcaf.LispTeRecord)2 DefaultMapping (org.onosproject.mapping.DefaultMapping)2