Add CRD for sdxl2cp entity

    Changes:
    - Add CRD services for sdxl2cp in SdxL2Store
    - Add name completer for sdxl2cp
    - Add CRD services for sdxl2cp in Sdxl2Service
    - Implement CRD services for sdxl2cp
    - Add CRD tests for sdxl2cp
    - Add CD commands for sdxl2cp
    - Minor modifications in other classes

Change-Id: I0e40f81db404f0e7574881af828ce8dc401ce389
diff --git a/sdx-l2/BUCK b/sdx-l2/BUCK
new file mode 100644
index 0000000..a24176b
--- /dev/null
+++ b/sdx-l2/BUCK
@@ -0,0 +1,24 @@
+COMPILE_DEPS = [
+    '//lib:CORE_DEPS',
+]
+
+BUNDLES = [
+    '//apps/sdx-l2:onos-apps-sdx-l2',
+]
+
+TEST_DEPS = [
+    '//lib:TEST_ADAPTERS',
+]
+
+osgi_jar_with_tests (
+    deps = COMPILE_DEPS,
+    test_deps = TEST_DEPS,
+)
+
+onos_app (
+  title = 'SDX-L2 Application',
+  category = 'Utility',
+  url = 'http://www.geant.org',
+  included_bundles = BUNDLES,
+  description = 'SDX-L2 application for ONOS project developed by GEANT',
+)
\ No newline at end of file
diff --git a/sdx-l2/pom.xml b/sdx-l2/pom.xml
index d55b2e7..cd49efa 100644
--- a/sdx-l2/pom.xml
+++ b/sdx-l2/pom.xml
@@ -85,25 +85,6 @@
         </dependency>
 
         <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-app-sdnip</artifactId>
