PageRenderTime 82ms CodeModel.GetById 45ms RepoModel.GetById 1ms app.codeStats 0ms

/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/CatalogHandlerTest.java

https://github.com/raschyoung/jclouds
Java | 143 lines | 111 code | 9 blank | 23 comment | 1 complexity | 734a106fbc48ff3c4e8c7e48ce26de40 MD5 | raw file
  1. /**
  2. *
  3. * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
  4. *
  5. * ====================================================================
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. * ====================================================================
  18. */
  19. package org.jclouds.trmk.vcloud_0_8.xml;
  20. import static org.jclouds.trmk.vcloud_0_8.TerremarkVCloudMediaType.CATALOGITEM_XML;
  21. import static org.testng.Assert.assertEquals;
  22. import java.io.InputStream;
  23. import java.net.URI;
  24. import org.jclouds.http.functions.ParseSax;
  25. import org.jclouds.http.functions.ParseSax.Factory;
  26. import org.jclouds.http.functions.config.SaxParserModule;
  27. import org.jclouds.trmk.vcloud_0_8.domain.Catalog;
  28. import org.jclouds.trmk.vcloud_0_8.domain.internal.ReferenceTypeImpl;
  29. import org.testng.annotations.Test;
  30. import com.google.inject.Guice;
  31. import com.google.inject.Injector;
  32. /**
  33. * Tests behavior of {@code CatalogHandler}
  34. *
  35. * @author Adrian Cole
  36. */
  37. @Test(groups = "unit")
  38. public class CatalogHandlerTest {
  39. private Injector injector;
  40. private Factory factory;
  41. public void testTerremark() {
  42. InputStream is = getClass().getResourceAsStream("/catalog.xml");
  43. injector = Guice.createInjector(new SaxParserModule());
  44. factory = injector.getInstance(ParseSax.Factory.class);
  45. Catalog result = (Catalog) factory.create(injector.getInstance(CatalogHandler.class)).parse(is);
  46. assertEquals(result.getName(), "Miami Environment 1");
  47. assert result.getDescription() == null;
  48. assertEquals(result.getHref(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"));
  49. assertEquals(
  50. result.get("CentOS 5.3 (32-bit)"),
  51. new ReferenceTypeImpl("CentOS 5.3 (32-bit)", CATALOGITEM_XML, URI
  52. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/5")));
  53. assertEquals(
  54. result.get("CentOS 5.3 (64-bit)"),
  55. new ReferenceTypeImpl("CentOS 5.3 (64-bit)", CATALOGITEM_XML, URI
  56. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/6")));
  57. assertEquals(
  58. result.get("RHEL 5.3 (32-bit)"),
  59. new ReferenceTypeImpl("RHEL 5.3 (32-bit)", CATALOGITEM_XML, URI
  60. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/7")));
  61. assertEquals(
  62. result.get("RHEL 5.3 (64-bit)"),
  63. new ReferenceTypeImpl("RHEL 5.3 (64-bit)", CATALOGITEM_XML, URI
  64. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/8")));
  65. assertEquals(result.get("Ubuntu JeOS 9.04 (32-bit)"), new ReferenceTypeImpl("Ubuntu JeOS 9.04 (32-bit)",
  66. CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/11")));
  67. assertEquals(result.get("Ubuntu JeOS 9.04 (64-bit)"), new ReferenceTypeImpl("Ubuntu JeOS 9.04 (64-bit)",
  68. CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/12")));
  69. assertEquals(result.get("Ubuntu Server 9.04 (32-bit)"), new ReferenceTypeImpl("Ubuntu Server 9.04 (32-bit)",
  70. CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/9")));
  71. assertEquals(result.get("Ubuntu Server 9.04 (64-bit)"), new ReferenceTypeImpl("Ubuntu Server 9.04 (64-bit)",
  72. CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/10")));
  73. assertEquals(
  74. result.get("Windows 2003 Enterprise R2 (32-bit)"),
  75. new ReferenceTypeImpl("Windows 2003 Enterprise R2 (32-bit)", CATALOGITEM_XML, URI
  76. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/1")));
  77. assertEquals(
  78. result.get("Windows 2003 Enterprise R2 (64-bit)"),
  79. new ReferenceTypeImpl("Windows 2003 Enterprise R2 (64-bit)", CATALOGITEM_XML, URI
  80. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/2")));
  81. assertEquals(
  82. result.get("Windows 2003 Standard R2 (32-bit)"),
  83. new ReferenceTypeImpl("Windows 2003 Standard R2 (32-bit)", CATALOGITEM_XML, URI
  84. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/3")));
  85. assertEquals(
  86. result.get("Windows 2003 Standard R2 (64-bit)"),
  87. new ReferenceTypeImpl("Windows 2003 Standard R2 (64-bit)", CATALOGITEM_XML, URI
  88. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/4")));
  89. assertEquals(
  90. result.get("Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)"),
  91. new ReferenceTypeImpl("Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)", CATALOGITEM_XML, URI
  92. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/23")));
  93. assertEquals(
  94. result.get("Windows Server 2008 Enterprise (32-bit)"),
  95. new ReferenceTypeImpl("Windows Server 2008 Enterprise (32-bit)", CATALOGITEM_XML, URI
  96. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/13")));
  97. assertEquals(
  98. result.get("Windows Server 2008 Enterprise (64-bit)"),
  99. new ReferenceTypeImpl("Windows Server 2008 Enterprise (64-bit)", CATALOGITEM_XML, URI
  100. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/15")));
  101. assertEquals(
  102. result.get("Windows Server 2008 Enterprise R2 (64-bit)"),
  103. new ReferenceTypeImpl("Windows Server 2008 Enterprise R2 (64-bit)", CATALOGITEM_XML, URI
  104. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/16")));
  105. assertEquals(
  106. result.get("Windows Server 2008 Standard (32-bit)"),
  107. new ReferenceTypeImpl("Windows Server 2008 Standard (32-bit)", CATALOGITEM_XML, URI
  108. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/17")));
  109. assertEquals(
  110. result.get("Windows Server 2008 Standard (64-bit)"),
  111. new ReferenceTypeImpl("Windows Server 2008 Standard (64-bit)", CATALOGITEM_XML, URI
  112. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/18")));
  113. assertEquals(
  114. result.get("Windows Server 2008 Standard R2 (64-bit)"),
  115. new ReferenceTypeImpl("Windows Server 2008 Standard R2 (64-bit)", CATALOGITEM_XML, URI
  116. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/19")));
  117. assertEquals(
  118. result.get("Windows Server 2008 Standard w.SQL 2008 Web (64-bit)"),
  119. new ReferenceTypeImpl("Windows Server 2008 Standard w.SQL 2008 Web (64-bit)", CATALOGITEM_XML, URI
  120. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/14")));
  121. assertEquals(
  122. result.get("Windows Web Server 2008 (32-bit)"),
  123. new ReferenceTypeImpl("Windows Web Server 2008 (32-bit)", CATALOGITEM_XML, URI
  124. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/20")));
  125. assertEquals(
  126. result.get("Windows Web Server 2008 (64-bit)"),
  127. new ReferenceTypeImpl("Windows Web Server 2008 (64-bit)", CATALOGITEM_XML, URI
  128. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/21")));
  129. assertEquals(
  130. result.get("Windows Web Server 2008 R2 (64-bit)"),
  131. new ReferenceTypeImpl("Windows Web Server 2008 R2 (64-bit)", CATALOGITEM_XML, URI
  132. .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22")));
  133. }
  134. }