com.amazonaws.services.sqs.model.GetQueueUrlRequest Java Examples
The following examples show how to use
com.amazonaws.services.sqs.model.GetQueueUrlRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamicQueueUrlDestinationResolverTest.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
@Test void testPotentiallyNoAccessToPerformGetQueueUrl() throws Exception { AmazonSQS amazonSqs = mock(AmazonSQS.class); AmazonServiceException exception = new QueueDoesNotExistException( "AWS.SimpleQueueService.NonExistentQueue"); exception.setErrorCode("AWS.SimpleQueueService.NonExistentQueue"); exception.setErrorMessage( "The specified queue does not exist or you do not have access to it."); String queueUrl = "noAccessGetQueueUrlName"; when(amazonSqs.getQueueUrl(new GetQueueUrlRequest(queueUrl))) .thenThrow(exception); DynamicQueueUrlDestinationResolver dynamicQueueDestinationResolver = new DynamicQueueUrlDestinationResolver( amazonSqs); try { dynamicQueueDestinationResolver.resolveDestination(queueUrl); } catch (DestinationResolutionException e) { assertThat(e.getMessage()).startsWith( "The queue does not exist or no access to perform action sqs:GetQueueUrl."); } }
Example #2
Source File: CloudWatchAlertDispatcher.java From s3mper with Apache License 2.0 | 6 votes |
private void initSqs(String keyId, String keySecret) { log.debug("Initializing SQS Client"); sqs = new AmazonSQSClient(new BasicAWSCredentials(keyId, keySecret)); //SQS Consistency Queue consistencyQueue = conf.get("s3mper.alert.sqs.queue", consistencyQueue); consistencyQueueUrl = sqs.getQueueUrl(new GetQueueUrlRequest(consistencyQueue)).getQueueUrl(); //SQS Timeout Queue timeoutQueue = conf.get("s3mper.timeout.sqs.queue", timeoutQueue); timeoutQueueUrl = sqs.getQueueUrl(new GetQueueUrlRequest(timeoutQueue)).getQueueUrl(); //SQS Notification Queue notificationQueue = conf.get("s3mper.notification.sqs.queue", notificationQueue); notificationQueueUrl = sqs.getQueueUrl(new GetQueueUrlRequest(notificationQueue)).getQueueUrl(); //Disable reporting (Testing purposes mostly) reportingDisabled = conf.getBoolean("s3mper.reporting.disabled", reportingDisabled); }
Example #3
Source File: AlertJanitor.java From s3mper with Apache License 2.0 | 6 votes |
public void initalize(URI uri, Configuration conf) { this.conf = conf; String keyId = conf.get("fs."+uri.getScheme()+".awsAccessKeyId"); String keySecret = conf.get("fs."+uri.getScheme()+".awsSecretAccessKey"); //An override option for accessing across accounts keyId = conf.get("fs."+uri.getScheme()+".override.awsAccessKeyId", keyId); keySecret = conf.get("fs."+uri.getScheme()+".override.awsSecretAccessKey", keySecret); sqs = new AmazonSQSClient(new BasicAWSCredentials(keyId, keySecret)); //SQS Consistency Queue consistencyQueue = conf.get("fs"+uri.getScheme()+".alert.sqs.queue", consistencyQueue); consistencyQueue = sqs.getQueueUrl(new GetQueueUrlRequest(consistencyQueue)).getQueueUrl(); //SQS Timeout Queue timeoutQueue = conf.get("fs"+uri.getScheme()+".timeout.sqs.queue", timeoutQueue); timeoutQueue = sqs.getQueueUrl(new GetQueueUrlRequest(timeoutQueue)).getQueueUrl(); }
Example #4
Source File: QueueMessagingTemplateTest.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
private AmazonSQSAsync createAmazonSqs() { AmazonSQSAsync amazonSqs = mock(AmazonSQSAsync.class); GetQueueUrlResult queueUrl = new GetQueueUrlResult(); queueUrl.setQueueUrl("https://queue-url.com"); when(amazonSqs.getQueueUrl(any(GetQueueUrlRequest.class))).thenReturn(queueUrl); ReceiveMessageResult receiveMessageResult = new ReceiveMessageResult(); com.amazonaws.services.sqs.model.Message message = new com.amazonaws.services.sqs.model.Message(); message.setBody("My message"); receiveMessageResult.withMessages(message); when(amazonSqs.receiveMessage(any(ReceiveMessageRequest.class))) .thenReturn(receiveMessageResult); return amazonSqs; }
Example #5
Source File: DynamicQueueUrlDestinationResolverTest.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
@Test void resolveDestination_withResourceIdResolver_nonUrlId_shouldGetUrlByResolvedName() throws Exception { String queueUrl = "http://queue.com"; String resolvedQueueName = "some-queue-name"; AmazonSQS amazonSqs = mock(AmazonSQS.class); when(amazonSqs.getQueueUrl(new GetQueueUrlRequest(resolvedQueueName))) .thenReturn(new GetQueueUrlResult().withQueueUrl(queueUrl)); ResourceIdResolver resourceIdResolver = mock(ResourceIdResolver.class); when(resourceIdResolver.resolveToPhysicalResourceId(anyString())) .thenReturn(resolvedQueueName); DynamicQueueUrlDestinationResolver dynamicQueueUrlDestinationResolver = new DynamicQueueUrlDestinationResolver( amazonSqs, resourceIdResolver); String physicalResourceId = dynamicQueueUrlDestinationResolver .resolveDestination("testQueue"); assertThat(physicalResourceId).isEqualTo("http://queue.com"); }
Example #6
Source File: DynamicQueueUrlDestinationResolverTest.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
@Test void testInvalidDestinationName() throws Exception { AmazonSQS amazonSqs = mock(AmazonSQS.class); AmazonServiceException exception = new QueueDoesNotExistException( "AWS.SimpleQueueService.NonExistentQueue"); exception.setErrorCode("AWS.SimpleQueueService.NonExistentQueue"); String queueUrl = "invalidName"; when(amazonSqs.getQueueUrl(new GetQueueUrlRequest(queueUrl))) .thenThrow(exception); DynamicQueueUrlDestinationResolver dynamicQueueDestinationResolver = new DynamicQueueUrlDestinationResolver( amazonSqs); try { dynamicQueueDestinationResolver.resolveDestination(queueUrl); } catch (DestinationResolutionException e) { assertThat(e.getMessage()).startsWith("The queue does not exist."); } }
Example #7
Source File: MessageListenerContainerTest.java From spring-cloud-aws with Apache License 2.0 | 6 votes |
@Test void testIsActive() throws Exception { AbstractMessageListenerContainer container = new StubAbstractMessageListenerContainer(); AmazonSQSAsync mock = mock(AmazonSQSAsync.class, withSettings().stubOnly()); container.setAmazonSqs(mock); container.setMessageHandler(mock(QueueMessageHandler.class)); container.afterPropertiesSet(); when(mock.getQueueUrl(new GetQueueUrlRequest().withQueueName("testQueue"))) .thenReturn(new GetQueueUrlResult() .withQueueUrl("http://testQueue.amazonaws.com")); container.start(); assertThat(container.isRunning()).isTrue(); container.stop(); assertThat(container.isRunning()).isFalse(); // Container can still be active an restarted later (e.g. paused for a while) assertThat(container.isActive()).isTrue(); }
Example #8
Source File: DefaultSqsQueueResourceFactoryTest.java From Cheddar with Apache License 2.0 | 6 votes |
@Test public void shouldCreateSqsQueueResource_withName() throws Exception { // Given final String name = randomString(); final String queueUrl = randomString(); final GetQueueUrlResult getQueueUrlResult = new GetQueueUrlResult().withQueueUrl(queueUrl); final GetQueueUrlRequest expectedGetQueueUrlRequest = new GetQueueUrlRequest(name); when(mockAmazonSqsClient.getQueueUrl(expectedGetQueueUrlRequest)).thenReturn(getQueueUrlResult); final SqsQueueResource mockSqsQueueResource = mock(SqsQueueResource.class); whenNew(SqsQueueResource.class).withArguments(name, queueUrl, mockAmazonSqsClient) .thenReturn(mockSqsQueueResource); // When final SqsQueueResource result = factory.createSqsQueueResource(name); // Then assertSame(mockSqsQueueResource, result); }
Example #9
Source File: AmazonSQSStubTest.java From aws-java-sdk-stubs with Apache License 2.0 | 6 votes |
@Test public void sendAndReceiveMessage() { final String queueName = "bizo"; final String messageBody = "hi everybody"; final CreateQueueRequest createQueueRequest = new CreateQueueRequest().withQueueName(queueName); sqs.createQueue(createQueueRequest); final GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest().withQueueName(queueName); final GetQueueUrlResult getQueueUrlResult = sqs.getQueueUrl(getQueueUrlRequest); final String queueUrl = getQueueUrlResult.getQueueUrl(); final SendMessageRequest sendMessageRequest = new SendMessageRequest().withQueueUrl(queueUrl).withMessageBody(messageBody); sqs.sendMessage(sendMessageRequest); final int maxNumberOfMessages = 10; final ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest().withQueueUrl(queueUrl).withMaxNumberOfMessages(maxNumberOfMessages); final ReceiveMessageResult receiveMessageResult = sqs.receiveMessage(receiveMessageRequest); final List<Message> messages = receiveMessageResult.getMessages(); assertThat(messages.size(), equalTo(1)); assertThat(messages.get(0).getBody(), equalTo(messageBody)); }
Example #10
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test(expected = InvalidDestinationException.class) public void testGetQueueUrlQueueNameThrowQueueDoesNotExistException() throws JMSException { GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME); doThrow(new QueueDoesNotExistException("qdnee")) .when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest)); wrapper.getQueueUrl(QUEUE_NAME); }
Example #11
Source File: AmazonSQSStubTest.java From aws-java-sdk-stubs with Apache License 2.0 | 5 votes |
@Test public void getQueueUrl() { final String queueName = "bizo"; final CreateQueueRequest createQueueRequest = new CreateQueueRequest().withQueueName(queueName); sqs.createQueue(createQueueRequest); final GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest().withQueueName(queueName); final GetQueueUrlResult getQueueUrlResult = sqs.getQueueUrl(getQueueUrlRequest); final String queueUrl = getQueueUrlResult.getQueueUrl(); assertThat(queueUrl, containsString(queueName)); }
Example #12
Source File: SQSImpl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@Override public Queue getQueueByName(GetQueueUrlRequest request, ResultCapture<GetQueueUrlResult> extractor) { ActionResult result = service.performAction("GetQueueByName", request, extractor); if (result == null) return null; return new QueueImpl(result.getResource()); }
Example #13
Source File: SQSImpl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@Override public Queue getQueueByName(String queueName, ResultCapture<GetQueueUrlResult> extractor) { GetQueueUrlRequest request = new GetQueueUrlRequest() .withQueueName(queueName); return getQueueByName(request, extractor); }
Example #14
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test public void testGetQueueUrlQueueName() throws JMSException { GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME); wrapper.getQueueUrl(QUEUE_NAME); verify(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest)); }
Example #15
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test public void testGetQueueUrlQueueNameWithAccountId() throws JMSException { GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME); getQueueUrlRequest.setQueueOwnerAWSAccountId(OWNER_ACCOUNT_ID); wrapper.getQueueUrl(QUEUE_NAME, OWNER_ACCOUNT_ID); verify(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest)); }
Example #16
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test(expected = JMSException.class) public void testGetQueueUrlQueueNameThrowAmazonClientException() throws JMSException { GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME); doThrow(new AmazonClientException("ace")) .when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest)); wrapper.getQueueUrl(QUEUE_NAME); }
Example #17
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test(expected = JMSException.class) public void testGetQueueUrlQueueNameThrowAmazonServiceException() throws JMSException { GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME); doThrow(new AmazonServiceException("ase")) .when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest)); wrapper.getQueueUrl(QUEUE_NAME); }
Example #18
Source File: AmazonSQSStubTest.java From aws-java-sdk-stubs with Apache License 2.0 | 5 votes |
@Test(expected = ReceiptHandleIsInvalidException.class) public void deleteMessageFailsWithInvalidReceiptHandle() { final String queueName = "bizo"; final String messageBody = "hi everybody"; final CreateQueueRequest createQueueRequest = new CreateQueueRequest().withQueueName(queueName); sqs.createQueue(createQueueRequest); final GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest().withQueueName(queueName); final GetQueueUrlResult getQueueUrlResult = sqs.getQueueUrl(getQueueUrlRequest); final String queueUrl = getQueueUrlResult.getQueueUrl(); final SendMessageRequest sendMessageRequest = new SendMessageRequest().withQueueUrl(queueUrl).withMessageBody(messageBody); sqs.sendMessage(sendMessageRequest); final ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest().withQueueUrl(queueUrl); final ReceiveMessageResult receiveMessageResult = sqs.receiveMessage(receiveMessageRequest); final List<Message> messages = receiveMessageResult.getMessages(); assertThat(messages.size(), equalTo(1)); final String receiptHandle = "bizo"; final DeleteMessageRequest deleteMessageRequest = new DeleteMessageRequest().withQueueUrl(queueUrl).withReceiptHandle(receiptHandle); sqs.deleteMessage(deleteMessageRequest); }
Example #19
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test(expected = InvalidDestinationException.class) public void testGetQueueUrlQueueNameWithAccountIdThrowQueueDoesNotExistException() throws JMSException { GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME); getQueueUrlRequest.setQueueOwnerAWSAccountId(OWNER_ACCOUNT_ID); doThrow(new QueueDoesNotExistException("qdnee")) .when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest)); wrapper.getQueueUrl(QUEUE_NAME,OWNER_ACCOUNT_ID); }
Example #20
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test public void testGetQueueUrl() throws JMSException { GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME); wrapper.getQueueUrl(getQueueUrlRequest); verify(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest)); }
Example #21
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test(expected = JMSException.class) public void testGetQueueUrlThrowAmazonClientException() throws JMSException { GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME); doThrow(new AmazonClientException("ace")) .when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest)); wrapper.getQueueUrl(getQueueUrlRequest); }
Example #22
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test(expected = JMSException.class) public void testGetQueueUrlThrowAmazonServiceException() throws JMSException { GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME); doThrow(new AmazonServiceException("ase")) .when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest)); wrapper.getQueueUrl(QUEUE_NAME); }
Example #23
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test public void testQueueExistsThrowQueueDoesNotExistException() throws JMSException { GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME); doThrow(new QueueDoesNotExistException("qdnee")) .when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest)); assertFalse(wrapper.queueExists(QUEUE_NAME)); }
Example #24
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test(expected = JMSException.class) public void testQueueExistsThrowAmazonClientException() throws JMSException { GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME); doThrow(new AmazonClientException("ace")) .when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest)); wrapper.queueExists(QUEUE_NAME); }
Example #25
Source File: AmazonSQSMessagingClientWrapperTest.java From amazon-sqs-java-messaging-lib with Apache License 2.0 | 5 votes |
@Test(expected = JMSException.class) public void testQueueExistsThrowAmazonServiceException() throws JMSException { GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest(QUEUE_NAME); doThrow(new AmazonServiceException("ase")) .when(amazonSQSClient).getQueueUrl(eq(getQueueUrlRequest)); wrapper.queueExists(QUEUE_NAME); }
Example #26
Source File: SQSScanWorkflow.java From emodb with Apache License 2.0 | 5 votes |
private String queryQueueUrl(String queueName) { try { return _sqs.getQueueUrl(new GetQueueUrlRequest(queueName)).getQueueUrl(); } catch (QueueDoesNotExistException e) { // Create the queue int visibilityTimeout = queueName.equals(_pendingScanRangeQueue) ? DEFAULT_TASK_CLAIM_VISIBILITY_TIMEOUT : DEFAULT_TASK_COMPLETE_VISIBILITY_TIMEOUT; return _sqs.createQueue( new CreateQueueRequest(queueName) .withAttributes(ImmutableMap.<String, String>of( "VisibilityTimeout", String.valueOf(visibilityTimeout))) ).getQueueUrl(); } }
Example #27
Source File: DynamicQueueUrlDestinationResolverTest.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
@Test void testNoAutoCreate() throws Exception { AmazonSQS amazonSqs = mock(AmazonSQS.class); String queueUrl = "https://foo/bar"; when(amazonSqs.getQueueUrl(new GetQueueUrlRequest("foo"))) .thenReturn(new GetQueueUrlResult().withQueueUrl(queueUrl)); DynamicQueueUrlDestinationResolver dynamicQueueDestinationResolver = new DynamicQueueUrlDestinationResolver( amazonSqs); assertThat(dynamicQueueDestinationResolver.resolveDestination("foo")) .isEqualTo(queueUrl); }
Example #28
Source File: AmazonSQSStubTest.java From aws-java-sdk-stubs with Apache License 2.0 | 5 votes |
@Test public void deleteMessageSucceedsWithValidReceiptHandle() { final String queueName = "bizo"; final String messageBody = "hi everybody"; final CreateQueueRequest createQueueRequest = new CreateQueueRequest().withQueueName(queueName); sqs.createQueue(createQueueRequest); final GetQueueUrlRequest getQueueUrlRequest = new GetQueueUrlRequest().withQueueName(queueName); final GetQueueUrlResult getQueueUrlResult = sqs.getQueueUrl(getQueueUrlRequest); final String queueUrl = getQueueUrlResult.getQueueUrl(); final SendMessageRequest sendMessageRequest = new SendMessageRequest().withQueueUrl(queueUrl).withMessageBody(messageBody); sqs.sendMessage(sendMessageRequest); final int maxNumberOfMessages = 10; final ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest().withQueueUrl(queueUrl).withMaxNumberOfMessages(maxNumberOfMessages); final ReceiveMessageResult receiveMessageResult = sqs.receiveMessage(receiveMessageRequest); final List<Message> messages = receiveMessageResult.getMessages(); assertThat(messages.size(), equalTo(1)); final String receiptHandle = messages.get(0).getReceiptHandle(); final DeleteMessageRequest deleteMessageRequest = new DeleteMessageRequest().withQueueUrl(queueUrl).withReceiptHandle(receiptHandle); try { sqs.deleteMessage(deleteMessageRequest); } catch (ReceiptHandleIsInvalidException e) { fail("ReceiptHandleIsInvalidException was thrown"); } }
Example #29
Source File: MessageListenerContainerTest.java From spring-cloud-aws with Apache License 2.0 | 5 votes |
@Test void testStopCallsDoStopMethodWithRunnable() throws Exception { CountDownLatch countDownLatch = new CountDownLatch(1); AbstractMessageListenerContainer container = new AbstractMessageListenerContainer() { @Override protected void doStart() { // do nothing in this case } @Override protected void doStop() { countDownLatch.countDown(); } }; AmazonSQSAsync mock = mock(AmazonSQSAsync.class, withSettings().stubOnly()); container.setAmazonSqs(mock); container.setMessageHandler(mock(QueueMessageHandler.class)); container.afterPropertiesSet(); when(mock.getQueueUrl(new GetQueueUrlRequest().withQueueName("testQueue"))) .thenReturn(new GetQueueUrlResult() .withQueueUrl("http://testQueue.amazonaws.com")); container.start(); container.stop(() -> { try { assertThat(countDownLatch.await(10, TimeUnit.MILLISECONDS)).isTrue(); } catch (InterruptedException e) { fail("Expected doStart() method to be called"); } }); }
Example #30
Source File: DefaultSqsQueueResourceFactory.java From Cheddar with Apache License 2.0 | 5 votes |
@Override public SqsQueueResource createSqsQueueResource(final String name) { final String queueUrl = amazonSqsClient.getQueueUrl(new GetQueueUrlRequest(name)).getQueueUrl(); logger.info("Using existing SQS queue: " + name); final SqsQueueResource sqsQueueResource = new SqsQueueResource(name, queueUrl, amazonSqsClient); return sqsQueueResource; }