-            <version>${onos.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.easymock</groupId>
-            <artifactId>easymock</artifactId>
-            <version>3.2</version>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-app-routing-api</artifactId>
-            <version>${onos.version}</version>
-        </dependency>
-
-        <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
             <version>5.0.0</version>
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPoint.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPoint.java
index fafb9d3..f5f6849 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPoint.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPoint.java
@@ -28,8 +28,8 @@
 import static com.google.common.base.Preconditions.*;
 
 /**
- * Sdx-l2 connection point expressed as composition of a:
- * ConnectPoint; Set of Vlanid; Customer edge MAC address (optional).
+ * SDX-L2 connection point expressed as composition of a:
+ * connect point; set of VLAN id; MAC address (optional).
  */
 public class SdxL2ConnectionPoint {
 
@@ -39,12 +39,12 @@
     private final MacAddress ceMac;
 
     /**
-     * Creates a new SDXL2 connection point.
+     * Creates a new SDX-L2 connection point.
      *
-     * @param name connection point name
-     * @param cPoint connection point
-     * @param vlans the customer edge vlans
-     * @param ceMac the customer edge router mac address
+     * @param name SDX-L2 connection point name
+     * @param cPoint connect point
+     * @param vlans the customer edge VLANs
+     * @param ceMac the customer edge router MAC address
      */
     public SdxL2ConnectionPoint(String name, ConnectPoint cPoint, List<VlanId> vlans, MacAddress ceMac) {
         this.name = name;
@@ -54,7 +54,7 @@
     }
 
     /**
-     * Return the name of SDXL2 connection point.
+     * Returns the name of SDX-L2 connection point.
      *
      * @return a string representing the name of connection point
      */
@@ -63,44 +63,44 @@
     }
 
     /**
-     * Returns the connection point.
+     * Returns the connect point.
      *
-     * @return connection point object
+     * @return connect point object
      */
     public ConnectPoint connectPoint() {
         return cPoint;
     }
 
     /**
-     * Returns the set of vlans that are used by the customer edge.
+     * Returns the set of VLANs that are used by the customer edge.
      *
-     * @return a set of vlan ids
+     * @return a set of VLAN ids
      */
     public List<VlanId> vlanIds() {
         return vlanIds;
     }
 
     /**
-     * Returns the customer edge mac address.
+     * Returns the customer edge MAC address.
      *
-     * @return a mac address object
+     * @return a MAC address object
      */
     public MacAddress macAddress() {
         return ceMac;
     }
 
     /**
-     * Parse a device connect point from a string, set of vlans from a string
-     * and mac from a string.
+     * Parse a device connect point from a string, set of VLANs from a string
+     * and MAC from a string.
      * The connect point should be in the format "deviceUri/portNumber".
-     * The vlans should be in the format "vlan1,vlan2,vlan3"
-     * The mac address should be in hex
+     * The VLANs should be in the format "vlan1,vlan2,vlan3"
+     * The MAC address should be in hex
      *
-     * @param name name of the SDXL2 cp
-     * @param connectPoint connection point to parse
-     * @param vlans vlanIds to parse
-     * @param mac mac address to parse
-     * @return a ConnectPoint based on the information in the string.
+     * @param name name of the SDX-L2 connection point
+     * @param connectPoint connect point to parse
+     * @param vlans VLAN ids to parse
+     * @param mac MAC address to parse
+     * @return a SDX-L2 connection point based on the information in the string.
      *
      */
     public static SdxL2ConnectionPoint
@@ -133,14 +133,14 @@
     }
 
     /**
-     * Parse a device connect point from a string and set of vlans from a string.
+     * Parse a device connect point from a string and set of VLANs from a string.
      * The connect point should be in the format "deviceUri/portNumber".
-     * The vlans should be in the format "vlan1,vlan2,vlan3"
+     * The VLANs should be in the format "vlan1,vlan2,vlan3"
      *
-     * @param name name of the SDXL2 cp
-     * @param connectPoint connection point to parse
-     * @param vlans vlanIds to parse
-     * @return a ConnectPoint based on the information in the string.
+     * @param name name of the SDX-L2 connection point
+     * @param connectPoint connect point to parse
+     * @param vlans VLAN ids to parse
+     * @return a SDX-L2 connection point based on the information in the string.
      *
      */
     public static SdxL2ConnectionPoint sdxl2ConnectionPoint(String name, String connectPoint, String vlans) {
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPointSerializer.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPointSerializer.java
index 698bc31..014d7fc 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPointSerializer.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2ConnectionPointSerializer.java
@@ -27,7 +27,7 @@
 import java.util.List;
 
 /**
- * Kryo serializer for SdxL2ConnectionPoint.
+ * Kryo serializer for SDX-L2 connection point.
  */
 public class SdxL2ConnectionPointSerializer extends Serializer<SdxL2ConnectionPoint> {
 
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2DistributedStore.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2DistributedStore.java
index 6b33025..4bee790 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2DistributedStore.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2DistributedStore.java
@@ -17,26 +17,34 @@
 package org.onosproject.sdxl2;
 
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Deactivate;
+import org.onlab.packet.VlanId;
 import org.onlab.util.KryoNamespace;
 import org.onosproject.store.primitives.DefaultDistributedSet;
 import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.ConsistentMap;
 import org.onosproject.store.service.DistributedPrimitive;
-import org.onosproject.store.service.DistributedSet;
 import org.onosproject.store.service.Serializer;
 import org.onosproject.store.service.StorageService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
+import java.util.Iterator;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
 
 /**
- * SDXL2 Store implementation backed by different distributed primitives.
+ * SDX-L2 Store implementation backed by different distributed primitives.
  */
 @Component(immediate = true)
 @Service
@@ -47,10 +55,39 @@
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     private StorageService storageService;
 
-    private DistributedSet<String> sdxL2s;
+    private Set<String> sdxL2s;
 
-    private static String errorAddSdx = "It is not possible to add ";
-    private static String errorRemoveSdx = "It is not possible to remove ";
+    private Map<SdxL2ConnectionPoint, String> sdxL2CPs;
+    private ConsistentMap<SdxL2ConnectionPoint, String> sdxL2cps;
+
+    private static String errorAddSdx = "It is not possible to add %s " +
+            "because it exists";
+
+    private static String errorRemoveSdx = "It is not possible to remove %s " +
+            "because it does not exist";
+
+    private static String errorAddSdxL2CPName = "It is not possible to add %s " +
+            "because there is a sdxl2cp with the same name";
+    private static String errorAddSdxL2CPVlans = "It is not possible to add %s " +
+            "because there is a conflict with %s on the vlan ids";
+    private static String errorAddSdxL2CPCP = "It is not possible to add %s " +
+            "because there is a conflict with %s on the connection point";
+    private static String errorAddSdxL2CPSdx = "It is not possible to add %s " +
+            "because the relative sdxl2 does not exist";
+
+    private static String errorGetSdxL2CPs = "It is not possible to list the sdxl2cps" +
+            "because sdxl2 %s does not exist";
+
+    private static String errorRemoveSdxL2CP = "It is not possible to remove %s " +
+            "because it does not exist";
+
+    public void initForTest() {
+
+        this.sdxL2s = Sets.newHashSet();
+
+        this.sdxL2CPs = new ConcurrentHashMap<SdxL2ConnectionPoint, String>();
+
+    }
 
     @Activate
     public void activate() {
@@ -67,6 +104,13 @@
                 .withName("sdxl2s")
                 .build(), DistributedPrimitive.DEFAULT_OPERTATION_TIMEOUT_MILLIS);
 
+        sdxL2cps = this.storageService
+                .<SdxL2ConnectionPoint, String>consistentMapBuilder()
+                .withSerializer(Serializer.using(custom))
+                .withName("sdxl2cps")
+                .build();
+        sdxL2CPs = sdxL2cps.asJavaMap();
+
         log.info("Started");
     }
 
@@ -76,41 +120,175 @@
     }
 
     /**
-     * Create a named sdx-l2.
+     * Creates a named SDX-L2.
      *
-     * @param sdxl2 sdx-l2 name
-     * @throws SdxL2Exception if sdxl2 exists
+     * @param sdxl2 SDX-L2 name
+     * @throws SdxL2Exception if SDX-L2 exists
      */
     @Override
     public void putSdxL2(String sdxl2) throws SdxL2Exception {
         boolean inserted = sdxL2s.add(sdxl2);
         if (!inserted) {
-            throw new SdxL2Exception(errorAddSdx + sdxl2);
+            throw new SdxL2Exception(String.format(errorAddSdx, sdxl2));
         }
     }
 
     /**
-     * Remove a named sdx-l2.
+     * Removes a named SDX-L2.
      *
-     * @param sdxl2 sdx-l2 name
-     * @throws SdxL2Exception if sdxl2 does not exist
+     * @param sdxl2 SDX-L2 name
+     * @throws SdxL2Exception if SDX-L2 does not exist
      */
     @Override
     public void removeSdxL2(String sdxl2) throws SdxL2Exception {
         boolean removed = sdxL2s.remove(sdxl2);
         if (!removed) {
-            throw new SdxL2Exception(errorRemoveSdx + sdxl2);
+            throw new SdxL2Exception(String.format(errorRemoveSdx, sdxl2));
         }
+
+        Set<Map.Entry<SdxL2ConnectionPoint, String>> toRemove = sdxL2CPs.entrySet().parallelStream().filter(
+                key_value -> {
+                    String sdxl2Temp = key_value.getValue();
+                    return sdxl2Temp.equals(sdxl2) ? true : false;
+                }).collect(Collectors.toSet());
+        toRemove.forEach(key_value -> sdxL2CPs.remove(key_value.getKey()));
     }
 
     /**
-     * Returns a set of sdxl2 names.
+     * Returns a set of SDX-L2 names.
      *
-     * @return a set of sdxl2 names
+     * @return a set of SDX-L2 names
      */
     @Override
     public Set<String> getSdxL2s() {
         return ImmutableSet.copyOf(sdxL2s);
     }
 
