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);
}
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);
}
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));
}
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"));
}
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));
}
Aggregations