Skip to content

Commit

Permalink
fix for codenarcLatestDepForkedTest
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyzhao2018 committed May 24, 2024
1 parent 34f130d commit b58d794
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import static org.testcontainers.containers.localstack.LocalStackContainer.Servi
import static org.testcontainers.containers.localstack.LocalStackContainer.Service.SQS

abstract class SnsClientTest extends VersionedNamingTestBase {
static final localstack = new LocalStackContainer(DockerImageName.parse("localstack/localstack:latest"))
static final LOCALSTACK = new LocalStackContainer(DockerImageName.parse("localstack/localstack:latest"))
.withServices( SQS, SNS)
@Shared AmazonSNSClient snsClient
@Shared SqsClient sqsClient
Expand All @@ -33,14 +33,14 @@ abstract class SnsClientTest extends VersionedNamingTestBase {
@Shared String testTopicARN

def setupSpec() {
localstack.start()
LOCALSTACK.start()
snsClient = AmazonSNSClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration( localstack.getEndpointOverride(SNS).toString(), localstack.getRegion()))
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration( LOCALSTACK.getEndpointOverride(SNS).toString(), LOCALSTACK.getRegion()))
.withCredentials( new AWSStaticCredentialsProvider(new BasicAWSCredentials("test", "test")))
.build()
sqsClient = SqsClient.builder()
.endpointOverride(localstack.getEndpointOverride(SQS))
.region(Region.of(localstack.getRegion()))
.endpointOverride(LOCALSTACK.getEndpointOverride(SQS))
.region(Region.of(LOCALSTACK.getRegion()))
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("test", "test")))
.build()
testQueueURL = sqsClient.createQueue { it.queueName("testqueue") }.queueUrl()
Expand All @@ -50,7 +50,7 @@ abstract class SnsClientTest extends VersionedNamingTestBase {
}

def cleanupSpec() {
localstack.stop()
LOCALSTACK.stop()
}

@Override
Expand Down Expand Up @@ -100,14 +100,14 @@ abstract class SnsClientTest extends VersionedNamingTestBase {
tags {
"$Tags.COMPONENT" "java-aws-sdk"
"$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT
"$Tags.HTTP_URL" localstack.getEndpointOverride(SNS).toString()+'/'
"$Tags.HTTP_URL" LOCALSTACK.getEndpointOverride(SNS).toString()+'/'
"$Tags.HTTP_METHOD" "POST"
"$Tags.HTTP_STATUS" 200
"$Tags.PEER_PORT" localstack.getEndpointOverride(SNS).port
"$Tags.PEER_HOSTNAME" localstack.getEndpointOverride(SNS).host
"$Tags.PEER_PORT" LOCALSTACK.getEndpointOverride(SNS).port
"$Tags.PEER_HOSTNAME" LOCALSTACK.getEndpointOverride(SNS).host
"aws.service" "AmazonSNS"
"aws_service" "sns"
"aws.endpoint" localstack.getEndpointOverride(SNS).toString()
"aws.endpoint" LOCALSTACK.getEndpointOverride(SNS).toString()
"aws.operation" "PublishRequest"
"aws.agent" "java-aws-sdk"
"aws.topic.name" "testtopic"
Expand All @@ -128,11 +128,11 @@ abstract class SnsClientTest extends VersionedNamingTestBase {
tags {
"$Tags.COMPONENT" "apache-httpclient"
"$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT
"$Tags.HTTP_URL" localstack.getEndpointOverride(SNS).toString()+'/'
"$Tags.HTTP_URL" LOCALSTACK.getEndpointOverride(SNS).toString()+'/'
"$Tags.HTTP_METHOD" "POST"
"$Tags.HTTP_STATUS" 200
"$Tags.PEER_PORT" localstack.getEndpointOverride(SNS).port
"$Tags.PEER_HOSTNAME" localstack.getEndpointOverride(SNS).host
"$Tags.PEER_PORT" LOCALSTACK.getEndpointOverride(SNS).port
"$Tags.PEER_HOSTNAME" LOCALSTACK.getEndpointOverride(SNS).host
defaultTags(true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import static org.testcontainers.containers.localstack.LocalStackContainer.Servi
import static org.testcontainers.containers.localstack.LocalStackContainer.Service.SQS

abstract class SnsClientTest extends VersionedNamingTestBase {
static final localstack = new LocalStackContainer(DockerImageName.parse("localstack/localstack:latest"))
static final LOCALSTACK = new LocalStackContainer(DockerImageName.parse("localstack/localstack:latest"))
.withServices( SQS, SNS)
@Shared SnsClient snsClient
@Shared SqsClient sqsClient
Expand All @@ -31,15 +31,15 @@ abstract class SnsClientTest extends VersionedNamingTestBase {
@Shared String testTopicARN

def setupSpec() {
localstack.start()
LOCALSTACK.start()
snsClient = SnsClient.builder()
.endpointOverride(localstack.getEndpointOverride(LocalStackContainer.Service.SNS))
.region(Region.of(localstack.getRegion()))
.endpointOverride(LOCALSTACK.getEndpointOverride(LocalStackContainer.Service.SNS))
.region(Region.of(LOCALSTACK.getRegion()))
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("test", "test")))
.build()
sqsClient = SqsClient.builder()
.endpointOverride(localstack.getEndpointOverride(SQS))
.region(Region.of(localstack.getRegion()))
.endpointOverride(LOCALSTACK.getEndpointOverride(SQS))
.region(Region.of(LOCALSTACK.getRegion()))
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("test", "test")))
.build()
testQueueURL = sqsClient.createQueue { it.queueName("testqueue") }.queueUrl()
Expand All @@ -49,7 +49,7 @@ abstract class SnsClientTest extends VersionedNamingTestBase {
}

def cleanupSpec() {
localstack.stop()
LOCALSTACK.stop()
}

@Override
Expand Down Expand Up @@ -100,11 +100,11 @@ abstract class SnsClientTest extends VersionedNamingTestBase {
tags {
"$Tags.COMPONENT" "java-aws-sdk"
"$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT
"$Tags.HTTP_URL" localstack.getEndpointOverride(SNS).toString()+'/'
"$Tags.HTTP_URL" LOCALSTACK.getEndpointOverride(SNS).toString()+'/'
"$Tags.HTTP_METHOD" "POST"
"$Tags.HTTP_STATUS" 200
"$Tags.PEER_PORT" localstack.getEndpointOverride(SNS).port
"$Tags.PEER_HOSTNAME" localstack.getEndpointOverride(SNS).host
"$Tags.PEER_PORT" LOCALSTACK.getEndpointOverride(SNS).port
"$Tags.PEER_HOSTNAME" LOCALSTACK.getEndpointOverride(SNS).host
"aws.service" "Sns"
"aws_service" "Sns"
"aws.operation" "Publish"
Expand Down

0 comments on commit b58d794

Please sign in to comment.