PageRenderTime 36ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java

https://github.com/regularfry/jclouds
Java | 85 lines | 52 code | 11 blank | 22 comment | 9 complexity | 2d05ff6ceadcd8c202bee7bc2aea4a86 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.deltacloud.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.BaseTemplateBuilderLiveTest;
  24. import org.jclouds.compute.domain.OsFamily;
  25. import org.jclouds.compute.domain.OsFamilyVersion64Bit;
  26. import org.jclouds.compute.domain.Template;
  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 DeltacloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
  37. public DeltacloudTemplateBuilderLiveTest() {
  38. provider = "deltacloud";
  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.startsWith("11") || input.version.equals("8.04")) && input.is64Bit;
  48. case DEBIAN:
  49. return !(input.version.equals("6.0")) && input.is64Bit;
  50. case CENTOS:
  51. return !(input.version.matches("5.[023]") || input.version.equals("8.04")) && input.is64Bit;
  52. case WINDOWS:
  53. return input.version.equals("2008 SP2") || input.version.equals("")
  54. || (input.version.equals("2008 R2") && input.is64Bit);
  55. default:
  56. return false;
  57. }
  58. }
  59. });
  60. }
  61. @Test
  62. public void testTemplateBuilder() {
  63. Template defaultTemplate = this.context.getComputeService().templateBuilder().build();
  64. assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
  65. assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04");
  66. assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
  67. assertEquals(defaultTemplate.getLocation().getId(), "http://localhost:3001/api/realms/us");
  68. assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
  69. }
  70. @Override
  71. protected Set<String> getIso3166Codes() {
  72. return ImmutableSet.<String> of();
  73. }
  74. }