Package org.jclouds.trmk.vcloud_0_8

Examples of org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient


      VDC vdc = createMock(VDC.class);
      URI templateURI = URI.create("template");
      URI vdcURI = URI.create("vdc");

      expect(template.getDescription()).andReturn(description).atLeastOnce();
      TerremarkVCloudClient client = createMock(TerremarkVCloudClient.class);
      VApp vApp = createMock(VApp.class);
      InternetServiceAndPublicIpAddressSupplier supplier = createMock(InternetServiceAndPublicIpAddressSupplier.class);
      expect(client.getVAppTemplate(templateURI)).andReturn(template);
      expect(
            client.instantiateVAppTemplateInVDC(vdcURI, templateURI, "name",
                  new InstantiateVAppTemplateOptions().productProperty("password", "password"))).andReturn(vApp);
      Task task = createMock(Task.class);
      URI vappLocation = URI.create("vapp");
      URI taskLocation = URI.create("task");

      expect(vApp.getHref()).andReturn(vappLocation).atLeastOnce();
      expect(vApp.getName()).andReturn("name").atLeastOnce();
      expect(client.deployVApp(vappLocation)).andReturn(task);
      expect(task.getHref()).andReturn(taskLocation).atLeastOnce();
      Predicate<URI> successTester = createMock(Predicate.class);
      expect(successTester.apply(taskLocation)).andReturn(true).atLeastOnce();
      expect(client.powerOnVApp(vappLocation)).andReturn(task);

      Predicate<VApp> notFoundTester = createMock(Predicate.class);
      Map<Status, NodeMetadata.Status> vAppStatusToNodeStatus = createMock(Map.class);

      TerremarkVCloudComputeClient computeClient = new TerremarkVCloudComputeClient(client,
View Full Code Here


   }

   @SuppressWarnings("unchecked")
   private DeleteKeyPair setupStrategy() {
      Map<String, Credentials> credentialStore = createMock(ConcurrentMap.class);
      TerremarkVCloudClient terremarkClient = createMock(TerremarkVCloudClient.class);

      return new DeleteKeyPair(terremarkClient, credentialStore);
   }
View Full Code Here

      VDC vdc = createMock(VDC.class);
      URI templateURI = URI.create("template");
      URI vdcURI = URI.create("vdc");

      expect(template.getDescription()).andReturn(description).atLeastOnce();
      TerremarkVCloudClient client = createMock(TerremarkVCloudClient.class);
      VApp vApp = createMock(VApp.class);
      InternetServiceAndPublicIpAddressSupplier supplier = createMock(InternetServiceAndPublicIpAddressSupplier.class);
      expect(client.getVAppTemplate(templateURI)).andReturn(template);
      expect(
            client.instantiateVAppTemplateInVDC(vdcURI, templateURI, "name",
                  new InstantiateVAppTemplateOptions().productProperty("password", "password"))).andReturn(vApp);
      Task task = createMock(Task.class);
      URI vappLocation = URI.create("vapp");
      URI taskLocation = URI.create("task");

      expect(vApp.getHref()).andReturn(vappLocation).atLeastOnce();
      expect(vApp.getName()).andReturn("name").atLeastOnce();
      expect(client.deployVApp(vappLocation)).andReturn(task);
      expect(task.getHref()).andReturn(taskLocation).atLeastOnce();
      Predicate<URI> successTester = createMock(Predicate.class);
      expect(successTester.apply(taskLocation)).andReturn(true).atLeastOnce();
      expect(client.powerOnVApp(vappLocation)).andReturn(task);

      Predicate<VApp> notFoundTester = createMock(Predicate.class);
      Map<Status, NodeMetadata.Status> vAppStatusToNodeStatus = createMock(Map.class);

      TerremarkVCloudComputeClient computeClient = new TerremarkVCloudComputeClient(client,
View Full Code Here

   }

   @SuppressWarnings("unchecked")
   private DeleteKeyPair setupStrategy() {
      Map<String, Credentials> credentialStore = createMock(ConcurrentMap.class);
      TerremarkVCloudClient terremarkClient = createMock(TerremarkVCloudClient.class);

      return new DeleteKeyPair(terremarkClient, credentialStore);
   }
View Full Code Here

      LoginCredentials keyPairCredentials = LoginCredentials.builder().privateKey(KeyPairHandlerTest.keyPair.getPrivateKey()).build();
      KeyPair keyPair = createMock(KeyPair.class);

      // setup expectations
      expect(strategy.credentialStore.containsKey("group#group")).andReturn(false);
      expect(strategy.createUniqueKeyPair.apply(new OrgAndName(org, "group"))).andReturn(keyPair);
      expect(keyPair.getFingerPrint()).andReturn(KeyPairHandlerTest.keyPair.getFingerPrint()).atLeastOnce();
      expect(strategy.credentialStore.put("group#group", keyPairCredentials)).andReturn(null);

      // replay mocks
      replay(keyPair);
