Search in sources :

Example 21 with ConfigApplyDelegate

use of org.onosproject.net.config.ConfigApplyDelegate in project trellis-control by opennetworkinglab.

the class SegmentRoutingAppConfigTest method setUp.

/**
 * Initialize test related variables.
 *
 * @throws Exception
 */
@Before
public void setUp() throws Exception {
    InputStream jsonStream = SegmentRoutingAppConfigTest.class.getResourceAsStream("/app.json");
    InputStream invalidJsonStream = SegmentRoutingAppConfigTest.class.getResourceAsStream("/app-invalid.json");
    InputStream mplsEcmpJsonStream = SegmentRoutingAppConfigTest.class.getResourceAsStream("/app-ecmp.json");
    String key = APP_NAME;
    ApplicationId subject = new TestApplicationId(key);
    ObjectMapper mapper = new ObjectMapper();
    JsonNode jsonNode = mapper.readTree(jsonStream);
    JsonNode invalidJsonNode = mapper.readTree(invalidJsonStream);
    JsonNode mplsEcmpJsonNode = mapper.readTree(mplsEcmpJsonStream);
    ConfigApplyDelegate delegate = new MockDelegate();
    config = new SegmentRoutingAppConfig();
    config.init(subject, key, jsonNode, mapper, delegate);
    invalidConfig = new SegmentRoutingAppConfig();
    invalidConfig.init(subject, key, invalidJsonNode, mapper, delegate);
    mplsEcmpConfig = new SegmentRoutingAppConfig();
    mplsEcmpConfig.init(subject, key, mplsEcmpJsonNode, mapper, delegate);
}
Also used : InputStream(java.io.InputStream) TestApplicationId(org.onosproject.TestApplicationId) JsonNode(com.fasterxml.jackson.databind.JsonNode) TestApplicationId(org.onosproject.TestApplicationId) ApplicationId(org.onosproject.core.ApplicationId) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) Before(org.junit.Before)

Example 22 with ConfigApplyDelegate

use of org.onosproject.net.config.ConfigApplyDelegate in project trellis-control by opennetworkinglab.

the class SegmentRoutingDeviceConfigTest method setUp.

@Before
public void setUp() throws Exception {
    InputStream jsonStream = SegmentRoutingDeviceConfigTest.class.getResourceAsStream("/device.json");
    InputStream ipv6JsonStream = SegmentRoutingDeviceConfigTest.class.getResourceAsStream("/device-ipv6.json");
    InputStream pairJsonStream = SegmentRoutingDeviceConfigTest.class.getResourceAsStream("/device-pair.json");
    InputStream invalidJsonStream = SegmentRoutingDeviceConfigTest.class.getResourceAsStream("/device-invalid.json");
    adjacencySids1 = new HashMap<>();
    Set<Integer> ports1 = new HashSet<>();
    ports1.add(2);
    ports1.add(3);
    adjacencySids1.put(100, ports1);
    Set<Integer> ports2 = new HashSet<>();
    ports2.add(4);
    ports2.add(5);
    adjacencySids1.put(200, ports2);
    adjacencySids2 = new HashMap<>();
    Set<Integer> ports3 = new HashSet<>();
    ports3.add(6);
    adjacencySids2.put(300, ports3);
    DeviceId subject = DeviceId.deviceId("of:0000000000000001");
    String key = "segmentrouting";
    ObjectMapper mapper = new ObjectMapper();
    JsonNode jsonNode = mapper.readTree(jsonStream);
    JsonNode ipv6JsonNode = mapper.readTree(ipv6JsonStream);
    JsonNode pairJsonNode = mapper.readTree(pairJsonStream);
    JsonNode invalidJsonNode = mapper.readTree(invalidJsonStream);
    ConfigApplyDelegate delegate = new MockDelegate();
    config = new SegmentRoutingDeviceConfig();
    config.init(subject, key, jsonNode, mapper, delegate);
    ipv6Config = new SegmentRoutingDeviceConfig();
    ipv6Config.init(subject, key, ipv6JsonNode, mapper, delegate);
    pairConfig = new SegmentRoutingDeviceConfig();
    pairConfig.init(subject, key, pairJsonNode, mapper, delegate);
    invalidConfig = new SegmentRoutingDeviceConfig();
    invalidConfig.init(subject, key, invalidJsonNode, mapper, delegate);
}
Also used : InputStream(java.io.InputStream) DeviceId(org.onosproject.net.DeviceId) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) HashSet(java.util.HashSet) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) Before(org.junit.Before)

Aggregations

ConfigApplyDelegate (org.onosproject.net.config.ConfigApplyDelegate)22 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)19 JsonNode (com.fasterxml.jackson.databind.JsonNode)16 Before (org.junit.Before)16 Test (org.junit.Test)10 InputStream (java.io.InputStream)7 DeviceId (org.onosproject.net.DeviceId)7 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)6 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)5 Matchers.is (org.hamcrest.Matchers.is)5 TestApplicationId (org.onosproject.TestApplicationId)5 Set (java.util.Set)4 Assert (org.junit.Assert)4 ApplicationId (org.onosproject.core.ApplicationId)4 ConnectPoint (org.onosproject.net.ConnectPoint)4 Map (java.util.Map)3 IpAddress (org.onlab.packet.IpAddress)3 VlanId (org.onlab.packet.VlanId)3 HostId (org.onosproject.net.HostId)3 HostLocation (org.onosproject.net.HostLocation)3