Search in sources :

Example 1 with MappingAddress

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

the class DefaultMappingKeyTest method testEquals.

/**
 * Tests equals() method.
 */
@Test
public void testEquals() {
    IpPrefix ip1 = IpPrefix.valueOf(IP_ADDRESS_1);
    MappingAddress address1 = MappingAddresses.ipv4MappingAddress(ip1);
    MappingKey key1 = DefaultMappingKey.builder().withAddress(address1).build();
    MappingKey sameAsKey1 = DefaultMappingKey.builder().withAddress(address1).build();
    IpPrefix ip2 = IpPrefix.valueOf(IP_ADDRESS_2);
    MappingAddress address2 = MappingAddresses.ipv4MappingAddress(ip2);
    MappingKey key2 = DefaultMappingKey.builder().withAddress(address2).build();
    new EqualsTester().addEqualityGroup(key1, sameAsKey1).addEqualityGroup(key2).testEquals();
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) MappingAddress(org.onosproject.mapping.addresses.MappingAddress) EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 2 with MappingAddress

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

the class DefaultMappingTreatmentTest method testBuilderMethods.

/**
 * Tests method defined on the Builder.
 */
@Test
public void testBuilderMethods() {
    IpPrefix ip = IpPrefix.valueOf(IP_ADDRESS_1);
    MappingAddress address = MappingAddresses.ipv4MappingAddress(ip);
    MappingTreatment.Builder builder = DefaultMappingTreatment.builder().withAddress(address).setUnicastPriority(10).setUnicastWeight(10);
    MappingTreatment treatment = builder.build();
    assertThat(treatment.instructions(), hasSize(2));
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) MappingAddress(org.onosproject.mapping.addresses.MappingAddress) Test(org.junit.Test)

Example 3 with MappingAddress

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

the class DefaultMappingTreatmentTest method testIllegalUnicastTypeConstruction.

/**
 * Tests illegal unicast type instruction construction.
 */
@Test(expected = IllegalArgumentException.class)
public void testIllegalUnicastTypeConstruction() {
    IpPrefix ip = IpPrefix.valueOf(IP_ADDRESS_1);
    MappingAddress address = MappingAddresses.ipv4MappingAddress(ip);
    DefaultMappingTreatment.builder().withAddress(address).setUnicastPriority(10).setUnicastWeight(10).setUnicastPriority(20).build();
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) MappingAddress(org.onosproject.mapping.addresses.MappingAddress) Test(org.junit.Test)

Example 4 with MappingAddress

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

the class MappingKeyCodec method encode.

@Override
public ObjectNode encode(MappingKey key, CodecContext context) {
    checkNotNull(key, "Mapping key cannot be null");
    final ObjectNode result = context.mapper().createObjectNode();
    final JsonCodec<MappingAddress> addressCodec = context.codec(MappingAddress.class);
    result.set(ADDRESS, addressCodec.encode(key.address(), context));
    return result;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) MappingAddress(org.onosproject.mapping.addresses.MappingAddress)

Example 5 with MappingAddress

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

the class MappingAddressCodecTest method ipv6MappingAddressTest.

/**
 * Tests IPv6 mapping address.
 */
@Test
public void ipv6MappingAddressTest() {
    MappingAddress address = MappingAddresses.ipv6MappingAddress(IPV6_PREFIX);
    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)

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