Skip to content

Commit

Permalink
Move the okhttpclient to the okhttp package
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Jul 4, 2019
1 parent 46d3642 commit 8e5176c
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 14 deletions.
3 changes: 1 addition & 2 deletions java/client/src/org/openqa/selenium/remote/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ java_library(
"html5/RemoteLocationContext.java",
"html5/RemoteSessionStorage.java",
"html5/RemoteWebStorage.java",
"internal/OkHttpClient.java",
"internal/OkHttpWebSocket.java",
"internal/JsonToWebElementConverter.java",
"internal/WebElementToJsonConverter.java",
"mobile/RemoteNetworkConnection.java",
Expand All @@ -135,6 +133,7 @@ java_library(
],
deps = [
"//java/client/src/org/openqa/selenium:selenium",
"//java/client/src/org/openqa/selenium/remote/http/okhttp:okhttp",
"//third_party/java/guava:guava",
],
)
Expand Down
2 changes: 1 addition & 1 deletion java/client/src/org/openqa/selenium/remote/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ java_library(
":capabilities",
":remote-lib",
"//java/client/src/org/openqa/selenium:core",
"//java/client/src/org/openqa/selenium/remote/http/okhttp",
"//third_party/java/bytebuddy:byte-buddy",
"//third_party/java/guava",
],
Expand Down Expand Up @@ -139,7 +140,6 @@ java_library(
"//java/client/src/org/openqa/selenium/remote/http",
"//java/client/src/org/openqa/selenium/remote/session",
"//third_party/java/guava",
"//third_party/java/okhttp3:okhttp",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static Factory createDefault() {
default:
try {
Class<? extends Factory> clazz =
Class.forName("org.openqa.selenium.remote.internal.OkHttpClient$Factory")
Class.forName("org.openqa.selenium.remote.http.okhttp.OkHttpClient$Factory")
.asSubclass(Factory.class);
return clazz.newInstance();
} catch (ReflectiveOperationException e) {
Expand Down
13 changes: 13 additions & 0 deletions java/client/src/org/openqa/selenium/remote/http/okhttp/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
java_library(
name = "okhttp",
srcs = glob(["*.java"]),
deps = [
"//java/client/src/org/openqa/selenium/remote/http:http",
"//third_party/java/guava:guava",
"//third_party/java/okhttp3:okhttp",
],
visibility = [
"//java/client/src/org/openqa/selenium/remote:",
"//java/client/test/org/openqa/selenium/remote/http/okhttp:",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ java_library(
"//third_party/java/okhttp3:okhttp",
],
visibility = [
"//java/client/src/org/openqa/selenium/remote:__pkg__",
"//java/client/test/org/openqa/selenium/remote/http/okhttp:__pkg__",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.remote.internal;
package org.openqa.selenium.remote.http.okhttp;

import com.google.common.base.Strings;
import okhttp3.*;
import okhttp3.ConnectionPool;
import okhttp3.Credentials;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.openqa.selenium.remote.http.ClientConfig;
import org.openqa.selenium.remote.http.HttpClient;
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.HttpResponse;
import org.openqa.selenium.remote.http.WebSocket;
import org.openqa.selenium.remote.http.*;

import java.io.IOException;
import java.io.UncheckedIOException;
Expand All @@ -30,7 +39,9 @@

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.openqa.selenium.remote.http.AddSeleniumUserAgent.USER_AGENT;
import static org.openqa.selenium.remote.http.Contents.*;
import static org.openqa.selenium.remote.http.Contents.bytes;
import static org.openqa.selenium.remote.http.Contents.empty;
import static org.openqa.selenium.remote.http.Contents.memoize;

public class OkHttpClient implements HttpClient {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.remote.internal;
package org.openqa.selenium.remote.http.okhttp;

import org.openqa.selenium.remote.http.WebSocket;

Expand Down
1 change: 0 additions & 1 deletion java/client/test/org/openqa/selenium/remote/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ java_test(
"W3CHandshakeResponseTest.java",
"W3CRemoteDriverTest.java",
"internal/HttpClientTestBase.java",
"internal/OkHttpClientTest.java",
"internal/WebElementToJsonConverterTest.java",
],
labels = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.remote.internal;
package org.openqa.selenium.remote.http.okhttp;

import org.openqa.selenium.remote.http.HttpClient;
import org.openqa.selenium.remote.internal.HttpClientTestBase;

public class OkHttpClientTest extends HttpClientTestBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.openqa.grid.internal;

import org.openqa.grid.web.Hub;
import org.openqa.selenium.remote.http.ClientConfig;
import org.openqa.selenium.remote.http.HttpClient;

import java.net.URL;
Expand Down Expand Up @@ -62,9 +63,10 @@ public HttpClient getHttpClient(URL url) {

@Override
public HttpClient getHttpClient(URL url, int connectionTimeout, int readTimeout) {
return httpClientFactory.builder()
return httpClientFactory.createClient(
ClientConfig.defaultConfig()
.baseUrl(url)
.connectionTimeout(Duration.ofSeconds(connectionTimeout))
.readTimeout(Duration.ofSeconds(readTimeout))
.createClient(url);
.readTimeout(Duration.ofSeconds(readTimeout)));
}
}
1 change: 1 addition & 0 deletions third_party/java/okhttp3/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ prebuilt_jar(
],
visibility = [
"//java/client/src/org/openqa/selenium/remote:remote-lib",
"//java/client/src/org/openqa/selenium/remote/http/okhttp:",
"//third_party/java/contrib:opentracing-okhttp3",
],
)

0 comments on commit 8e5176c

Please sign in to comment.