Search in sources :

Example 1 with ConfigApplyDelegate

use of org.onosproject.net.config.ConfigApplyDelegate in project onos by opennetworkinglab.

the class RouteConfigTest method setUp.

@Before
public void setUp() throws Exception {
    InputStream jsonStream = RouteConfigTest.class.getResourceAsStream("/route-config.json");
    ApplicationId subject = new TestApplicationId(KEY);
    ObjectMapper mapper = new ObjectMapper();
    JsonNode jsonNode = mapper.readTree(jsonStream);
    ConfigApplyDelegate delegate = new MockDelegate();
    config = new RouteConfig();
    config.init(subject, KEY, jsonNode, 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 2 with ConfigApplyDelegate

use of org.onosproject.net.config.ConfigApplyDelegate in project onos by opennetworkinglab.

the class RouterAdvertisementDeviceConfigTest method setUp.

@Before
public void setUp() throws Exception {
    InputStream jsonStream = RouterAdvertisementDeviceConfigTest.class.getResourceAsStream("/device.json");
    prefixes = new ArrayList<InterfaceIpAddress>();
    prefixes.add(InterfaceIpAddress.valueOf("2001:0558:FF10:04C9::6:100/120"));
    prefixes.add(InterfaceIpAddress.valueOf("2001:0558:FF10:04C9::7:100/120"));
    DeviceId subject = DeviceId.deviceId("of:0000000000000001");
    String key = "routeradvertisement";
    ObjectMapper mapper = new ObjectMapper();
    JsonNode jsonNode = mapper.readTree(jsonStream);
    ConfigApplyDelegate delegate = new MockDelegate();
    config = new RouterAdvertisementDeviceConfig();
    config.init(subject, key, jsonNode, mapper, delegate);
}
Also used : InputStream(java.io.InputStream) DeviceId(org.onosproject.net.DeviceId) JsonNode(com.fasterxml.jackson.databind.JsonNode) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) Before(org.junit.Before)

Example 3 with ConfigApplyDelegate

use of org.onosproject.net.config.ConfigApplyDelegate in project onos by opennetworkinglab.

the class VplsConfigManagerTest method testReloadConfigUpdateVpls.

/**
 * Updates VPLSs by sending new VPLS config.
 */
@Test
public void testReloadConfigUpdateVpls() {
    ((TestVpls) vplsConfigManager.vpls).initSampleData();
    VplsAppConfig vplsAppConfig = new VplsAppConfig();
    final ObjectMapper mapper = new ObjectMapper();
    final ConfigApplyDelegate delegate = new VplsAppConfigTest.MockCfgDelegate();
    JsonNode tree = null;
    try {
        tree = new ObjectMapper().readTree(TestConfigService.EMPTY_JSON_TREE);
    } catch (IOException e) {
        e.printStackTrace();
    }
    vplsAppConfig.init(APPID, APP_NAME, tree, mapper, delegate);
    VplsConfig vplsConfig = new VplsConfig(VPLS1, ImmutableSet.of(V100H1.name()), EncapsulationType.MPLS);
    vplsAppConfig.addVpls(vplsConfig);
    ((TestConfigService) vplsConfigManager.configService).setConfig(vplsAppConfig);
    NetworkConfigEvent event = new NetworkConfigEvent(NetworkConfigEvent.Type.CONFIG_ADDED, null, VplsAppConfig.class);
    ((TestConfigService) vplsConfigManager.configService).sendEvent(event);
    Collection<VplsData> vplss = vplsConfigManager.vpls.getAllVpls();
    assertEquals(1, vplss.size());
    VplsData expect = VplsData.of(VPLS1, EncapsulationType.MPLS);
    expect.addInterfaces(ImmutableSet.of(V100H1));
    expect.state(VplsData.VplsState.ADDED);
    assertTrue(vplss.contains(expect));
}
Also used : NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) VplsData(org.onosproject.vpls.api.VplsData) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) VplsTest(org.onosproject.vpls.VplsTest) Test(org.junit.Test)

Example 4 with ConfigApplyDelegate

use of org.onosproject.net.config.ConfigApplyDelegate in project onos by opennetworkinglab.

the class BandwidthCapacityTest method testConstruction.

