本文整理汇总了Java中com.amazonaws.services.sns.model.SetTopicAttributesRequest类的典型用法代码示例。如果您正苦于以下问题:Java SetTopicAttributesRequest类的具体用法?Java SetTopicAttributesRequest怎么用?Java SetTopicAttributesRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SetTopicAttributesRequest类属于com.amazonaws.services.sns.model包,在下文中一共展示了SetTopicAttributesRequest类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldSetPolicy_withPolicy
import com.amazonaws.services.sns.model.SetTopicAttributesRequest; //导入依赖的package包/类
@Test
public void shouldSetPolicy_withPolicy() {
// Given
final Policy mockPolicy = mock(Policy.class);
final String mockPolicyJson = randomString();
when(mockPolicy.toJson()).thenReturn(mockPolicyJson);
// When
snsTopicResource.setPolicy(mockPolicy);
// Then
final ArgumentCaptor<SetTopicAttributesRequest> captor = ArgumentCaptor
.forClass(SetTopicAttributesRequest.class);
verify(mockAmazonSnsClient).setTopicAttributes(captor.capture());
final SetTopicAttributesRequest setTopicAttributesRequest = captor.getValue();
assertEquals(topicArn, setTopicAttributesRequest.getTopicArn());
assertEquals("Policy", setTopicAttributesRequest.getAttributeName());
assertEquals(mockPolicyJson, setTopicAttributesRequest.getAttributeValue());
}
示例2: shouldThrowException_onAmazonClientExceptionFromSetPolicy
import com.amazonaws.services.sns.model.SetTopicAttributesRequest; //导入依赖的package包/类
@Test
public void shouldThrowException_onAmazonClientExceptionFromSetPolicy() {
// Given
final Policy mockPolicy = mock(Policy.class);
final String mockPolicyJson = randomString();
when(mockPolicy.toJson()).thenReturn(mockPolicyJson);
doThrow(AmazonClientException.class).when(mockAmazonSnsClient)
.setTopicAttributes(any(SetTopicAttributesRequest.class));
// When
AmazonClientException thrownException = null;
try {
snsTopicResource.setPolicy(mockPolicy);
} catch (final AmazonClientException e) {
thrownException = e;
}
// Then
assertNotNull(thrownException);
}
示例3: doStart
import com.amazonaws.services.sns.model.SetTopicAttributesRequest; //导入依赖的package包/类
@Override
public void doStart() throws Exception {
super.doStart();
snsClient = configuration.getAmazonSNSClient() != null
? configuration.getAmazonSNSClient() : createSNSClient();
// Override the setting Endpoint from url
if (ObjectHelper.isNotEmpty(configuration.getAmazonSNSEndpoint())) {
LOG.trace("Updating the SNS region with : {} " + configuration.getAmazonSNSEndpoint());
snsClient.setEndpoint(configuration.getAmazonSNSEndpoint());
}
if (configuration.getTopicArn() == null) {
// creates a new topic, or returns the URL of an existing one
CreateTopicRequest request = new CreateTopicRequest(configuration.getTopicName());
LOG.trace("Creating topic [{}] with request [{}]...", configuration.getTopicName(), request);
CreateTopicResult result = snsClient.createTopic(request);
configuration.setTopicArn(result.getTopicArn());
LOG.trace("Topic created with Amazon resource name: {}", configuration.getTopicArn());
}
if (ObjectHelper.isNotEmpty(configuration.getPolicy())) {
LOG.trace("Updating topic [{}] with policy [{}]", configuration.getTopicArn(), configuration.getPolicy());
snsClient.setTopicAttributes(new SetTopicAttributesRequest(configuration.getTopicArn(), "Policy", configuration.getPolicy()));
LOG.trace("Topic policy updated");
}
}
示例4: setTopicAttributes
import com.amazonaws.services.sns.model.SetTopicAttributesRequest; //导入依赖的package包/类
@Override
public SetTopicAttributesResult setTopicAttributes(SetTopicAttributesRequest setTopicAttributesRequest) throws AmazonServiceException, AmazonClientException {
Assert.assertEquals(DEFAULT_TOPIC_ARN, setTopicAttributesRequest.getTopicArn());
Assert.assertEquals("Policy", setTopicAttributesRequest.getAttributeName());
Assert.assertEquals("XXX", setTopicAttributesRequest.getAttributeValue());
return new SetTopicAttributesResult();
}
示例5: setAttributes
import com.amazonaws.services.sns.model.SetTopicAttributesRequest; //导入依赖的package包/类
@Override
public void setAttributes(String attributeName, String attributeValue,
ResultCapture<Void> extractor) {
SetTopicAttributesRequest request = new SetTopicAttributesRequest()
.withAttributeName(attributeName)
.withAttributeValue(attributeValue);
setAttributes(request, extractor);
}
示例6: testSetTopicAttributes_withNoRequestParams_shouldWork
import com.amazonaws.services.sns.model.SetTopicAttributesRequest; //导入依赖的package包/类
@Test
public void testSetTopicAttributes_withNoRequestParams_shouldWork() {
mockSns(new MockParameters());
assertNotNull(sns.setTopicAttributes(new SetTopicAttributesRequest()));
}
示例7: process
import com.amazonaws.services.sns.model.SetTopicAttributesRequest; //导入依赖的package包/类
public void process(Exchange exchange) throws Exception {
// TODO cache arns and don't create if not necessary
final String topic = determineTopic(exchange);
// creates a new topic, or returns the URL of an existing one
CreateTopicRequest request = new CreateTopicRequest(topic);
LOG.trace("Creating topic [{}] with request [{}]...", topic, request);
final AmazonSNS snsClient = getEndpoint().getSNSClient();
CreateTopicResult result = snsClient.createTopic(request);
final String topicArn = result.getTopicArn();
LOG.trace("Topic created with Amazon resource name: {}", topicArn);
final SnsConfiguration configuration = getEndpoint().getConfiguration();
if (ObjectHelper.isNotEmpty(configuration.getPolicy())) {
LOG.trace("Updating topic [{}] with policy [{}]", topicArn, configuration.getPolicy());
snsClient.setTopicAttributes(
new SetTopicAttributesRequest(topicArn, "Policy", configuration.getPolicy()));
LOG.trace("Topic policy updated");
}
PublishRequest publishRequest = new PublishRequest();
publishRequest.setTopicArn(topicArn);
publishRequest.setSubject(determineSubject(exchange));
publishRequest.setMessageStructure(determineMessageStructure(exchange));
publishRequest.setMessage(exchange.getIn().getBody(String.class));
LOG.trace("Sending request [{}] from exchange [{}]...", publishRequest, exchange);
PublishResult publishResult = snsClient.publish(publishRequest);
LOG.trace("Received result [{}]", publishResult);
Message message = getMessageForResponse(exchange);
message.setHeader(SnsConstants.MESSAGE_ID, publishResult.getMessageId());
}
示例8: setPolicy
import com.amazonaws.services.sns.model.SetTopicAttributesRequest; //导入依赖的package包/类
/**
* Sets the {@link Policy} of the AWS SNS topic
* @param policy {@link Policy} to set
* @throws AmazonClientException
*/
public void setPolicy(final Policy policy) throws AmazonClientException {
amazonSnsClient
.setTopicAttributes(new SetTopicAttributesRequest(topicArn, TOPIC_POLICY_ATTRIBUTE, policy.toJson()));
}
示例9: setAttributes
import com.amazonaws.services.sns.model.SetTopicAttributesRequest; //导入依赖的package包/类
/**
* Performs the <code>SetAttributes</code> action.
*
* <p>
* The following request parameters will be populated from the data of this
* <code>Topic</code> resource, and any conflicting parameter value set in
* the request will be overridden:
* <ul>
* <li>
* <b><code>TopicArn</code></b>
* - mapped from the <code>Arn</code> identifier.
* </li>
* </ul>
*
* <p>
*
* @see SetTopicAttributesRequest
*/
void setAttributes(SetTopicAttributesRequest request);