fixed map register map register dosn't delete old rlocs 57/4357/6
authorDavid Goldberg <david.goldberg@contextream.com>
Sun, 5 Jan 2014 03:12:36 +0000 (05:12 +0200)
committerDavid Goldberg <david.goldberg@contextream.com>
Sun, 19 Jan 2014 18:59:23 +0000 (20:59 +0200)
Signed-off-by: David Goldberg <david.goldberg@contextream.com>
Change-Id: Ic8b31417e41b2e5808a6fda67e8ca1b5ef3d92b5
Signed-off-by: David Goldberg <david.goldberg@contextream.com>
commons/parent/pom.xml
mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/interfaces/dao/MappingServiceRLOC.java
mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/type/lisp/address/LispIPAddress.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/LispMappingService.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java
mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServerTest.java
mappingservice/integrationtest/pom.xml
mappingservice/integrationtest/src/test/java/org/opendaylight/lispflowmapping/integrationtest/MappingServiceIntegrationTest.java
mappingservice/integrationtest/src/test/resources/logback.xml
mappingservice/northbound/pom.xml
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java

index 2aad455d6c7d1e23acf5f10d87ab93e5c9e79626..52595758bbe36ad9b690c47adbcf50c78826c495 100644 (file)
@@ -25,7 +25,7 @@
                <build.suffix>1.0.0</build.suffix>
                <yangtools.binding.version>0.6.0-SNAPSHOT</yangtools.binding.version>
                <yang.binding.version>0.6.0-SNAPSHOT</yang.binding.version>
-               <yang.version>0.5.9-SNAPSHOT</yang.version>
+               <yang.version>0.6.0-SNAPSHOT</yang.version>
                <yang.codegen.version>0.6.0-SNAPSHOT</yang.codegen.version>
                <sonar.host.url>https://sonar.opendaylight.org/</sonar.host.url>
                <sonar.branch>${user.name}-private-view</sonar.branch>
index 8581fd43576bdf77b932a325d7d6fabf3c63215c..852f48c7379695be0bc069731cf4b8ccb0a6de08 100644 (file)
@@ -40,40 +40,45 @@ public class MappingServiceRLOC {
         return record;
     }
 
