Package org.jclouds.xml.internal

Examples of org.jclouds.xml.internal.JAXBParser


      binder.bindToRequest(request, new Object());
   }

   public void testBindSingleVolume() throws IOException {
      VirtualDatacenterDto vdc = CloudResources.virtualDatacenterPut();
      BindVirtualDatacenterRefToPayload binder = new BindVirtualDatacenterRefToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      request = binder.bindToRequest(request, vdc);
      assertPayloadEquals(request.getPayload(), withHeader("<links><link href=\"" + vdc.getEditLink().getHref()
            + "\" rel=\"virtualdatacenter\"/></links>"), LinksDto.class);
   }
View Full Code Here


@Test(groups = "unit", testName = "BindNetworkRefToPayloadTest")
public class BindNetworkRefToPayloadTest {

   @Test(expectedExceptions = NullPointerException.class)
   public void testInvalidNullInput() {
      BindNetworkRefToPayload binder = new BindNetworkRefToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      binder.bindToRequest(request, null);
   }
View Full Code Here

      binder.bindToRequest(request, null);
   }

   @Test(expectedExceptions = IllegalArgumentException.class)
   public void testInvalidTypeInput() {
      BindNetworkRefToPayload binder = new BindNetworkRefToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      binder.bindToRequest(request, new Object());
   }
View Full Code Here

      binder.bindToRequest(request, new Object());
   }

   public void testBindNetworkRef() throws IOException {
      VLANNetworkDto network = NetworkResources.privateNetworkPut();
      BindNetworkRefToPayload binder = new BindNetworkRefToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      request = binder.bindToRequest(request, network);
      assertPayloadEquals(request.getPayload(), withHeader("<links><link href=\"" + network.getEditLink().getHref()
            + "\" rel=\"internalnetwork\"/></links>"), LinksDto.class);
   }
View Full Code Here

* Unit tests for the {@link MovedVolume} function.
*/
@Test(groups = "unit", testName = "MovedVolumeTest")
public class MovedVolumeTest {
   public void testReturnOriginalExceptionIfNotHttpResponseException() {
      MovedVolume function = new MovedVolume(new ReturnMoveVolumeReference(new JAXBParser("false"),
            TypeLiteral.get(MovedVolumeDto.class)));

      RuntimeException exception = new RuntimeException();

      try {
View Full Code Here

@Test(groups = "unit", testName = "BindIpRefToPayloadTest")
public class BindIpRefToPayloadTest {

   @Test(expectedExceptions = NullPointerException.class)
   public void testInvalidNullInput() {
      BindIpRefToPayload binder = new BindIpRefToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      binder.bindToRequest(request, null);
   }
View Full Code Here

         assertEquals(ex, exception);
      }
   }

   public void testReturnVolume() throws Exception {
      JAXBParser xmlParser = new JAXBParser("false");
      MovedVolume function = new MovedVolume(new ReturnMoveVolumeReference(new JAXBParser("false"),
            TypeLiteral.get(MovedVolumeDto.class)));

      VolumeManagementDto volume = new VolumeManagementDto();
      volume.setName("Test volume");
      MovedVolumeDto movedRef = new MovedVolumeDto();
      movedRef.setVolume(volume);

      HttpResponse response = EasyMock.createMock(HttpResponse.class);
      HttpResponseException exception = EasyMock.createMock(HttpResponseException.class);
      Payload payload = Payloads.newByteSourcePayload(ByteSource.wrap(xmlParser.toXML(movedRef).getBytes()));

      // Status code is called once
      expect(response.getStatusCode()).andReturn(Status.MOVED_PERMANENTLY.getStatusCode());
      // Get response gets called twice
      expect(exception.getResponse()).andReturn(response);
View Full Code Here

      binder.bindToRequest(request, null);
   }

   @Test(expectedExceptions = IllegalArgumentException.class)
   public void testInvalidTypeInput() {
      BindIpRefToPayload binder = new BindIpRefToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      binder.bindToRequest(request, new Object());
   }
View Full Code Here

   }

   public void testBindIpRef() throws IOException {
      PrivateIpDto ip = NetworkResources.privateIpPut();
      RESTLink selfLink = ip.searchLink("self");
      BindIpRefToPayload binder = new BindIpRefToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      request = binder.bindToRequest(request, ip);
      assertPayloadEquals(request.getPayload(), withHeader("<links><link href=\"" + selfLink.getHref() + "\" rel=\""
            + selfLink.getTitle() + "\"/></links>"), LinksDto.class);
View Full Code Here

*/
@Test(groups = "unit", testName = "BindNetworkConfigurationRefToPayloadTest")
public class BindNetworkConfigurationRefToPayloadTest {
   @Test(expectedExceptions = NullPointerException.class)
   public void testInvalidNullRequest() throws SecurityException, NoSuchMethodException {
      BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false"));
      binder.bindToRequest(null, new Object());
   }
View Full Code Here

TOP

Related Classes of org.jclouds.xml.internal.JAXBParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.