View Full Code Here

   }

   @SuppressWarnings("unchecked")
   private CreateNewKeyPairUnlessUserSpecifiedOtherwise setupStrategy() {
      Map<String, Credentials> credentialStore = createMock(ConcurrentMap.class);
      CreateUniqueKeyPair createUniqueKeyPair = createMock(CreateUniqueKeyPair.class);

      return new CreateNewKeyPairUnlessUserSpecifiedOtherwise(credentialStore, createUniqueKeyPair);
   }
View Full Code Here

   public void testExecuteWithDefaultOptionsAlreadyHasKey() throws SecurityException, NoSuchMethodException {
      // setup constants
      URI org = URI.create("org1");
      String identity = "identity";
      String group = "group";
      TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();

      // create mocks
      CreateNewKeyPairUnlessUserSpecifiedOtherwise strategy = setupStrategy();
      LoginCredentials keyPairCredentials = LoginCredentials.builder().privateKey(KeyPairHandlerTest.keyPair.getPrivateKey()).build();

      // setup expectations
      expect(strategy.credentialStore.containsKey("group#group")).andReturn(true);
      expect(strategy.credentialStore.get("group#group")).andReturn(keyPairCredentials);

      // replay mocks
      replayStrategy(strategy);

      // run
      strategy.execute(org, group, identity, options);
      assertEquals(options.getSshKeyFingerprint(), KeyPairHandlerTest.keyPair.getFingerPrint());

      // verify mocks
      verifyStrategy(strategy);
   }
View Full Code Here

   public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_reusesKeyWhenToldTo() {
      // setup constants
      URI org = URI.create("org1");
      String identity = "identity";
      String group = "group";
      TerremarkVCloudTemplateOptions options = sshKeyFingerprint("fingerprintFromUser");

      // create mocks
      CreateNewKeyPairUnlessUserSpecifiedOtherwise strategy = setupStrategy();

      // setup expectations

      // replay mocks
      replayStrategy(strategy);

      // run
      strategy.execute(org, group, identity, options);
      assertEquals(options.getSshKeyFingerprint(), "fingerprintFromUser");

      // verify mocks
      verifyStrategy(strategy);
   }
View Full Code Here

      // setup constants
      URI org = URI.create("org1");
      String identity = "identity";
      String group = "group";
      String systemGeneratedFingerprint = "systemGeneratedKeyPairfinger";
      TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();

      // create mocks
      CreateNewKeyPairUnlessUserSpecifiedOtherwise strategy = setupStrategy();
      LoginCredentials keyPairCredentials = LoginCredentials.builder().privateKey(KeyPairHandlerTest.keyPair.getPrivateKey()).build();
      KeyPair keyPair = createMock(KeyPair.class);

      // setup expectations
      expect(strategy.credentialStore.containsKey("group#group")).andReturn(false);
      expect(strategy.createUniqueKeyPair.apply(new OrgAndName(org, "group"))).andReturn(keyPair);
      expect(keyPair.getFingerPrint()).andReturn(KeyPairHandlerTest.keyPair.getFingerPrint()).atLeastOnce();
      expect(strategy.credentialStore.put("group#group", keyPairCredentials)).andReturn(null);

      // replay mocks
      replay(keyPair);
      replayStrategy(strategy);

      // run
      strategy.execute(org, group, identity, options);
      assertEquals(options.getSshKeyFingerprint(), systemGeneratedFingerprint);

      // verify mocks
      verify(keyPair);
      verifyStrategy(strategy);
   }
View Full Code Here

   public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_doesntCreateAKeyPairAndReturnsNullWhenToldNotTo() {
      // setup constants
      URI org = URI.create("org1");
      String identity = "identity";
      String group = "group";
      TerremarkVCloudTemplateOptions options = noKeyPair();

      // create mocks
      CreateNewKeyPairUnlessUserSpecifiedOtherwise strategy = setupStrategy();

      // setup expectations

      // replay mocks
      replayStrategy(strategy);

      // run
      strategy.execute(org, group, identity, options);
      assertEquals(options.getSshKeyFingerprint(), null);

      // verify mocks
      verifyStrategy(strategy);
   }
View Full Code Here

TOP

Related Classes of org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient

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.