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);
+    }
+
+}
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2MacVCManagerTest.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2MacVCManagerTest.java
new file mode 100644
index 0000000..32865c7
--- /dev/null
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2MacVCManagerTest.java
@@ -0,0 +1,430 @@
+/*
+ * 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.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
+import org.onosproject.TestApplicationId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.flow.DefaultTrafficSelector;
+import org.onosproject.net.flow.DefaultTrafficTreatment;
+import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.intent.AbstractIntentTest;
+import org.onosproject.net.intent.Intent;
+import org.onosproject.net.intent.IntentUtils;
+import org.onosproject.net.intent.Key;
+import org.onosproject.net.intent.PointToPointIntent;
+
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+
+import static java.lang.String.format;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+
+/**
+ * Unit tests for SDX-L2 Mac VC Manager.
+ */
+public class SdxL2MacVCManagerTest extends AbstractIntentTest {
+
+    private static final String SDXL2_2 = "sdxl2_test2";
+    private static final String CP1 = "of:00000000000001/1";
+    private static final String CP2 = "of:00000000000002/1";
+    private static final String CP5 = "of:00000000000002/4";
+    private static final String CP6 = "of:00000000000004/4";
+    private static final String CP7 = "of:0000000000000a/4";
+    private static final String CP8 = "of:00000000000009/4";
+    private static final String CP9 = "of:0000000000000a/4";
+    private static final String CP10 = "of:00000000000009/4";
+    private static final String VLANS1 = "2,3,4";
+    private static final ArrayList<String> VLANS1_ARRAY =
+            new ArrayList<String>(Arrays.asList(VLANS1.split(",")));
+    private static final String VLANS2 = "4,5,6";
+    private static final ArrayList<String> VLANS2_ARRAY =
+            new ArrayList<String>(Arrays.asList(VLANS2.split(",")));
+
+    private static final String VLANS5 = "100";
+    private static final String VLANS6 = "1";
+    private static final String VLANS7 = "1";
+    private static final String VLANS8 = "111";
+    private static final String VLANS9 = "1";
+    private static final String VLANS10 = "1";
+    private static final String CEMAC1 = "52:40:00:12:44:01";
+    private static final String CEMAC2 = "51:12:11:00:23:01";
+    private static final String CEMAC5 = "52:12:11:00:23:11";
+    private static final String CEMAC6 = "52:12:11:a0:23:11";
+    private static final String CEMAC7 = "52:12:21:00:25:11";
+    private static final String CEMAC8 = "52:12:14:a0:23:11";
+    private static final String CEMAC9 = "52:12:21:00:28:11";
+    private static final String CEMAC10 = "52:12:14:aa:23:11";
+    private static final String NAME_FORMAT = "%s:%s-%s";
+    private static final String KEY_FORMAT = "%s,%s";
+    private static final ApplicationId APPID = TestApplicationId.create("foo");
+    private static final int POINT_TO_POINT_INDEXES = 3;
+    private SdxL2MacVCManager manager;
+    private List<PointToPointIntent> intentList;
+
+    /**
+     * Prepare environment before starting testing MAC-based VCs.
+     */
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        SdxL2DistributedStore store = new SdxL2DistributedStore();
+        store.initForTest();
+        manager = new SdxL2MacVCManager(APPID, store, new IntentServiceTest());
+        intentList = setIntents();
+    }
+
+    /**
+     * Clean up environment after finishing testing MAC-based VCs.
+     */
+    @After
+    public void tearDown() {
+        super.tearDown();
+    }
+
+    public List<PointToPointIntent> setIntents() {
+        List<PointToPointIntent> intents = new ArrayList<PointToPointIntent>();
+        intents.addAll(setupConnectionPoints1To2());
+        intents.addAll(setupConnectionPoints5To6());
+        intents.addAll(setupConnectionPoints7To8());
+        intents.addAll(setupConnectionPoints9To10());
+        return intents;
+    }
+
+    private TrafficTreatment buildTreatment(VlanId setVlan,
+                                            VlanId pushVlan,
+                                            boolean popVlan) {
+
+        TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
+        if (setVlan != null) {
+            treatmentBuilder.setVlanId(setVlan);
+        }
+        if (pushVlan != null) {
+            treatmentBuilder.pushVlan();
+            treatmentBuilder.setVlanId(pushVlan);
+        }
+        if (popVlan) {
+            treatmentBuilder.popVlan();
+        }
+        return treatmentBuilder.build();
+    }
+
+    private TrafficSelector buildSelector(MacAddress ingressMac,
+                                          MacAddress egressMac,
+                                          Short etherType,
+                                          VlanId ingressTag) {
+
+        TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
+        selectorBuilder.matchEthSrc(ingressMac);
+        selectorBuilder.matchEthDst(egressMac);
+        if (etherType != null) {
+            selectorBuilder.matchEthType(etherType);
+        }
+        if (ingressTag != null) {
+            selectorBuilder.matchVlanId(ingressTag);
+        }
+        return selectorBuilder.build();
+    }
+
+    private Key generateIntentKey(String sdxl2, SdxL2ConnectionPoint cpOne, SdxL2ConnectionPoint cpTwo, String index) {
+        String cps = format(NAME_FORMAT, sdxl2, cpOne.name(), cpTwo.name());
+        String key = format(KEY_FORMAT, cps, index);
+        return Key.of(key, APPID);
+    }
+
+    @Test
+    public void testConnectionSetup() {
+        Iterator<SdxL2ConnectionPoint> lhs = setupLhsCPs().iterator();
+        Iterator<SdxL2ConnectionPoint> rhs = setupRhsCPs().iterator();
+        while (lhs.hasNext()) {
+            manager.addVC(SDXL2_2, lhs.next(), rhs.next());
+        }
+
+        assertEquals(intentList.size(), manager.intentService.getIntentCount());
+
+        for (Intent emulatedIntent : intentList) {
+            boolean found = false;
+            for (Intent realIntent : manager.intentService.getIntents()) {
+                if (emulatedIntent.key().equals(realIntent.key())) {
+                    found = true;
+                    assertTrue(format("Comparing %s and %s", emulatedIntent, realIntent),
+                               IntentUtils.intentsAreEqual(emulatedIntent, realIntent));
+                    break;
+                }
+            }
+            assertTrue(found);
+        }
+    }
+
+    public List<SdxL2ConnectionPoint> setupLhsCPs() {
+        List<SdxL2ConnectionPoint> cps = new ArrayList<SdxL2ConnectionPoint>();
+        SdxL2ConnectionPoint cpone = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+        cps.add(cpone);
+        SdxL2ConnectionPoint cpfive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5, CEMAC5);
+        cps.add(cpfive);
+        SdxL2ConnectionPoint cpseven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7, CEMAC7);
+        cps.add(cpseven);
+        SdxL2ConnectionPoint cpnine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST9", CP9, VLANS9, CEMAC9);
+        cps.add(cpnine);
+        return cps;
+    }
+
+    public List<SdxL2ConnectionPoint> setupRhsCPs() {
+        List<SdxL2ConnectionPoint> cps = new ArrayList<SdxL2ConnectionPoint>();
+        SdxL2ConnectionPoint cptwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2, CEMAC2);
+        cps.add(cptwo);
+        SdxL2ConnectionPoint cpsix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6, CEMAC6);
+        cps.add(cpsix);
+        SdxL2ConnectionPoint cpeight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8, CEMAC8);
+        cps.add(cpeight);
+        SdxL2ConnectionPoint cpten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", CP10, VLANS10, CEMAC10);
+        cps.add(cpten);
+        return cps;
+    }
+
+    private List<PointToPointIntent> setupConnectionPoints(String keyIndex,
+                                                           SdxL2ConnectionPoint lhs, String lhsID,
+                                                           String lhsMac, String lhsVlan,
+                                                           TrafficTreatment lhsBuiltTreatment,
+                                                           SdxL2ConnectionPoint rhs, String rhsID,
+                                                           String rhsMac, String rhsVlan,
+                                                           TrafficTreatment rhsBuiltTreatment) {
+        List<PointToPointIntent> intents = new ArrayList<PointToPointIntent>();
+        VlanId lhsVlanValue = null, rhsVlanValue = null;
+        if (lhsVlan != null) {
+            lhsVlanValue = VlanId.vlanId(Short.parseShort(lhsVlan));
+        }
+        if (rhsVlan != null) {
+            rhsVlanValue = VlanId.vlanId(Short.parseShort(rhsVlan));
+        }
+
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, lhs, rhs, keyIndex))
+                            .selector(buildSelector(MacAddress.valueOf(lhsMac),
+                                                    MacAddress.valueOf(rhsMac),
+                                                    null, lhsVlanValue))
+                            .treatment(lhsBuiltTreatment)
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(lhsID))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(rhsID))
+                            .priority(2000)
+                            .build());
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, rhs, lhs, keyIndex))
+                            .selector(buildSelector(MacAddress.valueOf(rhsMac),
+                                                    MacAddress.valueOf(lhsMac),
+                                                    null, rhsVlanValue))
+                            .treatment(rhsBuiltTreatment)
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(rhsID))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(lhsID))
+                            .priority(2000)
+                            .build());
+        return intents;
+    }
+
+    private List<PointToPointIntent> setupConnectionPoints1To2() {
+        List<PointToPointIntent> intents = new ArrayList<PointToPointIntent>();
+        String lhsID = CP1;
+        ArrayList<String> lhsVlan = VLANS1_ARRAY;
+        String lhsMac = CEMAC1;
+        String rhsID = CP2;
+        ArrayList<String> rhsVlan = VLANS2_ARRAY;
+        String rhsMac = CEMAC2;
+        SdxL2ConnectionPoint lhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint(
+                "TEST1", lhsID, VLANS1, lhsMac);
+        SdxL2ConnectionPoint rhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint(
+                "TEST2", rhsID, VLANS2, rhsMac);
+        TrafficTreatment lhsBuiltTreatment, rhsBuiltTreatment;
+
+        for (int i = 0; i < POINT_TO_POINT_INDEXES; i++) {
+            lhsBuiltTreatment = buildTreatment(VlanId.vlanId(rhsVlan.get(i)), null, false);
+            rhsBuiltTreatment = buildTreatment(VlanId.vlanId(lhsVlan.get(i)), null, false);
+            intents.addAll(setupConnectionPoints(Integer.toString(i + 1),
+                                    lhs, lhsID, lhsMac, lhsVlan.get(i), lhsBuiltTreatment,
+                                    rhs, rhsID, rhsMac, rhsVlan.get(i), rhsBuiltTreatment));
+        }
+        return intents;
+    }
+
+    private List<PointToPointIntent> setupConnectionPoints5To6() {
+        String lhsID = CP5;
+        String lhsVlan = VLANS5;
+        String lhsMac = CEMAC5;
+        SdxL2ConnectionPoint lhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", lhsID, lhsVlan, lhsMac);
+        String rhsID = CP6;
+        String rhsVlan = VLANS6;
+        String rhsMac = CEMAC6;
+        SdxL2ConnectionPoint rhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", rhsID, rhsVlan, rhsMac);
+        TrafficTreatment lhsBuiltTreatment =  buildTreatment(null, null, true);
+        TrafficTreatment rhsBuiltTreatment = buildTreatment(null, VlanId.vlanId(Short.parseShort(lhsVlan)), false);
+        return setupConnectionPoints("1", lhs, lhsID, lhsMac, lhsVlan, lhsBuiltTreatment,
+                                     rhs, rhsID, rhsMac, null, rhsBuiltTreatment);
+    }
+
+    private List<PointToPointIntent> setupConnectionPoints7To8() {
+        String lhsID = CP7;
+        String lhsVlan = VLANS7;
+        String lhsMac = CEMAC7;
+        SdxL2ConnectionPoint lhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", lhsID, lhsVlan, lhsMac);
+        String rhsID = CP8;
+        String rhsVlan = VLANS8;
+        String rhsMac = CEMAC8;
+        SdxL2ConnectionPoint rhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", rhsID, rhsVlan, rhsMac);
+        TrafficTreatment lhsBuiltTreatment = buildTreatment(null, VlanId.vlanId(Short.parseShort(rhsVlan)), false);
+        TrafficTreatment rhsBuiltTreatment = buildTreatment(null, null, true);
+        return setupConnectionPoints("1", lhs, lhsID, lhsMac, null, lhsBuiltTreatment,
+                                     rhs, rhsID, rhsMac, rhsVlan, rhsBuiltTreatment);
+    }
+
+    private List<PointToPointIntent> setupConnectionPoints9To10() {
+        String lhsID = CP9;
+        String lhsVlan = VLANS9;
+        String lhsMac = CEMAC9;
+        SdxL2ConnectionPoint lhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST9", lhsID, lhsVlan, lhsMac);
+        String rhsID = CP10;
+        String rhsVlan = VLANS10;
+        String rhsMac = CEMAC10;
+        SdxL2ConnectionPoint rhs = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", rhsID, rhsVlan, rhsMac);
+        TrafficTreatment nullTreatment = buildTreatment(null, null, false);
+        return setupConnectionPoints("1", lhs, lhsID, lhsMac, null, nullTreatment,
+                                     rhs, rhsID, rhsMac, null, nullTreatment);
+    }
+
+    @Test
+    public void removeConnection() {
+        testConnectionSetup();
+        List<PointToPointIntent> removedIntents = new ArrayList<PointToPointIntent>();
+
+        SdxL2ConnectionPoint cpone = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+        SdxL2ConnectionPoint cptwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2, CEMAC2);
+        removedIntents.addAll(setupConnectionPoints1To2());
+
+        SdxL2ConnectionPoint cpfive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5, CEMAC5);
+        SdxL2ConnectionPoint cpsix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6, CEMAC6);
+        removedIntents.addAll(setupConnectionPoints5To6());
+
+        SdxL2ConnectionPoint cpseven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7, CEMAC7);
+        SdxL2ConnectionPoint cpeight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8, CEMAC8);
+        removedIntents.addAll(setupConnectionPoints7To8());
+
+        manager.removeVC(cpone, cptwo);
+        manager.removeVC(cpfive, cpsix);
+        manager.removeVC(cpseven, cpeight);
+
+        assertEquals(2, manager.intentService.getIntentCount());
+
+        for (Intent removedIntent : removedIntents) {
+            boolean found = false;
+            for (Intent existingIntent : manager.intentService.getIntents()) {
+                if (removedIntent.key().equals(existingIntent.key())) {
+                    found = true;
+                    assertTrue(format("Intent %s equal %s", removedIntent, existingIntent),
+                               !IntentUtils.intentsAreEqual(removedIntent, existingIntent));
+                    break;
+                }
+            }
+            assertTrue(!found);
+        }
+
+    }
+
+    @Test
+    public void testRemoveVCbyCP() {
+        testConnectionSetup();
+
+        List<PointToPointIntent> removedIntents = new ArrayList<PointToPointIntent>();
+
+        SdxL2ConnectionPoint cpone = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+        removedIntents.addAll(setupConnectionPoints1To2());
+
+        SdxL2ConnectionPoint cpsix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6, CEMAC6);
+        removedIntents.addAll(setupConnectionPoints5To6());
+
+        SdxL2ConnectionPoint cpseven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7, CEMAC7);
+        removedIntents.addAll(setupConnectionPoints7To8());
+
+        SdxL2ConnectionPoint cpten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", CP10, VLANS10, CEMAC10);
+        removedIntents.addAll(setupConnectionPoints9To10());
+
+        manager.removeVC(cpone);
+        manager.removeVC(cpsix);
+        manager.removeVC(cpseven);
+        manager.removeVC(cpten);
+
+        assertEquals(Collections.emptySet(), manager.getVCs(Optional.ofNullable(null)));
+
+        assertEquals(0, manager.intentService.getIntentCount());
+
+        for (Intent removedIntent : removedIntents) {
+            boolean found = false;
+            for (Intent existingIntent : manager.intentService.getIntents()) {
+                if (removedIntent.key().equals(existingIntent.key())) {
+                    found = true;
+                    assertTrue(format("Intent %s equal %s", removedIntent, existingIntent),
+                               !IntentUtils.intentsAreEqual(removedIntent, existingIntent));
+                    break;
+                }
+            }
+            assertTrue(!found);
+        }
+
+    }
+
+    @Test
+    public void testRemoveVCbySdx() {
+        testConnectionSetup();
+
+        List<PointToPointIntent> removedIntents = new ArrayList<PointToPointIntent>();
+
+        removedIntents.addAll(setupConnectionPoints1To2());
+        removedIntents.addAll(setupConnectionPoints5To6());
+        removedIntents.addAll(setupConnectionPoints7To8());
+        removedIntents.addAll(setupConnectionPoints9To10());
+        manager.removeVCs(SDXL2_2);
+
+        assertEquals(Collections.emptySet(), manager.getVCs(Optional.ofNullable(null)));
+        assertEquals(Collections.emptySet(), manager.getVCs(Optional.of(SDXL2_2)));
+
+        for (Intent removedIntent : removedIntents) {
+            boolean found = false;
+            for (Intent existingIntent : manager.intentService.getIntents()) {
+                if (removedIntent.key().equals(existingIntent.key())) {
+                    found = true;
+                    assertTrue(format("Intent %s equal %s", removedIntent, existingIntent),
+                               !IntentUtils.intentsAreEqual(removedIntent, existingIntent));
+                    break;
+                }
+            }
+            assertTrue(!found);
+        }
+
+    }
+}
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ManagerTest.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ManagerTest.java
index 1b502b1..1017e72 100644
--- a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ManagerTest.java
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ManagerTest.java
@@ -19,23 +19,71 @@
 import com.google.common.collect.Sets;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 import org.onosproject.TestApplicationId;
