Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 1 | /* |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Laboratory |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 16 | |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 17 | package org.onosproject.vpls; |
| 18 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 19 | import com.fasterxml.jackson.databind.JsonNode; |
| 20 | import com.fasterxml.jackson.databind.ObjectMapper; |
Luca Prete | 1346564 | 2017-01-04 10:31:48 -0800 | [diff] [blame] | 21 | import com.google.common.collect.ImmutableSet; |
Luca Prete | 1346564 | 2017-01-04 10:31:48 -0800 | [diff] [blame] | 22 | import com.google.common.collect.Lists; |
| 23 | import com.google.common.collect.Maps; |
Luca Prete | 1346564 | 2017-01-04 10:31:48 -0800 | [diff] [blame] | 24 | import com.google.common.collect.Sets; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 25 | import org.onlab.packet.Ip4Address; |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 26 | import org.onlab.packet.IpAddress; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 27 | import org.onlab.packet.MacAddress; |
| 28 | import org.onlab.packet.VlanId; |
| 29 | import org.onosproject.TestApplicationId; |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 30 | import org.onosproject.cluster.LeadershipEvent; |
| 31 | import org.onosproject.cluster.LeadershipEventListener; |
| 32 | import org.onosproject.cluster.LeadershipServiceAdapter; |
| 33 | import org.onosproject.cluster.NodeId; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 34 | import org.onosproject.core.ApplicationId; |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 35 | import org.onosproject.core.CoreServiceAdapter; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 36 | import org.onosproject.core.IdGenerator; |
| 37 | import org.onosproject.incubator.net.intf.Interface; |
Luca Prete | a885482 | 2016-04-26 16:30:55 -0700 | [diff] [blame] | 38 | import org.onosproject.incubator.net.intf.InterfaceListener; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 39 | import org.onosproject.incubator.net.intf.InterfaceService; |
| 40 | import org.onosproject.net.ConnectPoint; |
| 41 | import org.onosproject.net.DefaultHost; |
| 42 | import org.onosproject.net.DeviceId; |
Luca Prete | 092e895 | 2016-10-26 16:25:56 +0200 | [diff] [blame] | 43 | import org.onosproject.net.EncapsulationType; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 44 | import org.onosproject.net.Host; |
| 45 | import org.onosproject.net.HostId; |
| 46 | import org.onosproject.net.HostLocation; |
| 47 | import org.onosproject.net.PortNumber; |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 48 | import org.onosproject.net.config.Config; |
| 49 | import org.onosproject.net.config.ConfigApplyDelegate; |
| 50 | import org.onosproject.net.config.NetworkConfigEvent; |
| 51 | import org.onosproject.net.config.NetworkConfigListener; |
| 52 | import org.onosproject.net.config.NetworkConfigServiceAdapter; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 53 | import org.onosproject.net.host.HostEvent; |
| 54 | import org.onosproject.net.host.HostListener; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 55 | import org.onosproject.net.host.HostServiceAdapter; |
| 56 | import org.onosproject.net.intent.Intent; |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 57 | import org.onosproject.net.intent.IntentData; |
| 58 | import org.onosproject.net.intent.IntentEvent; |
| 59 | import org.onosproject.net.intent.IntentListener; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 60 | import org.onosproject.net.intent.IntentServiceAdapter; |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 61 | import org.onosproject.net.intent.IntentState; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 62 | import org.onosproject.net.provider.ProviderId; |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 63 | import org.onosproject.store.StoreDelegate; |
| 64 | import org.onosproject.store.service.WallClockTimestamp; |
| 65 | import org.onosproject.vpls.api.Vpls; |
| 66 | import org.onosproject.vpls.api.VplsData; |
| 67 | import org.onosproject.vpls.config.VplsAppConfig; |
| 68 | import org.onosproject.vpls.config.VplsAppConfigTest; |
| 69 | import org.onosproject.vpls.config.VplsConfig; |
| 70 | import org.onosproject.vpls.store.VplsStoreAdapter; |
| 71 | import org.onosproject.vpls.store.VplsStoreEvent; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 72 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 73 | import java.io.IOException; |
Luca Prete | 1346564 | 2017-01-04 10:31:48 -0800 | [diff] [blame] | 74 | import java.util.Collection; |
| 75 | import java.util.Collections; |
Luca Prete | 1346564 | 2017-01-04 10:31:48 -0800 | [diff] [blame] | 76 | import java.util.List; |
| 77 | import java.util.Map; |
| 78 | import java.util.Set; |
| 79 | import java.util.concurrent.atomic.AtomicLong; |
| 80 | import java.util.stream.Collectors; |
| 81 | |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 82 | /** |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 83 | * Class provides data for VPLS testing. |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 84 | */ |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 85 | public abstract class VplsTest { |
| 86 | protected static final String APP_NAME = "org.onosproject.vpls"; |
| 87 | protected static final ApplicationId APPID = TestApplicationId.create(APP_NAME); |
| 88 | protected static final String DASH = "-"; |
| 89 | protected static final int PRIORITY_OFFSET = 1000; |
| 90 | protected static final String VPLS1 = "vpls1"; |
| 91 | protected static final String VPLS2 = "vpls2"; |
| 92 | protected static final String VPLS3 = "vpls3"; |
| 93 | protected static final String VPLS4 = "vpls4"; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 94 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 95 | protected static final PortNumber P1 = PortNumber.portNumber(1); |
| 96 | protected static final PortNumber P2 = PortNumber.portNumber(2); |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 97 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 98 | protected static final DeviceId DID1 = getDeviceId(1); |
| 99 | protected static final DeviceId DID2 = getDeviceId(2); |
| 100 | protected static final DeviceId DID3 = getDeviceId(3); |
| 101 | protected static final DeviceId DID4 = getDeviceId(4); |
| 102 | protected static final DeviceId DID5 = getDeviceId(5); |
| 103 | protected static final DeviceId DID6 = getDeviceId(6); |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 104 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 105 | protected static final ConnectPoint CP1 = new ConnectPoint(DID1, P1); |
| 106 | protected static final ConnectPoint CP2 = new ConnectPoint(DID2, P1); |
| 107 | protected static final ConnectPoint CP3 = new ConnectPoint(DID3, P1); |
| 108 | protected static final ConnectPoint CP4 = new ConnectPoint(DID4, P1); |
| 109 | protected static final ConnectPoint CP5 = new ConnectPoint(DID5, P1); |
| 110 | protected static final ConnectPoint CP6 = new ConnectPoint(DID6, P1); |
| 111 | protected static final ConnectPoint CP7 = new ConnectPoint(DID4, P2); |
| 112 | protected static final ConnectPoint CP8 = new ConnectPoint(DID3, P2); |
| 113 | protected static final ConnectPoint CP9 = new ConnectPoint(DID5, P1); |
| 114 | protected static final ConnectPoint CP10 = new ConnectPoint(DID5, P2); |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 115 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 116 | protected static final VlanId VLAN100 = VlanId.vlanId((short) 100); |
| 117 | protected static final VlanId VLAN200 = VlanId.vlanId((short) 200); |
| 118 | protected static final VlanId VLAN300 = VlanId.vlanId((short) 300); |
| 119 | protected static final VlanId VLAN400 = VlanId.vlanId((short) 400); |
| 120 | protected static final VlanId VLAN_NONE = VlanId.NONE; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 121 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 122 | protected static final MacAddress MAC1 = getMac(1); |
| 123 | protected static final MacAddress MAC2 = getMac(2); |
| 124 | protected static final MacAddress MAC3 = getMac(3); |
| 125 | protected static final MacAddress MAC4 = getMac(4); |
| 126 | protected static final MacAddress MAC5 = getMac(5); |
| 127 | protected static final MacAddress MAC6 = getMac(6); |
| 128 | protected static final MacAddress MAC7 = getMac(7); |
| 129 | protected static final MacAddress MAC8 = getMac(8); |
| 130 | protected static final MacAddress MAC9 = getMac(9); |
| 131 | protected static final MacAddress MAC10 = getMac(10); |
| 132 | protected static final MacAddress MAC11 = getMac(11); |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 133 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 134 | protected static final Ip4Address IP1 = Ip4Address.valueOf("192.168.1.1"); |
| 135 | protected static final Ip4Address IP2 = Ip4Address.valueOf("192.168.1.2"); |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 136 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 137 | protected static final HostId HID1 = HostId.hostId(MAC1, VLAN100); |
| 138 | protected static final HostId HID2 = HostId.hostId(MAC2, VLAN100); |
| 139 | protected static final HostId HID3 = HostId.hostId(MAC3, VLAN200); |
| 140 | protected static final HostId HID4 = HostId.hostId(MAC4, VLAN200); |
| 141 | protected static final HostId HID5 = HostId.hostId(MAC5, VLAN300); |
| 142 | protected static final HostId HID6 = HostId.hostId(MAC6, VLAN300); |
| 143 | protected static final HostId HID7 = HostId.hostId(MAC7, VLAN300); |
| 144 | protected static final HostId HID8 = HostId.hostId(MAC8, VLAN400); |
| 145 | protected static final HostId HID9 = HostId.hostId(MAC9); |
| 146 | protected static final HostId HID10 = HostId.hostId(MAC10); |
| 147 | protected static final HostId HID11 = HostId.hostId(MAC11); |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 148 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 149 | protected static final ProviderId PID = new ProviderId("of", "foo"); |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 150 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 151 | protected static final NodeId NODE_ID_1 = new NodeId("Node1"); |
| 152 | protected static final NodeId NODE_ID_2 = new NodeId("Node2"); |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 153 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 154 | protected static IdGenerator idGenerator; |
| 155 | |
| 156 | protected static final Interface V100H1 = |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 157 | new Interface("v100h1", CP1, null, null, VLAN100); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 158 | protected static final Interface V100H2 = |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 159 | new Interface("v100h2", CP2, null, null, VLAN100); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 160 | protected static final Interface V200H1 = |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 161 | new Interface("v200h1", CP3, null, null, VLAN200); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 162 | protected static final Interface V200H2 = |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 163 | new Interface("v200h2", CP4, null, null, VLAN200); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 164 | protected static final Interface V300H1 = |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 165 | new Interface("v300h1", CP5, null, null, VLAN300); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 166 | protected static final Interface V300H2 = |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 167 | new Interface("v300h2", CP6, null, null, VLAN300); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 168 | protected static final Interface V400H1 = |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 169 | new Interface("v400h1", CP7, null, null, VLAN400); |
| 170 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 171 | protected static final Interface VNONEH1 = |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 172 | new Interface("vNoneh1", CP8, null, null, VLAN_NONE); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 173 | protected static final Interface VNONEH2 = |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 174 | new Interface("vNoneh2", CP9, null, null, VLAN_NONE); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 175 | protected static final Interface VNONEH3 = |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 176 | new Interface("vNoneh3", CP10, null, null, VLAN_NONE); |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 177 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 178 | protected static final Host V100HOST1 = |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 179 | new DefaultHost(PID, HID1, MAC1, VLAN100, |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 180 | getLocation(1), Collections.singleton(IP1)); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 181 | protected static final Host V100HOST2 = |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 182 | new DefaultHost(PID, HID2, MAC2, VLAN100, |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 183 | getLocation(2), Sets.newHashSet()); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 184 | protected static final Host V200HOST1 = |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 185 | new DefaultHost(PID, HID3, MAC3, VLAN200, |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 186 | getLocation(3), Collections.singleton(IP2)); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 187 | protected static final Host V200HOST2 = |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 188 | new DefaultHost(PID, HID4, MAC4, VLAN200, |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 189 | getLocation(4), Sets.newHashSet()); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 190 | protected static final Host V300HOST1 = |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 191 | new DefaultHost(PID, HID5, MAC5, VLAN300, |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 192 | getLocation(5), Sets.newHashSet()); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 193 | protected static final Host V300HOST2 = |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 194 | new DefaultHost(PID, HID6, MAC6, VLAN300, |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 195 | getLocation(6), Sets.newHashSet()); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 196 | protected static final Host V300HOST3 = |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 197 | new DefaultHost(PID, HID7, MAC7, VLAN300, |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 198 | getLocation(7), Sets.newHashSet()); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 199 | protected static final Host V400HOST1 = |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 200 | new DefaultHost(PID, HID8, MAC8, VLAN400, |
| 201 | getLocation(4, 2), Sets.newHashSet()); |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 202 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 203 | protected static final Host VNONEHOST1 = |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 204 | new DefaultHost(PID, HID9, MAC9, VlanId.NONE, |
| 205 | getLocation(3, 2), Sets.newHashSet()); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 206 | protected static final Host VNONEHOST2 = |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 207 | new DefaultHost(PID, HID10, MAC10, VlanId.NONE, |
| 208 | getLocation(5, 1), Sets.newHashSet()); |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 209 | protected static final Host VNONEHOST3 = |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 210 | new DefaultHost(PID, HID11, MAC11, VlanId.NONE, |
| 211 | getLocation(5, 2), Sets.newHashSet()); |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 212 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 213 | protected static final Set<Interface> AVAILABLE_INTERFACES = |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 214 | ImmutableSet.of(V100H1, V100H2, V200H1, V200H2, V300H1, V300H2, |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 215 | V400H1, VNONEH1, VNONEH2, VNONEH3); |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 216 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 217 | protected static final Set<Host> AVAILABLE_HOSTS = |
Luca Prete | 092e895 | 2016-10-26 16:25:56 +0200 | [diff] [blame] | 218 | ImmutableSet.of(V100HOST1, V100HOST2, V200HOST1, |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 219 | V200HOST2, V300HOST1, V300HOST2, V300HOST3, |
| 220 | VNONEHOST1, VNONEHOST2, |
| 221 | V400HOST1, VNONEHOST3); |
| 222 | |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 223 | |
| 224 | /** |
| 225 | * Returns the device Id of the ith device. |
| 226 | * |
| 227 | * @param i the device to get the Id of |
| 228 | * @return the device Id |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 229 | */ |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 230 | protected static DeviceId getDeviceId(int i) { |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 231 | return DeviceId.deviceId("" + i); |
| 232 | } |
| 233 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 234 | /** |
| 235 | * Generates a mac address by given number. |
| 236 | * |
| 237 | * @param n the number to generate mac address |
| 238 | * @return the mac address |
| 239 | */ |
| 240 | protected static MacAddress getMac(int n) { |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 241 | return MacAddress.valueOf(String.format("00:00:00:00:00:%s", n)); |
| 242 | } |
| 243 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 244 | /** |
| 245 | * Generates a host location by given device number. |
| 246 | * |
| 247 | * @param i the given number |
| 248 | * @return the host location |
| 249 | */ |
| 250 | protected static HostLocation getLocation(int i) { |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 251 | return new HostLocation(new ConnectPoint(getDeviceId(i), P1), 123L); |
| 252 | } |
| 253 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 254 | /** |
| 255 | * Generates host location by given device number and port number. |
| 256 | * |
| 257 | * @param d the device number |
| 258 | * @param p the port number |
| 259 | * @return the host location |
| 260 | */ |
| 261 | protected static HostLocation getLocation(int d, int p) { |
Carolina Fernandez | b1cef5c | 2016-11-22 19:18:40 +0100 | [diff] [blame] | 262 | return new HostLocation(new ConnectPoint(getDeviceId(d), |
| 263 | PortNumber.portNumber(p)), 123L); |
| 264 | } |
| 265 | |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 266 | /** |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 267 | * Test core service; For generate test application ID. |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 268 | */ |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 269 | public class TestCoreService extends CoreServiceAdapter { |
| 270 | @Override |
| 271 | public ApplicationId registerApplication(String name) { |
| 272 | return TestApplicationId.create(name); |
| 273 | } |
| 274 | } |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 275 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 276 | /** |
| 277 | * Test intent service. |
| 278 | * Always install or withdraw success for any Intents. |
| 279 | */ |
| 280 | public class TestIntentService extends IntentServiceAdapter { |
| 281 | IntentListener listener; |
| 282 | List<IntentData> intents; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 283 | |
| 284 | public TestIntentService() { |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 285 | intents = Lists.newArrayList(); |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | @Override |
| 289 | public void submit(Intent intent) { |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 290 | intents.add(new IntentData(intent, IntentState.INSTALLED, new WallClockTimestamp())); |
| 291 | if (listener != null) { |
| 292 | IntentEvent.getEvent(IntentState.INSTALLED, intent).ifPresent(listener::event); |
| 293 | |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | @Override |
| 298 | public void withdraw(Intent intent) { |
| 299 | intents.forEach(intentData -> { |
| 300 | if (intentData.intent().key().equals(intent.key())) { |
| 301 | intentData.setState(IntentState.WITHDRAWN); |
| 302 | |
| 303 | if (listener != null) { |
| 304 | IntentEvent.getEvent(IntentState.WITHDRAWN, intent).ifPresent(listener::event); |
| 305 | } |
| 306 | } |
| 307 | }); |
| 308 | } |
| 309 | |
| 310 | @Override |
| 311 | public Iterable<Intent> getIntents() { |
| 312 | return intents.stream() |
| 313 | .map(IntentData::intent) |
| 314 | .collect(Collectors.toList()); |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | @Override |
| 318 | public long getIntentCount() { |
| 319 | return intents.size(); |
| 320 | } |
| 321 | |
| 322 | @Override |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 323 | public void addListener(IntentListener listener) { |
| 324 | this.listener = listener; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | @Override |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 328 | public void removeListener(IntentListener listener) { |
| 329 | this.listener = null; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 330 | } |
| 331 | } |
| 332 | |
| 333 | /** |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 334 | * Test leadership service. |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 335 | */ |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 336 | public class TestLeadershipService extends LeadershipServiceAdapter { |
| 337 | LeadershipEventListener listener; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 338 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 339 | @Override |
| 340 | public void addListener(LeadershipEventListener listener) { |
| 341 | this.listener = listener; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | @Override |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 345 | public void removeListener(LeadershipEventListener listener) { |
| 346 | this.listener = null; |
| 347 | } |
| 348 | |
| 349 | /** |
| 350 | * Sends the leadership event to the listener. |
| 351 | * |
| 352 | * @param event the Intent event |
| 353 | */ |
| 354 | public void sendEvent(LeadershipEvent event) { |
| 355 | if (listener != null && listener.isRelevant(event)) { |
| 356 | listener.event(event); |
| 357 | } |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | @Override |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 361 | public NodeId getLeader(String path) { |
| 362 | return NODE_ID_1; |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | /** |
| 367 | * Test interface service; contains all interfaces which already generated. |
| 368 | */ |
| 369 | public class TestInterfaceService implements InterfaceService { |
| 370 | |
| 371 | @Override |
| 372 | public void addListener(InterfaceListener listener) { |
| 373 | } |
| 374 | |
| 375 | @Override |
| 376 | public void removeListener(InterfaceListener listener) { |
| 377 | } |
| 378 | |
| 379 | @Override |
| 380 | public Set<Interface> getInterfaces() { |
| 381 | return AVAILABLE_INTERFACES; |
| 382 | } |
| 383 | |
| 384 | @Override |
| 385 | public Interface getInterfaceByName(ConnectPoint connectPoint, |
| 386 | String name) { |
| 387 | return AVAILABLE_INTERFACES.stream() |
| 388 | .filter(intf -> intf.name().equals(name)) |
| 389 | .findFirst() |
| 390 | .orElse(null); |
| 391 | } |
| 392 | |
| 393 | @Override |
| 394 | public Set<Interface> getInterfacesByPort(ConnectPoint port) { |
| 395 | return AVAILABLE_INTERFACES.stream() |
| 396 | .filter(intf -> intf.connectPoint().equals(port)) |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 397 | .collect(Collectors.toSet()); |
| 398 | } |
| 399 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 400 | @Override |
| 401 | public Set<Interface> getInterfacesByIp(IpAddress ip) { |
| 402 | return AVAILABLE_INTERFACES.stream() |
| 403 | .filter(intf -> intf.ipAddressesList().contains(ip)) |
| 404 | .collect(Collectors.toSet()); |
| 405 | } |
| 406 | |
| 407 | @Override |
| 408 | public Set<Interface> getInterfacesByVlan(VlanId vlan) { |
| 409 | return AVAILABLE_INTERFACES.stream() |
| 410 | .filter(intf -> intf.vlan().equals(vlan)) |
| 411 | .collect(Collectors.toSet()); |
| 412 | } |
| 413 | |
| 414 | @Override |
| 415 | public Interface getMatchingInterface(IpAddress ip) { |
| 416 | return AVAILABLE_INTERFACES.stream() |
| 417 | .filter(intf -> intf.ipAddressesList().contains(ip)) |
| 418 | .findFirst() |
| 419 | .orElse(null); |
| 420 | } |
| 421 | |
| 422 | @Override |
| 423 | public Set<Interface> getMatchingInterfaces(IpAddress ip) { |
| 424 | return AVAILABLE_INTERFACES.stream() |
| 425 | .filter(intf -> intf.ipAddressesList().contains(ip)) |
| 426 | .collect(Collectors.toSet()); |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | /** |
| 431 | * Test VPLS store. |
| 432 | */ |
| 433 | public class TestVplsStore extends VplsStoreAdapter { |
| 434 | /** |
| 435 | * Clears the store. |
| 436 | */ |
| 437 | public void clear() { |
| 438 | vplsDataMap.clear(); |
| 439 | } |
| 440 | |
| 441 | /** |
| 442 | * Gets the store delegate. |
| 443 | * |
| 444 | * @return the store delegate |
| 445 | */ |
| 446 | public StoreDelegate<VplsStoreEvent> delegate() { |
| 447 | return this.delegate; |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | /** |
| 452 | * Test VPLS. |
| 453 | * Provides basic VPLS functionality and stores VPLS information. |
| 454 | */ |
| 455 | public class TestVpls implements Vpls { |
| 456 | public Map<String, VplsData> testData; |
| 457 | |
| 458 | public TestVpls() { |
| 459 | testData = Maps.newHashMap(); |
| 460 | } |
| 461 | |
| 462 | public void initSampleData() { |
| 463 | testData.clear(); |
| 464 | VplsData vplsData = VplsData.of(VPLS1); |
| 465 | vplsData.addInterfaces(ImmutableSet.of(V100H1, V100H2)); |
| 466 | vplsData.state(VplsData.VplsState.ADDED); |
| 467 | testData.put(VPLS1, vplsData); |
| 468 | |
| 469 | vplsData = VplsData.of(VPLS2); |
| 470 | vplsData.addInterfaces(ImmutableSet.of(V200H1, V200H2)); |
| 471 | vplsData.state(VplsData.VplsState.ADDED); |
| 472 | testData.put(VPLS2, vplsData); |
| 473 | } |
| 474 | |
| 475 | @Override |
| 476 | public VplsData createVpls(String vplsName, EncapsulationType encapsulationType) { |
| 477 | VplsData vplsData = VplsData.of(vplsName, encapsulationType); |
| 478 | testData.put(vplsName, vplsData); |
| 479 | return vplsData; |
| 480 | } |
| 481 | |
| 482 | @Override |
| 483 | public VplsData removeVpls(VplsData vplsData) { |
| 484 | if (!testData.containsKey(vplsData.name())) { |
| 485 | return null; |
| 486 | } |
| 487 | |
| 488 | testData.remove(vplsData.name()); |
| 489 | return vplsData; |
| 490 | } |
| 491 | |
| 492 | @Override |
| 493 | public void addInterfaces(VplsData vplsData, Collection<Interface> interfaces) { |
| 494 | vplsData.addInterfaces(interfaces); |
| 495 | testData.put(vplsData.name(), vplsData); |
| 496 | } |
| 497 | |
| 498 | @Override |
| 499 | public void addInterface(VplsData vplsData, Interface iface) { |
| 500 | vplsData.addInterface(iface); |
| 501 | testData.put(vplsData.name(), vplsData); |
| 502 | } |
| 503 | |
| 504 | @Override |
| 505 | public void setEncapsulationType(VplsData vplsData, EncapsulationType encapsulationType) { |
| 506 | vplsData.encapsulationType(encapsulationType); |
| 507 | testData.put(vplsData.name(), vplsData); |
| 508 | } |
| 509 | |
| 510 | @Override |
| 511 | public VplsData getVpls(String vplsName) { |
| 512 | return testData.get(vplsName); |
| 513 | } |
| 514 | |
| 515 | @Override |
| 516 | public Collection<VplsData> getAllVpls() { |
| 517 | return testData.values(); |
| 518 | } |
| 519 | |
| 520 | @Override |
| 521 | public Collection<Interface> removeInterfaces(VplsData vplsData, Collection<Interface> interfaces) { |
| 522 | vplsData.removeInterfaces(interfaces); |
| 523 | testData.put(vplsData.name(), vplsData); |
| 524 | return interfaces; |
| 525 | } |
| 526 | |
| 527 | @Override |
| 528 | public Interface removeInterface(VplsData vplsData, Interface iface) { |
| 529 | vplsData.removeInterface(iface); |
| 530 | testData.put(vplsData.name(), vplsData); |
| 531 | return iface; |
| 532 | } |
| 533 | |
| 534 | @Override |
| 535 | public void removeAllVpls() { |
| 536 | testData.clear(); |
| 537 | } |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 538 | } |
| 539 | |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 540 | /** |
| 541 | * Represents a fake IdGenerator class for intents. |
| 542 | */ |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 543 | protected static class TestIdGenerator implements IdGenerator { |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 544 | private final AtomicLong id = new AtomicLong(0); |
| 545 | |
| 546 | @Override |
| 547 | public long getNewId() { |
| 548 | return id.getAndIncrement(); |
| 549 | } |
| 550 | |
| 551 | } |
| 552 | |
| 553 | /** |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 554 | * Test host service; contains all hosts which already generated. |
| 555 | * |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 556 | */ |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 557 | public class TestHostService extends HostServiceAdapter { |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 558 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 559 | private HostListener listener; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 560 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 561 | @Override |
| 562 | public Set<Host> getConnectedHosts(ConnectPoint connectPoint) { |
| 563 | return AVAILABLE_HOSTS.stream() |
| 564 | .filter(host -> host.location().equals(connectPoint)) |
| 565 | .collect(Collectors.toSet()); |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | @Override |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 569 | public Set<Host> getHostsByMac(MacAddress mac) { |
| 570 | return AVAILABLE_HOSTS.stream() |
| 571 | .filter(host -> host.mac().equals(mac)) |
| 572 | .collect(Collectors.toSet()); |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | @Override |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 576 | public Iterable<Host> getHosts() { |
| 577 | return AVAILABLE_HOSTS; |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | @Override |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 581 | public Set<Host> getHostsByVlan(VlanId vlanId) { |
| 582 | return AVAILABLE_HOSTS.stream() |
| 583 | .filter(host -> host.vlan().equals(vlanId)) |
| 584 | .collect(Collectors.toSet()); |
| 585 | } |
| 586 | |
| 587 | @Override |
| 588 | public int getHostCount() { |
| 589 | return AVAILABLE_HOSTS.size(); |
| 590 | } |
| 591 | |
| 592 | @Override |
| 593 | public Host getHost(HostId hostId) { |
| 594 | return AVAILABLE_HOSTS.stream() |
| 595 | .filter(host -> host.id().equals(hostId)) |
| 596 | .findFirst() |
| 597 | .orElse(null); |
| 598 | } |
| 599 | |
| 600 | @Override |
| 601 | public void addListener(HostListener listener) { |
| 602 | this.listener = listener; |
| 603 | } |
| 604 | |
| 605 | public void postHostEvent(HostEvent hostEvent) { |
| 606 | this.listener.event(hostEvent); |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 607 | } |
| 608 | } |
| 609 | |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 610 | /** |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 611 | * Test network configuration service. |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 612 | */ |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 613 | public class TestConfigService extends NetworkConfigServiceAdapter { |
| 614 | public static final String EMPTY_JSON_TREE = "{}"; |
| 615 | NetworkConfigListener listener; |
| 616 | VplsAppConfig vplsAppConfig; |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 617 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 618 | @Override |
| 619 | public void addListener(NetworkConfigListener listener) { |
| 620 | this.listener = listener; |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | @Override |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 624 | public void removeListener(NetworkConfigListener listener) { |
| 625 | this.listener = null; |
| 626 | } |
| 627 | |
| 628 | /** |
| 629 | * Sends network config event to listener. |
| 630 | * |
| 631 | * @param event the network config event |
| 632 | */ |
| 633 | public void sendEvent(NetworkConfigEvent event) { |
| 634 | if (listener != null) { |
| 635 | listener.event(event); |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 636 | } |
| 637 | } |
| 638 | |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 639 | /** |
| 640 | * Constructs test config service. |
| 641 | * Generates an VPLS configuration with sample VPLS configs. |
| 642 | */ |
| 643 | public TestConfigService() { |
| 644 | vplsAppConfig = new VplsAppConfig(); |
| 645 | final ObjectMapper mapper = new ObjectMapper(); |
| 646 | final ConfigApplyDelegate delegate = new VplsAppConfigTest.MockCfgDelegate(); |
| 647 | JsonNode tree = null; |
| 648 | try { |
| 649 | tree = new ObjectMapper().readTree(EMPTY_JSON_TREE); |
| 650 | } catch (IOException e) { |
| 651 | e.printStackTrace(); |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 652 | } |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 653 | vplsAppConfig.init(APPID, APP_NAME, tree, mapper, delegate); |
| 654 | VplsConfig vplsConfig = new VplsConfig(VPLS1, |
| 655 | ImmutableSet.of(V100H1.name(), V100H2.name()), |
| 656 | EncapsulationType.NONE); |
| 657 | vplsAppConfig.addVpls(vplsConfig); |
| 658 | vplsConfig = new VplsConfig(VPLS2, |
| 659 | ImmutableSet.of(V200H1.name(), V200H2.name()), |
| 660 | EncapsulationType.VLAN); |
| 661 | vplsAppConfig.addVpls(vplsConfig); |
| 662 | |
| 663 | } |
| 664 | |
| 665 | /** |
| 666 | * Overrides VPLS config to the config service. |
| 667 | * |
| 668 | * @param vplsAppConfig the new VPLS config |
| 669 | */ |
| 670 | public void setConfig(VplsAppConfig vplsAppConfig) { |
| 671 | this.vplsAppConfig = vplsAppConfig; |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | @Override |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 675 | public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) { |
| 676 | return (C) vplsAppConfig; |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | @Override |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 680 | public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) { |
| 681 | return (C) vplsAppConfig; |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 682 | } |
nosignal | 5fd282e | 2016-09-16 16:11:40 -0700 | [diff] [blame] | 683 | } |
Yi Tseng | f4e13e3 | 2017-03-30 15:38:39 -0700 | [diff] [blame] | 684 | |
Luca Prete | 9c2ee07 | 2016-02-16 11:00:44 -0800 | [diff] [blame] | 685 | } |