Skip to content

Commit

Permalink
Move some code around.
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyba committed May 6, 2014
1 parent 13de1e6 commit fa4bc4e
Show file tree
Hide file tree
Showing 23 changed files with 86 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openqa.selenium.remote.codec;
package org.openqa.selenium.remote;

import org.openqa.selenium.UnsupportedCommandException;
import org.openqa.selenium.remote.Command;
Expand All @@ -8,19 +8,23 @@
*
* @param <T> The type of an encoded command.
*/
public interface CommandCodec<T> extends Codec<Command, T> {
public interface CommandCodec<T> {

/**
* @inheritDoc
* Encodes a command.
*
* @param command the command to encode.
* @return the encoded command.
* @throws UnsupportedCommandException If the command is not supported by this codec.
*/
@Override
T encode(Command command);

/**
* @inheritDoc
* Decodes a command.
*
* @param encodedCommand the command to decode.
* @return the decoded command.
* @throws UnsupportedCommandException If the command is not supported by this codec.
*/
@Override
Command decode(T encodedCommand);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.openqa.selenium.remote;

import org.openqa.selenium.remote.codec.http.HttpMethod;
import org.openqa.selenium.remote.http.HttpMethod;

public class CommandInfo {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
import org.openqa.selenium.logging.LogType;
import org.openqa.selenium.logging.NeedsLocalLogs;
import org.openqa.selenium.logging.profiler.HttpProfilerLogEntry;
import org.openqa.selenium.remote.codec.http.HttpMethod;
import org.openqa.selenium.remote.codec.http.HttpRequest;
import org.openqa.selenium.remote.codec.http.JsonHttpCommandCodec;
import org.openqa.selenium.remote.codec.http.JsonHttpResponseCodec;
import org.openqa.selenium.remote.http.HttpMethod;
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.JsonHttpCommandCodec;
import org.openqa.selenium.remote.http.JsonHttpResponseCodec;
import org.openqa.selenium.remote.internal.HttpClientFactory;

import java.io.IOException;
Expand Down Expand Up @@ -278,8 +278,8 @@ private boolean isRedirect(HttpResponse response) {

private Response createResponse(HttpResponse httpResponse, HttpContext context)
throws IOException {
org.openqa.selenium.remote.codec.http.HttpResponse internalResponse =
new org.openqa.selenium.remote.codec.http.HttpResponse();
org.openqa.selenium.remote.http.HttpResponse internalResponse =
new org.openqa.selenium.remote.http.HttpResponse();

internalResponse.setStatus(httpResponse.getStatusLine().getStatusCode());
for (Header header : httpResponse.getAllHeaders()) {
Expand Down
4 changes: 2 additions & 2 deletions java/client/src/org/openqa/selenium/remote/HttpVerb.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.openqa.selenium.remote.codec.http.HttpMethod;
import org.openqa.selenium.remote.http.HttpMethod;

/**
* @deprecated Use {@link org.openqa.selenium.remote.codec.http.HttpMethod}.
* @deprecated Use {@link org.openqa.selenium.remote.http.HttpMethod}.
*/
@Deprecated
public enum HttpVerb {
Expand Down
29 changes: 29 additions & 0 deletions java/client/src/org/openqa/selenium/remote/ResponseCodec.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.openqa.selenium.remote;

import org.openqa.selenium.remote.Response;

/**
* Converts {@link Response} objects to and from another representation.
*
* @param <T> The type of an encoded response.
*/
public interface ResponseCodec<T> {

/**
* Encodes a response.
*
* @param response the response to encode.
* @return the encoded response.
* @throws IllegalArgumentException If the object cannot be encoded.
*/
T encode(Response response);

/**
* Decodes a response.
*
* @param encodedResponse the response to decode.
* @return the decoded response.
* @throws IllegalArgumentException If the object cannot be decoded.
*/
Response decode(T encodedResponse);
}
13 changes: 12 additions & 1 deletion java/client/src/org/openqa/selenium/remote/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ java_library(name = "augmenter",

java_library(name = "remote",
srcs = [
"CommandCodec.java",
"CommandInfo.java",
"CoordinatesUtils.java",
"ExecuteMethod.java",
Expand All @@ -89,25 +90,35 @@ java_library(name = "remote",
"RemoteWebDriver.java",
"RemoteWebElement.java",
"RemoteTouchScreen.java",
"ResponseCodec.java",
"UselessFileDetector.java",
"html5/RemoteApplicationCache.java",
"html5/RemoteDatabaseStorage.java",
"html5/RemoteLocalStorage.java",
"html5/RemoteLocationContext.java",
"html5/RemoteSessionStorage.java",
"html5/RemoteWebStorage.java",
"http/HttpMessage.java",
"http/HttpMethod.java",
"http/HttpRequest.java",
"http/HttpResponse.java",
"http/HttpStatusCodes.java",
"http/JsonHttpCommandCodec.java",
"http/JsonHttpResponseCodec.java",
"internal/CircularOutputStream.java",
"internal/JsonToWebElementConverter.java",
"internal/HttpClientFactory.java",
"internal/WebElementToJsonConverter.java",
"mobile/RemoteNetworkConnection.java",
],
deps = [
":api",
":common",
":http-session-id",
"//java/client/src/org/openqa/selenium:webdriver-api",
"//java/client/src/org/openqa/selenium/logging",
"//java/client/src/org/openqa/selenium/io",
"//java/client/src/org/openqa/selenium/net",
"//java/client/src/org/openqa/selenium/remote/codec",
"//third_party/java/apache-httpclient",
"//third_party/java/guava-libraries",
])
28 changes: 0 additions & 28 deletions java/client/src/org/openqa/selenium/remote/codec/Codec.java

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions java/client/src/org/openqa/selenium/remote/codec/build.desc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openqa.selenium.remote.codec.http;
package org.openqa.selenium.remote.http;

import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openqa.selenium.remote.codec.http;
package org.openqa.selenium.remote.http;

public enum HttpMethod {
DELETE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
limitations under the License.
*/

package org.openqa.selenium.remote.codec.http;
package org.openqa.selenium.remote.http;

public class HttpRequest extends HttpMessage {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
limitations under the License.
*/

package org.openqa.selenium.remote.codec.http;
package org.openqa.selenium.remote.http;

public class HttpResponse extends HttpMessage {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
limitations under the License.
*/

package org.openqa.selenium.remote.codec.http;
package org.openqa.selenium.remote.http;

public class HttpStatusCodes {
private HttpStatusCodes() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package org.openqa.selenium.remote.codec.http;
package org.openqa.selenium.remote.http;

import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.nullToEmpty;
import static com.google.common.net.HttpHeaders.CACHE_CONTROL;
import static com.google.common.net.HttpHeaders.CONTENT_LENGTH;
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
Expand All @@ -25,7 +24,7 @@
import org.openqa.selenium.remote.Command;
import org.openqa.selenium.remote.JsonToBeanConverter;
import org.openqa.selenium.remote.SessionId;
import org.openqa.selenium.remote.codec.CommandCodec;
import org.openqa.selenium.remote.CommandCodec;

import java.util.Comparator;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openqa.selenium.remote.codec.http;
package org.openqa.selenium.remote.http;

import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.base.Strings.nullToEmpty;
Expand All @@ -13,7 +13,7 @@
import org.openqa.selenium.remote.JsonException;
import org.openqa.selenium.remote.JsonToBeanConverter;
import org.openqa.selenium.remote.Response;
import org.openqa.selenium.remote.codec.ResponseCodec;
import org.openqa.selenium.remote.ResponseCodec;

/**
* A response codec that adheres to the Selenium project's JSON/HTTP wire protocol.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.openqa.selenium.remote.codec.http.JsonHttpCommandCodecTest;
import org.openqa.selenium.remote.codec.http.JsonHttpResponseCodecTest;
import org.openqa.selenium.remote.http.JsonHttpCommandCodecTest;
import org.openqa.selenium.remote.http.JsonHttpResponseCodecTest;

@RunWith(Suite.class)
@Suite.SuiteClasses({
Expand Down
5 changes: 2 additions & 3 deletions java/client/test/org/openqa/selenium/remote/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ java_test(name = "common-tests",
"HttpRequest.java",
"JsonToBeanConverterTest.java",
"RemoteCommonTests.java",
"codec/http/JsonHttpCommandCodecTest.java",
"codec/http/JsonHttpResponseCodecTest.java",
"http/JsonHttpCommandCodecTest.java",
"http/JsonHttpResponseCodecTest.java",
],
deps = [
"//java/client/src/org/openqa/selenium/remote",
"//java/client/src/org/openqa/selenium/remote:common",
"//java/client/src/org/openqa/selenium/remote/codec",
"//java/client/test/org/openqa/selenium:tests",
"//third_party/java/apache-httpclient",
"//third_party/java/junit",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openqa.selenium.remote.codec.http;
package org.openqa.selenium.remote.http;

import static com.google.common.base.Charsets.UTF_16;
import static com.google.common.base.Charsets.UTF_8;
Expand All @@ -12,9 +12,9 @@
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.openqa.selenium.remote.codec.http.HttpMethod.GET;
import static org.openqa.selenium.remote.codec.http.HttpMethod.DELETE;
import static org.openqa.selenium.remote.codec.http.HttpMethod.POST;
import static org.openqa.selenium.remote.http.HttpMethod.GET;
import static org.openqa.selenium.remote.http.HttpMethod.DELETE;
import static org.openqa.selenium.remote.http.HttpMethod.POST;

import com.google.common.collect.ImmutableMap;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openqa.selenium.remote.codec.http;
package org.openqa.selenium.remote.http;

import static com.google.common.base.Charsets.UTF_16;
import static com.google.common.base.Charsets.UTF_8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import com.google.common.net.MediaType;

import org.openqa.selenium.logging.LoggingHandler;
import org.openqa.selenium.remote.codec.http.HttpMethod;
import org.openqa.selenium.remote.codec.http.HttpRequest;
import org.openqa.selenium.remote.codec.http.HttpResponse;
import org.openqa.selenium.remote.http.HttpMethod;
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.HttpResponse;
import org.openqa.selenium.remote.server.xdrpc.CrossDomainRpc;
import org.openqa.selenium.remote.server.xdrpc.CrossDomainRpcLoader;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
package org.openqa.selenium.remote.server;

import static org.openqa.selenium.remote.DriverCommand.*;
import static org.openqa.selenium.remote.codec.http.HttpMethod.POST;
import static org.openqa.selenium.remote.http.HttpMethod.POST;

import org.openqa.selenium.UnsupportedCommandException;
import org.openqa.selenium.remote.Command;
import org.openqa.selenium.remote.ErrorCodes;
import org.openqa.selenium.remote.Response;
import org.openqa.selenium.remote.codec.http.HttpRequest;
import org.openqa.selenium.remote.codec.http.HttpResponse;
import org.openqa.selenium.remote.codec.http.JsonHttpCommandCodec;
import org.openqa.selenium.remote.codec.http.JsonHttpResponseCodec;
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.HttpResponse;
import org.openqa.selenium.remote.http.JsonHttpCommandCodec;
import org.openqa.selenium.remote.http.JsonHttpResponseCodec;
import org.openqa.selenium.remote.server.handler.AcceptAlert;
import org.openqa.selenium.remote.server.handler.AddConfig;
import org.openqa.selenium.remote.server.handler.AddCookie;
Expand Down
2 changes: 0 additions & 2 deletions java/server/src/org/openqa/selenium/remote/server/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ java_library(name = "restish",
"//java/client/src/org/openqa/selenium/remote",
"//java/client/src/org/openqa/selenium/remote:common",
"//java/client/src/org/openqa/selenium/remote:http-session-id",
"//java/client/src/org/openqa/selenium/remote/codec",
"//java/server/src/org/openqa/selenium/remote/server/log",
"//third_party/java/guava-libraries",
])
Expand All @@ -48,7 +47,6 @@ java_library(name = "server_core",
],
deps = [
":server_very_core",
"//java/client/src/org/openqa/selenium/remote/codec",
"//third_party/java/guava-libraries",
"//third_party/java/servlet-api",
],
Expand Down

0 comments on commit fa4bc4e

Please sign in to comment.