PageRenderTime 26ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java

https://github.com/regularfry/jclouds
Java | 65 lines | 36 code | 6 blank | 23 comment | 0 complexity | 9392c064bbfa7cd64c8254ecea07ddf9 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.xml;
  20. import static org.testng.Assert.assertEquals;
  21. import java.io.InputStream;
  22. import java.net.URI;
  23. import org.jclouds.http.functions.ParseSax;
  24. import org.jclouds.http.functions.ParseSax.Factory;
  25. import org.jclouds.http.functions.config.SaxParserModule;
  26. import org.jclouds.vcloud.VCloudMediaType;
  27. import org.jclouds.vcloud.domain.NetworkConnectionSection;
  28. import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
  29. import org.testng.annotations.Test;
  30. import com.google.common.collect.Iterables;
  31. import com.google.inject.Guice;
  32. import com.google.inject.Injector;
  33. /**
  34. * Tests behavior of {@code NetworkConnectionSectionHandler}
  35. *
  36. * @author Adrian Cole
  37. */
  38. @Test(groups = "unit")
  39. public class NetworkConnectionSectionHandlerTest {
  40. public void testVCloud1_0() {
  41. InputStream is = getClass().getResourceAsStream("/networkconnectionsection.xml");
  42. Injector injector = Guice.createInjector(new SaxParserModule());
  43. Factory factory = injector.getInstance(ParseSax.Factory.class);
  44. NetworkConnectionSection result = factory.create(injector.getInstance(NetworkConnectionSectionHandler.class))
  45. .parse(is);
  46. checkNetworkConnectionSection(result);
  47. }
  48. @Test(enabled = false)
  49. static void checkNetworkConnectionSection(NetworkConnectionSection result) {
  50. assertEquals(result.getHref(), URI
  51. .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/networkConnectionSection/"));
  52. assertEquals(result.getType(), VCloudMediaType.NETWORKCONNECTIONSECTION_XML);
  53. assertEquals(result.getInfo(), "Specifies the available VM network connections");
  54. assertEquals(result.getPrimaryNetworkConnectionIndex(), new Integer(0));
  55. assertEquals(result.getEdit(), new ReferenceTypeImpl(null, VCloudMediaType.NETWORKCONNECTIONSECTION_XML, URI
  56. .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/networkConnectionSection/")));
  57. NetworkConnectionHandlerTest.checkNetworkConnection(Iterables.getOnlyElement(result.getConnections()));
  58. }
  59. }