Package org.jclouds.openstack.marconi.v1.features

Examples of org.jclouds.openstack.marconi.v1.features.MessageApiMockTest


      MockWebServer server = mockOpenStackServer();
      server.enqueue(new MockResponse().setBody(accessRackspace));
      server.enqueue(new MockResponse().setResponseCode(200).setBody("{\"key1\":\"value1\"}"));

      try {
         MarconiApi api = api(server.getUrl("/").toString(), "openstack-marconi");
         QueueApi queueApi = api.getQueueApiForZoneAndClient("DFW", CLIENT_ID);
         Map<String, String> metadata = queueApi.getMetadata("jclouds-test");

         assertEquals(metadata.get("key1"), "value1");

         assertEquals(server.getRequestCount(), 2);
View Full Code Here


      MockWebServer server = mockOpenStackServer();
      server.enqueue(new MockResponse().setBody(accessRackspace));
      server.enqueue(new MockResponse().setResponseCode(200).setBody("{\"messages\":{\"claimed\":0,\"total\":0,\"free\":0}}"));

      try {
         MarconiApi api = api(server.getUrl("/").toString(), "openstack-marconi");
         QueueApi queueApi = api.getQueueApiForZoneAndClient("DFW", CLIENT_ID);
         QueueStats stats = queueApi.getStats("jclouds-test");

         assertEquals(stats.getMessagesStats().getClaimed(), 0);
         assertEquals(stats.getMessagesStats().getFree(), 0);
         assertEquals(stats.getMessagesStats().getTotal(), 0);
View Full Code Here

      MockWebServer server = mockOpenStackServer();
      server.enqueue(new MockResponse().setBody(accessRackspace));
      server.enqueue(new MockResponse().setResponseCode(200).setBody("{\"messages\": {\"claimed\": 0, \"oldest\": {\"age\": 0, \"href\": \"/v1/queues/jclouds-test/messages/526558b3f4919b655feba3a7\", \"created\": \"2013-10-21T16:39:15Z\"}, \"total\": 4, \"newest\": {\"age\": 0, \"href\": \"/v1/queues/jclouds-test/messages/526558b33ac24e663fc545e7\", \"created\": \"2013-10-21T16:39:15Z\"}, \"free\": 4}}"));

      try {
         MarconiApi api = api(server.getUrl("/").toString(), "openstack-marconi");
         QueueApi queueApi = api.getQueueApiForZoneAndClient("DFW", CLIENT_ID);
         QueueStats stats = queueApi.getStats("jclouds-test");

         assertEquals(stats.getMessagesStats().getClaimed(), 0);
         assertEquals(stats.getMessagesStats().getFree(), 4);
         assertEquals(stats.getMessagesStats().getTotal(), 4);
View Full Code Here

   public static class Builder extends BaseProviderMetadata.Builder {

      protected Builder(){
         id("rackspace-cloudqueues-us")
         .name("Rackspace Cloud Queues US")
         .apiMetadata(new MarconiApiMetadata().toBuilder()
                  .identityName("${userName}")
                  .credentialName("${apiKey}")
                  .defaultEndpoint("https://identity.api.rackspacecloud.com/v2.0/")
                  .endpointName("Rackspace Cloud Identity service URL ending in /v2.0/")
                  .documentation(URI.create("http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/overview.html"))
View Full Code Here

   public static class Builder extends BaseProviderMetadata.Builder {

      protected Builder(){
         id("rackspace-cloudqueues-uk")
         .name("Rackspace Cloud Queues UK")
         .apiMetadata(new MarconiApiMetadata().toBuilder()
               .identityName("${userName}")
               .credentialName("${apiKey}")
               .defaultEndpoint("https://lon.identity.api.rackspacecloud.com/v2.0/")
               .endpointName("Rackspace Cloud Identity service URL ending in /v2.0/")
               .documentation(URI.create("http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/overview.html"))
View Full Code Here

   public static class Builder extends BaseProviderMetadata.Builder {

      protected Builder(){
         id("rackspace-cloudqueues-uk")
         .name("Rackspace Cloud Queues UK")
         .apiMetadata(new MarconiApiMetadata().toBuilder()
               .identityName("${userName}")
               .credentialName("${apiKey}")
               .defaultEndpoint("https://lon.identity.api.rackspacecloud.com/v2.0/")
               .endpointName("Rackspace Cloud Identity service URL ending in /v2.0/")
               .documentation(URI.create("http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/overview.html"))
View Full Code Here

      if (rawQueueStats.getMessagesStats().getTotal() == 0) {
         return rawQueueStats;
      }
      else {
         // change the hrefs to ids
         Aged oldestWithHref = rawQueueStats.getMessagesStats().getOldest().get();
         Aged oldestWithId = oldestWithHref.toBuilder()
               .id(TO_ID_FROM_HREF.apply(oldestWithHref.getId()))
               .build();
         Aged newestWithHref = rawQueueStats.getMessagesStats().getNewest().get();
         Aged newestWithId = newestWithHref.toBuilder()
               .id(TO_ID_FROM_HREF.apply(newestWithHref.getId()))
               .build();

         MessagesStats messagesStatsWithIds = rawQueueStats.getMessagesStats().toBuilder()
               .oldest(oldestWithId)
View Full Code Here

      if (rawQueueStats.getMessagesStats().getTotal() == 0) {
         return rawQueueStats;
      }
      else {
         // change the hrefs to ids
         Aged oldestWithHref = rawQueueStats.getMessagesStats().getOldest().get();
         Aged oldestWithId = oldestWithHref.toBuilder()
               .id(TO_ID_FROM_HREF.apply(oldestWithHref.getId()))
               .build();
         Aged newestWithHref = rawQueueStats.getMessagesStats().getNewest().get();
         Aged newestWithId = newestWithHref.toBuilder()
               .id(TO_ID_FROM_HREF.apply(newestWithHref.getId()))
               .build();

         MessagesStats messagesStatsWithIds = rawQueueStats.getMessagesStats().toBuilder()
               .oldest(oldestWithId)
View Full Code Here

      try {
         MarconiApi api = api(server.getUrl("/").toString(), "openstack-marconi");
         ClaimApi claimApi = api.getClaimApiForZoneAndClientAndQueue("DFW", CLIENT_ID, "jclouds-test");

         Claim claim = claimApi.get("52a8d23eb04a584f1bbd4f47");

         assertEquals(claim.getMessages().size(), 2);
         assertEquals(claim.getId(), "52a8d23eb04a584f1bbd4f47");
         assertEquals(claim.getAge(), 209);
         assertEquals(claim.getTTL(), 300);

         assertEquals(claim.getMessages().get(0).getId(), "52a8a379b04a584f2ec2bc3e");
         assertEquals(claim.getMessages().get(0).getClaimId().get(), "52a8d23eb04a584f1bbd4f47");
         assertEquals(claim.getMessages().get(0).getAge(), 12182);
         assertEquals(claim.getMessages().get(0).getTTL(), 86400);

         assertEquals(claim.getMessages().get(1).getId(), "52a8a379b04a584f2ec2bc3f");
         assertEquals(claim.getMessages().get(1).getClaimId().get(), "52a8d23eb04a584f1bbd4f47");
         assertEquals(claim.getMessages().get(1).getAge(), 12182);
         assertEquals(claim.getMessages().get(1).getTTL(), 86400);

         assertEquals(server.getRequestCount(), 2);
         assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
         assertEquals(server.takeRequest().getRequestLine(), "GET /v1/123123/queues/jclouds-test/claims/52a8d23eb04a584f1bbd4f47 HTTP/1.1");
      }
View Full Code Here

      try {
         MarconiApi api = api(server.getUrl("/").toString(), "openstack-marconi");
         ClaimApi claimApi = api.getClaimApiForZoneAndClientAndQueue("DFW", CLIENT_ID, "jclouds-test");

         Claim claim = claimApi.get("52a8d23eb04a584f1bbd4f47");

         assertEquals(claim.getMessages().size(), 2);
         assertEquals(claim.getId(), "52a8d23eb04a584f1bbd4f47");
         assertEquals(claim.getAge(), 209);
         assertEquals(claim.getTTL(), 300);

         assertEquals(claim.getMessages().get(0).getId(), "52a8a379b04a584f2ec2bc3e");
         assertEquals(claim.getMessages().get(0).getClaimId().get(), "52a8d23eb04a584f1bbd4f47");
         assertEquals(claim.getMessages().get(0).getAge(), 12182);
         assertEquals(claim.getMessages().get(0).getTTL(), 86400);

         assertEquals(claim.getMessages().get(1).getId(), "52a8a379b04a584f2ec2bc3f");
         assertEquals(claim.getMessages().get(1).getClaimId().get(), "52a8d23eb04a584f1bbd4f47");
         assertEquals(claim.getMessages().get(1).getAge(), 12182);
         assertEquals(claim.getMessages().get(1).getTTL(), 86400);

         assertEquals(server.getRequestCount(), 2);
         assertEquals(server.takeRequest().getRequestLine(), "POST /tokens HTTP/1.1");
         assertEquals(server.takeRequest().getRequestLine(), "GET /v1/123123/queues/jclouds-test/claims/52a8d23eb04a584f1bbd4f47 HTTP/1.1");
      }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.marconi.v1.features.MessageApiMockTest

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.