PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImageTest.java

https://github.com/regularfry/jclouds
Java | 66 lines | 36 code | 9 blank | 21 comment | 0 complexity | f0cd260ce76fa6185ec54f0105f4ae10 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.cloudservers.compute.functions;
  20. import static org.testng.Assert.assertEquals;
  21. import java.net.UnknownHostException;
  22. import org.jclouds.cloudservers.functions.ParseImageFromJsonResponseTest;
  23. import org.jclouds.compute.config.BaseComputeServiceContextModule;
  24. import org.jclouds.compute.domain.Image;
  25. import org.jclouds.compute.domain.ImageBuilder;
  26. import org.jclouds.compute.domain.OperatingSystem;
  27. import org.jclouds.compute.domain.OsFamily;
  28. import org.jclouds.compute.reference.ComputeServiceConstants;
  29. import org.jclouds.domain.Credentials;
  30. import org.jclouds.json.Json;
  31. import org.jclouds.json.config.GsonModule;
  32. import org.testng.annotations.Test;
  33. import com.google.inject.Guice;
  34. /**
  35. * @author Adrian Cole
  36. */
  37. @Test(groups = "unit")
  38. public class CloudServersImageToImageTest {
  39. @Test
  40. public void testApplyWhereImageNotFound() throws UnknownHostException {
  41. assertEquals(
  42. convertImage(),
  43. new ImageBuilder()
  44. .name("CentOS 5.2")
  45. .operatingSystem(
  46. new OperatingSystem.Builder().family(OsFamily.CENTOS).version("5.2").description("CentOS 5.2").is64Bit(true)
  47. .build()).description("CentOS 5.2").defaultCredentials(new Credentials("root", null))
  48. .ids("2").version("1286712000000").build());
  49. }
  50. public static Image convertImage() {
  51. org.jclouds.cloudservers.domain.Image image = ParseImageFromJsonResponseTest.parseImage();
  52. CloudServersImageToImage parser = new CloudServersImageToImage(new CloudServersImageToOperatingSystem(new BaseComputeServiceContextModule() {
  53. }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule())
  54. .getInstance(Json.class))));
  55. return parser.apply(image);
  56. }
  57. }