You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by io...@apache.org on 2011/05/19 19:37:41 UTC

svn commit: r1125012 - in /karaf/cellar/trunk/hazelcast/src: main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java

Author: iocanel
Date: Thu May 19 17:37:41 2011
New Revision: 1125012

URL: http://svn.apache.org/viewvc?rev=1125012&view=rev
Log:
[KARAF-652] HazelcastServiceFactory now checks for null value the properties passed for building an instance. The test now properly initializes the factory.

Modified:
    karaf/cellar/trunk/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java
    karaf/cellar/trunk/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java

Modified: karaf/cellar/trunk/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java?rev=1125012&r1=1125011&r2=1125012&view=diff
==============================================================================
--- karaf/cellar/trunk/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java (original)
+++ karaf/cellar/trunk/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactory.java Thu May 19 17:37:41 2011
@@ -1,5 +1,19 @@
 /*
  * 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.
+ */
+
+/*
+ * 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
  *
@@ -76,57 +90,58 @@ public class HazelcastServiceFactory imp
             Boolean updated = Boolean.FALSE;
             //We need it to properly instantiate Hazelcast.
             Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+            if (properties != null) {
+                String newUsername = (String) properties.get("username");
+                if (username != null && !username.endsWith(newUsername)) {
+                    this.username = newUsername;
+                    updated = Boolean.TRUE;
+                }
 
-            String newUsername = (String) properties.get("username");
-            if (username != null && !username.endsWith(newUsername)) {
-                this.username = newUsername;
-                updated = Boolean.TRUE;
-            }
-
-            String newPassword = (String) properties.get("password");
-            if (password != null && !password.equals(newPassword)) {
-                this.password = newPassword;
-            }
+                String newPassword = (String) properties.get("password");
+                if (password != null && !password.equals(newPassword)) {
+                    this.password = newPassword;
+                }
 
-            Boolean newMulticastEnabled = Boolean.parseBoolean((String) properties.get("multicastEnabled"));
-            if (multicastEnabled != newMulticastEnabled) {
-                this.multicastEnabled = newMulticastEnabled;
-                updated = Boolean.TRUE;
-            }
+                Boolean newMulticastEnabled = Boolean.parseBoolean((String) properties.get("multicastEnabled"));
+                if (multicastEnabled != newMulticastEnabled) {
+                    this.multicastEnabled = newMulticastEnabled;
+                    updated = Boolean.TRUE;
+                }
 
-            String newMulticastGroup = (String) properties.get("multicastGroup");
-            if (multicastGroup != null && !multicastGroup.endsWith(newMulticastGroup)) {
-                this.multicastGroup = newMulticastGroup;
-                updated = Boolean.TRUE;
-            }
+                String newMulticastGroup = (String) properties.get("multicastGroup");
+                if (multicastGroup != null && !multicastGroup.endsWith(newMulticastGroup)) {
+                    this.multicastGroup = newMulticastGroup;
+                    updated = Boolean.TRUE;
+                }
 
-            int multicastPort = Integer.parseInt((String) properties.get("multicastPort"));
-            if (multicastPort != 0) {
-                this.multicastPort = multicastPort;
-                updated = Boolean.TRUE;
-            }
+                int multicastPort = Integer.parseInt((String) properties.get("multicastPort"));
+                if (multicastPort != 0) {
+                    this.multicastPort = multicastPort;
+                    updated = Boolean.TRUE;
+                }
 
-            int newMulticastTimeoutSeconds = Integer.parseInt((String) properties.get("multicastTimeoutSeconds"));
-            if (multicastTimeoutSeconds != 0 && multicastTimeoutSeconds != newMulticastTimeoutSeconds) {
-                this.multicastTimeoutSeconds = newMulticastTimeoutSeconds;
-                updated = Boolean.TRUE;
-            }
+                int newMulticastTimeoutSeconds = Integer.parseInt((String) properties.get("multicastTimeoutSeconds"));
+                if (multicastTimeoutSeconds != 0 && multicastTimeoutSeconds != newMulticastTimeoutSeconds) {
+                    this.multicastTimeoutSeconds = newMulticastTimeoutSeconds;
+                    updated = Boolean.TRUE;
+                }
 
-            Boolean newTcpIpEnabled = Boolean.parseBoolean((String) properties.get("tcpIpEnabled"));
-            if (tcpIpEnabled != newTcpIpEnabled) {
-                this.tcpIpEnabled = newTcpIpEnabled;
-                updated = Boolean.TRUE;
-            }
+                Boolean newTcpIpEnabled = Boolean.parseBoolean((String) properties.get("tcpIpEnabled"));
+                if (tcpIpEnabled != newTcpIpEnabled) {
+                    this.tcpIpEnabled = newTcpIpEnabled;
+                    updated = Boolean.TRUE;
+                }
 
-            String newTcpIpMembers = (String) properties.get("tcpIpMembers");
-            if (tcpIpMembers != null && !tcpIpMembers.endsWith(newTcpIpMembers)) {
-                updated = Boolean.TRUE;
-
-                String[] members = tcpIpMembers.split(",");
-                if (members != null && members.length > 0) {
-                    tcpIpMemberList = new ArrayList<String>();
-                    for (String member : members) {
-                        tcpIpMemberList.add(member);
+                String newTcpIpMembers = (String) properties.get("tcpIpMembers");
+                if (tcpIpMembers != null && !tcpIpMembers.endsWith(newTcpIpMembers)) {
+                    updated = Boolean.TRUE;
+
+                    String[] members = tcpIpMembers.split(",");
+                    if (members != null && members.length > 0) {
+                        tcpIpMemberList = new ArrayList<String>();
+                        for (String member : members) {
+                            tcpIpMemberList.add(member);
+                        }
                     }
                 }
             }

Modified: karaf/cellar/trunk/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java?rev=1125012&r1=1125011&r2=1125012&view=diff
==============================================================================
--- karaf/cellar/trunk/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java (original)
+++ karaf/cellar/trunk/hazelcast/src/test/java/org/apache/karaf/cellar/hazelcast/factory/HazelcastServiceFactoryTest.java Thu May 19 17:37:41 2011
@@ -32,6 +32,7 @@ public class HazelcastServiceFactoryTest
     public void setUp() throws Exception {
         factory.setUsername(GroupConfig.DEFAULT_GROUP_NAME);
         factory.setPassword(GroupConfig.DEFAULT_GROUP_PASSWORD);
+        factory.createOrUpdate(null);
 
     }
 
@@ -44,7 +45,6 @@ public class HazelcastServiceFactoryTest
     public void testDefaultInstance() throws InterruptedException {
         HazelcastInstance defaultInstance = Hazelcast.newHazelcastInstance(null);
         HazelcastInstance factoryInstance = factory.buildInstance();
-        Thread.sleep(5000);
         Assert.assertEquals(true, factoryInstance.getCluster().getMembers().size() >= 2);
     }
 }