use of com.google.api.client.http.HttpTransport in project endpoints-java by cloudendpoints.
the class GoogleAuthTest method constructHttpRequest.
private HttpRequest constructHttpRequest(final String content) throws IOException {
HttpTransport transport = new MockHttpTransport() {
@Override
public LowLevelHttpRequest buildRequest(String method, String url) throws IOException {
return new MockLowLevelHttpRequest() {
@Override
public LowLevelHttpResponse execute() throws IOException {
MockLowLevelHttpResponse result = new MockLowLevelHttpResponse();
result.setContentType("application/json");
result.setContent(content);
return result;
}
};
}
};
return transport.createRequestFactory().buildGetRequest(new GenericUrl("https://google.com")).setParser(new JsonObjectParser(new JacksonFactory()));
}
use of com.google.api.client.http.HttpTransport in project ddf by codice.
the class MetadataConfigurationParser method retrieveEntityDescriptorViaHttp.
private void retrieveEntityDescriptorViaHttp(String entityDescriptorString) throws IOException {
if (entityDescriptorString.startsWith(HTTP)) {
LOGGER.warn("Retrieving metadata via HTTP instead of HTTPS. The metadata configuration is unsafe!!!");
}
PropertyResolver propertyResolver = new PropertyResolver(entityDescriptorString);
HttpTransport httpTransport = new NetHttpTransport();
ExecutorService executor = Executors.newSingleThreadExecutor(StandardThreadFactoryBuilder.newThreadFactory("metadataConfigParserThread"));
ListeningExecutorService service = MoreExecutors.listeningDecorator(executor);
addHttpCallback(propertyResolver, httpTransport, service, executor);
try {
if (!service.isShutdown() && !service.awaitTermination(30, TimeUnit.SECONDS)) {
LOGGER.debug("Executor service shutdown timed out");
}
} catch (InterruptedException e) {
LOGGER.debug("Problem shutting down executor", e);
service.shutdown();
Thread.currentThread().interrupt();
}
}
use of com.google.api.client.http.HttpTransport in project beam by apache.
the class RetryHttpRequestInitializerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
HttpTransport lowLevelTransport = new HttpTransport() {
@Override
protected LowLevelHttpRequest buildRequest(String method, String url) throws IOException {
return mockLowLevelRequest;
}
};
// Retry initializer will pass through to credential, since we can have
// only a single HttpRequestInitializer, and we use multiple Credential
// types in the SDK, not all of which allow for retry configuration.
RetryHttpRequestInitializer initializer = new RetryHttpRequestInitializer(new MockNanoClock(), millis -> {
}, Arrays.asList(418), mockHttpResponseInterceptor);
storage = new Storage.Builder(lowLevelTransport, jsonFactory, initializer).setApplicationName("test").build();
}
use of com.google.api.client.http.HttpTransport in project heron by twitter.
the class GcsUploader method createStorage.
private Storage createStorage(Credential credential) throws GeneralSecurityException, IOException {
final HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
final JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
return new Storage.Builder(httpTransport, jsonFactory, credential).build();
}
use of com.google.api.client.http.HttpTransport in project gradle by gradle.
the class GcsClient method create.
public static GcsClient create(GcsConnectionProperties gcsConnectionProperties) throws GeneralSecurityException, IOException {
HttpTransport transport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory jsonFactory = new JacksonFactory();
Storage.Builder builder = new Storage.Builder(transport, jsonFactory, null);
if (gcsConnectionProperties.requiresAuthentication()) {
Supplier<Credential> credentialSupplier = getCredentialSupplier(transport, jsonFactory);
builder.setHttpRequestInitializer(new RetryHttpInitializerWrapper(credentialSupplier));
}
if (gcsConnectionProperties.getEndpoint().isPresent()) {
builder.setRootUrl(gcsConnectionProperties.getEndpoint().get().toString());
}
if (gcsConnectionProperties.getServicePath().isPresent()) {
builder.setServicePath(gcsConnectionProperties.getServicePath().get());
}
builder.setApplicationName("gradle");
return new GcsClient(builder.build());
}
Aggregations