+    /**
+     * Adds an SDX-L2 connection point to an SDX-L2.
+     *
+     * @param sdxl2 SDX-L2 name
+     * @param connectionPoint the connection point object
+     * @throws SdxL2Exception if it is not possible to add the SDX-L2 connection point
+     */
+    @Override
+    public void addSdxL2ConnectionPoint(String sdxl2, SdxL2ConnectionPoint connectionPoint) throws SdxL2Exception {
+
+        boolean exist = sdxL2s.contains(sdxl2);
+
+        if (!exist) {
+            throw new SdxL2Exception(String.format(errorAddSdxL2CPSdx, connectionPoint.name()));
+        }
+
+        Set<SdxL2ConnectionPoint> sdxl2cpsTemp = ImmutableSet.copyOf(sdxL2CPs.keySet());
+        Set<SdxL2ConnectionPoint> sdxl2cpsTempByName = sdxl2cpsTemp.parallelStream().filter(
+                sdxl2cpTemp-> sdxl2cpTemp.name().equals(connectionPoint.name()
+                )
+        ).collect(Collectors.toSet());
+
+        if (sdxl2cpsTempByName.size() != 0) {
+            throw new SdxL2Exception(String.format(errorAddSdxL2CPName, connectionPoint.name()));
+        }
+
+
+        Set<SdxL2ConnectionPoint> sdxl2cpsByCP = sdxl2cpsTemp.parallelStream().filter(
+                sdxl2cp_temp-> sdxl2cp_temp.connectPoint().equals(connectionPoint.connectPoint()
+                )
+        ).collect(Collectors.toSet());
+
+        String tempName;
+        List<VlanId> vlans = connectionPoint.vlanIds();
+        for (VlanId vlanId : vlans) {
+            Set<SdxL2ConnectionPoint> sdxl2cpsByVlan = sdxl2cpsByCP.parallelStream().filter(
+                    sdxl2cp_by_vlan -> (
+                            sdxl2cp_by_vlan.vlanIds().contains(vlanId) || sdxl2cp_by_vlan.vlanIds().size() == 0
+                    )).collect(Collectors.toSet());
+
+            tempName =  sdxl2cpsByVlan.iterator().hasNext() ?  sdxl2cpsByVlan.iterator().next().name() : null;
+
+            if (sdxl2cpsByVlan.size() != 0) {
+                throw new SdxL2Exception(String.format(errorAddSdxL2CPVlans, connectionPoint.name(), tempName));
+            }
+
+        }
+
+        tempName =  sdxl2cpsByCP.iterator().hasNext() ? sdxl2cpsByCP.iterator().next().name() : null;
+
+        if (sdxl2cpsByCP.size() != 0 && vlans.size() == 0) {
+            throw new SdxL2Exception(String.format(errorAddSdxL2CPCP, connectionPoint.name(), tempName));
+        }
+
+        sdxL2CPs.put(connectionPoint, sdxl2);
+
+    }
+
+    /**
+     * Returns all the SDX-L2 connection points names or the SDX-L2 2connection points names
+     * that are related to an SDX-L2.
+     *
+     * @param sdxl2 name (optional) of the SDX-L2
+     * @return a set of SDX-L2 connection points names, the result depends on the input parameter;
+     * @throws SdxL2Exception if SDX-L2 is present but it does not exist
+     */
+    @Override
+    public Set<String> getSdxL2ConnectionPoints(Optional<String> sdxl2) throws SdxL2Exception {
+
+        if (sdxl2.isPresent()) {
+
+            Set<Map.Entry<SdxL2ConnectionPoint, String>> toGet = sdxL2CPs.entrySet().parallelStream().filter(
+                    key_value -> {
+                        String sdxl2Temp = key_value.getValue();
+                        return sdxl2Temp.equals(sdxl2.get()) ? true : false;
+                    }).collect(Collectors.toSet());
+
+            Iterator<String> itsdxL2s = sdxL2s.iterator();
+            boolean found = false;
+            while (itsdxL2s.hasNext()) {
+                if (sdxl2.get().equals(itsdxL2s.next())) {
+                    found = true;
+                }
+            }
+
+            if (!found) {
+                throw new SdxL2Exception(String.format(errorGetSdxL2CPs, sdxl2.get()));
+            }
+
+            Set<String> cpsTemp = Sets.newHashSet();
+            for (Map.Entry<SdxL2ConnectionPoint, String> cp : toGet) {
+                cpsTemp.add(cp.getKey().name());
+            }
+
+            return cpsTemp;
+        }
+
+        return ImmutableSet.copyOf(sdxL2CPs.keySet()).parallelStream().map(
+                SdxL2ConnectionPoint::name).collect(Collectors.toSet());
+
+    }
+
+    /**
+     * Removes a named SDX-L2 connection point in an SDX-L2.
+     *
+     * @param sdxl2cp the connection point name
+     * @throws SdxL2Exception if SDX-L2 connection point does not exist
+     */
+    @Override
+    public void removeSdxL2ConnectionPoint(String sdxl2cp) throws SdxL2Exception {
+
+        Set<SdxL2ConnectionPoint> sdxl2cpsTemp = ImmutableSet.copyOf(sdxL2CPs.keySet());
+        Set<SdxL2ConnectionPoint> sdxl2cpsTempByName = sdxl2cpsTemp.parallelStream().filter(
+                sdxl2cpTemp -> sdxl2cpTemp.name().equals(sdxl2cp
+                )
+        ).collect(Collectors.toSet());
+
+        if (sdxl2cpsTempByName.size() == 0) {
+            throw new SdxL2Exception(String.format(errorRemoveSdxL2CP, sdxl2cp));
+        }
+
+        for (SdxL2ConnectionPoint sdxl2cpTemp : sdxl2cpsTempByName) {
+            sdxL2CPs.remove(sdxl2cpTemp);
+        }
+
+    }
+
 }
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Exception.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Exception.java
index c69e670..1692edc 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Exception.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Exception.java
@@ -17,7 +17,7 @@
 package org.onosproject.sdxl2;
 
 /**
- * SdxL2 exception for errors.
+ * SDX-L2 error Exception.
  */
 public class SdxL2Exception extends Exception {
 
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Manager.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Manager.java
index d9c77e3..f73fb24 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Manager.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Manager.java
@@ -28,13 +28,16 @@
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
+import java.util.Collections;
+import java.util.Optional;
 import java.util.Set;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 
 /**
- * Implementation of the Interface SdxL2Service.
+ * Implementation of the SdxL2Service.
  */
 @Component(immediate = true)
 @Service
@@ -63,12 +66,13 @@
     }
 
     /**
-     * Create a named sdxl2.
+     * Creates a named SDX-L2.
      *
-     * @param sdxl2 sdxl2 name
+     * @param sdxl2 SDX-L2 name
      */
     @Override
     public void createSdxL2(String sdxl2) {
+
         checkNotNull(sdxl2, "sdxl2 name cannot be null");
         checkState(!sdxl2.contains(","), "sdxl2 names cannot contain commas");
         checkState(!sdxl2.contains("|"), "sdxl2 names cannot contain pipe");
@@ -78,36 +82,94 @@
         try {
             this.sdxL2Store.putSdxL2(sdxl2);
         } catch (SdxL2Exception e) {
-            e.printStackTrace();
+            log.info(e.getMessage());
         }
 
     }
 
     /**
-     * Delete a named sdxl2.
+     * Deletes a named SDX-L2.
      *
-     * @param sdxl2 sdxl2 name
+     * @param sdxl2 SDX-L2 name
      */
     @Override
     public void deleteSdxL2(String sdxl2) {
+
         checkNotNull(sdxl2, "sdxl2 name cannot be null");
 
         try {
             this.sdxL2Store.removeSdxL2(sdxl2);
         } catch (SdxL2Exception e) {
-            e.printStackTrace();
+            log.info(e.getMessage());
         }
 
     }
 
     /**
-     * Returns a set of sdxl2 names.
+     * Returns a set of SDX-L2 names.
      *
-     * @return a set of sdxl2 names
+     * @return a set of SDX-L2 names
      */
     @Override
     public Set<String> getSdxL2s() {
         return this.sdxL2Store.getSdxL2s();
     }
 
