PageRenderTime 53ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/apis/vcloud/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java

https://github.com/edwardt/jclouds
Java | 90 lines | 55 code | 12 blank | 23 comment | 0 complexity | 70f1dae49160b98062bafbc359ffd2ee 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.vcloud.options;
  20. import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
  21. import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.customizeOnInstantiate;
  22. import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.description;
  23. import static org.testng.Assert.assertEquals;
  24. import java.net.URI;
  25. import org.jclouds.http.functions.config.SaxParserModule;
  26. import org.jclouds.vcloud.domain.network.FenceMode;
  27. import org.jclouds.vcloud.domain.network.NetworkConfig;
  28. import org.testng.annotations.Test;
  29. import com.google.common.collect.Iterables;
  30. import com.google.inject.Guice;
  31. import com.google.inject.Injector;
  32. /**
  33. * Tests behavior of {@code InstantiateVAppTemplateOptions}
  34. *
  35. * @author Adrian Cole
  36. */
  37. @Test(groups = "unit")
  38. public class InstantiateVAppTemplateOptionsTest {
  39. Injector injector = Guice.createInjector(new SaxParserModule());
  40. @Test
  41. public void testAddNetworkConfig() {
  42. InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
  43. options.addNetworkConfig(new NetworkConfig("default", URI.create("http://localhost"), FenceMode.BRIDGED));
  44. assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default");
  45. assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost"));
  46. assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED);
  47. }
  48. @Test
  49. public void testAddNetworkConfigStatic() {
  50. InstantiateVAppTemplateOptions options = addNetworkConfig(new NetworkConfig("default",
  51. URI.create("http://localhost"), FenceMode.BRIDGED));
  52. assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default");
  53. assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost"));
  54. assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED);
  55. }
  56. @Test
  57. public void testCustomizeOnInstantiate() {
  58. InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
  59. options.customizeOnInstantiate(true);
  60. assertEquals(options.shouldCustomizeOnInstantiate(), new Boolean(true));
  61. }
  62. @Test
  63. public void testCustomizeOnInstantiateStatic() {
  64. InstantiateVAppTemplateOptions options = customizeOnInstantiate(true);
  65. assertEquals(options.shouldCustomizeOnInstantiate(), new Boolean(true));
  66. }
  67. @Test
  68. public void testDescription() {
  69. InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
  70. options.description("foo");
  71. assertEquals(options.getDescription(), "foo");
  72. }
  73. @Test
  74. public void testDescriptionStatic() {
  75. InstantiateVAppTemplateOptions options = description("foo");
  76. assertEquals(options.getDescription(), "foo");
  77. }
  78. }