Examples of MockHttpTransport


Examples of com.google.api.client.testing.http.MockHttpTransport

      assertTrue(message.contains(DefaultCredentialProvider.HELP_PERMALINK));
    }
  }

  public void testDefaultCredentialAppEngineWithoutDependencyThrowsHelpfulLoadError() {
    HttpTransport transport = new MockHttpTransport();
    TestDefaultCredentialProvider testProvider = new TestDefaultCredentialProvider();
    testProvider.addType(GAE_SIGNAL_CLASS, MockAppEngineSystemProperty.class);

    try {
      testProvider.getDefaultCredential(transport, JSON_FACTORY);
View Full Code Here

Examples of com.google.api.client.testing.http.MockHttpTransport

      assertTrue(message.contains(DefaultCredentialProvider.APP_ENGINE_CREDENTIAL_CLASS));
    }
  }

  public void testDefaultCredentialAppEngineSingleClassLoadAttempt() {
    HttpTransport transport = new MockHttpTransport();
    TestDefaultCredentialProvider testProvider = new TestDefaultCredentialProvider();
    try {
      testProvider.getDefaultCredential(transport, JSON_FACTORY);
      fail("No credential expected for default test provider.");
    } catch (IOException expected) {
View Full Code Here

Examples of com.google.api.client.testing.http.MockHttpTransport

    }
    assertEquals(1, testProvider.getForNameCallCount());
  }

  public void testDefaultCredentialCaches() throws IOException  {
    HttpTransport transport = new MockHttpTransport();
    TestDefaultCredentialProvider testProvider = new TestDefaultCredentialProvider();
    testProvider.addType(DefaultCredentialProvider.APP_ENGINE_CREDENTIAL_CLASS,
        MockAppEngineCredential.class);
    testProvider.addType(GAE_SIGNAL_CLASS, MockAppEngineSystemProperty.class);
View Full Code Here

Examples of com.google.api.client.testing.http.MockHttpTransport

  public void testDefaultCredentialNonExistentFileThrows() throws Exception {
    File nonExistentFile = new java.io.File(getTempDirectory(), "DefaultCredentialBadFile.json");
    assertFalse(nonExistentFile.exists());

    HttpTransport transport = new MockHttpTransport();
    TestDefaultCredentialProvider testProvider = new TestDefaultCredentialProvider();
    testProvider.setEnv(DefaultCredentialProvider.CREDENTIAL_ENV_VAR,
        nonExistentFile.getAbsolutePath());
    try {
      testProvider.getDefaultCredential(transport, JSON_FACTORY);
View Full Code Here

Examples of com.google.api.client.testing.http.MockHttpTransport

      assertTrue(message.contains(nonExistentFile.getAbsolutePath()));
    }
  }

  public void testDefaultCredentialNotFoundError() {
    HttpTransport transport = new MockHttpTransport();
    TestDefaultCredentialProvider testProvider = new TestDefaultCredentialProvider();

    try {
      testProvider.getDefaultCredential(transport, JSON_FACTORY);
      fail();
View Full Code Here

Examples of com.google.api.client.testing.http.MockHttpTransport

* @author Yaniv Inbar
*/
public class GoogleJsonResponseExceptionTest extends TestCase {

  public void testFrom_noDetails() throws Exception {
    HttpTransport transport = new MockHttpTransport();
    HttpRequest request =
        transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL);
    request.setThrowExceptionOnExecuteError(false);
    HttpResponse response = request.execute();
    GoogleJsonResponseException ge =
        GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response);
    assertNull(ge.getDetails());
View Full Code Here

Examples of com.google.api.client.testing.http.MockHttpTransport

  public void testInitialize() throws Exception {
    CommonGoogleProtoClientRequestInitializer key =
        new CommonGoogleProtoClientRequestInitializer("foo");
    MockGoogleProtoClient client =
        new MockGoogleProtoClient.Builder(new MockHttpTransport(), HttpTesting.SIMPLE_URL, "test/",
            null).setApplicationName("Test Application").build();
    MyRequest request = new MyRequest(client, "GET", "", null, String.class);
    assertNull(request.key);
    key.initialize(request);
    assertEquals("foo", request.key);
View Full Code Here

Examples of com.google.api.client.testing.http.MockHttpTransport

    MockAppIdentityService appIdentity = new MockAppIdentityService();
    appIdentity.setAccessTokenText(expectedAccessToken);
    AppIdentityCredential.Builder builder = new AppIdentityCredential.Builder(SCOPES);
    builder.setAppIdentityService(appIdentity);
    AppIdentityCredential appCredential = builder.build();
    HttpTransport transport = new MockHttpTransport();
    HttpRequest request = transport.createRequestFactory().buildRequest(
        "get", null, null);

    appCredential.intercept(request);

    assertEquals(appIdentity.getGetAccessTokenCallCount(), 1);
View Full Code Here

Examples of com.google.api.client.testing.http.MockHttpTransport

  public void testAppEngineCredentialWrapper() throws IOException {
    final String expectedAccessToken = "ExpectedAccessToken";
    final Collection<String> emptyScopes = Collections.emptyList();

    HttpTransport transport = new MockHttpTransport();
    JsonFactory jsonFactory = new JacksonFactory();

    MockAppIdentityService appIdentity = new MockAppIdentityService();
    appIdentity.setAccessTokenText(expectedAccessToken);

    AppIdentityCredential.Builder builder = new AppIdentityCredential.Builder(emptyScopes);
    builder.setAppIdentityService(appIdentity);
    AppIdentityCredential appCredential = builder.build();

    GoogleCredential wrapper = new
        AppIdentityCredential.AppEngineCredentialWrapper(appCredential, transport, jsonFactory);

    HttpRequest request = transport.createRequestFactory().buildRequest("get", null, null);

    assertTrue(wrapper.createScopedRequired());
    try {
      wrapper.intercept(request);
      fail("Should not be able to use credential without scopes.");
View Full Code Here

Examples of com.google.api.client.testing.http.MockHttpTransport

    } catch (NullPointerException expected) {
    }
  }

  public void testAppEngineCredentialWrapperNullJsonFactoryThrows() throws IOException {
    HttpTransport transport = new MockHttpTransport();
    try {
      new AppIdentityCredential.AppEngineCredentialWrapper(transport, null);
      fail();
    } catch (NullPointerException expected) {
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.