Author: cmueller Date: Sat Nov 10 11:04:51 2012 New Revision: 1407758 URL: http://svn.apache.org/viewvc?rev=1407758&view=rev Log: CAMEL-5782: regression : invalid SetQueueAttributesRequest created, works on 2.10.1
Added: camel/branches/camel-2.10.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsEndpointTest.java Modified: camel/branches/camel-2.10.x/components/camel-aws/pom.xml camel/branches/camel-2.10.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java Modified: camel/branches/camel-2.10.x/components/camel-aws/pom.xml URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-aws/pom.xml?rev=1407758&r1=1407757&r2=1407758&view=diff ============================================================================== --- camel/branches/camel-2.10.x/components/camel-aws/pom.xml (original) +++ camel/branches/camel-2.10.x/components/camel-aws/pom.xml Sat Nov 10 11:04:51 2012 @@ -115,6 +115,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.easymock</groupId> + <artifactId>easymockclassextension</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <scope>test</scope> Modified: camel/branches/camel-2.10.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java?rev=1407758&r1=1407757&r2=1407758&view=diff ============================================================================== --- camel/branches/camel-2.10.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java (original) +++ camel/branches/camel-2.10.x/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java Sat Nov 10 11:04:51 2012 @@ -120,8 +120,6 @@ public class SqsEndpoint extends Schedul } private void updateQueueAttributes(AmazonSQSClient client) { - LOG.trace("Updating queue '{}' with the provided queue attributes...", configuration.getQueueName()); - SetQueueAttributesRequest request = new SetQueueAttributesRequest(); request.setQueueUrl(queueUrl); if (getConfiguration().getDefaultVisibilityTimeout() != null) { @@ -136,9 +134,12 @@ public class SqsEndpoint extends Schedul if (getConfiguration().getPolicy() != null) { request.getAttributes().put(QueueAttributeName.Policy.name(), String.valueOf(getConfiguration().getPolicy())); } - client.setQueueAttributes(request); - LOG.trace("Queue '{}' updated and available at {}'", configuration.getQueueName(), queueUrl); + if (!request.getAttributes().isEmpty()) { + LOG.trace("Updating queue '{}' with the provided queue attributes...", configuration.getQueueName()); + client.setQueueAttributes(request); + LOG.trace("Queue '{}' updated and available at {}'", configuration.getQueueName(), queueUrl); + } } @Override Added: camel/branches/camel-2.10.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsEndpointTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsEndpointTest.java?rev=1407758&view=auto ============================================================================== --- camel/branches/camel-2.10.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsEndpointTest.java (added) +++ camel/branches/camel-2.10.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsEndpointTest.java Sat Nov 10 11:04:51 2012 @@ -0,0 +1,55 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.aws.sqs; + +import org.apache.camel.impl.DefaultCamelContext; +import org.easymock.EasyMock; +import org.junit.Before; +import org.junit.Test; + +import com.amazonaws.services.sqs.AmazonSQSClient; +import com.amazonaws.services.sqs.model.ListQueuesResult; + +public class SqsEndpointTest { + + private SqsEndpoint endpoint; + private AmazonSQSClient amazonSQSClient; + + @Before + public void setUp() throws Exception { + amazonSQSClient = EasyMock.createMock(AmazonSQSClient.class); + + SqsConfiguration config = new SqsConfiguration(); + config.setQueueName("test-queue"); + config.setAmazonSQSClient(amazonSQSClient); + + endpoint = new SqsEndpoint("aws-sqs://test-queue", new SqsComponent(new DefaultCamelContext()), config); + + } + + @Test + public void doStartShouldNotCallUpdateQueueAttributesIfQueueExistAndNoOptionIsSpecified() throws Exception { + EasyMock.expect(amazonSQSClient.listQueues()) + .andReturn(new ListQueuesResult().withQueueUrls("https://sqs.us-east-1.amazonaws.com/ID/dummy-queue", "https://sqs.us-east-1.amazonaws.com/ID/test-queue")); + + EasyMock.replay(amazonSQSClient); + + endpoint.doStart(); + + EasyMock.verify(amazonSQSClient); + } +} \ No newline at end of file