Package org.jclouds.cloudstack.features

Examples of org.jclouds.cloudstack.features.ZoneClient


   @Test
   public void testLoad() throws UnknownHostException {
      final CloudStackClient client = createMock(CloudStackClient.class);
      SecurityGroupClient secClient = createMock(SecurityGroupClient.class);
      ZoneClient zoneClient = createMock(ZoneClient.class);
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);

      expect(group.getIngressRules()).andReturn(ImmutableSet.<IngressRule> of());
      expect(group.getId()).andReturn("sec-1234").anyTimes();
      expect(zone.isSecurityGroupsEnabled()).andReturn(true);
     
      expect(client.getSecurityGroupClient()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneClient()).andReturn(zoneClient);
      expect(client.getAsyncJobClient()).andReturn(jobClient).anyTimes();

      expect(zoneClient.getZone("zone-1")).andReturn(zone);
      expect(secClient.getSecurityGroupByName("group-1")).andReturn(null);
      expect(secClient.createSecurityGroup("group-1")).andReturn(group);
      expect(secClient.authorizeIngressPortsToCIDRs("sec-1234",
                                                    "TCP",
                                                    22,
View Full Code Here


  
   @Test
   public void testLoadAlreadyExists() throws UnknownHostException {
      final CloudStackClient client = createMock(CloudStackClient.class);
      SecurityGroupClient secClient = createMock(SecurityGroupClient.class);
      ZoneClient zoneClient = createMock(ZoneClient.class);
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);
View Full Code Here

   @Test(expectedExceptions = IllegalArgumentException.class)
   public void testLoadZoneNoSecurityGroups() throws UnknownHostException {
      final CloudStackClient client = createMock(CloudStackClient.class);
      SecurityGroupClient secClient = createMock(SecurityGroupClient.class);
      ZoneClient zoneClient = createMock(ZoneClient.class);
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);

      expect(zone.isSecurityGroupsEnabled()).andReturn(false);
     
      expect(client.getSecurityGroupClient()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneClient()).andReturn(zoneClient);
      expect(client.getAsyncJobClient()).andReturn(jobClient).anyTimes();

      expect(zoneClient.getZone("zone-1")).andReturn(zone);
      expect(secClient.getSecurityGroupByName("group-1")).andReturn(null);

      replay(client, secClient, zoneClient, zone, group);

      ZoneSecurityGroupNamePortsCidrs input = ZoneSecurityGroupNamePortsCidrs.builder()
View Full Code Here

   @Test
   public void testApply() throws UnknownHostException {
      final CloudStackClient client = createMock(CloudStackClient.class);
      SecurityGroupClient secClient = createMock(SecurityGroupClient.class);
      ZoneClient zoneClient = createMock(ZoneClient.class);
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);

      expect(group.getIngressRules()).andReturn(ImmutableSet.<IngressRule> of());
      expect(group.getId()).andReturn("sec-1234").anyTimes();
      expect(zone.isSecurityGroupsEnabled()).andReturn(true);
     
      expect(client.getSecurityGroupClient()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneClient()).andReturn(zoneClient);
      expect(client.getAsyncJobClient()).andReturn(jobClient).anyTimes();

      expect(zoneClient.getZone("zone-abc1")).andReturn(zone);
      expect(secClient.createSecurityGroup("group-1")).andReturn(group);
      expect(secClient.authorizeIngressPortsToCIDRs("sec-1234",
                                                    "TCP",
                                                    22,
                                                    22,
View Full Code Here

  
   @Test
   public void testApplyGroupAlreadyExists() throws UnknownHostException {
      final CloudStackClient client = createMock(CloudStackClient.class);
      SecurityGroupClient secClient = createMock(SecurityGroupClient.class);
      ZoneClient zoneClient = createMock(ZoneClient.class);
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);

      expect(group.getId()).andReturn("sec-1234").anyTimes();
      expect(zone.isSecurityGroupsEnabled()).andReturn(true);
     
      expect(client.getSecurityGroupClient()).andReturn(secClient)
         .anyTimes();
      expect(client.getZoneClient()).andReturn(zoneClient);
      expect(client.getAsyncJobClient()).andReturn(jobClient).anyTimes();

      expect(zoneClient.getZone("zone-abc2")).andReturn(zone);
      expect(secClient.createSecurityGroup("group-1")).andThrow(new IllegalStateException());
      expect(secClient.getSecurityGroupByName("group-1")).andReturn(group);

      replay(client, secClient, zoneClient, zone, group);
View Full Code Here

   @Test(expectedExceptions = IllegalArgumentException.class)
   public void testApplyZoneNoSecurityGroups() throws UnknownHostException {
      final CloudStackClient client = createMock(CloudStackClient.class);
      SecurityGroupClient secClient = createMock(SecurityGroupClient.class);
      ZoneClient zoneClient = createMock(ZoneClient.class);
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);
     
      SecurityGroup group = createMock(SecurityGroup.class);
     
      Zone zone = createMock(Zone.class);

      expect(zone.isSecurityGroupsEnabled()).andReturn(false);
     
      expect(client.getZoneClient()).andReturn(zoneClient);

      expect(zoneClient.getZone("zone-abc3")).andReturn(zone);

      replay(client, zoneClient, zone);

      ZoneSecurityGroupNamePortsCidrs input = ZoneSecurityGroupNamePortsCidrs.builder()
         .zone("zone-abc3")
View Full Code Here

        .build());

    @Test
    public void testZonesCommandPrintsZones() throws Exception {
        final ZonesCommand zonesCommand = new ZonesCommand(defaultProviderConfig);
        final ZoneClient zoneClient = mock(ZoneClient.class);
        when(client.getZoneClient()).thenReturn(zoneClient);
        when(zoneClient.listZones()).thenReturn(zones);

        zonesCommand.doExecuteWithContext(client, out);
        out.close();

        final String result = byteArrayOutputStream.toString();
View Full Code Here

        .build());

    @Test
    public void testZonesCommandPrintsZones() throws Exception {
        final ZonesCommand zonesCommand = new ZonesCommand(defaultProviderConfig);
        final ZoneClient zoneClient = mock(ZoneClient.class);
        when(client.getZoneClient()).thenReturn(zoneClient);
        when(zoneClient.listZones()).thenReturn(zones);

        zonesCommand.doExecuteWithContext(client, out);
        out.close();

        final String result = byteArrayOutputStream.toString();
View Full Code Here

TOP

Related Classes of org.jclouds.cloudstack.features.ZoneClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.