Skip to content

Commit 46b4413

Browse files
committed
Move JSON tests to the right package
1 parent d41da25 commit 46b4413

File tree

5 files changed

+44
-11
lines changed

5 files changed

+44
-11
lines changed

Rakefile

+2
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ task :test_remote_server => [
208208
'//java/server/test/org/openqa/selenium/remote/server/log:test:run',
209209
]
210210
task :test_remote => [
211+
'//java/client/test/org/openqa/selenium/json:small-tests:run',
211212
'//java/client/test/org/openqa/selenium/remote:common-tests:run',
212213
'//java/client/test/org/openqa/selenium/remote:client-tests:run',
213214
'//java/client/test/org/openqa/selenium/remote:remote-driver-tests:run',
@@ -256,6 +257,7 @@ task :test_java => [
256257

257258
task :test_java_small_tests => [
258259
"//java/client/test/org/openqa/selenium:small-tests:run",
260+
"//java/client/test/org/openqa/selenium/json:small-tests:run",
259261
"//java/client/test/org/openqa/selenium/support:small-tests:run",
260262
"//java/client/test/org/openqa/selenium/remote:common-tests:run",
261263
"//java/client/test/org/openqa/selenium/remote:client-tests:run",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
java_test(name = 'small-tests',
2+
srcs = [
3+
'BeanToJsonConverterTest.java',
4+
'JsonToBeanConverterTest.java',
5+
],
6+
deps = [
7+
'//java/client/src/org/openqa/selenium:selenium',
8+
'//java/client/src/org/openqa/selenium/remote:remote',
9+
'//third_party/java/gson:gson',
10+
'//third_party/java/guava:guava',
11+
'//third_party/java/hamcrest:hamcrest-library',
12+
'//third_party/java/httpcomponents:httpclient',
13+
'//third_party/java/junit:junit',
14+
],
15+
)

java/client/test/org/openqa/selenium/remote/BeanToJsonConverterTest.java renamed to java/client/test/org/openqa/selenium/json/BeanToJsonConverterTest.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
package org.openqa.selenium.remote;
18+
package org.openqa.selenium.json;
1919

2020
import static org.hamcrest.Matchers.containsString;
2121
import static org.hamcrest.Matchers.is;
@@ -52,6 +52,11 @@
5252
import org.openqa.selenium.logging.LogEntry;
5353
import org.openqa.selenium.logging.LogType;
5454
import org.openqa.selenium.logging.LoggingPreferences;
55+
import org.openqa.selenium.remote.CapabilityType;
56+
import org.openqa.selenium.remote.Command;
57+
import org.openqa.selenium.remote.DesiredCapabilities;
58+
import org.openqa.selenium.remote.DriverCommand;
59+
import org.openqa.selenium.remote.SessionId;
5560

5661
import java.awt.*;
5762
import java.io.StringReader;
@@ -151,7 +156,8 @@ public void testShouldConvertEnumsWithMethods() throws Exception {
151156

152157
@Test
153158
public void testNullAndAnEmptyStringAreEncodedDifferently() throws Exception {
154-
BeanToJsonConverter converter = new BeanToJsonConverter();
159+
BeanToJsonConverter
160+
converter = new BeanToJsonConverter();
155161

156162
String nullValue = converter.convert(null);
157163
String emptyString = converter.convert("");

java/client/test/org/openqa/selenium/remote/JsonToBeanConverterTest.java renamed to java/client/test/org/openqa/selenium/json/JsonToBeanConverterTest.java

+17-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
package org.openqa.selenium.remote;
18+
package org.openqa.selenium.json;
1919

2020
import static org.hamcrest.Matchers.equalTo;
2121
import static org.hamcrest.Matchers.hasEntry;
@@ -34,6 +34,7 @@
3434
import com.google.gson.JsonObject;
3535
import com.google.gson.JsonPrimitive;
3636

37+
import org.junit.Assert;
3738
import org.junit.Test;
3839
import org.junit.runner.RunWith;
3940
import org.junit.runners.JUnit4;
@@ -44,6 +45,13 @@
4445
import org.openqa.selenium.Proxy;
4546
import org.openqa.selenium.logging.LogType;
4647
import org.openqa.selenium.logging.LoggingPreferences;
48+
import org.openqa.selenium.remote.CapabilityType;
49+
import org.openqa.selenium.remote.Command;
50+
import org.openqa.selenium.remote.DesiredCapabilities;
51+
import org.openqa.selenium.remote.DriverCommand;
52+
import org.openqa.selenium.remote.ErrorCodes;
53+
import org.openqa.selenium.remote.Response;
54+
import org.openqa.selenium.remote.SessionId;
4755

4856
import java.util.Collections;
4957
import java.util.Date;
@@ -140,7 +148,7 @@ public void testShouldProperlyFillInACapabilitiesObject() throws Exception {
140148
capabilities.setJavascriptEnabled(true);
141149
String text = new BeanToJsonConverter().convert(capabilities);
142150

143-
DesiredCapabilities readCapabilities =
151+
Capabilities readCapabilities =
144152
new JsonToBeanConverter().convert(DesiredCapabilities.class, text);
145153

146154
assertEquals(capabilities, readCapabilities);
@@ -165,16 +173,18 @@ public void testShouldUseAMapToRepresentComplexObjects() throws Exception {
165173
toModel.addProperty("thing", "hairy");
166174
toModel.addProperty("hairy", "true");
167175

168-
Map<?,?> modelled = (Map<?,?>) new JsonToBeanConverter().convert(Object.class,
169-
toModel.toString());
176+
Map<?,?> modelled = (Map<?,?>) new JsonToBeanConverter().convert(
177+
Object.class,
178+
toModel.toString());
170179
assertEquals(2, modelled.size());
171180
}
172181

173182
@Test
174183
public void testShouldConvertAResponseWithAnElementInIt() throws Exception {
175184
String json =
176185
"{\"value\":{\"value\":\"\",\"text\":\"\",\"selected\":false,\"enabled\":true,\"id\":\"three\"},\"context\":\"con\",\"sessionId\":\"sess\"}";
177-
Response converted = new JsonToBeanConverter().convert(Response.class, json);
186+
Response
187+
converted = new JsonToBeanConverter().convert(Response.class, json);
178188

179189
Map<?,?> value = (Map<?,?>) converted.getValue();
180190
assertEquals("three", value.get("id"));
@@ -277,7 +287,7 @@ public void testShouldBeAbleToReconsituteASessionId() throws Exception {
277287
public void testShouldBeAbleToConvertACommand() throws Exception {
278288
SessionId sessionId = new SessionId("session id");
279289
Command original = new Command(sessionId, DriverCommand.NEW_SESSION,
280-
new HashMap<String, String>() {
290+
new HashMap<String, String>() {
281291
{
282292
put("food", "cheese");
283293
}
@@ -387,7 +397,7 @@ public void testShouldRecognizeNumericStatus() {
387397
.convert(Response.class, "{\"status\":0,\"value\":\"cheese\"}");
388398

389399
assertEquals(0, response.getStatus().intValue());
390-
assertEquals(new ErrorCodes().toState(0), response.getState());
400+
Assert.assertEquals(new ErrorCodes().toState(0), response.getState());
391401
String value = (String) response.getValue();
392402
assertEquals("cheese", value);
393403
}

java/client/test/org/openqa/selenium/remote/RemoteCommonTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919

2020
import org.junit.runner.RunWith;
2121
import org.junit.runners.Suite;
22+
import org.openqa.selenium.json.BeanToJsonConverterTest;
23+
import org.openqa.selenium.json.JsonToBeanConverterTest;
2224
import org.openqa.selenium.remote.http.JsonHttpCommandCodecTest;
2325
import org.openqa.selenium.remote.http.JsonHttpResponseCodecTest;
2426
import org.openqa.selenium.remote.http.W3CHttpResponseCodecTest;
2527

2628
@RunWith(Suite.class)
2729
@Suite.SuiteClasses({
28-
BeanToJsonConverterTest.class,
2930
DesiredCapabilitiesTest.class,
30-
JsonToBeanConverterTest.class,
3131
JsonHttpCommandCodecTest.class,
3232
JsonHttpResponseCodecTest.class,
3333
W3CHttpResponseCodecTest.class

0 commit comments

Comments
 (0)