Add CRD for l2-sdx entity
Changes:
- Add CRD commands for l2-sdx
- Add name completer for l2-sdx
- Define CRD in Sdxl2Service
- First implementation of Sdxl2Service
- Define CRD in storage service
- First implementation of storage service
- Add CRD tests for l2-sdx
Change-Id: Ie4797282186b504e95293a252785e28ccecf2ff3
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ConnectionPointTest.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ConnectionPointTest.java
index bea7ccc..9a3419a 100644
--- a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ConnectionPointTest.java
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ConnectionPointTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ManagerTest.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ManagerTest.java
new file mode 100644
index 0000000..fbe1ce4
--- /dev/null
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ManagerTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.sdxl2;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.TestApplicationId;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+
+/**
+ * Test network manager.
+ */
+public class SdxL2ManagerTest {
+
+ protected SdxL2Manager manager;
+
+ @Before
+ public void setUp() {
+ manager = new SdxL2Manager();
+ manager.appId = new TestApplicationId("sdxl2-test");
+ manager.sdxL2Store = new SdxL2TestStore();
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ public static final String SDXL2 = "test";
+ public static final String SDXL2_2 = "test2";
+
+
+ @Test
+ public void testCreateSdxL2s() {
+
+ manager.createSdxL2(SDXL2);
+ manager.createSdxL2(SDXL2_2);
+ manager.createSdxL2(SDXL2);
+ }
+
+ @Test
+ public void testRemoveSdxL2s() {
+ manager.createSdxL2(SDXL2);
+ manager.createSdxL2(SDXL2_2);
+ manager.deleteSdxL2(SDXL2);
+ manager.deleteSdxL2(SDXL2_2);
+ manager.deleteSdxL2(SDXL2);
+ }
+
+ @Test
+ public void testGetSdxL2s() {
+ Set<String> old = new HashSet<String>();
+ old.add(SDXL2_2);
+ old.add(SDXL2);
+ manager.createSdxL2(SDXL2);
+ manager.createSdxL2(SDXL2_2);
+ Set<String> sdxl2 = manager.getSdxL2s();
+ assertEquals(sdxl2, old);
+ manager.deleteSdxL2(SDXL2);
+ sdxl2 = manager.getSdxL2s();
+ assertNotEquals(sdxl2, old);
+ }
+
+}
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2TestStore.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2TestStore.java
new file mode 100644
index 0000000..6cf3ef2
--- /dev/null
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2TestStore.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.sdxl2;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+
+import java.util.Set;
+
+/**
+ * Stub class that emulates the behaviours of the SdxL2Store.
+ */
+public final class SdxL2TestStore implements SdxL2Store {
+
+ private Set<String> sdxL2s = Sets.newHashSet();
+
+ private static String errorAddSdx = "It is not possible to add ";
+ private static String errorRemoveSdx = "It is not possible to remove ";
+
+ /**
+ * Create a named sdx-l2.
+ *
+ * @param sdxl2 sdx-l2 name
+ * @throws SdxL2Exception if sdxl2 exists
+ */
+ @Override
+ public void putSdxL2(String sdxl2) throws SdxL2Exception {
+ boolean inserted = sdxL2s.add(sdxl2);
+ if (!inserted) {
+ throw new SdxL2Exception(errorAddSdx + sdxl2);
+ }
+ }
+
+ /**
+ * Remove a named sdx-l2.
+ *
+ * @param sdxl2 sdx-l2 name
+ * @throws SdxL2Exception if sdxl2 does not exist
+ */
+ @Override
+ public void removeSdxL2(String sdxl2) throws SdxL2Exception {
+ boolean removed = sdxL2s.remove(sdxl2);
+ if (!removed) {
+ throw new SdxL2Exception(errorRemoveSdx + sdxl2);
+ }
+ }
+
+ /**
+ * Returns a set of sdxl2 names.
+ *
+ * @return a set of sdxl2 names
+ */
+ @Override
+ public Set<String> getSdxL2s() {
+ return ImmutableSet.copyOf(sdxL2s);
+ }
+
+}
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/package-info.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/package-info.java
index 4a06994..de39d20 100644
--- a/sdx-l2/src/test/java/org/onosproject/sdxl2/package-info.java
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.