Update to Hazelcast 3.2.3

- Fix compilation, if you need to use Hazelcast 3.2.3
- Workaround for issue with recent Hazelcast version + PowerMock
- Unexpected exception should fail the test instead

Change-Id: I2ecf1deb3e38be98837e41b8df57b680ad2445a1
diff --git a/conf/hazelcast.default.xml b/conf/hazelcast.default.xml
index a65edce..dae7437 100644
--- a/conf/hazelcast.default.xml
+++ b/conf/hazelcast.default.xml
@@ -1,5 +1,5 @@
 <hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config
-	http://www.hazelcast.com/schema/config/hazelcast-config-3.0.xsd"
+	http://www.hazelcast.com/schema/config/hazelcast-config-3.2.xsd"
 	xmlns="http://www.hazelcast.com/schema/config"
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
diff --git a/conf/template/hazelcast.xml.template b/conf/template/hazelcast.xml.template
index 0865194..18ce863 100644
--- a/conf/template/hazelcast.xml.template
+++ b/conf/template/hazelcast.xml.template
@@ -1,5 +1,5 @@
 <hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config
-	http://www.hazelcast.com/schema/config/hazelcast-config-3.0.xsd"
+	http://www.hazelcast.com/schema/config/hazelcast-config-3.2.xsd"
 	xmlns="http://www.hazelcast.com/schema/config"
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <!-- Update xsd line, when upgrading Hazelcast version. -->
diff --git a/pom.xml b/pom.xml
index adc9a73..9e09386 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,7 +45,7 @@
      see https://github.com/OPENNETWORKINGLAB/ONOS/pull/425
     <github.global.server>github</github.global.server>
      -->
-    <hazelcast.version>3.0.2</hazelcast.version>
+    <hazelcast.version>3.2.3</hazelcast.version>
   </properties>
   <build>
     <plugins>
diff --git a/src/main/java/net/onrc/onos/apps/proxyarp/ProxyArpManager.java b/src/main/java/net/onrc/onos/apps/proxyarp/ProxyArpManager.java
index 04957f2..1b3167d 100644
--- a/src/main/java/net/onrc/onos/apps/proxyarp/ProxyArpManager.java
+++ b/src/main/java/net/onrc/onos/apps/proxyarp/ProxyArpManager.java
@@ -725,4 +725,15 @@
     public long getArpCleaningTimerPeriod() {
         return arpCleaningTimerPeriodConfig;
     }
+
+    /**
+     * Replaces the internal ArpCache.
+     *
+     * @param cache ArpCache instance
+     *
+     * @exclude Backdoor for unit testing purpose only, do not use.
+     */
+    void debugReplaceArpCache(final ArpCache cache) {
+        this.arpCache = cache;
+    }
 }
diff --git a/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZClient.java b/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZClient.java
index dc9d2f8..e568e09 100644
--- a/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZClient.java
+++ b/src/main/java/net/onrc/onos/core/datastore/hazelcast/HZClient.java
@@ -130,13 +130,13 @@
             final int port = baseHzConfig.getNetworkConfig().getPort();
 
             String server = System.getProperty("net.onrc.onos.core.datastore.hazelcast.client.server", "localhost");
-            clientConfig.addAddress(server + ":" + port);
+            clientConfig.getNetworkConfig().addAddress(server + ":" + port);
 
             // client mode connection limit.
             // set to 0 for fast fall back to Instance mode.
             String sAttempts = System.getProperty("net.onrc.onos.core.datastore.hazelcast.client.attemptLimit");
             if (sAttempts != null) {
-                clientConfig.setConnectionAttemptLimit(Integer.parseInt(sAttempts));
+                clientConfig.getNetworkConfig().setConnectionAttemptLimit(Integer.parseInt(sAttempts));
             }
 
             // copy group config from base Hazelcast configuration
@@ -148,7 +148,7 @@
 
             registerSerializer(clientConfig.getSerializationConfig());
 
-            log.info("Starting Hazelcast datastore client for [{}]", clientConfig.getAddressList());
+            log.info("Starting Hazelcast datastore client for [{}]", clientConfig.getNetworkConfig().getAddresses());
 
             try {
                 instance = HazelcastClient.newHazelcastClient(clientConfig);
diff --git a/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java b/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java
index a38a90b..60b32a1 100644
--- a/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java
+++ b/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java
@@ -2,8 +2,6 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
@@ -37,13 +35,11 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
 
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({ ProxyArpManager.class, ArpCache.class })
+// XXX Commented out as workaround for PowerMock + Hazelcast issue.
+//@RunWith(PowerMockRunner.class)
+//@PowerMockIgnore({ "net.onrc.onos.core.datastore.*", "com.hazelcast.*" })
+//@PrepareOnlyThisForTest({ ProxyArpManager.class })
 @SuppressWarnings({ "rawtypes", "unchecked" })
 public class ProxyArpManagerTest {
     String defaultStrAgingMsec = "60000";
@@ -89,7 +85,7 @@
         prepareExpectForGeneral();
     }
 
-    private void makeTestedObject() {
+    private void makeTestedObject() throws UnknownHostException {
         //Made tested values
         srcStrMac = "00:00:00:00:00:01";
         dstStrMac = "00:00:00:00:00:02";
@@ -105,18 +101,12 @@
         srcMac = new MACAddress(srcByteMac);
         cachedMac1 = new MACAddress(Ethernet.toMACAddress(cachedStrMac1));
         cachedMac2 = new MACAddress(Ethernet.toMACAddress(cachedStrMac2));
-        srcIp = null;
-        dstIp = null;
-        cachedIp1 = null;
-        cachedIp2 = null;
-        try {
-            srcIp = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(srcStrIp));
-            dstIp = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(dstStrIp));
-            cachedIp1 = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(cachedStrIp1));
-            cachedIp2 = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(cachedStrIp2));
-        } catch (UnknownHostException e) {
-            e.printStackTrace();
-        }
+
+        srcIp = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(srcStrIp));
+        dstIp = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(dstStrIp));
+        cachedIp1 = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(cachedStrIp1));
+        cachedIp2 = InetAddress.getByAddress(IPv4.toIPv4AddressBytes(cachedStrIp2));
+
         sw1Dpid = 1L;
         sw1Inport = 1;
         sw1Outport = 2;
@@ -247,12 +237,13 @@
     }
 
     private void prepareExpectForStartUp() {
-        try {
-            PowerMock.expectNew(ArpCache.class).andReturn(arpCache);
-        } catch (Exception e) {
-            fail("Exception:" + e.getMessage());
-        }
-        PowerMock.replayAll();
+        // XXX Commented out as workaround for PowerMock + Hazelcast issue.
+//        try {
+//            PowerMock.expectNew(ArpCache.class).andReturn(arpCache);
+//        } catch (Exception e) {
+//            fail("Exception:" + e.getMessage());
+//        }
+//        PowerMock.replayAll();
         EasyMock.expect(configInfoService.getVlan()).andReturn(vlanId);
         restApiService.addRestletRoutable(EasyMock.isA(ArpWebRoutable.class));
         EasyMock.expectLastCall();
@@ -339,6 +330,10 @@
                 eg, el, dev1, inPort1, sw1);
         arpManager.init(context);
         arpManager.startUp(context);
+
+        // XXX workaround for PowerMock + Hazelcast issue.
+        this.arpManager.debugReplaceArpCache(arpCache);
+
         MACAddress mac = arpManager.getMacAddress(cachedIp1);
         assertEquals(cachedMac1, mac);
     }