Package org.jclouds.xml.internal

Examples of org.jclouds.xml.internal.JAXBParser


      binder.bindToRequest(request, null);
   }

   @Test(expectedExceptions = IllegalArgumentException.class)
   public void testInvalidTypeInput() {
      BindHardDiskRefsToPayload binder = new BindHardDiskRefsToPayload(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 {
      BindHardDiskRefsToPayload binder = new BindHardDiskRefsToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      request = binder.bindToRequest(request, new DiskManagementDto[] {});
      assertPayloadEquals(request.getPayload(), withHeader("<links/>"), LinksDto.class);
   }
View Full Code Here

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

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

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

   public void testBindMultipleHardDisks() throws IOException {
      DiskManagementDto hardDisk = CloudResources.hardDiskPut();
      BindHardDiskRefsToPayload binder = new BindHardDiskRefsToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      request = binder.bindToRequest(request, new DiskManagementDto[] { hardDisk, hardDisk });
      assertPayloadEquals(request.getPayload(), withHeader("<links><link href=\"" + hardDisk.getEditLink().getHref()
            + "\" rel=\"" + binder.getRelToUse(hardDisk) + "\"/></links>"), LinksDto.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

    *            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

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.