PageRenderTime 35ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java

https://github.com/regularfry/jclouds
Java | 89 lines | 56 code | 11 blank | 22 comment | 14 complexity | 12a3c41353e0b3c41f99b25f61a3839a 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.slicehost.compute;
  20. import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
  21. import static org.testng.Assert.assertEquals;
  22. import java.io.IOException;
  23. import java.util.Set;
  24. import org.jclouds.compute.BaseTemplateBuilderLiveTest;
  25. import org.jclouds.compute.domain.OsFamily;
  26. import org.jclouds.compute.domain.OsFamilyVersion64Bit;
  27. import org.jclouds.compute.domain.Template;
  28. import org.testng.annotations.Test;
  29. import com.google.common.base.Predicate;
  30. import com.google.common.base.Predicates;
  31. import com.google.common.collect.ImmutableSet;
  32. /**
  33. *
  34. * @author Adrian Cole
  35. */
  36. @Test(groups = "live")
  37. public class SlicehostTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
  38. public SlicehostTemplateBuilderLiveTest() {
  39. provider = "slicehost";
  40. }
  41. @Override
  42. protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
  43. return Predicates.not(new Predicate<OsFamilyVersion64Bit>() {
  44. @Override
  45. public boolean apply(OsFamilyVersion64Bit input) {
  46. switch (input.family) {
  47. case UBUNTU:
  48. return !(input.version.startsWith("11.10") || input.version.equals("8.04") || (input.version
  49. .equals("11.04") && !input.is64Bit));
  50. case DEBIAN:
  51. return !(input.version.equals("6.0") && !input.is64Bit);
  52. case RHEL:
  53. return input.version.equals("") && input.is64Bit;
  54. case CENTOS:
  55. return input.version.equals("") || input.version.matches("5.[45]")
  56. || (input.version.equals("5.0") && input.is64Bit);
  57. case WINDOWS:
  58. return input.version.equals("") || (input.version.equals("2008 SP2") && !input.is64Bit)
  59. || input.version.equals("") || (input.version.equals("2008 R2") && input.is64Bit);
  60. default:
  61. return false;
  62. }
  63. }
  64. });
  65. }
  66. @Test
  67. public void testDefaultTemplateBuilder() throws IOException {
  68. Template defaultTemplate = context.getComputeService().templateBuilder().build();
  69. assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.04");
  70. assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
  71. assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
  72. assertEquals(getCores(defaultTemplate.getHardware()), 0.25d);
  73. }
  74. @Override
  75. protected Set<String> getIso3166Codes() {
  76. return ImmutableSet.<String> of("US-IL", "US-TX", "US-MO");
  77. }
  78. }