Examples of EC2Client


Examples of org.jclouds.ec2.EC2Client

   @SuppressWarnings("unchecked")
   @Test(expectedExceptions = ExecutionException.class)
   public void testApplyNoSuchElementExceptionMakesExecutionException() throws ExecutionException {

      EC2ImageParser parser = createMock(EC2ImageParser.class);
      EC2Client caller = createMock(EC2Client.class);
      AMIClient client = createMock(AMIClient.class);

      org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class);
      Image image = createNiceMock(Image.class);
      Set<? extends org.jclouds.ec2.domain.Image> images = ImmutableSet.<org.jclouds.ec2.domain.Image> of(ec2Image);

      expect(caller.getAMIServices()).andReturn(client).atLeastOnce();
      expect(client.describeImagesInRegion("region", imageIds("ami"))).andReturn(Set.class.cast(images));
      expect(parser.apply(ec2Image)).andThrow(new NoSuchElementException());

      replay(caller);
      replay(image);
View Full Code Here

Examples of org.jclouds.ec2.EC2Client

@Test(groups = "unit", singleThreaded = true, testName = "LoadPublicIpForInstanceOrNullTest")
public class LoadPublicIpForInstanceOrNullTest {

   @Test
   public void testReturnsPublicIpOnMatch() throws Exception {
      EC2Client client = createMock(EC2Client.class);
      ElasticIPAddressClient ipClient = createMock(ElasticIPAddressClient.class);

      expect(client.getElasticIPAddressServices()).andReturn(ipClient).atLeastOnce();
      expect(ipClient.describeAddressesInRegion("region")).andReturn(
               ImmutableSet.<PublicIpInstanceIdPair> of(new PublicIpInstanceIdPair("region", "1.1.1.1", "i-blah")))
               .atLeastOnce();

      replay(client);
View Full Code Here

Examples of org.jclouds.ec2.EC2Client

      verify(ipClient);
   }

   @Test
   public void testReturnsNullWhenNotFound() throws Exception {
      EC2Client client = createMock(EC2Client.class);
      ElasticIPAddressClient ipClient = createMock(ElasticIPAddressClient.class);

      expect(client.getElasticIPAddressServices()).andReturn(ipClient).atLeastOnce();

      expect(ipClient.describeAddressesInRegion("region")).andReturn(ImmutableSet.<PublicIpInstanceIdPair> of())
               .atLeastOnce();

      replay(client);
View Full Code Here

Examples of org.jclouds.ec2.EC2Client

   }

