-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor Spring Integration Pub/Sub Sample tests to use unique…
… resources (#2085) * chore: refactor Spring Integration Pub/Sub sample tests to use unique resources
- Loading branch information
Showing
18 changed files
with
463 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...-gcp-integration-pubsub-sample-polling-receiver/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
subscriptionName=exampleSubscription |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...lling-receiver/src/test/java/com/example/PollingReceiverIntegrationTestConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed 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 | ||
* | ||
* https://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 com.example; | ||
|
||
import com.google.cloud.ServiceOptions; | ||
import com.google.cloud.pubsub.v1.SubscriptionAdminClient; | ||
import com.google.cloud.pubsub.v1.TopicAdminClient; | ||
import com.google.pubsub.v1.ProjectName; | ||
import com.google.pubsub.v1.PushConfig; | ||
import com.google.pubsub.v1.Subscription; | ||
import com.google.pubsub.v1.SubscriptionName; | ||
import com.google.pubsub.v1.Topic; | ||
import com.google.pubsub.v1.TopicName; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
@TestConfiguration | ||
public class PollingReceiverIntegrationTestConfiguration { | ||
|
||
private String topicName; | ||
private TopicAdminClient topicAdminClient; | ||
|
||
private SubscriptionAdminClient subscriptionAdminClient; | ||
|
||
public PollingReceiverIntegrationTestConfiguration( | ||
TopicAdminClient topicAdminClient, | ||
SubscriptionAdminClient subscriptionAdminClient, | ||
@Value("${topicName}") String topicName) { | ||
this.topicAdminClient = topicAdminClient; | ||
this.subscriptionAdminClient = subscriptionAdminClient; | ||
this.topicName = topicName; | ||
} | ||
|
||
@Bean | ||
public Topic createTopic() { | ||
String projectName = ProjectName.of(ServiceOptions.getDefaultProjectId()).getProject(); | ||
return topicAdminClient.createTopic(TopicName.of(projectName, this.topicName)); | ||
} | ||
|
||
@Bean | ||
public Subscription createSubscription(@Qualifier("subscriptionName") String subscriptionName) { | ||
String projectName = ProjectName.of(ServiceOptions.getDefaultProjectId()).getProject(); | ||
return subscriptionAdminClient.createSubscription( | ||
SubscriptionName.of(projectName, subscriptionName), | ||
TopicName.of(projectName, this.topicName), | ||
PushConfig.getDefaultInstance(), | ||
10); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
...integration-pubsub-sample-polling-receiver/src/test/resources/application-test.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
topicName=topic-name-${random.uuid} | ||
subscriptionName=subscription-name-${random.uuid} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ng-cloud-gcp-integration-pubsub-sample-receiver/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
|
||
subscriptionName=exampleSubscription |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.