Return-Path: X-Original-To: apmail-cloudstack-dev-archive@www.apache.org Delivered-To: apmail-cloudstack-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7453117469 for ; Fri, 25 Sep 2015 16:01:39 +0000 (UTC) Received: (qmail 99353 invoked by uid 500); 25 Sep 2015 16:01:38 -0000 Delivered-To: apmail-cloudstack-dev-archive@cloudstack.apache.org Received: (qmail 99302 invoked by uid 500); 25 Sep 2015 16:01:38 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 99282 invoked by uid 99); 25 Sep 2015 16:01:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Sep 2015 16:01:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3E29EDFE2E; Fri, 25 Sep 2015 16:01:38 +0000 (UTC) From: borisroman To: dev@cloudstack.apache.org Reply-To: dev@cloudstack.apache.org References: In-Reply-To: Subject: [GitHub] cloudstack pull request: [BLOCKER] Combined PRs that fix VR issues Content-Type: text/plain Message-Id: <20150925160138.3E29EDFE2E@git1-us-west.apache.org> Date: Fri, 25 Sep 2015 16:01:38 +0000 (UTC) Github user borisroman commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/887#discussion_r40445748 --- Diff: server/test/com/cloud/network/firewall/FirewallManagerTest.java --- @@ -151,4 +182,38 @@ public void testApplyFWRules() { } } + @Test + public void testDetectRulesConflict() { + List ruleList = new ArrayList(); + FirewallRuleVO rule1 = spy(new FirewallRuleVO("rule1", 3, 500, "UDP", 1, 2, 1, Purpose.Vpn, null, null, null, null)); + FirewallRuleVO rule2 = spy(new FirewallRuleVO("rule2", 3, 1701, "UDP", 1, 2, 1, Purpose.Vpn, null, null, null, null)); + FirewallRuleVO rule3 = spy(new FirewallRuleVO("rule3", 3, 4500, "UDP", 1, 2, 1, Purpose.Vpn, null, null, null, null)); + + ruleList.add(rule1); + ruleList.add(rule2); + ruleList.add(rule3); + + FirewallManagerImpl firewallMgr = (FirewallManagerImpl)_firewallMgr; + + when(firewallMgr._firewallDao.listByIpAndPurposeAndNotRevoked(3,null)).thenReturn(ruleList); + when(rule1.getId()).thenReturn(1L); + when(rule2.getId()).thenReturn(2L); + when(rule3.getId()).thenReturn(3L); + + FirewallRule newRule1 = new FirewallRuleVO("newRule1", 3, 500, "TCP", 1, 2, 1, Purpose.PortForwarding, null, null, null, null); + FirewallRule newRule2 = new FirewallRuleVO("newRule2", 3, 1701, "TCP", 1, 2, 1, Purpose.PortForwarding, null, null, null, null); + FirewallRule newRule3 = new FirewallRuleVO("newRule3", 3, 4500, "TCP", 1, 2, 1, Purpose.PortForwarding, null, null, null, null); + + try { + firewallMgr.detectRulesConflict(newRule1); + firewallMgr.detectRulesConflict(newRule2); + firewallMgr.detectRulesConflict(newRule3); + } + catch (NetworkRuleConflictException ex) { + Assert.fail(); --- End diff -- It's better to not have the try catch structure in a test. If a test throws an exceptions it will automatically be handled as failure. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---