Package org.jclouds.xml.internal

Examples of org.jclouds.xml.internal.JAXBParser


    *            If there is an error during serialization.
    */
   public static void assertPayloadEquals(final Payload payload, final String expected,
         final Class<? extends SingleResourceTransportDto> entityClass) throws IOException {
      // Serialize and deserialize to avoid formatting issues
      XMLParser xml = new JAXBParser("false");
      SingleResourceTransportDto entity = xml.fromXML(expected, entityClass);
      String toMatch = xml.toXML(entity, entityClass);

      assertEquals(payload.getRawContent(), toMatch);
   }
View Full Code Here


* Unit tests for the {@link ReturnTaskReferenceOrNull} function.
*/
@Test(groups = "unit", testName = "ReturnTaskReferenceOrNullTest")
public class ReturnTaskReferenceOrNullTest {
   public void testReturnNullIfNoContent() {
      Function<HttpResponse, AcceptedRequestDto<String>> function = new ReturnTaskReferenceOrNull(new JAXBParser(
            "false"), createTypeLiteral());

      HttpResponse response = EasyMock.createMock(HttpResponse.class);

      expect(response.getStatusCode()).andReturn(Status.NO_CONTENT.getStatusCode());
View Full Code Here

      verify(response);
   }

   public void testReturnTaskIfAccepted() throws IOException {
      JAXBParser parser = new JAXBParser("false");
      AcceptedRequestDto<?> task = new AcceptedRequestDto<String>();
      Payload payload = Payloads.newByteSourcePayload(ByteSource.wrap(parser.toXML(task).getBytes()));

      Function<HttpResponse, AcceptedRequestDto<String>> function = new ReturnTaskReferenceOrNull(parser,
            createTypeLiteral());

      HttpResponse response = EasyMock.createMock(HttpResponse.class);
View Full Code Here

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

   @Test(expectedExceptions = NullPointerException.class)
   public void testInvalidNullInput() {
      BindVolumeRefsToPayload binder = new BindVolumeRefsToPayload(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() {
      BindVolumeRefsToPayload binder = new BindVolumeRefsToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      binder.bindToRequest(request, new Object());
   }
View Full Code Here

      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      binder.bindToRequest(request, new Object());
   }

   public void testBindEmptyArray() throws IOException {
      BindVolumeRefsToPayload binder = new BindVolumeRefsToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      request = binder.bindToRequest(request, new VolumeManagementDto[] {});
      assertPayloadEquals(request.getPayload(), withHeader("<links/>"), LinksDto.class);
   }
View Full Code Here

      assertPayloadEquals(request.getPayload(), withHeader("<links/>"), LinksDto.class);
   }

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

            + "\" rel=\"" + binder.getRelToUse(volume) + "\"/></links>"), LinksDto.class);
   }

   public void testBindMultipleVolumes() throws IOException {
      VolumeManagementDto volume = CloudResources.volumePut();
      BindVolumeRefsToPayload binder = new BindVolumeRefsToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      request = binder.bindToRequest(request, new VolumeManagementDto[] { volume, volume });
      assertPayloadEquals(request.getPayload(), withHeader("<links><link href=\"" + volume.getEditLink().getHref()
            + "\" rel=\"" + binder.getRelToUse(volume) + "\"/></links>"), LinksDto.class);
   }
View Full Code Here

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

   @Test(expectedExceptions = NullPointerException.class)
   public void testInvalidNullInput() {
      BindVirtualDatacenterRefToPayload binder = new BindVirtualDatacenterRefToPayload(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() {
      BindVirtualDatacenterRefToPayload binder = new BindVirtualDatacenterRefToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      binder.bindToRequest(request, 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.