+    /**
+     * Adds an SDX-L2 connection point to an SDX-L2.
+     *
+     * @param sdxl2   SDX-L2 name
+     * @param sdxl2cp SDX-L2 connection point object
+     */
+    @Override
+    public void addSdxL2ConnectionPoint(String sdxl2, SdxL2ConnectionPoint sdxl2cp) {
+
+        checkNotNull(sdxl2, "sdxl2 name cannot be null");
+        checkNotNull(sdxl2cp, "SdxL2ConnectionPoint cannot be null");
+
+        try {
+            this.sdxL2Store.addSdxL2ConnectionPoint(sdxl2, sdxl2cp);
+        } catch (SdxL2Exception e) {
+            log.info(e.getMessage());
+        }
+
+    }
+
+    /**
+     * Returns all the SDX-L2 connection points names in a SDX-L2 or all the SDX-L2 connection points names.
+     *
+     * @param sdxl2 SDX-L2 name
+     * @return a set of SDX-L2 connection points names
+     */
+    @Override
+    public Set<String> getSdxL2ConnectionPoints(Optional<String> sdxl2) {
+
+        try {
+            return this.sdxL2Store.getSdxL2ConnectionPoints(sdxl2);
+        } catch (SdxL2Exception e) {
+            log.info(e.getMessage());
+        }
+
+        return Collections.emptySet();
+
+    }
+
+    /**
+     * Removes an SDX-L2 connection point from an SDX-L2.
+     *
+     * @param sdxl2cp SDX-L2 connection point name
+     */
+    @Override
+    public void removeSdxL2ConnectionPoint(String sdxl2cp) {
+
+        checkNotNull(sdxl2cp, "SdxL2ConnectionPoint name cannot be null");
+
+        try {
+            this.sdxL2Store.removeSdxL2ConnectionPoint(sdxl2cp);
+        } catch (SdxL2Exception e) {
+            log.info(e.getMessage());
+        }
+
+    }
+
 }
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Service.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Service.java
index e61d121..57c1be2 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Service.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Service.java
@@ -16,34 +16,58 @@
 
 package org.onosproject.sdxl2;
 
