PageRenderTime 25ms CodeModel.GetById 28ms RepoModel.GetById 5ms app.codeStats 0ms

/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java

https://github.com/mattstep/jclouds
Java | 87 lines | 54 code | 11 blank | 22 comment | 11 complexity | 4ba327f02cdc81d95ccc14a60ef13ac3 MD5 | raw file
  1. /**
  2. * Licensed to jclouds, Inc. (jclouds) under one or more
  3. * contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. jclouds licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. 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,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. package org.jclouds.rackspace.cloudservers.compute;
  20. import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
  21. import static org.testng.Assert.assertEquals;
  22. import java.util.Set;
  23. import org.jclouds.compute.domain.OsFamily;
  24. import org.jclouds.compute.domain.OsFamilyVersion64Bit;
  25. import org.jclouds.compute.domain.Template;
  26. import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest;
  27. import org.testng.annotations.Test;
  28. import com.google.common.base.Predicate;
  29. import com.google.common.base.Predicates;
  30. import com.google.common.collect.ImmutableSet;
  31. /**
  32. *
  33. * @author Adrian Cole
  34. */
  35. @Test(groups = "live")
  36. public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
  37. public CloudServersUSTemplateBuilderLiveTest() {
  38. provider = "cloudservers-us";
  39. }
  40. @Override
  41. protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
  42. return Predicates.not(new Predicate<OsFamilyVersion64Bit>() {
  43. @Override
  44. public boolean apply(OsFamilyVersion64Bit input) {
  45. switch (input.family) {
  46. case UBUNTU:
  47. return (input.version.equals("") || input.version.matches("1[012].04") || input.version.startsWith("11"))
  48. && input.is64Bit;
  49. case DEBIAN:
  50. return input.is64Bit && !input.version.equals("5.0");
  51. case CENTOS:
  52. return (input.version.equals("") || input.version.matches("5.[60]") || input.version.equals("6.0"))
  53. && input.is64Bit;
  54. case WINDOWS:
  55. return input.version.equals("2008 SP2") || input.version.equals("")
  56. || (input.version.equals("2008 R2") && input.is64Bit);
  57. default:
  58. return false;
  59. }
  60. }
  61. });
  62. }
  63. @Test
  64. public void testTemplateBuilder() {
  65. Template defaultTemplate = this.view.getComputeService().templateBuilder().build();
  66. assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
  67. assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "12.04");
  68. assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
  69. assertEquals(defaultTemplate.getLocation().getId(), provider);
  70. assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
  71. }
  72. @Override
  73. protected Set<String> getIso3166Codes() {
  74. return ImmutableSet.<String> of("US-IL", "US-TX");
  75. }
  76. }