Package com.google.api.client.json.jackson2

Examples of com.google.api.client.json.jackson2.JacksonFactory


    assertEquals(100 + (MAX_AGE - AGE) * 1000, certs.getExpirationTimeMilliseconds());
  }

  public void testGetCacheTimeInSec() throws Exception {
    GooglePublicKeysManager certs =
        new GooglePublicKeysManager.Builder(new MockHttpTransport(), new JacksonFactory()).build();
    assertEquals(12000, certs.getCacheTimeInSec(
        new HttpHeaders().setAge(345L).setCacheControl("max-age=" + MAX_AGE)));
    assertEquals(0, certs.getCacheTimeInSec(new HttpHeaders()));
    assertEquals(0, certs.getCacheTimeInSec(new HttpHeaders().setAge(345L)));
    assertEquals(
View Full Code Here


            return result;
          }
        };
      }
    };
    JsonFactory jsonFactory = new JacksonFactory();
    MockGoogleJsonClient client = new MockGoogleJsonClient.Builder(
        transport, jsonFactory, HttpTesting.SIMPLE_URL, "", null, false).setApplicationName(
        "Test Application").build();
    MockGoogleJsonClientRequest<String> request =
        new MockGoogleJsonClientRequest<String>(client, "GET", "foo", null, String.class);
View Full Code Here

  public void testInitialize() throws Exception {
    CommonGoogleJsonClientRequestInitializer key =
        new CommonGoogleJsonClientRequestInitializer("foo");
    MockGoogleJsonClient client = new MockGoogleJsonClient.Builder(
        new MockHttpTransport(), new JacksonFactory(), HttpTesting.SIMPLE_URL, "test/", null,
        false).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

  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);
View Full Code Here

    String authHeader = headers.getAuthorization();
    assertTrue(authHeader.contains(expectedAccessToken));
  }

  public void testAppEngineCredentialWrapperNullTransportThrows() throws IOException {
    JsonFactory jsonFactory = new JacksonFactory();
    try {
      new AppIdentityCredential.AppEngineCredentialWrapper(null, jsonFactory);
      fail();
    } catch (NullPointerException expected) {
    }
View Full Code Here

  @Test
  public void testDescribeRequestAndResponseForApiClient() throws Exception {
    HttpRequestInitializer initializer = mock(HttpRequestInitializer.class);
    NetHttpTransport transport = new NetHttpTransport();
    Storage storage = new Storage.Builder(transport, new JacksonFactory(), initializer)
        .setApplicationName("bla").build();
    HttpRequest request = storage.objects().delete("b", "o").buildHttpRequest();
    request.getHeaders().clear();
    request.getHeaders().put("k1", "v1");
    request.getHeaders().put("k2", "v2");
View Full Code Here

  OauthRawGcsService(OAuthURLFetchService urlfetch, ImmutableSet<HTTPHeader> headers) {
    this.urlfetch = checkNotNull(urlfetch, "Null urlfetch");
    this.headers = checkNotNull(headers, "Null headers");
    AppIdentityCredential cred = new AppIdentityCredential(OAUTH_SCOPES);
    storage = new Storage.Builder(new UrlFetchTransport(), new JacksonFactory(), cred)
        .setApplicationName(SystemProperty.applicationId.get()).build();
  }
View Full Code Here

    private NetHttpTransport transport;
    private JacksonFactory jsonFactory;

    public BatchGoogleDriveClientFactory() {
        this.transport = new NetHttpTransport();
        this.jsonFactory = new JacksonFactory();
    }
View Full Code Here

    private JacksonFactory jsonFactory;
    private FileDataStoreFactory dataStoreFactory;
   
    public InteractiveGoogleDriveClientFactory() {
        this.transport = new NetHttpTransport();
        this.jsonFactory = new JacksonFactory();
    }
View Full Code Here

    this.backupName = backupName;
    this.historyCount = history;
    this.historyName = history > 0 ? backupName + " " + new SimpleDateFormat("yyyy.MM.dd_HH.mm.ss").format(new Date()) : null;

    final HttpTransport httpTransport = new NetHttpTransport();
    final JsonFactory jsonFactory = new JacksonFactory();

    final GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(httpTransport, jsonFactory, googleDriveOptions.getClientID(), googleDriveOptions.getClientSecret(),
        Arrays.asList(DriveScopes.DRIVE)).setAccessType("offline").setApprovalPrompt("auto").build();

    this.clientTokenPath = Paths.get(googleDriveOptions.getClientTokenPath());

    try {
      final String clientTokenAsJson = Files.exists(this.clientTokenPath) ? FileUtils.readFileToString(this.clientTokenPath.toFile()) : null;

      credential = new GoogleCredential.Builder().setTransport(new NetHttpTransport()).setJsonFactory(new GsonFactory())
          .setClientSecrets(googleDriveOptions.getClientID(), googleDriveOptions.getClientSecret()).build();

      if (StringUtils.isEmpty(clientTokenAsJson)) {

        final String url = flow.newAuthorizationUrl().setRedirectUri(REDIRECT_URL).build();
        System.out.println("Please open the following URL in your browser, copy the authorization code and enter below.");
        System.out.println("\n" + url + "\n");
        final String code = new BufferedReader(new InputStreamReader(System.in)).readLine().trim();

        clientToken = flow.newTokenRequest(code).setRedirectUri(REDIRECT_URL).execute();

        storeClientToken(jsonFactory);
        LOGGER.log(Level.INFO, "client token stored in '" + this.clientTokenPath + "'");
      } else {

        clientToken = jsonFactory.createJsonParser(clientTokenAsJson).parse(GoogleTokenResponse.class);
      }

      credential.setFromTokenResponse(clientToken);

    } catch (final IOException e) {
View Full Code Here

TOP

Related Classes of com.google.api.client.json.jackson2.JacksonFactory

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.