+import org.onosproject.core.IdGenerator;
+import org.onosproject.net.intent.Intent;
+import org.onosproject.net.intent.MockIdGenerator;
 
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Optional;
 import java.util.Set;
 
+import static java.lang.String.format;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
-
+import static org.junit.Assert.assertNull;
 
 /**
  * Tests SdxL2Manager functionality.
  */
 public class SdxL2ManagerTest {
 
+    public static final String SDXL2 = "test";
+    public static final String SDXL2_2 = "test2";
+    public static final String CP1 = "of:00000000000001/1";
+    public static final String CP2 = "of:00000000000002/1";
+    public static final String CP3 = "of:00000000000003/1";
+    public static final String CP4 = "of:00000000000003/2";
+    public static final String CP5 = "of:00000000000004/2";
+    public static final String VLANS1 = "1,2,3,4";
+    public static final String VLANS2 = "-1";
+    public static final String VLANS3 = "1,2,3";
+    public static final String VLANS4 = "2,2,2";
+    public static final String VLANS7 = "5";
+    public static final String VLANS8 = "3,2,1";
+    public static final String CEMAC1 = "52:40:00:12:44:01";
+    public static final String CEMAC2 = "52:44:00:12:44:01";
+    public static final String CEMAC3 = "54:40:00:12:44:01";
+    public static final String CEMAC4 = "52:40:00:12:42:01";
+    public static final String CEMAC5 = "52:40:00:10:44:01";
+    public static final String CEMAC6 = "52:40:00:12:46:01";
+    public static final String CP6 = "of:00000000000004/3";
+    public static final String CP7 = "of:00000000000004/3";
+    public static final String CP8 = "of:00000000000005/2";
+    public static final String VLANS6 = "1,2,3,4";
+    public static final String VLANS5 = "8,9,10";
+    public static final String CEMAC7 = "52:40:00:12:46:01";
+    public static final String CEMAC8 = "52:40:90:12:46:01";
+    @Rule
+    public ExpectedException exceptionAddVC1 = ExpectedException.none();
+    @Rule
+    public ExpectedException exceptionAddVC2 = ExpectedException.none();
+    @Rule
+    public ExpectedException exceptionRemoveVC1 = ExpectedException.none();
+    @Rule
+    public ExpectedException exceptionRemoveVC2 = ExpectedException.none();
+    @Rule
+    public ExpectedException exceptionSdxL2Name = ExpectedException.none();
+    @Rule
+    public ExpectedException exceptionDelSdxL2Name = ExpectedException.none();
+    @Rule
+    public ExpectedException exceptionGetVC2 = ExpectedException.none();
     protected SdxL2Manager manager;
+    protected IdGenerator idGenerator = new MockIdGenerator();
 
     @Before
     public void setUp() {
@@ -44,19 +92,19 @@
         SdxL2DistributedStore store = new SdxL2DistributedStore();
         store.initForTest();
         manager.sdxL2Store = store;
+        SdxL2MacVCManager vcManager = new SdxL2MacVCManager(
+                manager.appId, manager.sdxL2Store, new IntentServiceTest());
+        manager.vcManager = vcManager;
+        Intent.bindIdGenerator(idGenerator);
     }
 
     @After
     public void tearDown() {
+        Intent.unbindIdGenerator(idGenerator);
     }
 
-    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);
@@ -85,23 +133,8 @@
         assertNotEquals(sdxl2, old);
     }
 
