コード例 #1
0
  /*
   * Retrieve the default Google Cloud Storage bucket name.
   */
  @Test
  public void testGetDefaultGcsBucketName() {
    ApiProxy.Environment env = ApiProxy.getCurrentEnvironment();
    String expectedBucketName;
    Property property = property("testGetDefaultGcsBucketName");
    if (property.exists()) {
      expectedBucketName = property.getPropertyValue();
    } else {
      expectedBucketName =
          (String) env.getAttributes().get("com.google.appengine.runtime.default_version_hostname");
    }

    try {
      String bucketName = appIdentity.getDefaultGcsBucketName();
      Assert.assertEquals(expectedBucketName, bucketName);
    } catch (AppIdentityServiceFailureException aisfe) {
      // TODO: This means that there is no default bucket setup for this project.  Have a better way
      // to verify this.
    }
  }