Move routing from incubator to a separate app
Change-Id: I961d10af99c572b1f8d9b3d37c6f52dd04422007
diff --git a/apps/route-service/api/src/test/java/org/onosproject/routeservice/RouteConfigTest.java b/apps/route-service/api/src/test/java/org/onosproject/routeservice/RouteConfigTest.java
new file mode 100644
index 0000000..1e48420
--- /dev/null
+++ b/apps/route-service/api/src/test/java/org/onosproject/routeservice/RouteConfigTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.routeservice;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableSet;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onosproject.TestApplicationId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.config.Config;
+import org.onosproject.net.config.ConfigApplyDelegate;
+
+import java.io.InputStream;
+import java.util.Set;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.*;
+
+/**
+ * Tests for class {@link RouteConfigTest}.
+ */
+public class RouteConfigTest {
+ private static final String KEY = "org.onosproject.routing";
+
+ private static final IpPrefix PREFIX1 = IpPrefix.valueOf("10.0.0.1/24");
+ private static final IpPrefix PREFIX2 = IpPrefix.valueOf("20.0.0.1/24");
+ private static final IpPrefix PREFIX3 = IpPrefix.valueOf("30.0.0.1/24");
+ private static final IpAddress NEXTHOP1 = IpAddress.valueOf("192.168.1.1");
+ private static final IpAddress NEXTHOP2 = IpAddress.valueOf("192.168.2.1");
+ private static final Route ROUTE1 = new Route(Route.Source.STATIC, PREFIX1, NEXTHOP1);
+ private static final Route ROUTE2 = new Route(Route.Source.STATIC, PREFIX2, NEXTHOP1);
+ private static final Route ROUTE3 = new Route(Route.Source.STATIC, PREFIX3, NEXTHOP2);
+ private static final Set<Route> EXPECTED_ROUTES = ImmutableSet.of(ROUTE1, ROUTE2, ROUTE3);
+ private static final Set<Route> UNEXPECTED_ROUTES = ImmutableSet.of(ROUTE1, ROUTE2);
+
+ private RouteConfig config;
+
+ @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);
+ }
+
+ @Test
+ public void getRoutes() throws Exception {
+ assertThat(config.getRoutes(), is(EXPECTED_ROUTES));
+ assertThat(config.getRoutes(), not(UNEXPECTED_ROUTES));
+ }
+
+ private class MockDelegate implements ConfigApplyDelegate {
+ @Override
+ public void onApply(Config config) {
+ }
+ }
+}
diff --git a/apps/route-service/api/src/test/java/org/onosproject/routeservice/RouteServiceAdapter.java b/apps/route-service/api/src/test/java/org/onosproject/routeservice/RouteServiceAdapter.java
new file mode 100644
index 0000000..1d6ec19
--- /dev/null
+++ b/apps/route-service/api/src/test/java/org/onosproject/routeservice/RouteServiceAdapter.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.routeservice;
+
+import org.onlab.packet.IpAddress;
+
+import java.util.Collection;
+import java.util.Optional;
+
+/**
+ * Adapter class for the route service.
+ */
+public class RouteServiceAdapter implements RouteAdminService {
+ @Override
+ public void update(Collection<Route> routes) {
+
+ }
+
+ @Override
+ public void withdraw(Collection<Route> routes) {
+
+ }
+
+ @Override
+ public Collection<RouteInfo> getRoutes(RouteTableId id) {
+ return null;
+ }
+
+ @Override
+ public Collection<RouteTableId> getRouteTables() {
+ return null;
+ }
+
+ @Override
+ public Route longestPrefixMatch(IpAddress ip) {
+ return null;
+ }
+
+ @Override
+ public Optional<ResolvedRoute> longestPrefixLookup(IpAddress ip) {
+ return null;
+ }
+
+ @Override
+ public void addListener(RouteListener listener) {
+
+ }
+
+ @Override
+ public void removeListener(RouteListener listener) {
+
+ }
+}
diff --git a/apps/route-service/api/src/test/java/org/onosproject/routeservice/RouteStoreAdapter.java b/apps/route-service/api/src/test/java/org/onosproject/routeservice/RouteStoreAdapter.java
new file mode 100644
index 0000000..bf9e527
--- /dev/null
+++ b/apps/route-service/api/src/test/java/org/onosproject/routeservice/RouteStoreAdapter.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.routeservice;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * Adapter class for the route store.
+ */
+public class RouteStoreAdapter implements RouteStore {
+ @Override
+ public void updateRoute(Route route) {
+
+ }
+
+ @Override
+ public void removeRoute(Route route) {
+
+ }
+
+ @Override
+ public Set<RouteTableId> getRouteTables() {
+ return null;
+ }
+
+ @Override
+ public Collection<RouteSet> getRoutes(RouteTableId table) {
+ return null;
+ }
+
+ @Override
+ public Collection<Route> getRoutesForNextHop(IpAddress ip) {
+ return null;
+ }
+
+ @Override
+ public RouteSet getRoutes(IpPrefix prefix) {
+ return null;
+ }
+
+ @Override
+ public void setDelegate(RouteStoreDelegate delegate) {
+
+ }
+
+ @Override
+ public void unsetDelegate(RouteStoreDelegate delegate) {
+
+ }
+
+ @Override
+ public boolean hasDelegate() {
+ return false;
+ }
+}