@Test
public void testConstruction() {
    BandwidthCapacity config = new BandwidthCapacity();
    ConfigApplyDelegate delegate = configApply -> {
    };
    ObjectMapper mapper = new ObjectMapper();
    ConnectPoint cp = NetTestTools.connectPoint("cp1", 3);
    config.init(cp, "KEY", JsonNodeFactory.instance.objectNode(), mapper, delegate);
    double expectedBw = 1.0;
    config.capacity(Bandwidth.mbps(expectedBw));
    assertThat(config.isValid(), is(true));
    assertThat(config.toString(), containsString("capacity"));
}
Also used : NetTestTools(org.onosproject.net.NetTestTools) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) Bandwidth(org.onlab.util.Bandwidth) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) Matchers.is(org.hamcrest.Matchers.is) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Matchers.containsString(org.hamcrest.Matchers.containsString) ConnectPoint(org.onosproject.net.ConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) Test(org.junit.Test)

Example 5 with ConfigApplyDelegate

use of org.onosproject.net.config.ConfigApplyDelegate in project onos by opennetworkinglab.

the class BasicHostConfigTest method testConstruction.

/**
 * Tests construction, setters and getters of a BasicHostConfig object.
 */
@Test
public void testConstruction() {
    BasicHostConfig config = new BasicHostConfig();
    ConfigApplyDelegate delegate = configApply -> {
    };
    ObjectMapper mapper = new ObjectMapper();
    HostId hostId = NetTestTools.hid("12:34:56:78:90:ab/1");
    IpAddress ip1 = IpAddress.valueOf("1.1.1.1");
    IpAddress ip2 = IpAddress.valueOf("1.1.1.2");
    IpAddress ip3 = IpAddress.valueOf("1.1.1.3");
    Set<IpAddress> ips = ImmutableSet.of(ip1, ip2, ip3);
    HostLocation loc1 = new HostLocation(NetTestTools.connectPoint("d1", 1), System.currentTimeMillis());
    HostLocation loc2 = new HostLocation(NetTestTools.connectPoint("d2", 2), System.currentTimeMillis());
    Set<HostLocation> locs = ImmutableSet.of(loc1, loc2);
    HostLocation loc3 = new HostLocation(NetTestTools.connectPoint("d3", 1), System.currentTimeMillis());
    HostLocation loc4 = new HostLocation(NetTestTools.connectPoint("d4", 2), System.currentTimeMillis());
    Set<HostLocation> auxLocations = ImmutableSet.of(loc3, loc4);
    VlanId vlanId = VlanId.vlanId((short) 10);
    EthType ethType = EthType.EtherType.lookup((short) 0x88a8).ethType();
    config.init(hostId, "KEY", JsonNodeFactory.instance.objectNode(), mapper, delegate);
    config.setIps(ips).setLocations(locs).setAuxLocations(auxLocations).setInnerVlan(vlanId).setOuterTpid(ethType);
    assertThat(config.isValid(), is(true));
    assertThat(config.name(), is("-"));
    assertThat(config.ipAddresses(), hasSize(3));
    assertThat(config.ipAddresses(), hasItems(ip1, ip2, ip3));
    assertThat(config.locations(), hasSize(2));
    assertThat(config.locations(), hasItems(loc1, loc2));
    assertThat(config.auxLocations(), hasSize(2));
    assertThat(config.auxLocations(), hasItems(loc3, loc4));
    assertThat(config.innerVlan(), is(vlanId));
    assertThat(config.outerTpid(), is(ethType));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) HostLocation(org.onosproject.net.HostLocation) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Test(org.junit.Test) Matchers.hasItems(org.hamcrest.Matchers.hasItems) EthType(org.onlab.packet.EthType) NetTestTools(org.onosproject.net.NetTestTools) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Matchers.is(org.hamcrest.Matchers.is) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) HostId(org.onosproject.net.HostId) IpAddress(org.onlab.packet.IpAddress) EthType(org.onlab.packet.EthType) HostLocation(org.onosproject.net.HostLocation) IpAddress(org.onlab.packet.IpAddress) HostId(org.onosproject.net.HostId) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) VlanId(org.onlab.packet.VlanId) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) Test(org.junit.Test)

Aggregations

ConfigApplyDelegate (org.onosproject.net.config.ConfigApplyDelegate)17 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)14 JsonNode (com.fasterxml.jackson.databind.JsonNode)11 Before (org.junit.Before)11 Test (org.junit.Test)7 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)6 InputStream (java.io.InputStream)5 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)5 Matchers.is (org.hamcrest.Matchers.is)5 DeviceId (org.onosproject.net.DeviceId)4 TestApplicationId (org.onosproject.TestApplicationId)3 NetTestTools (org.onosproject.net.NetTestTools)3 Set (java.util.Set)2 ApplicationId (org.onosproject.core.ApplicationId)2 ConnectPoint (org.onosproject.net.ConnectPoint)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 FALSE (java.lang.Boolean.FALSE)1 TRUE (java.lang.Boolean.TRUE)1