-    public void setRecord(LocatorRecord record) {
+    public MappingServiceRLOC setRecord(LocatorRecord record) {
         this.record = record;
+        return this;
     }
 
     public int getTtl() {
         return ttl;
     }
 
-    public void setTtl(int ttl) {
+    public MappingServiceRLOC setTtl(int ttl) {
         this.ttl = ttl;
+        return this;
     }
 
     public Action getAction() {
         return action;
     }
 
-    public void setAction(Action action) {
+    public MappingServiceRLOC setAction(Action action) {
         this.action = action;
+        return this;
     }
 
     public boolean isAuthoritative() {
         return authoritative;
     }
 
-    public void setAuthoritative(boolean authoritative) {
+    public MappingServiceRLOC setAuthoritative(boolean authoritative) {
         this.authoritative = authoritative;
+        return this;
     }
 
     public Date getRegisterdDate() {
         return registerdDate;
     }
 
-    public void setRegisterdDate(Date registerdDate) {
+    public MappingServiceRLOC setRegisterdDate(Date registerdDate) {
         this.registerdDate = registerdDate;
+        return this;
     }
 
     @Override
index 6842114ff08d64c7d1c44d0bf6cb1fe584cde841..06376e80b4393748a0a29661a130ad2430f03fd8 100644 (file)
@@ -68,7 +68,6 @@ public abstract class LispIPAddress extends LispAddress implements IMaskable {
         try {
             this.address = InetAddress.getByAddress(byteRepresentation.array());
         } catch (UnknownHostException e) {
-            e.printStackTrace();
         }
 
     }
index 1367810e7f65e043baacb0cda6a746838bdcd511..0eec064d494f436750f2bd0c9526bb03473b7d16 100644 (file)
@@ -129,7 +129,7 @@ public class LispMappingService implements CommandProvider, IFlowMapping, Bindin
             registerWithOSGIConsole();
             logger.info("LISP (RFC6830) Mapping Service init finished");
         } catch (Throwable t) {
-            t.printStackTrace();
+            logger.error(t.getStackTrace().toString());
         }
     }
 
index 390751fe70b52dbacb841f7684b48dd45d7e529d..ca1029851761a39d1036e31a377ea6215374882c 100644 (file)
@@ -9,7 +9,8 @@
 package org.opendaylight.lispflowmapping.implementation.lisp;
 
 import java.util.ArrayList;
-import java.util.List;
+import java.util.Date;
+import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.commons.lang3.BooleanUtils;
@@ -67,17 +68,40 @@ public class MapServer implements IMapServerAsync {
                         break;
                     }
                 }
-                MappingServiceValue value = new MappingServiceValue();
+                IMappingServiceKey key = MappingServiceKeyUtil.generateMappingServiceKey(eidRecord.getLispAddressContainer(),
+                        eidRecord.getMaskLength());
+                MappingServiceValue value = null;
+                Map<String, ?> locators = dao.get(key);
+                if (locators != null) {
+                    value = (MappingServiceValue) locators.get("value");
+                }
+                if (value == null) {
+                    value = new MappingServiceValue();
+                    value.setRlocs(new ArrayList<MappingServiceRLOC>());
+                }
+                if (value.getRlocs() == null) {
+                    value.setRlocs(new ArrayList<MappingServiceRLOC>());
+                }
+
                 MappingEntry<MappingServiceValue> entry = new MappingEntry<MappingServiceValue>("value", value);
-                List<MappingServiceRLOC> rlocs = new ArrayList<MappingServiceRLOC>();
                 if (eidRecord.getLocatorRecord() != null) {
+                    Map<LocatorRecord, MappingServiceRLOC> currentRLOCs = new HashMap<LocatorRecord, MappingServiceRLOC>();
+                    for (MappingServiceRLOC msr : value.getRlocs()) {
+                        currentRLOCs.put(msr.getRecord(), msr);
+                    }
+
                     for (LocatorRecord locatorRecord : eidRecord.getLocatorRecord()) {
-                        rlocs.add(new MappingServiceRLOC(locatorRecord, eidRecord.getRecordTtl(), eidRecord.getAction(), eidRecord.isAuthoritative()));
+                        if (currentRLOCs.containsKey(locatorRecord)) {
+                            currentRLOCs.get(locatorRecord).setAction(eidRecord.getAction()).setAuthoritative(eidRecord.isAuthoritative())
+                                    .setRegisterdDate(new Date(System.currentTimeMillis())).setTtl(eidRecord.getRecordTtl());
+                        } else {
+
+                            value.getRlocs().add(
+                                    new MappingServiceRLOC(locatorRecord, eidRecord.getRecordTtl(), eidRecord.getAction(), eidRecord
+                                            .isAuthoritative()));
+                        }
                     }
                 }
-                value.setRlocs(rlocs);
-                IMappingServiceKey key = MappingServiceKeyUtil.generateMappingServiceKey(eidRecord.getLispAddressContainer(),
-                        eidRecord.getMaskLength());
                 dao.put(key, entry);
 
             }
index a7d096ca60da1a1afa31018f810dbefff5422d76..48f26f4db28918f2c29124b06e2d31e169c42971 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.lispflowmapping.implementation.lisp;
 import static org.junit.Assert.assertEquals;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -26,6 +27,7 @@ import org.opendaylight.lispflowmapping.implementation.util.LispAFIConvertor;
 import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
 import org.opendaylight.lispflowmapping.interfaces.dao.IMappingServiceKey;
 import org.opendaylight.lispflowmapping.interfaces.dao.MappingEntry;
+import org.opendaylight.lispflowmapping.interfaces.dao.MappingServiceRLOC;
 import org.opendaylight.lispflowmapping.interfaces.dao.MappingServiceValue;
 import org.opendaylight.lispflowmapping.tools.junit.BaseTestCase;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.LispAFIAddress;
@@ -94,6 +96,93 @@ public class MapServerTest extends BaseTestCase {
         assertEquals(rloc, ((MappingServiceValue) entries[0].getValue()).getRlocs().get(0).getRecord().getLispAddressContainer().getAddress());
     }
 
+    @Test
+    public void handleMapRegister__TestOtherKeyExists() throws Exception {
+        mapRegisterBuilder.setWantMapNotify(false);
+
+        Map<String, MappingServiceValue> result = new HashMap<String, MappingServiceValue>();
+        MappingServiceValue value = new MappingServiceValue();
+        value.setRlocs(new ArrayList<MappingServiceRLOC>());
+        LocatorRecord rec = new LocatorRecordBuilder().setLispAddressContainer(LispAFIConvertor.toContainer(eid)).build();
+        MappingServiceRLOC msr = new MappingServiceRLOC(rec, 60, Action.NoAction, false);
+        value.getRlocs().add(msr);
+        result.put("value", value);
+        allowing(lispDAO)
+                .get(weq(MappingServiceKeyUtil.generateMappingServiceKey(mapRegisterBuilder.getEidToLocatorRecord().get(0).getLispAddressContainer(),
+                        32)));
+        ret(result);
+        addGetExpectations(eid, 32);
+        msr = new MappingServiceRLOC(new LocatorRecordBuilder().setLispAddressContainer(LispAFIConvertor.toContainer(rloc)).build(), 60,
+                Action.NoAction, false);
+        value.getRlocs().add(msr);
+        MappingEntry<MappingServiceValue> entry = new MappingEntry<MappingServiceValue>("value", value);
+        allowing(lispDAO).put(
+                MappingServiceKeyUtil.generateMappingServiceKey(mapRegisterBuilder.getEidToLocatorRecord().get(0).getLispAddressContainer(), 32),
+                entry);
+
+        testedMapServer.handleMapRegister(mapRegisterBuilder.build());
+
+    }
+
+    @Test
+    public void handleMapRegister__TestKeyExistsAndOther() throws Exception {
+        mapRegisterBuilder.setWantMapNotify(false);
+
+        Map<String, MappingServiceValue> result = new HashMap<String, MappingServiceValue>();
+        MappingServiceValue value = new MappingServiceValue();
+        value.setRlocs(new ArrayList<MappingServiceRLOC>());
+        LocatorRecord rec = new LocatorRecordBuilder().setLispAddressContainer(LispAFIConvertor.toContainer(eid)).build();
+        MappingServiceRLOC msr = new MappingServiceRLOC(rec, 60, Action.NoAction, false);
+        value.getRlocs().add(msr);
+        rec = new LocatorRecordBuilder().setLispAddressContainer(LispAFIConvertor.toContainer(rloc)).build();
+        msr = new MappingServiceRLOC(rec, 60, Action.NoAction, false);
+        value.getRlocs().add(msr);
+        result.put("value", value);
+        allowing(lispDAO)
+                .get(weq(MappingServiceKeyUtil.generateMappingServiceKey(mapRegisterBuilder.getEidToLocatorRecord().get(0).getLispAddressContainer(),
+                        32)));
+        ret(result);
+        addGetExpectations(eid, 32);
+        msr = new MappingServiceRLOC(new LocatorRecordBuilder().setLispAddressContainer(LispAFIConvertor.toContainer(rloc)).build(), 60,
+                Action.NoAction, false);
+        value.getRlocs().add(msr);
+        MappingEntry<MappingServiceValue> entry = new MappingEntry<MappingServiceValue>("value", value);
+        allowing(lispDAO).put(
+                MappingServiceKeyUtil.generateMappingServiceKey(mapRegisterBuilder.getEidToLocatorRecord().get(0).getLispAddressContainer(), 32),
+                entry);
+
+        testedMapServer.handleMapRegister(mapRegisterBuilder.build());
+
+    }
+
+    @Test
+    public void handleMapRegister__TestSameKeyExists() throws Exception {
+        mapRegisterBuilder.setWantMapNotify(false);
+
+        Map<String, MappingServiceValue> result = new HashMap<String, MappingServiceValue>();
+        MappingServiceValue value = new MappingServiceValue();
+        value.setRlocs(new ArrayList<MappingServiceRLOC>());
+        LocatorRecord rec = new LocatorRecordBuilder().setLispAddressContainer(LispAFIConvertor.toContainer(rloc)).build();
+        MappingServiceRLOC msr = new MappingServiceRLOC(rec, 40, Action.Drop, true);
+        value.getRlocs().add(msr);
+        result.put("value", value);
+        allowing(lispDAO)
+                .get(weq(MappingServiceKeyUtil.generateMappingServiceKey(mapRegisterBuilder.getEidToLocatorRecord().get(0).getLispAddressContainer(),
+                        32)));
+        ret(result);
+        addGetExpectations(eid, 32);
+        MappingServiceRLOC expectedMsr = new MappingServiceRLOC(rec, 60, Action.NoAction, false);
+        value = new MappingServiceValue();
+        value.setRlocs(Arrays.asList(expectedMsr));
+        MappingEntry<MappingServiceValue> entry = new MappingEntry<MappingServiceValue>("value", value);
+        allowing(lispDAO).put(
+                MappingServiceKeyUtil.generateMappingServiceKey(mapRegisterBuilder.getEidToLocatorRecord().get(0).getLispAddressContainer(), 32),
+                entry);
+
+        testedMapServer.handleMapRegister(mapRegisterBuilder.build());
+
+    }
+
     @Test
     public void handleMapRegisterIpv4__ValidNotifyEchoesRegister() throws Exception {
         mapRegisterBuilder.getEidToLocatorRecord().add(
index f16705fde2ae5558974cac9fe4db50238b8a93b0..0ed3adbe2f54b7848b2458b7f53330ba6783012a 100644 (file)
@@ -35,7 +35,7 @@
        <build>
                <pluginManagement>
                        <plugins>
-                               
+
                                <plugin>
                                        <groupId>org.eclipse.m2e</groupId>
                                        <artifactId>lifecycle-mapping</artifactId>
                        <artifactId>sal-binding-it</artifactId>
                        <version>1.0-SNAPSHOT</version>
                </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>sal-binding-util</artifactId>
+                       <version>1.0-SNAPSHOT</version>
+               </dependency>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>sal-common-api</artifactId>
                        <artifactId>netconf-impl</artifactId>
                        <version>${netconf.version}</version>
                </dependency>
+               <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>${osgi.core.version}</version>
+            <scope>provided</scope>
+        </dependency>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>containermanager.it.implementation</artifactId>
                        <version>0.4.1-SNAPSHOT</version>
                </dependency>
 
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>protocol-framework</artifactId>
+               </dependency>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>sal</artifactId>
                <dependency>
                        <groupId>commons-fileupload</groupId>
                        <artifactId>commons-fileupload</artifactId>
-                       <version>1.2.2</version>
                </dependency>
                <dependency>
                        <groupId>commons-codec</groupId>
                <dependency>
                        <groupId>equinoxSDK381</groupId>
                        <artifactId>javax.servlet</artifactId>
-                       <version>3.0.0.v201112011016</version>
                </dependency>
                <dependency>
                        <groupId>equinoxSDK381</groupId>
                        <artifactId>javax.servlet.jsp</artifactId>
-                       <version>2.2.0.v201112011158</version>
                </dependency>
                <dependency>
                        <groupId>equinoxSDK381</groupId>
                        <artifactId>org.eclipse.equinox.ds</artifactId>
-                       <version>1.4.0.v20120522-1841</version>
                </dependency>
                <dependency>
                        <groupId>equinoxSDK381</groupId>
                        <artifactId>org.eclipse.equinox.util</artifactId>
-                       <version>1.0.400.v20120522-2049</version>
                </dependency>
                <dependency>
                        <groupId>equinoxSDK381</groupId>
                        <artifactId>org.eclipse.osgi</artifactId>
-                       <version>3.8.1.v20120830-144521</version>
                </dependency>
                <dependency>
                        <groupId>equinoxSDK381</groupId>
                        <artifactId>org.apache.felix.gogo.command</artifactId>
-                       <version>0.8.0.v201108120515</version>
                </dependency>
                <dependency>
                        <groupId>equinoxSDK381</groupId>
                        <artifactId>org.apache.felix.gogo.runtime</artifactId>
-                       <version>0.8.0.v201108120515</version>
                </dependency>
                <dependency>
                        <groupId>equinoxSDK381</groupId>
                        <artifactId>org.apache.felix.gogo.shell</artifactId>
-                       <version>0.8.0.v201110170705</version>
                </dependency>
                <dependency>
                        <groupId>equinoxSDK381</groupId>
                        <artifactId>org.eclipse.equinox.cm</artifactId>
-                       <version>1.0.400.v20120522-1841</version>
                </dependency>
                <dependency>
                        <groupId>equinoxSDK381</groupId>
                        <artifactId>org.eclipse.equinox.console</artifactId>
-                       <version>1.0.0.v20120522-1841</version>
                </dependency>
                <dependency>
                        <groupId>equinoxSDK381</groupId>
                        <artifactId>org.eclipse.equinox.launcher</artifactId>
-                       <version>1.3.0.v20120522-1813</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>org.apache.felix.dependencymanager</artifactId>
-                       <version>3.1.0</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>org.apache.felix.dependencymanager.shell</artifactId>
-                       <version>3.0.1</version>
                </dependency>
                <dependency>
                        <groupId>com.google.code.gson</groupId>
                        <artifactId>gson</artifactId>
-                       <version>2.1</version>
                        <scope>compile</scope>
                </dependency>
                <dependency>
                        <groupId>org.jboss.spec.javax.transaction</groupId>
                        <artifactId>jboss-transaction-api_1.1_spec</artifactId>
-                       <version>1.0.1.Final</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>org.apache.felix.fileinstall</artifactId>
-                       <version>3.1.6</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.commons</groupId>
                <dependency>
                        <groupId>virgomirror</groupId>
                        <artifactId>org.eclipse.jdt.core.compiler.batch</artifactId>
-                       <version>3.8.0.I20120518-2145</version>
                </dependency>
                <dependency>
                        <groupId>eclipselink</groupId>
                        <artifactId>javax.persistence</artifactId>
-                       <version>2.0.4.v201112161009</version>
                </dependency>
                <dependency>
                        <groupId>eclipselink</groupId>
                        <artifactId>javax.resource</artifactId>
-                       <version>1.5.0.v200906010428</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>javax.activation</artifactId>
-                       <version>1.1.0.v201211130549</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>javax.annotation</artifactId>
-                       <version>1.1.0.v201209060031</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>javax.ejb</artifactId>
-                       <version>3.1.1.v201204261316</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>javax.el</artifactId>
-                       <version>2.2.0.v201108011116</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>javax.mail.glassfish</artifactId>
-                       <version>1.4.1.v201108011116</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>javax.xml.rpc</artifactId>
-                       <version>1.1.0.v201005080400</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>org.apache.catalina</artifactId>
-                       <version>7.0.32.v201211201336</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>org.apache.catalina.ha</artifactId>
-                       <version>7.0.32.v201211201952</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>org.apache.catalina.tribes</artifactId>
-                       <version>7.0.32.v201211201952</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>org.apache.coyote</artifactId>
-                       <version>7.0.32.v201211201952</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>org.apache.el</artifactId>
-                       <version>7.0.32.v201211081135</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>org.apache.jasper</artifactId>
-                       <version>7.0.32.v201211201952</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>org.apache.juli.extras</artifactId>
-                       <version>7.0.32.v201211081135</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>org.apache.tomcat.api</artifactId>
-                       <version>7.0.32.v201211081135</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>org.apache.tomcat.util</artifactId>
-                       <version>7.0.32.v201211201952</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>javax.servlet.jsp.jstl</artifactId>
-                       <version>1.2.0.v201105211821</version>
                </dependency>
                <dependency>
                        <groupId>orbit</groupId>
                        <artifactId>javax.servlet.jsp.jstl.impl</artifactId>
-                       <version>1.2.0.v201210211230</version>
                </dependency>
                <!-- Add Pax Exam -->
                <dependency>
-            <exclusions>
-                <exclusion>  <!-- declare the exclusion here -->
-                    <groupId>org.ops4j.pax.exam</groupId>
-                    <artifactId>pax-exam-container-native</artifactId>
-                </exclusion>
-            </exclusions>
+                       <exclusions>
+                               <exclusion>  <!-- declare the exclusion here -->
+                                       <groupId>org.ops4j.pax.exam</groupId>
+                                       <artifactId>pax-exam-container-native</artifactId>
+                               </exclusion>
+                       </exclusions>
                        <groupId>org.ops4j.pax.exam</groupId>
                        <artifactId>pax-exam-container-forked</artifactId>
                        <scope>test</scope>
-            <version>${exam.version}</version>
+                       <version>${exam.version}</version>
                </dependency>
                <dependency>
                        <groupId>org.ops4j.pax.exam</groupId>
                <dependency>
                        <groupId>org.ow2.asm</groupId>
                        <artifactId>asm-all</artifactId>
-                       <version>4.1</version>
                </dependency>
                <dependency>
                        <groupId>org.springframework</groupId>
                <dependency>
                        <groupId>org.aopalliance</groupId>
                        <artifactId>com.springsource.org.aopalliance</artifactId>
-                       <version>1.0.0</version>
                </dependency>
                <dependency>
                        <groupId>org.springframework</groupId>
                <dependency>
                        <groupId>org.ow2.chameleon.management</groupId>
                        <artifactId>chameleon-mbeans</artifactId>
-                       <version>1.0.0</version>
                </dependency>
                <!-- Jersey for JAXRS -->
                <dependency>
                        <artifactId>sal-binding-broker-impl</artifactId>
                        <version>1.0-SNAPSHOT</version>
                </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>config-netconf-connector</artifactId>
+                       <version>${netconf.version}</version>
+                       <scope>test</scope>
+               </dependency>
                <dependency>
             <groupId>org.opendaylight.controller</groupId>
-            <artifactId>config-netconf-connector</artifactId>
-            <version>${netconf.version}</version>
-            <scope>test</scope>
+            <artifactId>config-persister-file-xml-adapter</artifactId>
+            <version>${config.version}</version>
         </dependency>
                <dependency>
-          <groupId>org.opendaylight.controller.model</groupId>
-          <artifactId>model-inventory</artifactId>
-          <version>${mdsal.version}</version>
-        </dependency>
+                       <groupId>org.opendaylight.controller.model</groupId>
+                       <artifactId>model-inventory</artifactId>
+                       <version>${mdsal.version}</version>
+               </dependency>
                <dependency>
                        <groupId>org.javassist</groupId>
                        <artifactId>javassist</artifactId>
-                       <version>3.17.1-GA</version>
                </dependency>
                <dependency>
-                         <groupId>org.opendaylight.controller.thirdparty</groupId>
-                         <artifactId>exificient</artifactId>
-                         <version>0.9.2-SNAPSHOT</version>
+                       <groupId>org.opendaylight.controller.thirdparty</groupId>
+                       <artifactId>exificient</artifactId>
                </dependency>
 
                <dependency>
                        <groupId>org.opendaylight.controller.thirdparty</groupId>
                        <artifactId>com.sun.jersey.jersey-servlet</artifactId>
                </dependency>
-               
+
                <dependency>
-      <groupId>com.fasterxml.jackson.core</groupId>
-      <artifactId>jackson-annotations</artifactId>
-      <version>${jackson.version}</version>
-    </dependency>
+                       <groupId>com.fasterxml.jackson.core</groupId>
+                       <artifactId>jackson-annotations</artifactId>
+                       <version>${jackson.version}</version>
+               </dependency>
 
-    <dependency>
-      <groupId>com.fasterxml.jackson.core</groupId>
-      <artifactId>jackson-core</artifactId>
-      <version>${jackson.version}</version>
-    </dependency>
+               <dependency>
+                       <groupId>com.fasterxml.jackson.core</groupId>
+                       <artifactId>jackson-core</artifactId>
+                       <version>${jackson.version}</version>
+               </dependency>
 
-    <dependency>
-      <groupId>com.fasterxml.jackson.core</groupId>
-      <artifactId>jackson-databind</artifactId>
-      <version>${jackson.version}</version>
-    </dependency>
-    
-    <dependency>
-       <groupId>com.fasterxml.jackson.jaxrs</groupId>
-       <artifactId>jackson-jaxrs-json-provider</artifactId>
-       <version>${jackson.version}</version>
-    </dependency>
+               <dependency>
+                       <groupId>com.fasterxml.jackson.core</groupId>
+                       <artifactId>jackson-databind</artifactId>
+                       <version>${jackson.version}</version>
+               </dependency>
+
+               <dependency>
+                       <groupId>com.fasterxml.jackson.jaxrs</groupId>
+                       <artifactId>jackson-jaxrs-json-provider</artifactId>
+                       <version>${jackson.version}</version>
+               </dependency>
+
+               <dependency>
+                       <groupId>com.fasterxml.jackson.jaxrs</groupId>
+                       <artifactId>jackson-jaxrs-base</artifactId>
+                       <version>${jackson.version}</version>
+               </dependency>
 
-      <dependency>
-         <groupId>com.fasterxml.jackson.jaxrs</groupId>
-         <artifactId>jackson-jaxrs-base</artifactId>
-         <version>${jackson.version}</version>
-      </dependency>
-    
                <dependency>
                        <groupId>org.codehaus.jackson</groupId>
                        <artifactId>jackson-mapper-asl</artifactId>
                <dependency>
                        <groupId>org.codehaus.jettison</groupId>
                        <artifactId>jettison</artifactId>
-                       <version>1.3.3</version>
                </dependency>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <version>0.4.1-SNAPSHOT</version>
                </dependency>
                <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>forwardingrulesmanager</artifactId>
-      <version>0.5.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>hosttracker</artifactId>
-      <version>${hosttracker.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>topologymanager</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
-    </dependency>
-               <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>forwardingrulesmanager.implementation</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
-    </dependency>
-               <dependency>
-  <groupId>org.opendaylight.controller</groupId>
-  <artifactId>statisticsmanager</artifactId>
-  <version>0.5.0-SNAPSHOT</version>
-</dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>statisticsmanager.implementation</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
-    </dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>forwardingrulesmanager</artifactId>
+                       <version>0.5.0-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>hosttracker</artifactId>
+                       <version>${hosttracker.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>topologymanager</artifactId>
+                       <version>0.4.1-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>forwardingrulesmanager.implementation</artifactId>
+                       <version>0.4.1-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>statisticsmanager</artifactId>
+                       <version>0.5.0-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>statisticsmanager.implementation</artifactId>
+                       <version>0.4.1-SNAPSHOT</version>
+               </dependency>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>connectionmanager</artifactId>
                        <version>0.2.3-SNAPSHOT</version>
                </dependency>
 
-        <dependency>
-            <groupId>xml-apis</groupId>
-            <artifactId>xml-apis</artifactId>
-            <version>1.4.01</version>
-        </dependency>
-    </dependencies>
+               <dependency>
+                       <groupId>org.opendaylight.yangtools</groupId>
+                       <artifactId>mockito-configuration</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>xml-apis</groupId>
+                       <artifactId>xml-apis</artifactId>
+                       <version>1.4.01</version>
+               </dependency>
+       </dependencies>
 
        <profiles>
                <profile>
index dd7f7915bdd8998acb884234fd7834da8f85fe60..05b8bee3fc9f4062c0b2d33937264f7462a8c21e 100644 (file)
@@ -7,7 +7,15 @@
  */
 package org.opendaylight.lispflowmapping.integrationtest;
 
-import aQute.lib.osgi.Constants;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -106,9 +114,10 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.util.Filter;
 import org.ops4j.pax.exam.util.PathUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -118,21 +127,7 @@ import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.systemPackages;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-
-//import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
-//import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapNotify;
-//import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRegister;
-//import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapReply;
-//import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest;
+import aQute.lib.osgi.Constants;
 
 @RunWith(PaxExam.class)
 public class MappingServiceIntegrationTest {
@@ -315,6 +310,7 @@ public class MappingServiceIntegrationTest {
 
                 mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager").versionAsInProject(),
                 mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager.shell").versionAsInProject(),
+                mavenBundle("org.osgi", "org.osgi.core").versionAsInProject(),
 
                 mavenBundle("com.google.code.gson", "gson").versionAsInProject(),
                 mavenBundle("org.jboss.spec.javax.transaction", "jboss-transaction-api_1.1_spec").versionAsInProject(),
@@ -354,40 +350,8 @@ public class MappingServiceIntegrationTest {
                 TestHelper.bindingIndependentSalBundles(),
                 TestHelper.bindingAwareSalBundles(),
                 TestHelper.mdSalCoreBundles(),
+                TestHelper.junitAndMockitoBundles(),
 
-                // Specific bundles
-                mavenBundle(ODL, "config-api").versionAsInProject(),
-                mavenBundle(ODL, "sal-binding-api").versionAsInProject(), //
-                mavenBundle(ODL, "sal-binding-config").versionAsInProject(),
-                mavenBundle(ODL, "sal-binding-broker-impl").versionAsInProject(), //
-                mavenBundle(ODL, "sal-common").versionAsInProject(), //
-                mavenBundle(ODL, "sal-common-api").versionAsInProject(), //
-                mavenBundle(ODL, "sal-common-impl").versionAsInProject(),
-                mavenBundle(ODL, "sal-common-util").versionAsInProject(), //
-
-                mavenBundle(YANG, "concepts").versionAsInProject(),
-                mavenBundle(YANG, "yang-binding").versionAsInProject(), //
-                mavenBundle(YANG, "yang-common").versionAsInProject(), //
-                mavenBundle(YANG + ".model", "ietf-inet-types").versionAsInProject(),//
-                mavenBundle(YANG + ".model", "ietf-yang-types").versionAsInProject(),//
-                mavenBundle(YANG + ".thirdparty", "xtend-lib-osgi").versionAsInProject(),//
-                mavenBundle(YANG, "yang-data-api").versionAsInProject(), //
-                mavenBundle(YANG, "yang-data-impl").versionAsInProject(), //
-                mavenBundle(YANG, "yang-model-api").versionAsInProject(), //
-                mavenBundle(YANG, "yang-model-util").versionAsInProject(), //
-                mavenBundle(YANG, "yang-parser-api").versionAsInProject(),
-                mavenBundle(YANG, "yang-parser-impl").versionAsInProject(),
-                mavenBundle(YANG, "binding-generator-spi").versionAsInProject(), //
-                mavenBundle(YANG, "binding-model-api").versionAsInProject(), //
-                mavenBundle(YANG, "binding-generator-util").versionAsInProject(),
-                mavenBundle(YANG, "yang-parser-impl").versionAsInProject(),
-                mavenBundle(YANG, "binding-type-provider").versionAsInProject(),
-                mavenBundle(YANG, "binding-generator-api").versionAsInProject(),
-                mavenBundle(YANG, "binding-generator-spi").versionAsInProject(),
-                mavenBundle(YANG, "binding-generator-impl").versionAsInProject(),
-                mavenBundle(YANG + ".thirdparty", "antlr4-runtime-osgi-nohead").versionAsInProject(), //
-
-                mavenBundle("com.google.guava", "guava").versionAsInProject(), //
                 mavenBundle("org.javassist", "javassist").versionAsInProject(), //
 
                 // Northbound bundles
@@ -470,15 +434,6 @@ public class MappingServiceIntegrationTest {
                 mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.southbound").versionAsInProject(), //
                 mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.northbound").versionAsInProject(), //
 
-                // Additions
-                mavenBundle(ODL, "sal-core-api").versionAsInProject().update(), //
-                mavenBundle(ODL, "sal-core-spi").versionAsInProject().update(), //
-                mavenBundle(ODL, "sal-broker-impl").versionAsInProject(), //
-                mavenBundle(ODL, "sal-connector-api").versionAsInProject(), //
-
-                mavenBundle(ODL, "config-api").versionAsInProject(), //
-                mavenBundle(ODL, "config-manager").versionAsInProject(), //
-
                 junitBundles());
     }
 
@@ -1275,6 +1230,32 @@ public class MappingServiceIntegrationTest {
 
     }
 
+    @Test
+    public void mapRegisterMapRegisterAndMapRequest() throws SocketTimeoutException {
+
+        LispIpv4Address eid = asIPAfiAddress("1.2.3.4");
+        MapRegister mb = createMapRegister(eid, asIPAfiAddress("4.3.2.1"));
+        sendMapRegister(mb);
+        MapNotify mapNotify = receiveMapNotify();
+        MapRequest mr = createMapRequest(eid);
+        sendMapRequest(mr);
+        MapReply mapReply = receiveMapReply();
+        assertEquals(mb.getEidToLocatorRecord().get(0).getLocatorRecord().get(0).getLispAddressContainer(), mapReply.getEidToLocatorRecord().get(0)
+                .getLocatorRecord().get(0).getLispAddressContainer());
+        MapRegister mb2 = createMapRegister(eid, asIPAfiAddress("4.3.2.2"));
+        sendMapRegister(mb2);
+        mapNotify = receiveMapNotify();
+        assertEquals(8, mapNotify.getNonce().longValue());
+        mr = createMapRequest(eid);
+        sendMapRequest(mr);
+        mapReply = receiveMapReply();
+        assertEquals(2, mapReply.getEidToLocatorRecord().get(0).getLocatorRecord().size());
+        assertEquals(mb.getEidToLocatorRecord().get(0).getLocatorRecord().get(0).getLispAddressContainer(), mapReply.getEidToLocatorRecord().get(0)
+                .getLocatorRecord().get(0).getLispAddressContainer());
+        assertEquals(mb2.getEidToLocatorRecord().get(0).getLocatorRecord().get(0).getLispAddressContainer(), mapReply.getEidToLocatorRecord().get(0)
+                .getLocatorRecord().get(1).getLispAddressContainer());
+    }
+
     @Test
     public void mapRequestMapRegisterAndMapRequestTestTimeout() throws SocketTimeoutException {
 
@@ -1394,7 +1375,7 @@ public class MappingServiceIntegrationTest {
         assertEquals(expectedAction, mapReply.getEidToLocatorRecord().get(0).getAction());
     }
 
-    private MapRegister createMapRegister(LispIpv4Address eid) {
+    private MapRegister createMapRegister(LispIpv4Address eid, LispIpv4Address rloc) {
         MapRegisterBuilder mapRegisterbuilder = new MapRegisterBuilder();
         mapRegisterbuilder.setWantMapNotify(true);
         mapRegisterbuilder.setNonce((long) 8);
@@ -1403,7 +1384,7 @@ public class MappingServiceIntegrationTest {
         etlrBuilder.setMaskLength((short) 24);
         etlrBuilder.setRecordTtl(254);
         LocatorRecordBuilder recordBuilder = new LocatorRecordBuilder();
-        recordBuilder.setLispAddressContainer(LispAFIConvertor.toContainer(asIPAfiAddress("4.3.2.1")));
+        recordBuilder.setLispAddressContainer(LispAFIConvertor.toContainer(rloc));
         etlrBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
         etlrBuilder.getLocatorRecord().add(recordBuilder.build());
         mapRegisterbuilder.setEidToLocatorRecord(new ArrayList<EidToLocatorRecord>());
@@ -1412,6 +1393,10 @@ public class MappingServiceIntegrationTest {
         return mapRegister;
     }
 
+    private MapRegister createMapRegister(LispIpv4Address eid) {
+        return createMapRegister(eid, asIPAfiAddress("4.3.2.1"));
+    }
+
     private MapRequest createMapRequest(LispIpv4Address eid) {
         MapRequestBuilder mapRequestBuilder = new MapRequestBuilder();
         mapRequestBuilder.setNonce((long) 4);
@@ -1472,7 +1457,6 @@ public class MappingServiceIntegrationTest {
             logger.info("Sending MapRegister to LispPlugin on socket");
             socket.send(packet);
         } catch (Throwable t) {
-            t.printStackTrace();
             fail();
         }
     }
@@ -1493,7 +1477,6 @@ public class MappingServiceIntegrationTest {
         } catch (SocketTimeoutException ste) {
             throw ste;
         } catch (Throwable t) {
-            t.printStackTrace();
             fail();
             return null;
         }
@@ -1508,7 +1491,6 @@ public class MappingServiceIntegrationTest {
         try {
             socket = new DatagramSocket(new InetSocketAddress(ourAddress, LispMessage.PORT_NUM));
         } catch (SocketException e) {
-            e.printStackTrace();
             fail();
         }
         return socket;
@@ -1553,12 +1535,11 @@ public class MappingServiceIntegrationTest {
         Bundle b[] = bc.getBundles();
         for (Bundle element : b) {
             int state = element.getState();
-            logger.debug("Bundle:" + element.getSymbolicName() + ",v" + element.getVersion() + ", state:" + stateToString(state));
+            logger.debug("Bundle[" + element.getBundleId() + "]:" + element.getSymbolicName() + ",v" + element.getVersion() + ", state:"
+                    + stateToString(state));
             if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {
                 logger.debug("Bundle:" + element.getSymbolicName() + " state:" + stateToString(state));
 
-                // UNCOMMENT to see why bundles didn't resolve!
-
                 try {
                     String host = element.getHeaders().get(Constants.FRAGMENT_HOST);
                     if (host != null) {
@@ -1579,6 +1560,7 @@ public class MappingServiceIntegrationTest {
         if (debugit) {
             logger.warn(("Do some debugging because some bundle is unresolved"));
         }
+        // assertNotNull(broker);
 
         int retry = 0;
         ServiceReference r = null;
@@ -1592,7 +1574,6 @@ public class MappingServiceIntegrationTest {
                 try {
                     Thread.sleep(1000);
                 } catch (InterruptedException e) {
-                    e.printStackTrace();
                 }
             }
             retry += 1;
@@ -1610,7 +1591,6 @@ public class MappingServiceIntegrationTest {
         try {
             Thread.sleep(1000);
         } catch (InterruptedException e) {
-            e.printStackTrace();
         }
 
         // If LispMappingServer is null, cannot work
index 50983e22cfd8885e8e1f6680bbe074c22cd59ec2..4655c0eece6044469700682071d03bf86fcbd381 100644 (file)
@@ -7,7 +7,7 @@
     </encoder>
   </appender>
 
-  <root level="info">
+  <root level="warn">
     <appender-ref ref="STDOUT" />
   </root>
 </configuration>
index 88c9add950d8032c470894e3515735149cc2ce57..cb5b0b1495b060a84e26558682b05a4819f8c41a 100644 (file)
@@ -88,7 +88,6 @@
                                                        javax.xml.bind.annotation,
                                                        org.slf4j,
                                                        org.apache.catalina.filters,
-                                                       org.codehaus.jackson.jaxrs,
                                                        !org.codehaus.enunciate.jaxrs,
                                                        org.apache.felix.dm,
                                                        org.apache.commons.lang3.builder,
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>sal</artifactId>
-                       <version>0.7.0-SNAPSHOT</version>
                </dependency>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
index 4d9fe5b8c1d9cd8edae333fb893aea286ccd0597..c0f747e8e79c208fd9717be91bf4b6bb0d1ba4b3 100644 (file)
@@ -226,7 +226,6 @@ public class LispSouthboundPlugin extends AbstractBindingAwareProvider implement
                         try {
                             Thread.sleep(500);
                         } catch (InterruptedException e) {
-                            e.printStackTrace();
                         }
                     }
                 }