+import java.util.Optional;
 import java.util.Set;
 
 /**
- * Service that allows to create virtual named SDXL2s
- * In which it is possible to provide connectivity
+ * Service that allows to create virtual named sdx-l2s
+ * in which is possible to provide connectivity
  * (layer 2 Virtual Circuits - VC) between edge ports.
  */
 public interface SdxL2Service {
 
     /**
-     * Create a named SDXL2.
+     * Creates a named SDX-L2.
      *
-     * @param sdxl2 SDXL2 name
+     * @param sdxl2 SDX-L2 name
      */
     void createSdxL2(String sdxl2);
 
     /**
-     * Delete a named SDXL2.
+     * Deletes a named SDX-L2.
      *
-     * @param sdxl2 SDXL2 name
+     * @param sdxl2 SDX-L2 name
      */
     void deleteSdxL2(String sdxl2);
 
     /**
-     * Returns a set of SDXL2 names.
+     * Returns a set of SDX-L2 names.
      *
-     * @return a set of SDXL2 names
+     * @return a set of SDX-L2 names
      */
     Set<String> getSdxL2s();
 
+    /**
+     * Adds an SDX-L2 connection point to an SDX-L2.
+     *
+     * @param sdxl2 SDX-L2 name
+     * @param sdxl2cp SDX-L2 connection point object
+     */
+    void addSdxL2ConnectionPoint(String sdxl2, SdxL2ConnectionPoint sdxl2cp);
+
+    /**
+     * Returns all the SDX-L2 connection points names in a SDX-L2 or all the SDX-L2 connection points names.
+     *
+     * @param sdxl2 SDX-L2 name
+     * @return a set of SDX-L2 connection points names
+     */
+    Set<String> getSdxL2ConnectionPoints(Optional<String> sdxl2);
+
+    /**
+     * Removes an SDX-L2 connection point from an SDX-L2.
+     *
+     * @param sdxl2cp SDX-L2 connection point name
+     */
+    void removeSdxL2ConnectionPoint(String sdxl2cp);
+
 }
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Store.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Store.java
index 6380a65..217a52a 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Store.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/SdxL2Store.java
@@ -16,34 +16,63 @@
 
 package org.onosproject.sdxl2;
 
+import java.util.Optional;
 import java.util.Set;
 
 /**
- * Storage service of sdxl2 application.
+ * Storage service for SDX-L2 application.
  */
 public interface SdxL2Store {
 
     /**
-     * Create a named sdx-l2.
+     * Creates a named SDX-L2.
      *
-     * @param sdxl2 sdx-l2 name
-     * @throws SdxL2Exception if sdxl2 exists
+     * @param sdxl2 SDX-L2 name
+     * @throws SdxL2Exception if SDX-L2 exists
      */
     void putSdxL2(String sdxl2) throws SdxL2Exception;
 
     /**
-     * Remove a named sdx-l2.
+     * Removes a named SDX-L2.
      *
-     * @param sdxl2 sdx-l2 name
-     * @throws SdxL2Exception if sdxl2 does not exist
+     * @param sdxl2 SDX-L2 name
+     * @throws SdxL2Exception if SDX-L2 does not exist
      */
     void removeSdxL2(String sdxl2) throws SdxL2Exception;
 
     /**
-     * Returns a set of sdxl2 names.
+     * Returns a set of SDX-L2 names.
      *
-     * @return a set of sdxl2 names
+     * @return a set of SDX-L2 names
      */
     Set<String> getSdxL2s();
 
+    /**
+     * Adds an SDX-L2 connection point to an SDX-L2.
+     *
+     * @param sdxl2 SDX-L2 name
+     * @param connectionPoint the SDX-L2 connection point object
+     * @throws SdxL2Exception if it is not possible to add the SDX-L2 connection point
+     */
+    void addSdxL2ConnectionPoint(String sdxl2, SdxL2ConnectionPoint connectionPoint) throws SdxL2Exception;
+
+    /**
+     * Returns all the SDX-L2 connection points names or the SDX-L2 connection points name
+     * that are related to an SDX-L2.
+     *
+     * @param sdxl2 name (optional) of the SDX-L2
+     * @return a set of SDX-L2 connection points names, the result depends on the input parameter;
+     * @throws SdxL2Exception if SDX-L2 is present but it does not exist
+     */
+    Set<String> getSdxL2ConnectionPoints(Optional<String> sdxl2) throws SdxL2Exception;
+
+
+    /**
+     * Removes a named SDX-L2 connection point in an SDX-L2.
+     *
+     * @param sdxl2cp the connection point name
+     * @throws SdxL2Exception if the connection point does not exist
+     */
+    void removeSdxL2ConnectionPoint(String sdxl2cp) throws SdxL2Exception;
+
 }
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2AddCPCommand.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2AddCPCommand.java
new file mode 100644
index 0000000..eb000b8
--- /dev/null
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2AddCPCommand.java
@@ -0,0 +1,66 @@
+/*
+ * 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.cli;
+
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.sdxl2.SdxL2ConnectionPoint;
+import org.onosproject.sdxl2.SdxL2Service;
+
+/**
+ * CLI to create a named SDX-L2 connection point.
+ */
+@Command(scope = "sdxl2", name = "sdxl2cp-add", description = "Create a named sdx-l2 connection point")
+public class SdxL2AddCPCommand extends AbstractShellCommand {
+
+    @Argument(index = 0, name = "sdxl2name", description = "Sdxl2name",
+            required = true, multiValued = false)
+    String sdxl2name = null;
+
+    @Argument(index = 1, name = "connectionpoint", description = "Connection point",
+            required = true, multiValued = false)
+    String cp = null;
+
+    @Argument(index = 2, name = "vlans", description = "Customer edge vlans separated by comma",
+            required = true, multiValued = false)
+    String vlans = null;
+
+    @Argument(index = 3, name = "sdxl2cpname", description = "Sdxl2 connection point name",
+            required = true, multiValued = false)
+    String sdxl2cpname = null;
+
+    @Option(name = "-ce_mac", description = "Customer edge mac address",
+            required = false, multiValued = false)
+    String mac = null;
+
+    @Override
+    protected void execute() {
+        SdxL2Service sdxl2Service = get(SdxL2Service.class);
+        SdxL2ConnectionPoint sdxl2cp;
+        if (mac != null) {
+            sdxl2cp = SdxL2ConnectionPoint.sdxl2ConnectionPoint(sdxl2cpname, cp, vlans, mac);
+        } else {
+            sdxl2cp = SdxL2ConnectionPoint.sdxl2ConnectionPoint(sdxl2cpname, cp, vlans);
+        }
+        sdxl2Service.addSdxL2ConnectionPoint(sdxl2name, sdxl2cp);
+    }
+
+}
+
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2AddCommand.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2AddCommand.java
index 141f2f3..c7bb963 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2AddCommand.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2AddCommand.java
@@ -22,9 +22,9 @@
 import org.onosproject.sdxl2.SdxL2Service;
 
 /**
- * CLI to create sdxl2.
+ * CLI to create SDX-L2.
  */