   @Test
   public void testReturnsNullWhenNotAssigned() throws Exception {
      EC2Client client = createMock(EC2Client.class);
      ElasticIPAddressClient ipClient = createMock(ElasticIPAddressClient.class);

      expect(client.getElasticIPAddressServices()).andReturn(ipClient).atLeastOnce();

      expect(ipClient.describeAddressesInRegion("region")).andReturn(
               ImmutableSet.<PublicIpInstanceIdPair> of(new PublicIpInstanceIdPair("region", "1.1.1.1", null)))
               .atLeastOnce();
View Full Code Here

Examples of org.jclouds.ec2.EC2Client

@Test(groups = "unit", testName = "CreateUniqueKeyPairTest")
public class CreateUniqueKeyPairTest {
  
   @Test
   public void testApply() throws UnknownHostException {
      final EC2Client client = createMock(EC2Client.class);
      KeyPairClient keyClient = createMock(KeyPairClient.class);
      KeyPair pair = createMock(KeyPair.class);

      expect(client.getKeyPairServices()).andReturn(keyClient).atLeastOnce();

      expect(keyClient.createKeyPairInRegion("region", "jclouds#group#1")).andReturn(pair);

      replay(client);
      replay(keyClient);
View Full Code Here

Examples of org.jclouds.ec2.EC2Client

   }

   @SuppressWarnings( { "unchecked" })
   @Test
   public void testApplyWithIllegalStateException() throws UnknownHostException {
      final EC2Client client = createMock(EC2Client.class);
      KeyPairClient keyClient = createMock(KeyPairClient.class);
      final Supplier<String> uniqueIdSupplier = createMock(Supplier.class);

      KeyPair pair = createMock(KeyPair.class);

      expect(client.getKeyPairServices()).andReturn(keyClient).atLeastOnce();

      expect(uniqueIdSupplier.get()).andReturn("1");
      expect(keyClient.createKeyPairInRegion("region", "jclouds#group#1")).andThrow(new IllegalStateException());
      expect(uniqueIdSupplier.get()).andReturn("2");
      expect(keyClient.createKeyPairInRegion("region", "jclouds#group#2")).andReturn(pair);
View Full Code Here

Examples of org.jclouds.ec2.EC2Client

   @SuppressWarnings("unchecked")
   @Test
   public void testWhenInstancesPresentSingleCall() {

      EC2Client client = createMock(EC2Client.class);
      InstanceClient instanceClient = createMock(InstanceClient.class);

      expect(client.getInstanceServices()).andReturn(instanceClient);

      // avoid imatcher fail.  if you change this, be sure to check multiple jres
      expect(instanceClient.describeInstancesInRegion("us-east-1", "i-aaaa", "i-bbbb")).andReturn(
            Set.class.cast(ImmutableSet.of(Reservation.builder().region("us-east-1")
                  .instances(ImmutableSet.of(instance1, instance2)).build())));
View Full Code Here

Examples of org.jclouds.ec2.EC2Client

         assertFalse(InetAddresses2.isPrivateIPAddress(ip));
         HostAndPort socket = HostAndPort.fromParts(ip, 22);
         assertTrue(socketTester.apply(socket), String.format("failed to open socket %s on node %s", socket, node));

         // check that there is an elastic ip correlating to it
         EC2Client ec2 = EC2Client.class.cast(context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi());
         Set<PublicIpInstanceIdPair> ipidpairs =
               ec2.getElasticIPAddressServices().describeAddressesInRegion(region, publicIps.toArray(new String[0]));
         assertEquals(ipidpairs.size(), 1, String.format("there should only be one address pair (%s)",
               Iterables.toString(ipidpairs)));

         // check that the elastic ip is in node.publicAddresses
         PublicIpInstanceIdPair ipidpair = Iterables.get(ipidpairs, 0);
         assertEquals(region + "/" + ipidpair.getInstanceId(), node.getId());
        
         // delete the node
         context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));

         // check that the ip is deallocated
         Set<PublicIpInstanceIdPair> ipidcheck =
                 ec2.getElasticIPAddressServices().describeAddressesInRegion(region, ipidpair.getPublicIp());
         assertTrue(Iterables.isEmpty(ipidcheck), String.format("there should be no address pairs (%s)",
               Iterables.toString(ipidcheck)));
      } finally {
         context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
         if (context != null)
View Full Code Here

Examples of org.jclouds.ec2.EC2Client

      verify(strategy.utils);
   }

   @SuppressWarnings("unchecked")
   private EC2CreateNodesInGroupThenAddToSet setupStrategy(final NodeMetadata node) {
      EC2Client client = createMock(EC2Client.class);
      CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions createKeyPairAndSecurityGroupsAsNeededAndReturncustomize = createMock(CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class);
      PresentInstances presentInstances = createMock(PresentInstances.class);
      RunningInstanceToNodeMetadata runningInstanceToNodeMetadata = createMock(RunningInstanceToNodeMetadata.class);
      LoadingCache<RunningInstance, Optional<LoginCredentials>> instanceToCredentials = createMock(LoadingCache.class);
      LoadingCache<RegionAndName, String> elasticIpCache = createMock(LoadingCache.class);
View Full Code Here

Examples of org.jclouds.ec2.EC2Client

public class EC2DestroyNodeStrategyTest {

   @SuppressWarnings("unchecked")
   @Test
   public void testDestroyNodeTerminatesInstanceAndReturnsRefreshedNode() throws Exception {
      EC2Client client = createMock(EC2Client.class);
      InstanceClient instanceClient = createMock(InstanceClient.class);
      GetNodeMetadataStrategy getNode = createMock(GetNodeMetadataStrategy.class);
      LoadingCache<RegionAndName, String> elasticIpCache = createMock(LoadingCache.class);

      NodeMetadata node = createMock(NodeMetadata.class);

      expect(client.getInstanceServices()).andReturn(instanceClient).atLeastOnce();
      expect(instanceClient.terminateInstancesInRegion("region", "i-blah")).andReturn(null);
      expect(getNode.getNode("region/i-blah")).andReturn(node);

      replay(client);
      replay(getNode);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.