cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [21/53] [abbrv] git commit: updated refs/heads/reporter to 5c99784
Date Wed, 15 Apr 2015 08:05:21 GMT
findbugs: pattern in used in split method

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/67719b1b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/67719b1b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/67719b1b

Branch: refs/heads/reporter
Commit: 67719b1be068c8e58e604fb3c255f946ed0c7d5c
Parents: 6f2fb92
Author: Daan Hoogland <dhoogland@schubergphilis.com>
Authored: Sun Apr 12 20:57:20 2015 +0200
Committer: Daan Hoogland <dhoogland@schubergphilis.com>
Committed: Sun Apr 12 20:57:20 2015 +0200

----------------------------------------------------------------------
 .../network/bigswitch/BigSwitchBcfUtils.java    |  4 +-
 .../bigswitch/BigSwitchBcfUtilsTest.java        | 74 ++++++++++++++++++++
 2 files changed, 77 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67719b1b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java
b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java
index 676275a..242089f 100644
--- a/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java
+++ b/plugins/network-elements/bigswitch/src/com/cloud/network/bigswitch/BigSwitchBcfUtils.java
@@ -528,11 +528,13 @@ public class BigSwitchBcfUtils {
         }
     }
 
+    // returns null: should throw something^%*%#&
+    // Integer -> int
     public Integer getSubnetMaskLength(String maskString){
         if(!IPAddress.isValidIPv4(maskString)){
             return null;
         }
-        String[] octets = maskString.split(".");
+        String[] octets = maskString.split("\\.");
         Integer bits = 0;
         for (String o: octets){
             switch(o){

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67719b1b/plugins/network-elements/bigswitch/test/com/cloud/network/bigswitch/BigSwitchBcfUtilsTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/bigswitch/test/com/cloud/network/bigswitch/BigSwitchBcfUtilsTest.java
b/plugins/network-elements/bigswitch/test/com/cloud/network/bigswitch/BigSwitchBcfUtilsTest.java
new file mode 100644
index 0000000..3433f8c
--- /dev/null
+++ b/plugins/network-elements/bigswitch/test/com/cloud/network/bigswitch/BigSwitchBcfUtilsTest.java
@@ -0,0 +1,74 @@
+package com.cloud.network.bigswitch;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.dc.dao.VlanDao;
+import com.cloud.host.dao.HostDao;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.dao.BigSwitchBcfDao;
+import com.cloud.network.dao.FirewallRulesCidrsDao;
+import com.cloud.network.dao.FirewallRulesDao;
+import com.cloud.network.dao.IPAddressDao;
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.vpc.NetworkACLItemCidrsDao;
+import com.cloud.network.vpc.NetworkACLItemDao;
+import com.cloud.network.vpc.dao.VpcDao;
+import com.cloud.vm.dao.NicDao;
+import com.cloud.vm.dao.VMInstanceDao;
+
+public class BigSwitchBcfUtilsTest {
+
+    @Mock
+    NetworkDao networkDao;
+    @Mock
+    NicDao nicDao;
+    @Mock
+    VMInstanceDao vmDao;
+    @Mock
+    HostDao hostDao;
+    @Mock
+    VpcDao vpcDao;
+    @Mock
+    BigSwitchBcfDao bigswitchBcfDao;
+    @Mock
+    AgentManager agentMgr;
+    @Mock
+    VlanDao vlanDao;
+    @Mock
+    IPAddressDao ipAddressDao;
+    @Mock
+    FirewallRulesDao fwRulesDao;
+    @Mock
+    FirewallRulesCidrsDao fwCidrsDao;
+    @Mock
+    NetworkACLItemDao aclItemDao;
+    @Mock
+    NetworkACLItemCidrsDao aclItemCidrsDao;
+    @Mock
+    NetworkModel networkModel;
+    @Mock
+    BigSwitchBcfUtils bsUtil;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        bsUtil = new BigSwitchBcfUtils(networkDao, nicDao, vmDao, hostDao,
+                vpcDao, bigswitchBcfDao, agentMgr, vlanDao, ipAddressDao,
+                fwRulesDao, fwCidrsDao, aclItemDao, aclItemCidrsDao,
+                networkModel);
+    }
+
+    @Test
+    public void getSubnetMaskLengthTest() {
+        Integer rc = bsUtil.getSubnetMaskLength("255.255.255.254");
+        assertEquals("failed", new Integer(31), rc);
+        rc = bsUtil.getSubnetMaskLength("128.255.255.254");
+        assertEquals("failed", new Integer(1), rc);
+    }
+}


Mime
View raw message