|
33 | 33 | import com.google.cloud.bigquery.TableInfo;
|
34 | 34 | import com.google.cloud.pubsub.v1.SubscriptionAdminClient;
|
35 | 35 | import com.google.cloud.pubsub.v1.TopicAdminClient;
|
| 36 | +import com.google.protobuf.Duration; |
36 | 37 | import com.google.pubsub.v1.SubscriptionName;
|
37 | 38 | import com.google.pubsub.v1.TopicName;
|
38 | 39 | import java.io.ByteArrayOutputStream;
|
@@ -73,6 +74,12 @@ public class AdminIT {
|
73 | 74 | "java_samples_data_set" + _suffix.replace("-", "_");
|
74 | 75 | private static final String bigquerySubscriptionId = "iam-bigquery-subscription-" + _suffix;
|
75 | 76 | private static final String bigqueryTableId = "java_samples_table_" + _suffix;
|
| 77 | + private static final String cloudStorageSubscriptionId = |
| 78 | + "iam-cloud-storage-subscription-" + _suffix; |
| 79 | + private static final String cloudStorageFilenamePrefix = "log_events_"; |
| 80 | + private static final String cloudStorageFilenameSuffix = ".txt"; |
| 81 | + private static final Duration cloudStorageMaxDuration = |
| 82 | + Duration.newBuilder().setSeconds(300).build(); |
76 | 83 | private static final String gcpServiceAccount =
|
77 | 84 |
|
78 | 85 | // AWS Kinesis ingestion settings.
|
@@ -322,13 +329,30 @@ public void testAdmin() throws Exception {
|
322 | 329 | assertThat(bout.toString()).contains("Created a BigQuery subscription:");
|
323 | 330 | assertThat(bout.toString()).contains(bigqueryTablePath);
|
324 | 331 |
|
| 332 | + bout.reset(); |
| 333 | + // Test create a Cloud Storage subscription. |
| 334 | + CreateCloudStorageSubscriptionExample.createCloudStorageSubscription( |
| 335 | + projectId, |
| 336 | + topicId, |
| 337 | + cloudStorageSubscriptionId, |
| 338 | + cloudStorageBucket, |
| 339 | + cloudStorageFilenamePrefix, |
| 340 | + cloudStorageFilenameSuffix, |
| 341 | + cloudStorageMaxDuration); |
| 342 | + assertThat(bout.toString()).contains("Created a CloudStorage subscription:"); |
| 343 | + assertThat(bout.toString()).contains(cloudStorageBucket); |
| 344 | + assertThat(bout.toString()).contains(cloudStorageFilenamePrefix); |
| 345 | + assertThat(bout.toString()).contains(cloudStorageFilenameSuffix); |
| 346 | + assertThat(bout.toString()).contains(Long.toString(cloudStorageMaxDuration.getSeconds())); |
| 347 | + |
325 | 348 | bout.reset();
|
326 | 349 | // Test delete subscription.
|
327 | 350 | DeleteSubscriptionExample.deleteSubscriptionExample(projectId, pullSubscriptionId);
|
328 | 351 | DeleteSubscriptionExample.deleteSubscriptionExample(projectId, pushSubscriptionId);
|
329 | 352 | DeleteSubscriptionExample.deleteSubscriptionExample(projectId, orderedSubscriptionId);
|
330 | 353 | DeleteSubscriptionExample.deleteSubscriptionExample(projectId, exactlyOnceSubscriptionId);
|
331 | 354 | DeleteSubscriptionExample.deleteSubscriptionExample(projectId, bigquerySubscriptionId);
|
| 355 | + DeleteSubscriptionExample.deleteSubscriptionExample(projectId, cloudStorageSubscriptionId); |
332 | 356 | assertThat(bout.toString()).contains("Deleted subscription.");
|
333 | 357 |
|
334 | 358 | bout.reset();
|
|
0 commit comments