Java Code Examples for com.google.cloud.storage.testing.RemoteStorageHelper#generateBucketName()

The following examples show how to use com.google.cloud.storage.testing.RemoteStorageHelper#generateBucketName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ITBlobSnippets.java    From google-cloud-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testMoveObject() {
  String blob = "movethisblob";
  storage.create(BlobInfo.newBuilder(BlobId.of(BUCKET, blob)).build());
  assertNotNull(storage.get(BUCKET, blob));
  String newBucket = RemoteStorageHelper.generateBucketName();
  storage.create(BucketInfo.newBuilder(newBucket).build());
  try {
    MoveObject.moveObject(PROJECT_ID, BUCKET, blob, newBucket);
    assertNotNull(storage.get(newBucket, blob));
    assertNull(storage.get(BUCKET, blob));
  } finally {
    storage.delete(newBucket, blob);
    storage.delete(newBucket);
  }
}
 
Example 2
Source File: GcsBucket.java    From gcp-ingestion with Mozilla Public License 2.0 5 votes vote down vote up
/** Find credentials in the environment and create a bucket in GCS. */
@Override
protected void starting(Description description) {
  RemoteStorageHelper storageHelper = RemoteStorageHelper.create();
  storage = storageHelper.getOptions().getService();
  bucket = RemoteStorageHelper.generateBucketName();
  storage.create(BucketInfo.newBuilder(bucket).build());
}
 
Example 3
Source File: KeyStoreIntegrationTest.java    From gcp-ingestion with Mozilla Public License 2.0 5 votes vote down vote up
/** Create a storage bucket for metadata and keys. */
@Before
public void createBucket() {
  RemoteStorageHelper storageHelper = RemoteStorageHelper.create();
  storage = storageHelper.getOptions().getService();
  projectId = storageHelper.getOptions().getProjectId();
  bucket = RemoteStorageHelper.generateBucketName();
  storage.create(BucketInfo.of(bucket));
}
 
Example 4
Source File: StorageIntegrationTest.java    From gcp-ingestion with Mozilla Public License 2.0 5 votes vote down vote up
/** Find credentials in the environment and create a bucket in GCS. */
@Before
public void createBucket() {
  RemoteStorageHelper storageHelper = RemoteStorageHelper.create();
  storage = storageHelper.getOptions().getService();
  projectId = storageHelper.getOptions().getProjectId();
  bucket = RemoteStorageHelper.generateBucketName();
  storage.create(BucketInfo.of(bucket));
}
 
Example 5
Source File: ITBucketSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateBucketWithStorageClassAndLocation() {
  String newBucket = RemoteStorageHelper.generateBucketName();
  CreateBucketWithStorageClassAndLocation.createBucketWithStorageClassAndLocation(
      PROJECT_ID, newBucket);
  try {
    Bucket remoteBucket = storage.get(newBucket);
    assertNotNull(remoteBucket);
    assertEquals("COLDLINE", remoteBucket.getStorageClass().name());
    assertEquals("ASIA", remoteBucket.getLocation());
  } finally {
    storage.delete(newBucket);
  }
}
 
Example 6
Source File: ITBucketSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeleteBucket() {
  String newBucket = RemoteStorageHelper.generateBucketName();
  storage.create(BucketInfo.newBuilder(newBucket).build());
  assertNotNull(storage.get(newBucket));
  try {
    DeleteBucket.deleteBucket(PROJECT_ID, newBucket);
    assertNull(storage.get(newBucket));
  } finally {
    storage.delete(newBucket);
  }
}
 
Example 7
Source File: ITBlobSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testCopyObject() {
  String newBucket = RemoteStorageHelper.generateBucketName();
  storage.create(BucketInfo.newBuilder(newBucket).build());
  try {
    CopyObject.copyObject(PROJECT_ID, BUCKET, BLOB, newBucket);
    assertNotNull(storage.get(newBucket, BLOB));
  } finally {
    storage.delete(newBucket, BLOB);
    storage.delete(newBucket);
  }
}
 
Example 8
Source File: ITStorageSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testLockRetentionPolicy() {
  String tempBucket = RemoteStorageHelper.generateBucketName();
  Bucket bucket = storageSnippets.createBucket(tempBucket);
  assertNotNull(bucket);
  bucket = storageSnippets.setRetentionPolicy(tempBucket, RETENTION_PERIOD);
  assertEquals(bucket.getRetentionPeriod(), RETENTION_PERIOD);
  bucket = storageSnippets.lockRetentionPolicy(tempBucket);
  assertTrue(bucket.retentionPolicyIsLocked());
}
 
Example 9
Source File: ITStorageSnippets.java    From google-cloud-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testUniformBucketLevelAccess() {
  String tempBucket = RemoteStorageHelper.generateBucketName();
  Bucket bucket = storageSnippets.createBucket(tempBucket);
  assertNotNull(bucket);
  bucket = storageSnippets.enableUniformBucketLevelAccess(tempBucket);
  assertTrue(bucket.getIamConfiguration().isUniformBucketLevelAccessEnabled());
  assertNotNull(bucket.getIamConfiguration().getUniformBucketLevelAccessLockedTime());
  bucket = storageSnippets.getUniformBucketLevelAccess(tempBucket);
  assertTrue(bucket.getIamConfiguration().isUniformBucketLevelAccessEnabled());
  assertNotNull(bucket.getIamConfiguration().getUniformBucketLevelAccessLockedTime());
  bucket = storageSnippets.disableUniformBucketLevelAccess(tempBucket);
  assertFalse(bucket.getIamConfiguration().isUniformBucketLevelAccessEnabled());
}