Package org.jclouds.trmk.vcloud_0_8.domain.internal

Examples of org.jclouds.trmk.vcloud_0_8.domain.internal.ErrorImpl


      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

   public void testTerremark() {
      InputStream is = getClass().getResourceAsStream("/catalog.xml");
      injector = Guice.createInjector(new SaxParserModule());
      factory = injector.getInstance(ParseSax.Factory.class);
      Catalog result = factory.create(injector.getInstance(CatalogHandler.class)).parse(is);
      assertEquals(result.getName(), "Miami Environment 1");
      assert result.getDescription() == null;

      assertEquals(result.getHref(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"));
      assertEquals(
            result.get("CentOS 5.3 (32-bit)"),
            new ReferenceTypeImpl("CentOS 5.3 (32-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/5")));
      assertEquals(
            result.get("CentOS 5.3 (64-bit)"),
            new ReferenceTypeImpl("CentOS 5.3 (64-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/6")));
      assertEquals(
            result.get("RHEL 5.3 (32-bit)"),
            new ReferenceTypeImpl("RHEL 5.3 (32-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/7")));
      assertEquals(
            result.get("RHEL 5.3 (64-bit)"),
            new ReferenceTypeImpl("RHEL 5.3 (64-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/8")));
      assertEquals(result.get("Ubuntu JeOS 9.04 (32-bit)"), new ReferenceTypeImpl("Ubuntu JeOS 9.04 (32-bit)",
            CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/11")));
      assertEquals(result.get("Ubuntu JeOS 9.04 (64-bit)"), new ReferenceTypeImpl("Ubuntu JeOS 9.04 (64-bit)",
            CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/12")));
      assertEquals(result.get("Ubuntu Server 9.04 (32-bit)"), new ReferenceTypeImpl("Ubuntu Server 9.04 (32-bit)",
            CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/9")));
      assertEquals(result.get("Ubuntu Server 9.04 (64-bit)"), new ReferenceTypeImpl("Ubuntu Server 9.04 (64-bit)",
            CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/10")));
      assertEquals(
            result.get("Windows 2003 Enterprise R2 (32-bit)"),
            new ReferenceTypeImpl("Windows 2003 Enterprise R2 (32-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/1")));
      assertEquals(
            result.get("Windows 2003 Enterprise R2 (64-bit)"),
            new ReferenceTypeImpl("Windows 2003 Enterprise R2 (64-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/2")));
      assertEquals(
            result.get("Windows 2003 Standard R2 (32-bit)"),
            new ReferenceTypeImpl("Windows 2003 Standard R2 (32-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/3")));
      assertEquals(
            result.get("Windows 2003 Standard R2 (64-bit)"),
            new ReferenceTypeImpl("Windows 2003 Standard R2 (64-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/4")));
      assertEquals(
            result.get("Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)"),
            new ReferenceTypeImpl("Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/23")));
      assertEquals(
            result.get("Windows Server 2008 Enterprise (32-bit)"),
            new ReferenceTypeImpl("Windows Server 2008 Enterprise (32-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/13")));
      assertEquals(
            result.get("Windows Server 2008 Enterprise (64-bit)"),
            new ReferenceTypeImpl("Windows Server 2008 Enterprise (64-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/15")));
      assertEquals(
            result.get("Windows Server 2008 Enterprise R2 (64-bit)"),
            new ReferenceTypeImpl("Windows Server 2008 Enterprise R2 (64-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/16")));
      assertEquals(
            result.get("Windows Server 2008 Standard (32-bit)"),
            new ReferenceTypeImpl("Windows Server 2008 Standard (32-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/17")));
      assertEquals(
            result.get("Windows Server 2008 Standard (64-bit)"),
            new ReferenceTypeImpl("Windows Server 2008 Standard (64-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/18")));
      assertEquals(
            result.get("Windows Server 2008 Standard R2 (64-bit)"),
            new ReferenceTypeImpl("Windows Server 2008 Standard R2 (64-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/19")));
      assertEquals(
            result.get("Windows Server 2008 Standard w.SQL 2008 Web (64-bit)"),
            new ReferenceTypeImpl("Windows Server 2008 Standard w.SQL 2008 Web (64-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/14")));
      assertEquals(
            result.get("Windows Web Server 2008 (32-bit)"),
            new ReferenceTypeImpl("Windows Web Server 2008 (32-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/20")));
      assertEquals(
            result.get("Windows Web Server 2008 (64-bit)"),
            new ReferenceTypeImpl("Windows Web Server 2008 (64-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/21")));
      assertEquals(
            result.get("Windows Web Server 2008 R2 (64-bit)"),
            new ReferenceTypeImpl("Windows Web Server 2008 R2 (64-bit)", CATALOGITEM_XML, URI
                  .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22")));
   }
View Full Code Here

   public void test1() throws UnknownHostException {
      InputStream is = getClass().getResourceAsStream(
            "/CustomizationParameters.xml");

      CustomizationParameters result = factory
            .create(injector.getInstance(CustomizationParametersHandler.class))
            .parse(is);
      assertEquals(result, new CustomizationParameters(true, false, false));
   }
View Full Code Here

      return returnVal.equals("") ? null : returnVal;
   }

   @Override
   public CustomizationParameters getResult() {
      return new CustomizationParameters(customizeNetwork, customizePassword, customizeSSH);
   }
View Full Code Here

   public void test() throws UnknownHostException {
      InputStream is = getClass().getResourceAsStream("/InternetServices.xml");

      Set<InternetService> result = factory.create(injector.getInstance(InternetServicesHandler.class)).parse(is);
      assertEquals(result.toString(), ImmutableSet.of(new InternetService("IS_for_Jim2", URI
               .create("https://services.vcloudexpress.terremark.com/api/v0.8/InternetServices/524"),
               new PublicIpAddress("10.1.22.159", URI
                        .create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/4208")), 45,
               Protocol.HTTP, false, 1, "Some test service")).toString());
   }
View Full Code Here

TOP

Related Classes of org.jclouds.trmk.vcloud_0_8.domain.internal.ErrorImpl

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.