Package com.google.api.client.googleapis.testing.compute

Examples of com.google.api.client.googleapis.testing.compute.MockMetadataServerTransport


  static final String ACCESS_TOKEN = "ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_QtAS08i85nHq39HE3C2LTrCARA";

  public void testExecuteRefreshToken() throws Exception {

    HttpTransport transport = new MockMetadataServerTransport(ACCESS_TOKEN);

    ComputeCredential credential = new ComputeCredential(transport, new JacksonFactory());

    assertTrue(credential.refreshToken());
    assertEquals(ACCESS_TOKEN, credential.getAccessToken());
View Full Code Here


    assertSame(firstCall, secondCall);
  }

  public void testDefaultCredentialCompute() throws IOException {
    HttpTransport transport = new MockMetadataServerTransport(ACCESS_TOKEN);
    TestDefaultCredentialProvider testProvider = new TestDefaultCredentialProvider();

    Credential defaultCredential = testProvider.getDefaultCredential(transport, JSON_FACTORY);
    assertNotNull(defaultCredential);
View Full Code Here

    assertTrue(defaultCredential.refreshToken());
    assertEquals(ACCESS_TOKEN, defaultCredential.getAccessToken());
  }

  public void testDefaultCredentialComputeErrorNotFound() throws IOException {
    MockMetadataServerTransport transport = new MockMetadataServerTransport(ACCESS_TOKEN);
    transport.setTokenRequestStatusCode(HttpStatusCodes.STATUS_CODE_NOT_FOUND);
    TestDefaultCredentialProvider testProvider = new TestDefaultCredentialProvider();

    Credential defaultCredential = testProvider.getDefaultCredential(transport, JSON_FACTORY);
    assertNotNull(defaultCredential);
View Full Code Here

      assertTrue(message.contains("scope"));
    }
  }

  public void testDefaultCredentialComputeErrorUnexpected() throws IOException {
    MockMetadataServerTransport transport = new MockMetadataServerTransport(ACCESS_TOKEN);
    transport.setTokenRequestStatusCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR);
    TestDefaultCredentialProvider testProvider = new TestDefaultCredentialProvider();

    Credential defaultCredential = testProvider.getDefaultCredential(transport, JSON_FACTORY);
    assertNotNull(defaultCredential);
View Full Code Here

TOP

Related Classes of com.google.api.client.googleapis.testing.compute.MockMetadataServerTransport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.