-@Command(scope = "sdxl2", name = "sdxl2-add", description = "Create a sdxl2")
+@Command(scope = "sdxl2", name = "sdxl2-add", description = "Create a sdx-l2")
 public class SdxL2AddCommand extends AbstractShellCommand {
 
     @Argument(index = 0, name = "sdxl2name", description = "Sdxl2 name", required = true, multiValued = false)
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2ListCommand.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2ListCommand.java
index e027d11..56fc850 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2ListCommand.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2ListCommand.java
@@ -23,9 +23,9 @@
 import java.util.Set;
 
 /**
- * CLI to list sdxl2.
+ * CLI to list the SDX-L2s.
  */
-@Command(scope = "sdxl2", name = "sdxl2-list", description = "Lists the sdxl2s")
+@Command(scope = "sdxl2", name = "sdxl2-list", description = "Lists the sdx-l2s")
 public class SdxL2ListCommand extends AbstractShellCommand {
 
     private static final String HEADER           = "\n\u001B[1;37mSDXL2\u001B[0m";
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2RemoveCPCommand.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2RemoveCPCommand.java
new file mode 100644
index 0000000..3e1dfee
--- /dev/null
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2RemoveCPCommand.java
@@ -0,0 +1,42 @@
+/*
+ * 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.cli;
+
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.sdxl2.SdxL2Service;
+
+/**
+ * CLI to delete a named SDX-L2 connection point.
+ */
+@Command(scope = "sdxl2", name = "sdxl2cp-remove", description = "Remove a named sdxl2 connection point")
+public class SdxL2RemoveCPCommand extends AbstractShellCommand {
+
+    @Argument(index = 0, name = "sdxl2cpname", description = "Sdxl2 connection point name",
+            required = true, multiValued = false)
+    String sdxl2cpname = null;
+
+    @Override
+    protected void execute() {
+        SdxL2Service sdxl2Service = get(SdxL2Service.class);
+        sdxl2Service.removeSdxL2ConnectionPoint(sdxl2cpname);
+    }
+
+}
+
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2RemoveCommand.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2RemoveCommand.java
index 4a01a61..aecb899 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2RemoveCommand.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/SdxL2RemoveCommand.java
@@ -22,9 +22,9 @@
 import org.onosproject.sdxl2.SdxL2Service;
 
 /**
- * CLI to delete a named sdxl2.
+ * CLI to delete a named SDX-L2.
  */
-@Command(scope = "sdxl2", name = "sdxl2-remove", description = "Delete a sdxl2")
+@Command(scope = "sdxl2", name = "sdxl2-remove", description = "Delete a sdx-l2")
 public class SdxL2RemoveCommand extends AbstractShellCommand {
 
     @Argument(index = 0, name = "sdxl2name", description = "Sdxl2 name",
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/SdxL2CPNameCompleter.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/SdxL2CPNameCompleter.java
new file mode 100644
index 0000000..706c1e3
--- /dev/null
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/SdxL2CPNameCompleter.java
@@ -0,0 +1,39 @@
+/*
+ * 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.cli.completer;
+
+import org.apache.karaf.shell.console.Completer;
+import org.apache.karaf.shell.console.completer.StringsCompleter;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.sdxl2.SdxL2Service;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * Completes SDX-L2 connection point names.
+ */
+public class SdxL2CPNameCompleter implements Completer {
+
+    @Override
+    public int complete(String buffer, int cursor, List<String> candidates) {
+        StringsCompleter delegate = new StringsCompleter();
+        SdxL2Service service = AbstractShellCommand.get(SdxL2Service.class);
+        delegate.getStrings().addAll(service.getSdxL2ConnectionPoints(Optional.ofNullable(null)));
+        return delegate.complete(buffer, cursor, candidates);
+    }
+}
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/SdxL2NameCompleter.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/SdxL2NameCompleter.java
index bd64da1..50b4366 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/SdxL2NameCompleter.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/SdxL2NameCompleter.java
@@ -24,7 +24,7 @@
 import java.util.List;
 
 /**
- * Completes SDXL2 names.
+ * Completes SDX-L2 names.
  */
 public class SdxL2NameCompleter implements Completer {
 
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/package-info.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/package-info.java
index 7920073..753c338 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/package-info.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/completer/package-info.java
@@ -15,6 +15,6 @@
  */
 
 /**
- * Provides the implementation of L2-SDX CLI completers.
+ * Provides the implementation of SDX-L2 CLI completers.
  */
 package org.onosproject.sdxl2.cli.completer;
diff --git a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/package-info.java b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/package-info.java
index ba9de9e..b94a3c1 100644
--- a/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/package-info.java
+++ b/sdx-l2/src/main/java/org/onosproject/sdxl2/cli/package-info.java
@@ -15,6 +15,6 @@
  */
 
 /**
- * Provides the implementation of L2-SDX CLI commands.
+ * Provides the implementation of SDX-L2 CLI commands.
  */
 package org.onosproject.sdxl2.cli;
diff --git a/sdx-l2/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/sdx-l2/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index e81d722..06a2060 100644
--- a/sdx-l2/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/sdx-l2/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -28,8 +28,23 @@
         <command>
             <action class="org.onosproject.sdxl2.cli.SdxL2ListCommand"/>
         </command>
+        <command>
+            <action class="org.onosproject.sdxl2.cli.SdxL2AddCPCommand"/>
+            <completers>
+                <ref component-id="sdxl2Completer"/>
+                <ref component-id="connectPointCompleter"/>
+            </completers>
+        </command>
+        <command>
+            <action class="org.onosproject.sdxl2.cli.SdxL2RemoveCPCommand"/>
+            <completers>
+                <ref component-id="sdxl2cpnameCompleter"/>
+            </completers>
+        </command>
     </command-bundle>
 
     <bean id="sdxl2Completer" class="org.onosproject.sdxl2.cli.completer.SdxL2NameCompleter"/>
+    <bean id="connectPointCompleter" class="org.onosproject.cli.net.ConnectPointCompleter"/>
+    <bean id="sdxl2cpnameCompleter" class="org.onosproject.sdxl2.cli.completer.SdxL2CPNameCompleter"/>
 
 </blueprint>
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ConnectionPointTest.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ConnectionPointTest.java
index 9a3419a..ae20d28 100644
--- a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ConnectionPointTest.java
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ConnectionPointTest.java
@@ -30,7 +30,7 @@
 import static org.junit.Assert.assertNotEquals;
 
 /**
- * Test SdxL2ConnectionPoint functionalities.
+ * Tests SdxL2ConnectionPoint functionality.
  */
 public class SdxL2ConnectionPointTest {
 
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 fbe1ce4..f1d1321 100644
--- a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ManagerTest.java
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2ManagerTest.java
@@ -16,12 +16,14 @@
 
 package org.onosproject.sdxl2;
 
+import com.google.common.collect.Sets;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.onosproject.TestApplicationId;
 
 import java.util.HashSet;
+import java.util.Optional;
 import java.util.Set;
 
 import static org.junit.Assert.assertEquals;
@@ -29,7 +31,7 @@
 
 
 /**
- * Test network manager.
+ * Tests SdxL2Manager functionality.
  */
 public class SdxL2ManagerTest {
 
@@ -39,7 +41,9 @@
     public void setUp() {
         manager = new SdxL2Manager();
         manager.appId = new TestApplicationId("sdxl2-test");
-        manager.sdxL2Store = new SdxL2TestStore();
+        SdxL2DistributedStore store = new SdxL2DistributedStore();
+        store.initForTest();
+        manager.sdxL2Store = store;
     }
 
     @After
@@ -81,4 +85,159 @@
         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() {
+
+        manager.createSdxL2(SDXL2);
+        manager.createSdxL2(SDXL2_2);
+        manager.createSdxL2("test1");
+
+        SdxL2ConnectionPoint one = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM1", CP1, VLANS1, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2, one);
+
+        SdxL2ConnectionPoint three = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM2", CP2, VLANS2, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2, three);
+
+        SdxL2ConnectionPoint six = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM3", CP1, VLANS7, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, six);
+
+        SdxL2ConnectionPoint seven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("MI3", CP3, VLANS3, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2, seven);
+
+        SdxL2ConnectionPoint nine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI1", CP4, VLANS8, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, nine);
+
+        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");
+        manager.addSdxL2ConnectionPoint("test1", fourteen);
+
+        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);
+        manager.addSdxL2ConnectionPoint(SDXL2, two);
+
+        SdxL2ConnectionPoint four = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM2", CP2, VLANS2, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, four);
+
+        SdxL2ConnectionPoint five = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM3", CP1, VLANS2, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, five);
+
+        SdxL2ConnectionPoint eight = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM4", CP3, VLANS4, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2, eight);
+
+        SdxL2ConnectionPoint eleven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI3", CP5, VLANS1, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, eleven);
+
+        SdxL2ConnectionPoint twelve = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI31", CP5, VLANS1, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, twelve);
+
+        SdxL2ConnectionPoint thirteen = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI31", CP5, VLANS8, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, thirteen);
+
+    }
+
+    @Test
+    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();
+
+        SdxL2ConnectionPoint one = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM1", CP1, VLANS1, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2, one);
+        allExt.add(one.name());
+        allExtBySdxl2.add(one.name());
+        SdxL2ConnectionPoint three = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM2", CP2, VLANS2, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2, three);
+        allExt.add(three.name());
+        allExtBySdxl2.add(three.name());
+        SdxL2ConnectionPoint six = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM3", CP1, VLANS7, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, six);
+        allExt.add(six.name());
+        allExtBySdxl22.add(six.name());
+        SdxL2ConnectionPoint seven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("MI3", CP3, VLANS3, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2, seven);
+        allExt.add(seven.name());
+        allExtBySdxl2.add(seven.name());
+        SdxL2ConnectionPoint nine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI1", CP4, VLANS8, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, nine);
+        allExt.add(nine.name());
+        allExtBySdxl22.add(nine.name());
+        SdxL2ConnectionPoint ten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI2", CP5, VLANS2, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2, ten);
+        allExt.add(ten.name());
+        allExtBySdxl2.add(ten.name());
+
+        Set<String> all = manager.getSdxL2ConnectionPoints(Optional.ofNullable(null));
+        Set<String> allBySdxl2 = manager.getSdxL2ConnectionPoints(Optional.of(SDXL2));
+        Set<String> allBySdxl22 = manager.getSdxL2ConnectionPoints(Optional.of(SDXL2_2));
+
+        assertEquals(allExt, all);
+        assertNotEquals(allExtBySdxl2, all);
+        assertNotEquals(allExtBySdxl22, all);
+
+        assertNotEquals(allExt, allBySdxl2);
+        assertEquals(allExtBySdxl2, allBySdxl2);
+        assertNotEquals(allExtBySdxl22, allBySdxl2);
+
+        assertNotEquals(allExt, allBySdxl22);
+        assertNotEquals(allExtBySdxl2, allBySdxl22);
+        assertEquals(allExtBySdxl22, allBySdxl22);
+
+    }
+
+    @Test
+    public void testremoveSdxL2ConnectionPoint() {
+
+        manager.createSdxL2(SDXL2);
+        manager.createSdxL2(SDXL2_2);
+
+        SdxL2ConnectionPoint one = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM1", CP1, VLANS1, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2, one);
+
+        SdxL2ConnectionPoint three = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM2", CP2, VLANS2, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2, three);
+
+        SdxL2ConnectionPoint six = SdxL2ConnectionPoint.sdxl2ConnectionPoint("ROM3", CP1, VLANS7, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, six);
+
+        SdxL2ConnectionPoint seven = SdxL2ConnectionPoint.sdxl2ConnectionPoint("MI3", CP3, VLANS3, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2, seven);
+
+        SdxL2ConnectionPoint nine = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI1", CP4, VLANS8, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2_2, nine);
+
+        SdxL2ConnectionPoint ten = SdxL2ConnectionPoint.sdxl2ConnectionPoint("FI2", CP5, VLANS2, CEMAC1);
+        manager.addSdxL2ConnectionPoint(SDXL2, ten);
+
+        manager.removeSdxL2ConnectionPoint(one.name());
+        manager.removeSdxL2ConnectionPoint(six.name());
+        manager.removeSdxL2ConnectionPoint(one.name());
+        manager.removeSdxL2ConnectionPoint("ROM");
+
+    }
+
 }
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2TestStore.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2TestStore.java
deleted file mode 100644
index 6cf3ef2..0000000
--- a/sdx-l2/src/test/java/org/onosproject/sdxl2/SdxL2TestStore.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.sdxl2;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
-
-import java.util.Set;
-
-/**
- * Stub class that emulates the behaviours of the SdxL2Store.
- */
-public final class SdxL2TestStore implements SdxL2Store {
-
-    private Set<String> sdxL2s = Sets.newHashSet();
-
-    private static String errorAddSdx = "It is not possible to add ";
-    private static String errorRemoveSdx = "It is not possible to remove ";
-
-    /**
-     * Create a named sdx-l2.
-     *
-     * @param sdxl2 sdx-l2 name
-     * @throws SdxL2Exception if sdxl2 exists
-     */
-    @Override
-    public void putSdxL2(String sdxl2) throws SdxL2Exception {
-        boolean inserted = sdxL2s.add(sdxl2);
-        if (!inserted) {
-            throw new SdxL2Exception(errorAddSdx + sdxl2);
-        }
-    }
-
-    /**
-     * Remove a named sdx-l2.
-     *
-     * @param sdxl2 sdx-l2 name
-     * @throws SdxL2Exception if sdxl2 does not exist
-     */
-    @Override
-    public void removeSdxL2(String sdxl2) throws SdxL2Exception {
-        boolean removed = sdxL2s.remove(sdxl2);
-        if (!removed) {
-            throw new SdxL2Exception(errorRemoveSdx + sdxl2);
-        }
-    }
-
-    /**
-     * Returns a set of sdxl2 names.
-     *
-     * @return a set of sdxl2 names
-     */
-    @Override
-    public Set<String> getSdxL2s() {
-        return ImmutableSet.copyOf(sdxL2s);
-    }
-
-}
diff --git a/sdx-l2/src/test/java/org/onosproject/sdxl2/package-info.java b/sdx-l2/src/test/java/org/onosproject/sdxl2/package-info.java
index de39d20..a358545 100644
--- a/sdx-l2/src/test/java/org/onosproject/sdxl2/package-info.java
+++ b/sdx-l2/src/test/java/org/onosproject/sdxl2/package-info.java
@@ -15,6 +15,6 @@
  */
 
 /**
- * Test sdx-l2 functionalities.
+ * Tests SDX-L2 functionality.
  */
 package org.onosproject.sdxl2;