Package org.jclouds.xml.internal

Examples of org.jclouds.xml.internal.JAXBParser


   /**
    * Marshals a JAXB annotated object into XML. The XML is output using
    * {@link org.jclouds.logging.Logger#debug(String)}
    */
   protected void debug(final Object object) {
      JAXBParser parser = new JAXBParser("true");
      try {
         String xml = parser.toXML(object);
         logger.debug(Strings.padStart(Strings.padEnd(" " + object.getClass().toString() + " ", 70, '-'), 80, '-'));
         logger.debug(xml);
         logger.debug(Strings.repeat("-", 80));
      } catch (IOException ioe) {
         Throwables.propagate(ioe);
View Full Code Here


* @author Ignasi Barrera
*/
@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.newPayload(parser.toXML(task));

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

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

* @author Ignasi Barrera
*/
@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

         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.newPayload(xmlParser.toXML(movedRef));

      // 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

*/
@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

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

   @Test(expectedExceptions = IllegalArgumentException.class)
   public void testInvalidRequestType() throws SecurityException, NoSuchMethodException {
      BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false"));

      binder.bindToRequest(HttpRequest.builder().method("m").endpoint("http://localhost").build(), new Object());
   }
View Full Code Here

      Invokable<?, ?> method = method(TestNetworkConfig.class, "withAll", VirtualMachineDto.class, VLANNetworkDto.class);
      GeneratedHttpRequest request = GeneratedHttpRequest.builder()
            .invocation(Invocation.create(method, Lists.<Object> newArrayList(vm, null))).method(HttpMethod.GET)
            .endpoint(URI.create("http://localhost")).build();

      BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false"));
      binder.bindToRequest(request, null);
   }
View Full Code Here

      Invokable<?, ?> method = method(TestNetworkConfig.class, "withAll", VirtualMachineDto.class, VLANNetworkDto.class);
      GeneratedHttpRequest request = GeneratedHttpRequest.builder()
            .invocation(Invocation.create(method, ImmutableList.<Object> of(vm, network))).method(HttpMethod.GET)
            .endpoint(URI.create("http://localhost")).build();

      BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false"));
      binder.bindToRequest(request, network);
   }
View Full Code Here

      Invokable<?, ?> method = method(TestNetworkConfig.class, "withoutVirtualMachine", VLANNetworkDto.class);
      GeneratedHttpRequest request = GeneratedHttpRequest.builder()
            .invocation(Invocation.create(method, ImmutableList.<Object> of(network))).method(HttpMethod.GET)
            .endpoint(URI.create("http://localhost")).build();

      BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false"));
      binder.bindToRequest(request, network);
   }
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.