-    public static final String CP1 = "of:00000000000001/1";
-    public static final String CP2 = "of:00000000000002/1";
-    public static final String CP3 = "of:00000000000003/1";
-    public static final String CP4 = "of:00000000000003/2";
-    public static final String CP5 = "of:00000000000004/2";
-
-    public static final String VLANS1 = "1,2,3,4";
-    public static final String VLANS2 = "-1";
-    public static final String VLANS3 = "1,2,3";
-    public static final String VLANS4 = "2,2,2";
-    public static final String VLANS7 = "5";
-    public static final String VLANS8 = "3,2,1";
-
-    public static final String CEMAC1 = "52:40:00:12:44:01";
-
     @Test
-    public void testaddSdxL2ConnectionPoint() {
+    public void testAddSdxL2ConnectionPoint() {
 
         manager.createSdxL2(SDXL2);
         manager.createSdxL2(SDXL2_2);
@@ -125,12 +158,12 @@
         SdxL2ConnectionPoint ten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI2", CP5, VLANS2, CEMAC1);
         manager.addSdxL2ConnectionPoint(SDXL2, ten);
 
-        SdxL2ConnectionPoint fourteen = SdxL2ConnectionPoint.sdxl2ConnectionPoint("RO1",
-                "of:0000000000000003/3", "1", "52:54:00:04:E5:9E");
+        SdxL2ConnectionPoint fourteen = SdxL2ConnectionPoint.
+                sdxl2ConnectionPoint("RO1", "of:0000000000000003/3", "1", "52:54:00:04:E5:9E");
         manager.addSdxL2ConnectionPoint("test1", fourteen);
 
-        SdxL2ConnectionPoint fifteen = SdxL2ConnectionPoint.sdxl2ConnectionPoint("RO2",
-                "of:0000000000000009/3", "1", "52:54:00:68:F7:D9");
+        SdxL2ConnectionPoint fifteen = SdxL2ConnectionPoint.
+                sdxl2ConnectionPoint("RO2", "of:0000000000000009/3", "1", "52:54:00:68:F7:D9");
         manager.addSdxL2ConnectionPoint("test1", fifteen);
 
         SdxL2ConnectionPoint two = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM1", CP2, VLANS1, CEMAC1);
@@ -157,14 +190,14 @@
     }
 
     @Test
-    public void testgetSdxL2ConnectionPoints() {
+    public void testGetSdxL2ConnectionPoints() {
 
         manager.createSdxL2(SDXL2);
         manager.createSdxL2(SDXL2_2);
 
         Set<String> allExt = Sets.newHashSet();
         Set<String> allExtBySdxl2 = Sets.newHashSet();
-        Set<String> allExtBySdxl22 = Sets.newHashSet();
+        Set<String> allExtBySdxl2Aux = Sets.newHashSet();
 
         SdxL2ConnectionPoint one = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM1", CP1, VLANS1, CEMAC1);
         manager.addSdxL2ConnectionPoint(SDXL2, one);
@@ -177,7 +210,7 @@
         SdxL2ConnectionPoint six = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM3", CP1, VLANS7, CEMAC1);
         manager.addSdxL2ConnectionPoint(SDXL2_2, six);
         allExt.add(six.name());
-        allExtBySdxl22.add(six.name());
+        allExtBySdxl2Aux.add(six.name());
         SdxL2ConnectionPoint seven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("MI3", CP3, VLANS3, CEMAC1);
         manager.addSdxL2ConnectionPoint(SDXL2, seven);
         allExt.add(seven.name());
@@ -185,7 +218,7 @@
         SdxL2ConnectionPoint nine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI1", CP4, VLANS8, CEMAC1);
         manager.addSdxL2ConnectionPoint(SDXL2_2, nine);
         allExt.add(nine.name());
-        allExtBySdxl22.add(nine.name());
+        allExtBySdxl2Aux.add(nine.name());
         SdxL2ConnectionPoint ten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI2", CP5, VLANS2, CEMAC1);
         manager.addSdxL2ConnectionPoint(SDXL2, ten);
         allExt.add(ten.name());
@@ -197,20 +230,20 @@
 
         assertEquals(allExt, all);
         assertNotEquals(allExtBySdxl2, all);
-        assertNotEquals(allExtBySdxl22, all);
+        assertNotEquals(allExtBySdxl2Aux, all);
 
         assertNotEquals(allExt, allBySdxl2);
         assertEquals(allExtBySdxl2, allBySdxl2);
-        assertNotEquals(allExtBySdxl22, allBySdxl2);
+        assertNotEquals(allExtBySdxl2Aux, allBySdxl2);
 
         assertNotEquals(allExt, allBySdxl22);
         assertNotEquals(allExtBySdxl2, allBySdxl22);
-        assertEquals(allExtBySdxl22, allBySdxl22);
+        assertEquals(allExtBySdxl2Aux, allBySdxl22);
 
     }
 
     @Test
-    public void testremoveSdxL2ConnectionPoint() {
+    public void testRemoveSdxL2ConnectionPoint() {
 
         manager.createSdxL2(SDXL2);
         manager.createSdxL2(SDXL2_2);
@@ -241,7 +274,50 @@
     }
 
     @Test
-    public void testgetSdxL2ConnectionPoint() {
+    public void test2RemoveSdxL2s() {
+        manager.createSdxL2(SDXL2);
+        manager.createSdxL2(SDXL2_2);
+
+        Set<String> sdxL2CPs = Sets.newHashSet();
+        Set<String> sdxl2CPsAux = Sets.newHashSet();
+
+        SdxL2ConnectionPoint one = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM1", CP1, VLANS1, CEMAC1);
+        sdxL2CPs.add(one.name());
+        manager.addSdxL2ConnectionPoint(SDXL2, one);
+
+        SdxL2ConnectionPoint three = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM2", CP2, VLANS2, CEMAC1);
+        sdxL2CPs.add(three.name());
+        manager.addSdxL2ConnectionPoint(SDXL2, three);
+
+        SdxL2ConnectionPoint six = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM3", CP1, VLANS7, CEMAC1);
+        sdxl2CPsAux.add(six.name());
+        manager.addSdxL2ConnectionPoint(SDXL2_2, six);
+
+        SdxL2ConnectionPoint seven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("MI3", CP3, VLANS3, CEMAC1);
+        sdxL2CPs.add(seven.name());
+        manager.addSdxL2ConnectionPoint(SDXL2, seven);
+
+        SdxL2ConnectionPoint nine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI1", CP4, VLANS8, CEMAC1);
+        sdxl2CPsAux.add(nine.name());
+        manager.addSdxL2ConnectionPoint(SDXL2_2, nine);
+
+        SdxL2ConnectionPoint ten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI2", CP5, VLANS2, CEMAC1);
+        sdxL2CPs.add(ten.name());
+        manager.addSdxL2ConnectionPoint(SDXL2, ten);
+
+        manager.deleteSdxL2(SDXL2);
+
+        assertEquals(sdxl2CPsAux, this.manager.getSdxL2ConnectionPoints(Optional.of(SDXL2_2)));
+        assertEquals(sdxl2CPsAux, this.manager.getSdxL2ConnectionPoints(Optional.ofNullable(null)));
+        manager.deleteSdxL2(SDXL2_2);
+
+        assertEquals(Collections.emptySet(), this.manager.getSdxL2ConnectionPoints(Optional.of(SDXL2)));
+        assertEquals(Collections.emptySet(), this.manager.getSdxL2ConnectionPoints(Optional.of(SDXL2_2)));
+
+    }
+
+    @Test
+    public void testGetSdxL2ConnectionPoint() {
 
         manager.createSdxL2(SDXL2);
         manager.createSdxL2(SDXL2_2);
@@ -284,4 +360,240 @@
 
     }
 
+    @Test
+    public void testAddVCChecks() {
+
+        manager.createSdxL2(SDXL2);
+        manager.createSdxL2(SDXL2_2);
+
+        SdxL2ConnectionPoint one = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM1", CP1, VLANS1, CEMAC1);
+        SdxL2ConnectionPoint two = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM2", CP2, VLANS2, CEMAC2);
+        SdxL2ConnectionPoint three = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM3", CP1, VLANS7, CEMAC3);
+        SdxL2ConnectionPoint four = SdxL2ConnectionPoint.sdxl2ConnectionPoint("MI3", CP3, VLANS3, CEMAC4);
+        SdxL2ConnectionPoint five = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI1", CP4, VLANS8, CEMAC5);
+        SdxL2ConnectionPoint six = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI2", CP5, VLANS2, CEMAC6);
+        SdxL2ConnectionPoint seven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI23", CP6, VLANS6, CEMAC7);
+        SdxL2ConnectionPoint eight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI24", CP7, VLANS5, CEMAC8);
+        SdxL2ConnectionPoint nine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI25", CP8, VLANS5, CEMAC8);
+
+        manager.addSdxL2ConnectionPoint(SDXL2, one);
+        manager.addSdxL2ConnectionPoint(SDXL2, two);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, three);
+        manager.addSdxL2ConnectionPoint(SDXL2, four);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, five);
+        manager.addSdxL2ConnectionPoint(SDXL2, six);
+        manager.addSdxL2ConnectionPoint(SDXL2, seven);
+        manager.addSdxL2ConnectionPoint(SDXL2, eight);
+        manager.addSdxL2ConnectionPoint(SDXL2, nine);
+
+        manager.addVC(SDXL2, two.name(), six.name());
+        manager.addVC(SDXL2, seven.name(), nine.name());
+        manager.addVC(SDXL2, one.name(), two.name());
+        manager.addVC(SDXL2, one.name(), four.name());
+        manager.addVC(SDXL2, one.name(), six.name());
+        manager.addVC(SDXL2, two.name(), four.name());
+        manager.addVC(SDXL2, seven.name(), eight.name());
+
+        exceptionAddVC2.expect(IllegalStateException.class);
+        manager.addVC(SDXL2, four.name() + "x", five.name());
+        manager.addVC(SDXL2, one.name(), three.name());
+        manager.addVC(SDXL2, one.name(), five.name());
+        manager.addVC(SDXL2, two.name(), three.name());
+        manager.addVC(SDXL2, two.name(), five.name());
+        manager.addVC(SDXL2, three.name(), four.name());
+        manager.addVC(SDXL2, three.name(), five.name());
+        manager.addVC(SDXL2, three.name(), six.name());
+        manager.addVC(SDXL2, four.name(), five.name());
+    }
+
+    @Test
+    public void testRemoveVCChecks() {
+
+        manager.createSdxL2(SDXL2);
+        manager.createSdxL2(SDXL2_2);
+
+        SdxL2ConnectionPoint one = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM1", CP1, VLANS1, CEMAC1);
+        SdxL2ConnectionPoint two = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM2", CP2, VLANS2, CEMAC2);
+        SdxL2ConnectionPoint three = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM3", CP1, VLANS7, CEMAC3);
+        SdxL2ConnectionPoint four = SdxL2ConnectionPoint.sdxl2ConnectionPoint("MI3", CP3, VLANS3, CEMAC4);
+        SdxL2ConnectionPoint five = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI1", CP4, VLANS8, CEMAC5);
+        SdxL2ConnectionPoint six = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI2", CP5, VLANS2, CEMAC6);
+        SdxL2ConnectionPoint seven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI23", CP6, VLANS6, CEMAC7);
+        SdxL2ConnectionPoint eight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI24", CP7, VLANS5, CEMAC8);
+        SdxL2ConnectionPoint nine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI25", CP8, VLANS5, CEMAC8);
+
+        manager.addSdxL2ConnectionPoint(SDXL2, one);
+        manager.addSdxL2ConnectionPoint(SDXL2, two);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, three);
+        manager.addSdxL2ConnectionPoint(SDXL2, four);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, five);
+        manager.addSdxL2ConnectionPoint(SDXL2, six);
+        manager.addSdxL2ConnectionPoint(SDXL2, seven);
+        manager.addSdxL2ConnectionPoint(SDXL2, eight);
+        manager.addSdxL2ConnectionPoint(SDXL2, nine);
+
+        manager.addVC(SDXL2, two.name(), six.name());
+        manager.addVC(SDXL2, seven.name(), nine.name());
+
+        String vc;
+        vc = two.name().compareTo(six.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, two.name(), six.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, six.name(), two.name());
+        manager.removeVC(vc);
+
+        vc = seven.name().compareTo(nine.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, seven.name(), nine.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, seven.name(), nine.name());
+        manager.removeVC(vc);
+
+        vc = one.name().compareTo(four.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, one.name(), four.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, four.name(), one.name());
+        manager.removeVC(vc);
+        vc = one.name().compareTo(five.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, one.name(), five.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, five.name(), one.name());
+        manager.removeVC(vc);
+        vc = one.name().compareTo(six.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, one.name(), six.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, six.name(), one.name());
+        manager.removeVC(vc);
+        vc = two.name().compareTo(three.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, two.name(), three.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, three.name(), two.name());
+        manager.removeVC(vc);
+        vc = two.name().compareTo(four.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, two.name(), four.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, four.name(), two.name());
+        manager.removeVC(vc);
+        vc = two.name().compareTo(five.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, two.name(), five.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, five.name(), two.name());
+        manager.removeVC(vc);
+        vc = three.name().compareTo(four.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, three.name(), four.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, four.name(), three.name());
+        manager.removeVC(vc);
+        vc = three.name().compareTo(five.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, three.name(), five.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, five.name(), three.name());
+        manager.removeVC(vc);
+        vc = three.name().compareTo(six.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, three.name(), six.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, six.name(), three.name());
+        manager.removeVC(vc);
+        vc = four.name().compareTo(five.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, four.name(), five.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, five.name(), four.name());
+        manager.removeVC(vc);
+        vc = seven.name().compareTo(eight.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, seven.name(), eight.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, eight.name(), seven.name());
+        manager.removeVC(vc);
+        vc = seven.name().compareTo(nine.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2_2, seven.name(), nine.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, seven.name(), nine.name());
+        manager.removeVC(vc);
+        vc = seven.name().compareTo(nine.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2 + "x", seven.name(), nine.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, seven.name(), nine.name());
+        manager.removeVC(vc);
+
+        exceptionRemoveVC1.expect(IllegalStateException.class);
+        vc = one.name().compareTo(three.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, one.name(), three.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, three.name(), one.name());
+        manager.removeVC(vc);
+        manager.removeVC(":A");
+        manager.removeVC("A:B");
+
+        vc = four.name().compareTo(five.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, four.name() + "x", five.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, five.name(), four.name() + "x");
+        manager.removeVC(vc);
+
+        vc = one.name().compareTo(two.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, one.name(), two.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, two.name(), one.name());
+        manager.removeVC(vc);
+    }
+
+    @Test
+    public void testSdxL2NameChecks() {
+        String sdxL2 = "";
+        String sdxL2Aux = "test3,4";
+
+        exceptionSdxL2Name.expect(NullPointerException.class);
+        exceptionSdxL2Name.expectMessage("name cannot be null");
+        manager.createSdxL2(null);
+
+        manager.createSdxL2(sdxL2);
+
+        exceptionSdxL2Name.expect(IllegalStateException.class);
+        exceptionSdxL2Name.expectMessage("names cannot contain commas");
+        manager.createSdxL2(sdxL2Aux);
+    }
+
+    @Test
+    public void testDeleteSdxL2NameChecks() {
+        String sdxL2 = "";
+        exceptionDelSdxL2Name.expect(NullPointerException.class);
+        exceptionDelSdxL2Name.expectMessage("name cannot be null");
+        manager.deleteSdxL2(null);
+        manager.createSdxL2(sdxL2);
+        manager.deleteSdxL2(sdxL2);
+    }
+
+    @Test
+    public void testGetVC() {
+        manager.createSdxL2(SDXL2);
+        manager.createSdxL2(SDXL2_2);
+
+        SdxL2ConnectionPoint one = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM1", CP1, VLANS1, CEMAC1);
+        SdxL2ConnectionPoint two = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM2", CP2, VLANS2, CEMAC2);
+        SdxL2ConnectionPoint three = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM3", CP1, VLANS7, CEMAC3);
+        SdxL2ConnectionPoint four = SdxL2ConnectionPoint.sdxl2ConnectionPoint("MI3", CP3, VLANS3, CEMAC4);
+        SdxL2ConnectionPoint five = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI1", CP4, VLANS8, CEMAC5);
+        SdxL2ConnectionPoint six = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI2", CP5, VLANS2, CEMAC6);
+        SdxL2ConnectionPoint seven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI23", CP6, VLANS6, CEMAC7);
+        SdxL2ConnectionPoint eight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI24", CP7, VLANS5, CEMAC8);
+        SdxL2ConnectionPoint nine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI25", CP8, VLANS5, CEMAC8);
+
+        String vc;
+        VirtualCircuit expectedVC;
+        VirtualCircuit actualVC;
+
+        manager.addSdxL2ConnectionPoint(SDXL2, one);
+        manager.addSdxL2ConnectionPoint(SDXL2, two);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, three);
+        manager.addSdxL2ConnectionPoint(SDXL2, four);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, five);
+        manager.addSdxL2ConnectionPoint(SDXL2, six);
+        manager.addSdxL2ConnectionPoint(SDXL2, seven);
+        manager.addSdxL2ConnectionPoint(SDXL2, eight);
+        manager.addSdxL2ConnectionPoint(SDXL2, nine);
+
+        // VC created using the manager, check against manually generates
+        manager.addVC(SDXL2, two.name(), six.name());
+        vc = two.name().compareTo(six.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, two.name(), six.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, six.name(), two.name());
+        expectedVC = new VirtualCircuit(two, six);
+        actualVC = manager.getVirtualCircuit(vc);
+        assertEquals(expectedVC, actualVC);
+
+        // VC not created, check that getVC returns null if VC does not exist
+        vc = one.name().compareTo(two.name().toString()) < 0 ?
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, one.name(), two.name()) :
+                format(SdxL2VCManager.NAME_FORMAT, SDXL2, two.name(), one.name());
+        expectedVC = new VirtualCircuit(one, two);
+        actualVC = manager.getVirtualCircuit(vc);
+        assertNotEquals(expectedVC, actualVC);
+        assertNull(actualVC);
+
+        // Testing illegal character
+        exceptionGetVC2.expect(IllegalStateException.class);
+        manager.getVirtualCircuit(":A");
+        manager.getVirtualCircuit("A:B");
+    }
 }
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2MplsVCManagerTest.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2MplsVCManagerTest.java
new file mode 100644
index 0000000..914678b
--- /dev/null
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2MplsVCManagerTest.java
@@ -0,0 +1,756 @@
+/*
+ * 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.onlab.packet.VlanId;
+import org.onosproject.TestApplicationId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.net.flow.DefaultTrafficSelector;
+import org.onosproject.net.flow.DefaultTrafficTreatment;
+import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.intent.AbstractIntentTest;
+import org.onosproject.net.intent.Constraint;
+import org.onosproject.net.intent.Intent;
+import org.onosproject.net.intent.IntentUtils;
+import org.onosproject.net.intent.Key;
+import org.onosproject.net.intent.PointToPointIntent;
+import org.onosproject.net.intent.constraint.EncapsulationConstraint;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Optional;
+
+import static java.lang.String.format;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Unit tests for SDX-L2 MPLS VC Manager.
+ */
+public class SdxL2MplsVCManagerTest extends AbstractIntentTest {
+
+    private static final String SDXL2_2 = "sdxl2_test2";
+    private static final String CP1 = "of:00000000000001/1";
+    private static final String CP2 = "of:00000000000002/1";
+    private static final String CP5 = "of:00000000000002/4";
+    private static final String CP6 = "of:00000000000004/4";
+    private static final String CP7 = "of:0000000000000a/4";
+    private static final String CP8 = "of:00000000000009/4";
+    private static final String CP9 = "of:0000000000000a/4";
+    private static final String CP10 = "of:00000000000009/4";
+    private static final String VLANS1 = "2,3,4";
+    private static final String VLANS2 = "4,5,6";
+    private static final String VLANS5 = "100";
+    private static final String VLANS6 = "1";
+    private static final String VLANS7 = "1";
+    private static final String VLANS8 = "111";
+    private static final String VLANS9 = "1";
+    private static final String VLANS10 = "1";
+    private static final String NAME_FORMAT = "%s:%s-%s";
+    private static final String KEY_FORMAT = "%s,%s";
+    private static final ApplicationId APPID = TestApplicationId.create("foo");
+    private SdxL2MplsVCManager manager;
+    private List<PointToPointIntent> intentList;
+
+    /**
+     * Prepare environment before starting testing MPLS-based VCs.
+     */
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        SdxL2DistributedStore store = new SdxL2DistributedStore();
+        store.initForTest();
+        manager = new SdxL2MplsVCManager(APPID, store, new IntentServiceTest());
+        intentList = setIntents();
+    }
+
+    /**
+     * Clean up environment after finishing testing MPLS-based VCs.
+     */
+    @After
+    public void tearDown() {
+        super.tearDown();
+    }
+
+    private List<PointToPointIntent> setIntents() {
+        List<PointToPointIntent> intents = new ArrayList<PointToPointIntent>();
+        List<Constraint> encapsulation = buildConstraints();
+        SdxL2ConnectionPoint cpOne = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1);
+        SdxL2ConnectionPoint cpTwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2);
+
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpOne, cpTwo, "1"))
+                            .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("2"))))
+                            .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("4")), null, false))
+                            .constraints(encapsulation)
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                            .priority(2000)
+                            .build());
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpTwo, cpOne, "1"))
+                            .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("4"))))
+                            .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("2")), null, false))
+                            .constraints(encapsulation)
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                            .priority(2000)
+                            .build());
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpOne, cpTwo, "2"))
+                            .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("3"))))
+                            .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("5")), null, false))
+                            .constraints(encapsulation)
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                            .priority(2000)
+                            .build());
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpTwo, cpOne, "2"))
+                            .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("5"))))
+                            .constraints(encapsulation)
+                            .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("3")), null, false))
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                            .priority(2000)
+                            .build());
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpOne, cpTwo, "3"))
+                            .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("4"))))
+                            .constraints(encapsulation)
+                            .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("6")), null, false))
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                            .priority(2000)
+                            .build());
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpTwo, cpOne, "3"))
+                            .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("6"))))
+                            .constraints(encapsulation)
+                            .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("4")), null, false))
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                            .priority(2000)
+                            .build());
+
+        SdxL2ConnectionPoint cpFive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5);
+        SdxL2ConnectionPoint cpSix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6);
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpFive, cpSix, "1"))
+                            .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("100"))))
+                            .treatment(buildTreatment(null, null, true))
+                            .constraints(encapsulation)
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                            .priority(2000)
+                            .build());
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpSix, cpFive, "1"))
+                            .selector(buildSelector(null, null))
+                            .constraints(encapsulation)
+                            .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("100")), false))
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                            .priority(2000)
+                            .build());
+
+        SdxL2ConnectionPoint cpSeven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7);
+        SdxL2ConnectionPoint cpEight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8);
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpSeven, cpEight, "1"))
+                            .selector(buildSelector(null, null))
+                            .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("111")), false))
+                            .constraints(encapsulation)
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                            .priority(2000)
+                            .build());
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpEight, cpSeven, "1"))
+                            .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("111"))))
+                            .constraints(encapsulation)
+                            .treatment(buildTreatment(null, null, true))
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                            .priority(2000)
+                            .build());
+
+        SdxL2ConnectionPoint cpNine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST9", CP9, VLANS9);
+        SdxL2ConnectionPoint cpTen = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", CP10, VLANS10);
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpNine, cpTen, "1"))
+                            .selector(buildSelector(null, null))
+                            .constraints(encapsulation)
+                            .treatment(buildTreatment(null, null, false))
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP9))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP10))
+                            .priority(2000)
+                            .build());
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpTen, cpNine, "1"))
+                            .selector(buildSelector(null, null))
+                            .constraints(encapsulation)
+                            .treatment(buildTreatment(null, null, false))
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP10))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP9))
+                            .priority(2000)
+                            .build());
+
+        return intents;
+    }
+
+    private TrafficTreatment buildTreatment(VlanId setVlan,
+                                            VlanId pushVlan,
+                                            boolean popVlan) {
+
+        TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
+        if (setVlan != null) {
+            treatmentBuilder.setVlanId(setVlan);
+        }
+        if (pushVlan != null) {
+            treatmentBuilder.pushVlan();
+            treatmentBuilder.setVlanId(pushVlan);
+        }
+        if (popVlan) {
+            treatmentBuilder.popVlan();
+        }
+        return treatmentBuilder.build();
+    }
+
+    private TrafficSelector buildSelector(Short ethertype,
+                                          VlanId ingresstag) {
+
+        TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
+        if (ethertype != null) {
+            selectorBuilder.matchEthType(ethertype);
+        }
+        if (ingresstag != null) {
+            selectorBuilder.matchVlanId(ingresstag);
+        }
+        return selectorBuilder.build();
+    }
+
+    private List<Constraint> buildConstraints() {
+        final List<Constraint> constraints = new LinkedList<>();
+        constraints.add(new EncapsulationConstraint(EncapsulationType.MPLS));
+        return constraints;
+    }
+
+    private Key generateIntentKey(String sdxl2, SdxL2ConnectionPoint cpOne,
+                                  SdxL2ConnectionPoint cpTwo, String index) {
+        String cps = format(NAME_FORMAT, sdxl2, cpOne.name(), cpTwo.name());
+        String key = format(KEY_FORMAT, cps, index);
+        return Key.of(key, APPID);
+    }
+
+    @Test
+    public void testConnectionSetup() {
+        Iterator<SdxL2ConnectionPoint> lhs = setupLhsCPs().iterator();
+        Iterator<SdxL2ConnectionPoint> rhs = setupRhsCPs().iterator();
+        while (lhs.hasNext()) {
+            manager.addVC(SDXL2_2, lhs.next(), rhs.next());
+        }
+
+        assertEquals(intentList.size(), manager.intentService.getIntentCount());
+
+        for (Intent emulatedIntent : intentList) {
+            boolean found = false;
+            for (Intent realIntent : manager.intentService.getIntents()) {
+                if (emulatedIntent.key().equals(realIntent.key())) {
+                    found = true;
+                    assertTrue(format("Comparing %s and %s", emulatedIntent, realIntent),
+                               IntentUtils.intentsAreEqual(emulatedIntent, realIntent));
+                    break;
+                }
+            }
+            assertTrue(found);
+        }
+
+    }
+
+    private List<SdxL2ConnectionPoint> setupLhsCPs() {
+
+        List<SdxL2ConnectionPoint> cps = new ArrayList<>();
+        SdxL2ConnectionPoint cpOne = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1);
+        cps.add(cpOne);
+        SdxL2ConnectionPoint cpFive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5);
+        cps.add(cpFive);
+        SdxL2ConnectionPoint cpSeven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7);
+        cps.add(cpSeven);
+        SdxL2ConnectionPoint cpNine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST9", CP9, VLANS9);
+        cps.add(cpNine);
+
+        return cps;
+    }
+
+    private List<SdxL2ConnectionPoint> setupRhsCPs() {
+
+        List<SdxL2ConnectionPoint> cps = new ArrayList<SdxL2ConnectionPoint>();
+        SdxL2ConnectionPoint cpTwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2);
+        cps.add(cpTwo);
+        SdxL2ConnectionPoint cpSix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6);
+        cps.add(cpSix);
+        SdxL2ConnectionPoint cpEight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8);
+        cps.add(cpEight);
+        SdxL2ConnectionPoint cpTen = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", CP10, VLANS10);
+        cps.add(cpTen);
+
+        return cps;
+    }
+
+
+    @Test
+    public void removeConnection() {
+        testConnectionSetup();
+
+        List<PointToPointIntent> removedIntents = new ArrayList<>();
+        SdxL2ConnectionPoint cpOne = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1);
+        SdxL2ConnectionPoint cpTwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2);
+
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpOne, cpTwo, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("2"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("4")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpTwo, cpOne, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("4"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("2")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpOne, cpTwo, "2"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("3"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("5")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpTwo, cpOne, "2"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("5"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("3")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpOne, cpTwo, "3"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("4"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("6")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpTwo, cpOne, "3"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("6"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("4")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpFive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5);
+        SdxL2ConnectionPoint cpSix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpFive, cpSix, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("100"))))
+                                    .treatment(buildTreatment(null, null, true))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpSix, cpFive, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("100")), false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpSeven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7);
+        SdxL2ConnectionPoint cpEight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpSeven, cpEight, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("111")), false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpEight, cpSeven, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("111"))))
+                                    .treatment(buildTreatment(null, null, true))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                                    .priority(2000)
+                                    .build());
+        manager.removeVC(cpOne, cpTwo);
+        manager.removeVC(cpFive, cpSix);
+        manager.removeVC(cpSeven, cpEight);
+
+        assertEquals(2, manager.intentService.getIntentCount());
+
+        for (Intent removedIntent : removedIntents) {
+            boolean found = false;
+            for (Intent existingIntent : manager.intentService.getIntents()) {
+                if (removedIntent.key().equals(existingIntent.key())) {
+                    found = true;
+                    assertTrue(format("Intent %s equal %s", removedIntent, existingIntent),
+                               !IntentUtils.intentsAreEqual(removedIntent, existingIntent));
+                    break;
+                }
+            }
+            assertTrue(!found);
+        }
+    }
+
+
+    @Test
+    public void testremoveVCbyCP() {
+        testConnectionSetup();
+
+        List<PointToPointIntent> removedIntents = new ArrayList<PointToPointIntent>();
+        SdxL2ConnectionPoint cpOne = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1);
+        SdxL2ConnectionPoint cpTwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2);
+
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpOne, cpTwo, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("2"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("4")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpTwo, cpOne, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("4"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("2")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpOne, cpTwo, "2"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("3"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("5")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpTwo, cpOne, "2"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("5"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("3")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpOne, cpTwo, "3"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("4"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("6")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpTwo, cpOne, "3"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("6"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("4")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpFive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5);
+        SdxL2ConnectionPoint cpSix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpFive, cpSix, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("100"))))
+                                    .treatment(buildTreatment(null, null, true))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpSix, cpFive, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("100")), false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpSeven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7);
+        SdxL2ConnectionPoint cpEight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpSeven, cpEight, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("111")), false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpEight, cpSeven, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("111"))))
+                                    .treatment(buildTreatment(null, null, true))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpNine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST9", CP9, VLANS9);
+        SdxL2ConnectionPoint cpTen = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", CP10, VLANS10);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpNine, cpTen, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP9))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP10))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpTen, cpNine, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP10))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP9))
+                                    .priority(2000)
+                                    .build());
+
+
+        manager.removeVC(cpOne);
+        manager.removeVC(cpSix);
+        manager.removeVC(cpSeven);
+        manager.removeVC(cpTen);
+
+        assertEquals(Collections.emptySet(), manager.getVCs(Optional.ofNullable(null)));
+
+        assertEquals(0, manager.intentService.getIntentCount());
+
+        for (Intent removedIntent : removedIntents) {
+            boolean found = false;
+            for (Intent existingIntent : manager.intentService.getIntents()) {
+                if (removedIntent.key().equals(existingIntent.key())) {
+                    found = true;
+                    assertTrue(format("Intent %s equal %s", removedIntent, existingIntent),
+                               !IntentUtils.intentsAreEqual(removedIntent, existingIntent));
+                    break;
+                }
+            }
+            assertTrue(!found);
+        }
+
+    }
+
+    @Test
+    public void testremoveVCbySdx() {
+        testConnectionSetup();
+
+        List<PointToPointIntent> removedIntents = new ArrayList<>();
+        SdxL2ConnectionPoint cpOne = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1);
+        SdxL2ConnectionPoint cpTwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2);
+
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpOne, cpTwo, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("2"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("4")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpTwo, cpOne, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("4"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("2")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpOne, cpTwo, "2"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("3"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("5")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpTwo, cpOne, "2"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("5"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("3")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpOne, cpTwo, "3"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("4"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("6")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpTwo, cpOne, "3"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("6"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("4")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpFive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5);
+        SdxL2ConnectionPoint cpSix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpFive, cpSix, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("100"))))
+                                    .treatment(buildTreatment(null, null, true))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpSix, cpFive, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("100")), false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpSeven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7);
+        SdxL2ConnectionPoint cpEight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpSeven, cpEight, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("111")), false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpEight, cpSeven, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("111"))))
+                                    .treatment(buildTreatment(null, null, true))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpNine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST9", CP9, VLANS9);
+        SdxL2ConnectionPoint cpTen = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", CP10, VLANS10);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpNine, cpTen, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP9))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP10))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpTen, cpNine, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP10))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP9))
+                                    .priority(2000)
+                                    .build());
+
+        manager.removeVCs(SDXL2_2);
+        assertEquals(Collections.emptySet(), manager.getVCs(Optional.ofNullable(null)));
+        assertEquals(Collections.emptySet(), manager.getVCs(Optional.of(SDXL2_2)));
+
+        for (Intent removedIntent : removedIntents) {
+            boolean found = false;
+            for (Intent existingIntent : manager.intentService.getIntents()) {
+                if (removedIntent.key().equals(existingIntent.key())) {
+                    found = true;
+                    assertTrue(format("Intent %s equal %s", removedIntent, existingIntent),
+                               !IntentUtils.intentsAreEqual(removedIntent, existingIntent));
+                    break;
+                }
+            }
+            assertTrue(!found);
+        }
+    }
+}
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2VCManagerTest.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2VCManagerTest.java
new file mode 100644
index 0000000..26323fb
--- /dev/null
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2VCManagerTest.java
@@ -0,0 +1,254 @@
+/*
+ * 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.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.TestApplicationId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.IdGenerator;
+import org.onosproject.net.intent.Intent;
+import org.onosproject.net.intent.Key;
+import org.onosproject.net.intent.MockIdGenerator;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+
+import static java.lang.String.format;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNull;
+
+
+public class SdxL2VCManagerTest {
+
+    private static final String SDXL2_1 = "sdxl2_test1";
+    private static final String CP1 = "of:00000000000001/1";
+    private static final String CP2 = "of:00000000000002/1";
+    private static final String VLANS1 = "2,3,4";
+    private static final String VLANS2 = "4,5,6";
+    private static final String CEMAC1 = "52:40:00:12:44:01";
+    private static final String CEMAC2 = "51:12:11:00:23:01";
+    private static final String CP3 = "of:00000000000002/2";
+    private static final String VLANS3 = "8,9,10";
+    private static final String CEMAC3 = "52:12:11:00:23:01";
+    private static final String SDXL2_2 = "sdxl2_test2";
+    private static final String CP5 = "of:00000000000002/4";
+    private static final String VLANS5 = "100";
+    private static final String CEMAC5 = "52:12:11:00:23:11";
+    private static final String CP6 = "of:00000000000004/4";
+    private static final String VLANS6 = "1";
+    private static final String CEMAC6 = "52:12:11:a0:23:11";
+    private static final String CP7 = "of:0000000000000a/4";
+    private static final String VLANS7 = "1";
+    private static final String CEMAC7 = "52:12:21:00:25:11";
+    private static final String CP8 = "of:00000000000009/4";
+    private static final String VLANS8 = "111";
+    private static final String CEMAC8 = "52:12:14:a0:23:11";
+    private static final String CP9 = "of:0000000000000a/4";
+    private static final String VLANS9 = "1";
+    private static final String CEMAC9 = "52:12:21:00:28:11";
+    private static final String CP10 = "of:00000000000009/4";
+    private static final String VLANS10 = "1";
+    private static final String CEMAC10 = "52:12:14:aa:23:11";
+    private static final ApplicationId APPID = TestApplicationId.create("foo");
+    @Rule
+    public ExpectedException exceptionAddVC = ExpectedException.none();
+    @Rule
+    public ExpectedException exceptionRemoveVC = ExpectedException.none();
+    @Rule
+    public ExpectedException exceptionGetVC = ExpectedException.none();
+    private SdxL2MacVCManager manager;
+    private IdGenerator idGenerator = new MockIdGenerator();
+
+    /**
+     * Prepare environment before starting testing VCs.
+     */
+    @Before
+    public void setUp() {
+        SdxL2DistributedStore store = new SdxL2DistributedStore();
+        store.initForTest();
+        manager = new SdxL2MacVCManager(
+                APPID, store, new IntentServiceTest());
+        Intent.bindIdGenerator(idGenerator);
+    }
+
+    /**
+     * Clean up environment after finishing testing VCs.
+     */
+    @After
+    public void tearDown() {
+        Intent.unbindIdGenerator(idGenerator);
+    }
+
+    @Test
+    public void testgenerateKey() {
+        SdxL2ConnectionPoint cpOne = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+        SdxL2ConnectionPoint cpOneAux = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2, CEMAC1);
+
+        SdxL2ConnectionPoint cpTwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2, CEMAC1);
+        SdxL2ConnectionPoint cpTwoAux = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+
+        Key key1 = manager.generateIntentKey(SDXL2_1, cpOne, cpTwo, "1");
+        Key key2 = manager.generateIntentKey(SDXL2_1, cpOneAux, cpTwoAux, "1");
+        assertNotEquals(key1, key2);
+
+        Key key3 = manager.generateIntentKey(SDXL2_1, cpOne, cpTwoAux, "1");
+        Key key4 = manager.generateIntentKey(SDXL2_1, cpOneAux, cpTwo, "1");
+        assertNotEquals(key3, key4);
+    }
+
+    @Test
+    public void testAddVCChecks() {
+
+        SdxL2ConnectionPoint cpFive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+        SdxL2ConnectionPoint cpSix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2, CEMAC2);
+        manager.addVC(SDXL2_1, cpFive, cpSix);
+
+        SdxL2ConnectionPoint cpSeven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2, CEMAC2);
+        SdxL2ConnectionPoint cpEight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+        manager.addVC(SDXL2_1, cpSeven, cpEight);
+
+        SdxL2ConnectionPoint cpNine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+        SdxL2ConnectionPoint cpTen = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST3", CP3, VLANS3, CEMAC3);
+        manager.addVC(SDXL2_1, cpNine, cpTen);
+
+        exceptionAddVC.expect(IllegalStateException.class);
+        SdxL2ConnectionPoint cpOne = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+        SdxL2ConnectionPoint cpTwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2, CEMAC1);
+        manager.addVC(SDXL2_1, cpOne, cpTwo);
+    }
+
+    @Test
+    public void testremoveVCChecks() {
+        SdxL2ConnectionPoint cpOne = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+        SdxL2ConnectionPoint cpTwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2, CEMAC1);
+
+        SdxL2ConnectionPoint cpFive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+        SdxL2ConnectionPoint cpSix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2, CEMAC2);
+
+        SdxL2ConnectionPoint cpSeven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2, CEMAC2);
+        SdxL2ConnectionPoint cpEight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+
+        SdxL2ConnectionPoint cpNine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+        SdxL2ConnectionPoint cpTen = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST3", CP3, VLANS3, CEMAC3);
+
+        manager.addVC(SDXL2_1, cpFive, cpSix);
+        manager.removeVC(cpFive, cpSix);
+        manager.removeVC(cpSeven, cpEight);
+        manager.removeVC(cpNine, cpTen);
+
+        exceptionRemoveVC.expect(IllegalStateException.class);
+        manager.removeVC(cpOne, cpTwo);
+    }
+
+    @Test
+    public void testGetVC() {
+        connectionSetup();
+
+        Iterator<SdxL2ConnectionPoint> lhs = setupLhsCPs().iterator();
+        Iterator<SdxL2ConnectionPoint> rhs = setupRhsCPs().iterator();
+        String vc;
+        SdxL2ConnectionPoint one;
+        SdxL2ConnectionPoint two;
+        while (lhs.hasNext()) {
+            one = lhs.next();
+            two = rhs.next();
+            vc = one.toString().compareTo(two.toString()) < 0 ?
+                    format(SdxL2VCManager.SDXL2_CPS_FORMAT, one, two) :
+                    format(SdxL2VCManager.SDXL2_CPS_FORMAT, two, one);
+            assertEquals(vc, manager.getVC(one, two));
+        }
+
+        SdxL2ConnectionPoint cpLeft = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+        SdxL2ConnectionPoint cpRight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP3, VLANS3, CEMAC1);
+
+        // This VC has not been created before
+        vc = cpLeft.toString().compareTo(cpRight.toString()) < 0 ?
+                format(SdxL2VCManager.SDXL2_CPS_FORMAT, cpLeft, cpRight) :
+                format(SdxL2VCManager.SDXL2_CPS_FORMAT, cpRight, cpLeft);
+
+        assertNull(manager.getVC(cpLeft, cpRight));
+    }
+
+    @Test
+    public void testgetVCs() {
+        connectionSetup();
+        Iterator<SdxL2ConnectionPoint> lhs = setupLhsCPs().iterator();
+        Iterator<SdxL2ConnectionPoint> rhs = setupRhsCPs().iterator();
+        Set<String> expectedVCs = Sets.newHashSet();
+        String vc;
+        String lhsName;
+        String rhsName;
+        while (lhs.hasNext()) {
+            lhsName = lhs.next().name();
+            rhsName = rhs.next().name();
+            vc = lhsName.compareTo(rhsName.toString()) < 0 ?
+                    format(SdxL2VCManager.NAME_FORMAT, SDXL2_2, lhsName, rhsName) :
+                    format(SdxL2VCManager.NAME_FORMAT, SDXL2_2, rhsName, lhsName);
+            expectedVCs.add(vc);
+        }
+        Set<String> vcs = manager.getVCs(Optional.of(SDXL2_2));
+        assertEquals(expectedVCs, vcs);
+        vcs = manager.getVCs(Optional.of(SDXL2_1));
+        assertEquals(Collections.emptySet(), vcs);
+        vcs = manager.getVCs(Optional.ofNullable(null));
+        assertEquals(expectedVCs, vcs);
+    }
+
+    public List<SdxL2ConnectionPoint> setupLhsCPs() {
+        List<SdxL2ConnectionPoint> cps = new ArrayList<SdxL2ConnectionPoint>();
+        SdxL2ConnectionPoint cpone = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1, CEMAC1);
+        cps.add(cpone);
+        SdxL2ConnectionPoint cpfive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5, CEMAC5);
+        cps.add(cpfive);
+        SdxL2ConnectionPoint cpseven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7, CEMAC7);
+        cps.add(cpseven);
+        SdxL2ConnectionPoint cpnine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST9", CP9, VLANS9, CEMAC9);
+        cps.add(cpnine);
+        return cps;
+    }
+
+    public List<SdxL2ConnectionPoint> setupRhsCPs() {
+        List<SdxL2ConnectionPoint> cps = new ArrayList<SdxL2ConnectionPoint>();
+        SdxL2ConnectionPoint cptwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2, CEMAC2);
+        cps.add(cptwo);
+        SdxL2ConnectionPoint cpsix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6, CEMAC6);
+        cps.add(cpsix);
+        SdxL2ConnectionPoint cpeight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8, CEMAC8);
+        cps.add(cpeight);
+        SdxL2ConnectionPoint cpten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", CP10, VLANS10, CEMAC10);
+        cps.add(cpten);
+        return cps;
+    }
+
+    private void connectionSetup() {
+        Iterator<SdxL2ConnectionPoint> lhs = setupLhsCPs().iterator();
+        Iterator<SdxL2ConnectionPoint> rhs = setupRhsCPs().iterator();
+        while (lhs.hasNext()) {
+            manager.addVC(SDXL2_2, lhs.next(), rhs.next());
+        }
+    }
+}
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2VlanVCManagerTest.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2VlanVCManagerTest.java
new file mode 100644
index 0000000..e6dd921
--- /dev/null
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2VlanVCManagerTest.java
@@ -0,0 +1,723 @@
+/*
+ * 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.onlab.packet.VlanId;
+import org.onosproject.TestApplicationId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.EncapsulationType;
+import org.onosproject.net.flow.DefaultTrafficSelector;
+import org.onosproject.net.flow.DefaultTrafficTreatment;
+import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.intent.AbstractIntentTest;
+import org.onosproject.net.intent.Constraint;
+import org.onosproject.net.intent.Intent;
+import org.onosproject.net.intent.IntentUtils;
+import org.onosproject.net.intent.Key;
+import org.onosproject.net.intent.PointToPointIntent;
+import org.onosproject.net.intent.constraint.EncapsulationConstraint;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+
+import static java.lang.String.format;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Unit tests for SdxL2VlanVCManager.
+ */
+public class SdxL2VlanVCManagerTest extends AbstractIntentTest {
+
+    private static final String SDXL2_2 = "sdxl2_test2";
+    private static final String CP1 = "of:00000000000001/1";
+    private static final String CP2 = "of:00000000000002/1";
+    private static final String CP5 = "of:00000000000002/4";
+    private static final String CP6 = "of:00000000000004/4";
+    private static final String CP7 = "of:0000000000000a/4";
+    private static final String CP8 = "of:00000000000009/4";
+    private static final String CP9 = "of:0000000000000a/4";
+    private static final String CP10 = "of:00000000000009/4";
+    private static final String VLANS1 = "2,3,4";
+    private static final ArrayList<String> VLANS1_ARRAY =
+            new ArrayList<String>(Arrays.asList(VLANS1.split(",")));;
+    private static final String VLANS2 = "4,5,6";
+    private static final ArrayList<String> VLANS2_ARRAY =
+            new ArrayList<String>(Arrays.asList(VLANS2.split(",")));;
+    private static final String VLANS5 = "100";
+    private static final String VLANS6 = "1";
+    private static final String VLANS7 = "1";
+    private static final String VLANS8 = "111";
+    private static final String VLANS9 = "1";
+    private static final String VLANS10 = "1";
+    private static final String NAME_FORMAT = "%s:%s-%s";
+    private static final String KEY_FORMAT = "%s,%s";
+    private static final ApplicationId APPID = TestApplicationId.create("foo");
+    private static final int POINT_TO_POINT_INDEXES = 3;
+    private SdxL2VlanVCManager manager;
+    private List<PointToPointIntent> intentList;
+
+    /**
+     * Prepare environment before starting testing VLAN-based VCs.
+     */
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        SdxL2DistributedStore store = new SdxL2DistributedStore();
+        store.initForTest();
+        manager = new SdxL2VlanVCManager(
+                APPID, store, new IntentServiceTest());
+        intentList = setIntents();
+    }
+
+    /**
+     * Clean up environment after finishing testing VLAN-based VCs.
+     */
+    @After
+    public void tearDown() {
+        super.tearDown();
+    }
+
+    public List<PointToPointIntent> setIntents() {
+        List<PointToPointIntent> intents = new ArrayList<PointToPointIntent>();
+        List<Constraint> encapsulation = buildConstraints();
+
+        SdxL2ConnectionPoint cpone = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1);
+        SdxL2ConnectionPoint cptwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2);
+        for (int i = 0; i < POINT_TO_POINT_INDEXES; i++) {
+            intents.add(PointToPointIntent.builder()
+                                .appId(APPID)
+                                .key(generateIntentKey(SDXL2_2, cpone, cptwo, Integer.toString(i + 1))) // 1
+                                .selector(buildSelector(null, VlanId.vlanId(Short.parseShort(VLANS1_ARRAY.get(i)))))
+                                .treatment(buildTreatment(
+                                        VlanId.vlanId(Short.parseShort(VLANS2_ARRAY.get(i))), null, false))
+                                .constraints(encapsulation)
+                                .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                .priority(2000)
+                                .build());
+            intents.add(PointToPointIntent.builder()
+                                .appId(APPID)
+                                .key(generateIntentKey(SDXL2_2, cptwo, cpone, Integer.toString(i + 1)))
+                                .selector(buildSelector(null, VlanId.vlanId(Short.parseShort(VLANS2_ARRAY.get(i)))))
+                                .treatment(buildTreatment(
+                                        VlanId.vlanId(Short.parseShort(VLANS1_ARRAY.get(i))), null, false))
+                                .constraints(encapsulation)
+                                .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                .priority(2000)
+                                .build());
+        }
+
+        SdxL2ConnectionPoint cpfive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5);
+        SdxL2ConnectionPoint cpsix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6);
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpfive, cpsix, "1"))
+                            .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("100"))))
+                            .treatment(buildTreatment(null, null, true))
+                            .constraints(encapsulation)
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                            .priority(2000)
+                            .build());
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpsix, cpfive, "1"))
+                            .selector(buildSelector(null, null))
+                            .constraints(encapsulation)
+                            .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("100")), false))
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                            .priority(2000)
+                            .build());
+
+        SdxL2ConnectionPoint cpseven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7);
+        SdxL2ConnectionPoint cpeight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8);
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpseven, cpeight, "1"))
+                            .selector(buildSelector(null, null))
+                            .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("111")), false))
+                            .constraints(encapsulation)
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                            .priority(2000)
+                            .build());
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpeight, cpseven, "1"))
+                            .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("111"))))
+                            .constraints(encapsulation)
+                            .treatment(buildTreatment(null, null, true))
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                            .priority(2000)
+                            .build());
+
+        SdxL2ConnectionPoint cpnine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST9", CP9, VLANS9);
+        SdxL2ConnectionPoint cpten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", CP10, VLANS10);
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpnine, cpten, "1"))
+                            .selector(buildSelector(null, null))
+                            .constraints(encapsulation)
+                            .treatment(buildTreatment(null, null, false))
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP9))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP10))
+                            .priority(2000)
+                            .build());
+        intents.add(PointToPointIntent.builder()
+                            .appId(APPID)
+                            .key(generateIntentKey(SDXL2_2, cpten, cpnine, "1"))
+                            .selector(buildSelector(null, null))
+                            .constraints(encapsulation)
+                            .treatment(buildTreatment(null, null, false))
+                            .ingressPoint(ConnectPoint.deviceConnectPoint(CP10))
+                            .egressPoint(ConnectPoint.deviceConnectPoint(CP9))
+                            .priority(2000)
+                            .build());
+
+        return intents;
+    }
+
+    private TrafficTreatment buildTreatment(VlanId setVlan,
+                                            VlanId pushVlan,
+                                            boolean popVlan) {
+
+        TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
+        if (setVlan != null) {
+            treatmentBuilder.setVlanId(setVlan);
+        }
+        if (pushVlan != null) {
+            treatmentBuilder.pushVlan();
+            treatmentBuilder.setVlanId(pushVlan);
+        }
+        if (popVlan) {
+            treatmentBuilder.popVlan();
+        }
+        return treatmentBuilder.build();
+    }
+
+    private TrafficSelector buildSelector(Short ethertype,
+                                          VlanId ingresstag) {
+
+        TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
+        if (ethertype != null) {
+            selectorBuilder.matchEthType(ethertype);
+        }
+        if (ingresstag != null) {
+            selectorBuilder.matchVlanId(ingresstag);
+        }
+        return selectorBuilder.build();
+    }
+
+    protected List<Constraint> buildConstraints() {
+        final List<Constraint> constraints = new LinkedList<>();
+        constraints.add(new EncapsulationConstraint(EncapsulationType.VLAN));
+        return constraints;
+    }
+
+    private Key generateIntentKey(String sdxl2, SdxL2ConnectionPoint cpone, SdxL2ConnectionPoint cptwo, String index) {
+        String cps = format(NAME_FORMAT, sdxl2, cpone.name(), cptwo.name());
+        String key = format(KEY_FORMAT, cps, index);
+        return Key.of(key, APPID);
+    }
+
+    @Test
+    public void testConnectionSetup() {
+        Iterator<SdxL2ConnectionPoint> lhs = setupLhsCPs().iterator();
+        Iterator<SdxL2ConnectionPoint> rhs = setupRhsCPs().iterator();
+        while (lhs.hasNext() && rhs.hasNext()) {
+            manager.addVC(SDXL2_2, lhs.next(), rhs.next());
+        }
+
+        assertEquals(intentList.size(), manager.intentService.getIntentCount());
+
+        for (Intent emulatedIntent : intentList) {
+            boolean found = false;
+            for (Intent realIntent : manager.intentService.getIntents()) {
+                if (emulatedIntent.key().equals(realIntent.key())) {
+                    found = true;
+                    assertTrue(format("Comparing %s and %s", emulatedIntent, realIntent),
+                               IntentUtils.intentsAreEqual(emulatedIntent, realIntent));
+                    break;
+                }
+            }
+            assertTrue(found);
+        }
+    }
+
+    public List<SdxL2ConnectionPoint> setupLhsCPs() {
+        List<SdxL2ConnectionPoint> cps = new ArrayList<SdxL2ConnectionPoint>();
+        SdxL2ConnectionPoint cpone = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1);
+        cps.add(cpone);
+        SdxL2ConnectionPoint cpfive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5);
+        cps.add(cpfive);
+        SdxL2ConnectionPoint cpseven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7);
+        cps.add(cpseven);
+        SdxL2ConnectionPoint cpnine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST9", CP9, VLANS9);
+        cps.add(cpnine);
+        return cps;
+    }
+
+    public List<SdxL2ConnectionPoint> setupRhsCPs() {
+        List<SdxL2ConnectionPoint> cps = new ArrayList<SdxL2ConnectionPoint>();
+        SdxL2ConnectionPoint cptwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2);
+        cps.add(cptwo);
+        SdxL2ConnectionPoint cpsix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6);
+        cps.add(cpsix);
+        SdxL2ConnectionPoint cpeight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8);
+        cps.add(cpeight);
+        SdxL2ConnectionPoint cpten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", CP10, VLANS10);
+        cps.add(cpten);
+        return cps;
+    }
+
+
+    @Test
+    public void removeConnection() {
+        testConnectionSetup();
+
+        List<PointToPointIntent> removedIntents = new ArrayList<PointToPointIntent>();
+        SdxL2ConnectionPoint cpone = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1);
+        SdxL2ConnectionPoint cptwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2);
+
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpone, cptwo, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("2"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("4")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cptwo, cpone, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("4"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("2")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpone, cptwo, "2"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("3"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("5")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cptwo, cpone, "2"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("5"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("3")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpone, cptwo, "3"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("4"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("6")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cptwo, cpone, "3"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("6"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("4")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpfive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5);
+        SdxL2ConnectionPoint cpsix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpfive, cpsix, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("100"))))
+                                    .treatment(buildTreatment(null, null, true))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpsix, cpfive, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("100")), false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpseven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7);
+        SdxL2ConnectionPoint cpeight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpseven, cpeight, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("111")), false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpeight, cpseven, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("111"))))
+                                    .treatment(buildTreatment(null, null, true))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                                    .priority(2000)
+                                    .build());
+
+        manager.removeVC(cpone, cptwo);
+        manager.removeVC(cpfive, cpsix);
+        manager.removeVC(cpseven, cpeight);
+
+        assertEquals(2, manager.intentService.getIntentCount());
+
+        for (Intent removedIntent : removedIntents) {
+            boolean found = false;
+            for (Intent existingIntent : manager.intentService.getIntents()) {
+                if (removedIntent.key().equals(existingIntent.key())) {
+                    found = true;
+                    assertTrue(format("Intent %s equal %s", removedIntent, existingIntent),
+                               !IntentUtils.intentsAreEqual(removedIntent, existingIntent));
+                    break;
+                }
+            }
+            assertTrue(!found);
+        }
+
+    }
+
+
+    @Test
+    public void testRemoveVCbyCP() {
+        testConnectionSetup();
+
+        List<PointToPointIntent> removedIntents = new ArrayList<PointToPointIntent>();
+        SdxL2ConnectionPoint cpone = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1);
+        SdxL2ConnectionPoint cptwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2);
+
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpone, cptwo, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("2"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("4")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cptwo, cpone, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("4"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("2")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpone, cptwo, "2"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("3"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("5")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cptwo, cpone, "2"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("5"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("3")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpone, cptwo, "3"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("4"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("6")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cptwo, cpone, "3"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("6"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("4")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpfive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5);
+        SdxL2ConnectionPoint cpsix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpfive, cpsix, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("100"))))
+                                    .treatment(buildTreatment(null, null, true))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpsix, cpfive, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("100")), false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpseven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7);
+        SdxL2ConnectionPoint cpeight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpseven, cpeight, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("111")), false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpeight, cpseven, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("111"))))
+                                    .treatment(buildTreatment(null, null, true))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpnine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST9", CP9, VLANS9);
+        SdxL2ConnectionPoint cpten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", CP10, VLANS10);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpnine, cpten, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP9))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP10))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpten, cpnine, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP10))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP9))
+                                    .priority(2000)
+                                    .build());
+
+        manager.removeVC(cpone);
+        manager.removeVC(cpsix);
+        manager.removeVC(cpseven);
+        manager.removeVC(cpten);
+
+        assertEquals(Collections.emptySet(), manager.getVCs(Optional.ofNullable(null)));
+
+        assertEquals(0, manager.intentService.getIntentCount());
+
+        for (Intent removedIntent : removedIntents) {
+            boolean found = false;
+            for (Intent existingIntent : manager.intentService.getIntents()) {
+                if (removedIntent.key().equals(existingIntent.key())) {
+                    found = true;
+                    assertTrue(format("Intent %s equal %s", removedIntent, existingIntent),
+                               !IntentUtils.intentsAreEqual(removedIntent, existingIntent));
+                    break;
+                }
+            }
+            assertTrue(!found);
+        }
+
+    }
+
+    @Test
+    public void testremoveVCbySdx() {
+        testConnectionSetup();
+
+        List<PointToPointIntent> removedIntents = new ArrayList<PointToPointIntent>();
+        SdxL2ConnectionPoint cpone = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST1", CP1, VLANS1);
+        SdxL2ConnectionPoint cptwo = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST2", CP2, VLANS2);
+
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpone, cptwo, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("2"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("4")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cptwo, cpone, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("4"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("2")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpone, cptwo, "2"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("3"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("5")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cptwo, cpone, "2"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("5"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("3")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpone, cptwo, "3"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("4"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("6")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cptwo, cpone, "3"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("6"))))
+                                    .treatment(buildTreatment(VlanId.vlanId(Short.parseShort("4")), null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP2))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP1))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpfive = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST5", CP5, VLANS5);
+        SdxL2ConnectionPoint cpsix = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST6", CP6, VLANS6);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpfive, cpsix, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("100"))))
+                                    .treatment(buildTreatment(null, null, true))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpsix, cpfive, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("100")), false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP6))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP5))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpseven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST7", CP7, VLANS7);
+        SdxL2ConnectionPoint cpeight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST8", CP8, VLANS8);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpseven, cpeight, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, VlanId.vlanId(Short.parseShort("111")), false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpeight, cpseven, "1"))
+                                    .selector(buildSelector(null, VlanId.vlanId(Short.parseShort("111"))))
+                                    .treatment(buildTreatment(null, null, true))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP8))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP7))
+                                    .priority(2000)
+                                    .build());
+
+        SdxL2ConnectionPoint cpnine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST9", CP9, VLANS9);
+        SdxL2ConnectionPoint cpten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("TEST10", CP10, VLANS10);
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpnine, cpten, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP9))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP10))
+                                    .priority(2000)
+                                    .build());
+        removedIntents.add(PointToPointIntent.builder()
+                                    .appId(APPID)
+                                    .key(generateIntentKey(SDXL2_2, cpten, cpnine, "1"))
+                                    .selector(buildSelector(null, null))
+                                    .treatment(buildTreatment(null, null, false))
+                                    .ingressPoint(ConnectPoint.deviceConnectPoint(CP10))
+                                    .egressPoint(ConnectPoint.deviceConnectPoint(CP9))
+                                    .priority(2000)
+                                    .build());
+
+        manager.removeVCs(SDXL2_2);
+        assertEquals(Collections.emptySet(), manager.getVCs(Optional.ofNullable(null)));
+        assertEquals(Collections.emptySet(), manager.getVCs(Optional.of(SDXL2_2)));
+
+        for (Intent removedIntent : removedIntents) {
+            boolean found = false;
+            for (Intent existingIntent : manager.intentService.getIntents()) {
+                if (removedIntent.key().equals(existingIntent.key())) {
+                    found = true;
+                    assertTrue(format("Intent %s equal %s", removedIntent, existingIntent),
+                               !IntentUtils.intentsAreEqual(removedIntent, existingIntent));
+                    break;
+                }
+            }
+            assertTrue(!found);
+        }
+
+    }
+}
\ No newline at end of file
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/VirtualCircuitTest.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/VirtualCircuitTest.java
new file mode 100644
index 0000000..97dadcb
--- /dev/null
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/VirtualCircuitTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+/**
+ * Tests VirtualCircuit functionalities.
+ */
+public class VirtualCircuitTest {
+
+
+    public static final String CP1 = "of:00000000000001/1";
+    public static final String CP2 = "of:00000000000002/1";
+    public static final String VLANS1 = "1,2,3,4";
+    public static final String VLANS3 = "1,2,3";
+    public static final String CEMAC1 = "52:40:00:12:44:01";
+    public static final String CEMAC6 = "52:40:00:12:44:02";
+
+    /*
+     * Tests VC with different VLANs.
+     */
+    @Test
+    public void testVC1() {
+        SdxL2ConnectionPoint scp1 = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI1", CP1, VLANS1, CEMAC1);
+        SdxL2ConnectionPoint scp2 = SdxL2ConnectionPoint.sdxl2ConnectionPoint("GE4", CP2, VLANS3, CEMAC6);
+        VirtualCircuit vc1 = new VirtualCircuit(scp1, scp2);
+    }
+
+    /*
+    Tests creating VC with the same VLANs.
+    */
+    @Test
+    public void testVCEquality() {
+        SdxL2ConnectionPoint scp1 = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI1", CP1, VLANS1, CEMAC1);
+        SdxL2ConnectionPoint scp2 = SdxL2ConnectionPoint.sdxl2ConnectionPoint("GE4", CP2, VLANS3, CEMAC6);
+        VirtualCircuit vc1 = new VirtualCircuit(scp1, scp2);
+        VirtualCircuit vc2 = new VirtualCircuit(scp2, scp1);
+        assertEquals(vc1, vc2);
+        SdxL2ConnectionPoint scp3 = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI2", CP1, VLANS1, CEMAC1);
+        VirtualCircuit vc3 = new VirtualCircuit(scp1, scp3);
+        assertNotEquals(vc1, vc3);
+    }
+
+}