summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/SdncDhcpEventConsumer.java3
-rw-r--r--dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncDhcpEventConsumer.java9
2 files changed, 10 insertions, 2 deletions
diff --git a/dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/SdncDhcpEventConsumer.java b/dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/SdncDhcpEventConsumer.java
index 666ed68e1..03560d309 100644
--- a/dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/SdncDhcpEventConsumer.java
+++ b/dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/SdncDhcpEventConsumer.java
@@ -124,8 +124,7 @@ public class SdncDhcpEventConsumer extends SdncDmaapConsumer {
try {
- jdbcDataSource.writeData("INSERT INTO DHCP_MAP(mac_addr, ip_addr) VALUES('" + macAddr + "','" + ipAddr + "')",
- null, null);
+ jdbcDataSource.writeData("INSERT INTO DHCP_MAP(mac_addr, ip_addr) VALUES('" + macAddr + "','" + ipAddr + "') ON DUPLICATE KEY UPDATE ip_addr = '"+ipAddr+"'", null, null);
} catch (SQLException e) {
LOG.error("Could not insert DHCP event data into the database ", e);
diff --git a/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncDhcpEventConsumer.java b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncDhcpEventConsumer.java
index 8c3a839c2..04f098ade 100644
--- a/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncDhcpEventConsumer.java
+++ b/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestSdncDhcpEventConsumer.java
@@ -42,6 +42,9 @@ public class TestSdncDhcpEventConsumer {
private static final String VALID_DHCP_EVENT = "{\"msg_name\":\"DHCPACK\"," +
"\"macaddr\":\"fa:16:3e:8f:ea:68\"," +
"\"yiaddr\":\"10.3.0.2\"}";
+ private static final String SECOND_DHCP_EVENT = "{\"msg_name\":\"DHCPACK\"," +
+ "\"macaddr\":\"fa:16:3e:8f:ea:68\"," +
+ "\"yiaddr\":\"10.3.0.3\"}";
private static final String MISSING_MSG_NAME_DHCP_EVENT = "{\"macaddr\":\"fa:16:3e:8f:ea:68\"," +
"\"yiaddr\":\"10.3.0.2\"}";
private static final String MISSING_MAC_ADDR_DHCP_EVENT = "{\"msg_name\":\"DHCPACK\"," +
@@ -104,11 +107,17 @@ public class TestSdncDhcpEventConsumer {
@Test
public void testValid() throws InvalidMessageException, SQLException {
consumer.processMsg(VALID_DHCP_EVENT);
+ consumer.processMsg(SECOND_DHCP_EVENT);
CachedRowSet results = dblibSvc.getData(GET_DHCP_MAPPING, null, null);
if (!results.next()) {
fail("Test query ["+GET_DHCP_MAPPING+"] returned no data");
+ } else {
+ String ipAddr = results.getString("ip_addr");
+ if (!"10.3.0.3".equals(ipAddr)) {
+ fail("Expecting ipAddr to be 10.3.0.3, but was "+ipAddr);
+ }
}
}