Introduces Virtual Circuit functionality for SDX-L2
Changes:
- Implements commands: sdxl2vc, sdxl2vc-add, sdxl2vc-list, sdxl2vc-remove
- Custom exceptions handled at the VC manager
- Updated README
- Updated unit tests
- Grouped some documentation and code
- Reduced checkstyle warnings
Change-Id: I4cb211dcfd1f3517f4e594c1cc1c816f9c3cdbe3
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/IntentServiceTest.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/IntentServiceTest.java
new file mode 100644
index 0000000..a9711d3
--- /dev/null
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/IntentServiceTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.Sets;
+import org.onosproject.net.intent.Intent;
+import org.onosproject.net.intent.IntentServiceAdapter;
+import org.onosproject.net.intent.Key;
+
+import java.util.Set;
+
+/**
+ * Represents a fake IntentService class that easily allows to store and
+ * retrieve intents without implementing the IntentService logic.
+ */
+public class IntentServiceTest extends IntentServiceAdapter {
+
+ private Set<Intent> intents;
+
+ /**
+ * Defines a set of intents.
+ */
+ public IntentServiceTest() {
+ intents = Sets.newHashSet();
+ }
+
+ @Override
+ public void submit(Intent intent) {
+ intents.add(intent);
+ }
+
+ @Override
+ public long getIntentCount() {
+ return intents.size();
+ }
+
+ @Override
+ public Iterable<Intent> getIntents() {
+ return Sets.newHashSet(intents.iterator());
+ }
+
+ @Override
+ public Intent getIntent(Key intentKey) {
+ for (Intent intent : intents) {
+ if (intent.key().equals(intentKey)) {
+ return intent;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void withdraw(Intent intent) {
+ intents.remove(intent);
+ }
+
+}