brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjcorbett <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Ported some Clocker changes back ...
Date Tue, 15 Dec 2015 12:42:32 GMT
Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/1101#discussion_r47630831
  
    --- Diff: locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/networking/JcloudsLocationSecurityGroupCustomizerTest.java
---
    @@ -147,6 +149,59 @@ public void testAddPermissionsToNode() {
         }
     
         @Test
    +    public void testRemovePermissionsFromNode() {
    +        IpPermission ssh = newPermission(22);
    +        IpPermission jmx = newPermission(31001);
    +        String nodeId = "node";
    +        SecurityGroup sharedGroup = newGroup(customizer.getNameForSharedSecurityGroup());
    +        SecurityGroup group = newGroup("id");
    +        when(securityApi.listSecurityGroupsForNode(nodeId)).thenReturn(ImmutableSet.of(sharedGroup,
group));
    +        when(computeService.getContext().unwrap().getId()).thenReturn("aws-ec2");
    +
    +        customizer.addPermissionsToLocation(ImmutableList.of(ssh, jmx), nodeId, computeService);
    +        customizer.removePermissionsFromLocation(ImmutableList.of(jmx), nodeId, computeService);
    +
    +        verify(securityApi, never()).removeIpPermission(ssh, group);
    +        verify(securityApi, times(1)).removeIpPermission(jmx, group);
    +    }
    +
    +    @Test
    +    public void testRemoveMultiplePermissionsFromNode() {
    +        IpPermission ssh = newPermission(22);
    +        IpPermission jmx = newPermission(31001);
    +        String nodeId = "node";
    +        SecurityGroup sharedGroup = newGroup(customizer.getNameForSharedSecurityGroup());
    +        SecurityGroup group = newGroup("id");
    +        when(securityApi.listSecurityGroupsForNode(nodeId)).thenReturn(ImmutableSet.of(sharedGroup,
group));
    +        when(computeService.getContext().unwrap().getId()).thenReturn("aws-ec2");
    +
    +        customizer.addPermissionsToLocation(ImmutableList.of(ssh, jmx), nodeId, computeService);
    +        customizer.removePermissionsFromLocation(ImmutableList.of(ssh, jmx), nodeId,
computeService);
    +
    +        verify(securityApi, times(1)).removeIpPermission(ssh, group);
    +        verify(securityApi, times(1)).removeIpPermission(jmx, group);
    +    }
    +
    +
    +    @Test
    +    public void testAddPermissionWhenNoExtension() {
    +        IpPermission ssh = newPermission(22);
    +        IpPermission jmx = newPermission(31001);
    +        String nodeId = "node";
    +
    +        when(securityApi.listSecurityGroupsForNode(nodeId)).thenReturn(Collections.<SecurityGroup>emptySet());
    +
    +        RuntimeException exception = null;
    +        try {
    +            customizer.addPermissionsToLocation(ImmutableList.of(ssh, jmx), nodeId, computeService);
    --- End diff --
    
    The approach we generally take is to `fail("should have thrown some exception")` after
the exceptional statement and then to assert on the exception in the catch block. You can
also use `Exceptions.getFirstInteresting(e)` and the recent additions of `shouldHaveFailedPreviously()`
and `expectedFailure()` to the `Asserts` class.


---
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.
---

Mime
View raw message