当前位置: 首页>>代码示例>>Java>>正文


Java SetTopicAttributesRequest类代码示例

本文整理汇总了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());
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:20,代码来源:SnsTopicResourceTest.java

示例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);
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:21,代码来源:SnsTopicResourceTest.java

示例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");
    }
    
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:34,代码来源:SnsEndpoint.java

示例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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:AmazonSNSClientMock.java

示例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);
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:10,代码来源:TopicImpl.java

示例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()));
}
 
开发者ID:daflockinger,项目名称:unitstack,代码行数:6,代码来源:MockSnsTest.java

示例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());
	}
 
开发者ID:highsource,项目名称:aufzugswaechter,代码行数:45,代码来源:DynamicSnsProducer.java

示例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()));
}
 
开发者ID:travel-cloud,项目名称:Cheddar,代码行数:10,代码来源:SnsTopicResource.java

示例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);
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:20,代码来源:Topic.java


注:本文中的com.amazonaws.services.sns.model.SetTopicAttributesRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。