Example #1
0
  public void testSendMessageWhenResponseIs2xx() throws Exception {

    HttpResponse sendMessageResponse =
        HttpResponse.builder()
            .statusCode(200)
            .payload(payloadFromResourceWithContentType("/send_message.xml", "text/xml"))
            .build();

    SQSApi apiWhenExist = requestSendsResponse(sendMessage, sendMessageResponse);

    assertEquals(
        apiWhenExist.getMessageApiForQueue(queue).send("hardyharhar").toString(),
        new SendMessageResponseTest().expected().toString());
  }
Example #2
0
  public void testReceiveMessagesWhenResponseIs2xx() throws Exception {

    HttpResponse receiveMessagesResponse =
        HttpResponse.builder()
            .statusCode(200)
            .payload(payloadFromResourceWithContentType("/messages.xml", "text/xml"))
            .build();

    SQSApi apiWhenExist = requestSendsResponse(receiveMessages, receiveMessagesResponse);

    assertEquals(
        apiWhenExist.getMessageApiForQueue(queue).receive(10).toString(),
        new ReceiveMessageResponseTest().expected().toString());
  }
Example #3
0
  public void testDeleteMessageWhenResponseIs2xx() throws Exception {

    HttpResponse deleteMessageResponse =
        HttpResponse.builder()
            .statusCode(200)
            .payload(
                payloadFromStringWithContentType(
                    "<DeleteMessageResponse><ResponseMetadata><RequestId>b5293cb5-d306-4a17-9048-b263635abe42</RequestId></ResponseMetadata></DeleteMessageResponse>",
                    "text/xml"))
            .build();

    SQSApi apiWhenExist = requestSendsResponse(deleteMessage, deleteMessageResponse);

    apiWhenExist.getMessageApiForQueue(queue).delete("eXJYhj5rDr9cAe");
  }
Example #4
0
  public void testChangeMessageVisibilityWhenResponseIs2xx() throws Exception {

    HttpResponse changeMessageVisibilityResponse =
        HttpResponse.builder()
            .statusCode(200)
            .payload(
                payloadFromStringWithContentType(
                    "<ChangeMessageVisibilityResponse><ResponseMetadata><RequestId>b5293cb5-d306-4a17-9048-b263635abe42</RequestId></ResponseMetadata></ChangeMessageVisibilityResponse>",
                    "text/xml"))
            .build();

    SQSApi apiWhenExist =
        requestSendsResponse(changeMessageVisibility, changeMessageVisibilityResponse);

    apiWhenExist.getMessageApiForQueue(queue).changeVisibility("eXJYhj5rDr9cAe", 10);
  }
Example #5
0
  public void testDeleteMessageMapWhenResponseIs2xx() throws Exception {

    HttpResponse deleteMessageResponse =
        HttpResponse.builder()
            .statusCode(200)
            .payload(payloadFromResourceWithContentType("/delete_message_batch.xml", "text/xml"))
            .build();

    SQSApi apiWhenExist = requestSendsResponse(deleteMessageMap, deleteMessageResponse);

    assertEquals(
        apiWhenExist
            .getMessageApiForQueue(queue)
            .delete(ImmutableMap.of("foo1", "eXJYhj5rDr9cAe", "foo2", "fffeeerrr"))
            .toString(),
        new DeleteMessageBatchResponseTest().expected().toString());
  }
Example #6
0
  public void testSendMessageWithDelaysMapWhenResponseIs2xx() throws Exception {

    HttpResponse sendMessageResponse =
        HttpResponse.builder()
            .statusCode(200)
            .payload(payloadFromResourceWithContentType("/send_message_batch.xml", "text/xml"))
            .build();

    SQSApi apiWhenExist = requestSendsResponse(sendMessageWithDelaysMap, sendMessageResponse);

    assertEquals(
        apiWhenExist
            .getMessageApiForQueue(queue)
            .sendWithDelays(ImmutableMap.of("payload1", 1, "payload2", 10))
            .toString(),
        new SendMessageBatchResponseTest().expected().toString());
  }
Example #7
0
  public void testChangeMessageVisibilityMapWhenResponseIs2xx() throws Exception {

    HttpResponse sendMessageResponse =
        HttpResponse.builder()
            .statusCode(200)
            .payload(
                payloadFromResourceWithContentType(
                    "/change_message_visibility_batch.xml", "text/xml"))
            .build();

    SQSApi apiWhenExist = requestSendsResponse(changeMessageVisibilityMap, sendMessageResponse);

    assertEquals(
        apiWhenExist
            .getMessageApiForQueue(queue)
            .changeVisibility(ImmutableMap.of("aaaaaaaaa", 1, "bbbbbbbbb", 10))
            .toString(),
        new ChangeMessageVisibilityBatchResponseTest().expected().toString());
  }