summaryrefslogtreecommitdiffstats
path: root/uitest/src/com
diff options
context:
space:
mode:
authorTaras Hupalo <taras.hupalo@gmail.com>2014-08-12 15:28:41 +0300
committerLeif Åstrand <leif@vaadin.com>2014-08-26 09:51:15 +0000
commitf2551a9fc03636deb5fcd3f30c761dca946c8341 (patch)
treeb59bc2c5ea1f7471dec4ef59826614b4f6d0adbf /uitest/src/com
parentc8d58261954de18ef67eaf9043bd93360202cf06 (diff)
downloadvaadin-framework-f2551a9fc03636deb5fcd3f30c761dca946c8341.tar.gz
vaadin-framework-f2551a9fc03636deb5fcd3f30c761dca946c8341.zip
replaced all org.json.* usages with elemental.json.* (#8942)
Change-Id: I4809fbbdb48f3e36c8e1da8552ff3fa734714105
Diffstat (limited to 'uitest/src/com')
-rw-r--r--uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java10
-rw-r--r--uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java7
-rw-r--r--uitest/src/com/vaadin/tests/extensions/JavascriptManagerTest.java15
-rw-r--r--uitest/src/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java6
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7a3/Flot.java10
-rw-r--r--uitest/src/com/vaadin/tests/minitutorials/v7a3/JSAPIUI.java12
-rw-r--r--uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java5
-rw-r--r--uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java5
-rw-r--r--uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java12
9 files changed, 35 insertions, 47 deletions
diff --git a/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java b/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java
index 5a64cb6a00..bd7522aab7 100644
--- a/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java
+++ b/uitest/src/com/vaadin/tests/components/javascriptcomponent/BasicJavaScriptComponent.java
@@ -19,9 +19,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.json.JSONArray;
-import org.json.JSONException;
-
import com.vaadin.annotations.JavaScript;
import com.vaadin.server.ConnectorResource;
import com.vaadin.server.DownloadStream;
@@ -39,6 +36,7 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.HasComponents;
import com.vaadin.ui.JavaScriptFunction;
+import elemental.json.JsonArray;
public class BasicJavaScriptComponent extends AbstractTestUI {
@@ -78,15 +76,15 @@ public class BasicJavaScriptComponent extends AbstractTestUI {
});
addFunction("messageToServer", new JavaScriptFunction() {
@Override
- public void call(JSONArray arguments) throws JSONException {
+ public void call(JsonArray arguments) {
log.log("Got callback message: " + arguments.getString(0));
}
});
addFunction("reportParentIds", new JavaScriptFunction() {
@Override
- public void call(JSONArray arguments) throws JSONException {
- JSONArray parentIds = arguments.getJSONArray(0);
+ public void call(JsonArray arguments) {
+ JsonArray parentIds = arguments.getArray(0);
if (!parentIds.getString(0).equals(getConnectorId())) {
log.log("Connector ids doesn't match");
}
diff --git a/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java b/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java
index c21a38a0ac..710a4f8fe3 100644
--- a/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java
+++ b/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java
@@ -19,8 +19,6 @@ package com.vaadin.tests.components.table;
import java.util.ArrayList;
import java.util.Collection;
-import org.json.JSONObject;
-
import com.vaadin.annotations.Push;
import com.vaadin.server.ClientConnector;
import com.vaadin.server.StreamVariable;
@@ -30,6 +28,7 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.ConnectorTracker;
import com.vaadin.ui.Table;
+import elemental.json.JsonObject;
@Push
public class TableRemovedQuicklySendsInvalidRpcCalls extends AbstractTestUI {
@@ -125,12 +124,12 @@ public class TableRemovedQuicklySendsInvalidRpcCalls extends AbstractTestUI {
}
@Override
- public JSONObject getDiffState(ClientConnector connector) {
+ public JsonObject getDiffState(ClientConnector connector) {
return tracker.getDiffState(connector);
}
@Override
- public void setDiffState(ClientConnector connector, JSONObject diffState) {
+ public void setDiffState(ClientConnector connector, JsonObject diffState) {
tracker.setDiffState(connector, diffState);
}
diff --git a/uitest/src/com/vaadin/tests/extensions/JavascriptManagerTest.java b/uitest/src/com/vaadin/tests/extensions/JavascriptManagerTest.java
index b89e16d755..4807bb9029 100644
--- a/uitest/src/com/vaadin/tests/extensions/JavascriptManagerTest.java
+++ b/uitest/src/com/vaadin/tests/extensions/JavascriptManagerTest.java
@@ -16,16 +16,15 @@
package com.vaadin.tests.extensions;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.JavaScript;
import com.vaadin.ui.JavaScriptFunction;
+import elemental.json.JsonArray;
+import elemental.json.JsonNull;
+
public class JavascriptManagerTest extends AbstractTestUI {
private Log log = new Log(5);
@@ -36,14 +35,14 @@ public class JavascriptManagerTest extends AbstractTestUI {
final JavaScript js = JavaScript.getCurrent();
js.addFunction("testing.doTest", new JavaScriptFunction() {
@Override
- public void call(JSONArray arguments) throws JSONException {
+ public void call(JsonArray arguments) {
log.log("Got " + arguments.length() + " arguments");
- log.log("Argument 1 as a number: " + arguments.getInt(0));
+ log.log("Argument 1 as a number: " + (int) arguments.getNumber(0));
log.log("Argument 2 as a string: " + arguments.getString(1));
log.log("Argument 3.p as a boolean: "
- + arguments.getJSONObject(2).getBoolean("p"));
+ + arguments.getObject(2).getBoolean("p"));
log.log("Argument 4 is JSONObject.NULL: "
- + (arguments.get(3) == JSONObject.NULL));
+ + (arguments.get(3) instanceof JsonNull));
js.removeFunction("testing.doTest");
}
});
diff --git a/uitest/src/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java b/uitest/src/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java
index d3e0edf04c..6f14fb301c 100644
--- a/uitest/src/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java
+++ b/uitest/src/com/vaadin/tests/extensions/SimpleJavaScriptExtensionTest.java
@@ -16,9 +16,6 @@
package com.vaadin.tests.extensions;
-import org.json.JSONArray;
-import org.json.JSONException;
-
import com.vaadin.annotations.JavaScript;
import com.vaadin.annotations.StyleSheet;
import com.vaadin.server.AbstractJavaScriptExtension;
@@ -31,6 +28,7 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.JavaScriptFunction;
import com.vaadin.ui.Notification;
+import elemental.json.JsonArray;
public class SimpleJavaScriptExtensionTest extends AbstractTestUI {
@@ -71,7 +69,7 @@ public class SimpleJavaScriptExtensionTest extends AbstractTestUI {
});
addFunction("greetToServer", new JavaScriptFunction() {
@Override
- public void call(JSONArray arguments) throws JSONException {
+ public void call(JsonArray arguments) {
Notification.show(getState().getPrefix()
+ arguments.getString(0));
}
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/Flot.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/Flot.java
index f4aca81ffa..86666b12e8 100644
--- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/Flot.java
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/Flot.java
@@ -20,13 +20,11 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.json.JSONArray;
-import org.json.JSONException;
-
import com.vaadin.annotations.JavaScript;
import com.vaadin.ui.AbstractJavaScriptComponent;
import com.vaadin.ui.JavaScriptFunction;
import com.vaadin.ui.Notification;
+import elemental.json.JsonArray;
@JavaScript({
"https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js",
@@ -42,9 +40,9 @@ public class Flot extends AbstractJavaScriptComponent {
});
addFunction("onPlotClick", new JavaScriptFunction() {
@Override
- public void call(JSONArray arguments) throws JSONException {
- int seriesIndex = arguments.getInt(0);
- int dataIndex = arguments.getInt(1);
+ public void call(JsonArray arguments) {
+ int seriesIndex = (int) arguments.getNumber(0);
+ int dataIndex = (int) arguments.getNumber(1);
Notification.show("Clicked on [" + seriesIndex + ", "
+ dataIndex + "]");
}
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a3/JSAPIUI.java b/uitest/src/com/vaadin/tests/minitutorials/v7a3/JSAPIUI.java
index 8f1eda6816..e98fe6d066 100644
--- a/uitest/src/com/vaadin/tests/minitutorials/v7a3/JSAPIUI.java
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7a3/JSAPIUI.java
@@ -1,8 +1,5 @@
package com.vaadin.tests.minitutorials.v7a3;
-import org.json.JSONArray;
-import org.json.JSONException;
-
import com.vaadin.server.ExternalResource;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.JavaScript;
@@ -12,6 +9,9 @@ import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
import com.vaadin.ui.UI;
+import elemental.json.JsonArray;
+import elemental.json.JsonException;
+
public class JSAPIUI extends UI {
@Override
public void init(VaadinRequest request) {
@@ -19,7 +19,7 @@ public class JSAPIUI extends UI {
JavaScript.getCurrent().addFunction("com.example.api.notify",
new JavaScriptFunction() {
@Override
- public void call(JSONArray arguments) throws JSONException {
+ public void call(JsonArray arguments) {
try {
String caption = arguments.getString(0);
if (arguments.length() == 1) {
@@ -28,10 +28,10 @@ public class JSAPIUI extends UI {
} else {
// type should be in [1]
Notification.show(caption,
- Type.values()[arguments.getInt(1)]);
+ Type.values()[((int) arguments.getNumber(1))]);
}
- } catch (JSONException e) {
+ } catch (JsonException e) {
// We'll log in the console, you might not want to
JavaScript.getCurrent().execute(
"console.error('" + e.getMessage() + "')");
diff --git a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java
index 6e2784f21d..e7a74775bf 100644
--- a/uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java
+++ b/uitest/src/com/vaadin/tests/push/TrackMessageSizeUI.java
@@ -23,8 +23,6 @@ import java.net.URL;
import javax.servlet.ServletContext;
import org.apache.commons.io.IOUtils;
-import org.json.JSONArray;
-import org.json.JSONException;
import com.vaadin.annotations.JavaScript;
import com.vaadin.server.VaadinRequest;
@@ -32,6 +30,7 @@ import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinServletService;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.JavaScriptFunction;
+import elemental.json.JsonArray;
// Load vaadinPush.js so that jQueryVaadin is defined
@JavaScript("vaadin://vaadinPush.debug.js")
@@ -58,7 +57,7 @@ public class TrackMessageSizeUI extends AbstractTestUIWithLog {
getPage().getJavaScript().addFunction("logToServer",
new JavaScriptFunction() {
@Override
- public void call(JSONArray arguments) throws JSONException {
+ public void call(JsonArray arguments) {
String message = arguments.getString(0);
log(message);
}
diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java
index 47bb212347..dcba561599 100644
--- a/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java
+++ b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java
@@ -86,9 +86,8 @@ public class SerializerTestTest extends MultiBrowserTest {
getLogRow(logRow++));
Assert.assertEquals("state.floatArray: [57, 0, -12]",
getLogRow(logRow++));
- Assert.assertEquals("state.floatObjectValue: 1.0000001",
- getLogRow(logRow++));
- Assert.assertEquals("state.floatValue: 3.14159", getLogRow(logRow++));
+ Assert.assertTrue(getLogRow(logRow++).startsWith("state.floatObjectValue: 1.0000001"));
+ Assert.assertTrue(getLogRow(logRow++).startsWith("state.floatValue: 3.14159"));
Assert.assertEquals("state.longArray: [-57841235865, 57]",
getLogRow(logRow++));
Assert.assertEquals("state.longObjectValue: 577431841360",
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index d2313a0709..1e1cbedbd6 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -30,13 +30,13 @@ import java.net.URL;
import java.util.Collections;
import java.util.List;
+import elemental.json.JsonObject;
+import elemental.json.impl.JsonUtil;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHttpEntityEnclosingRequest;
-import org.json.JSONException;
-import org.json.JSONObject;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
@@ -1247,7 +1247,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest(
"POST", sessionURL.toExternalForm());
HttpResponse response = client.execute(host, r);
- JSONObject object = extractObject(response);
+ JsonObject object = extractObject(response);
URL myURL = new URL(object.getString("proxyId"));
if ((myURL.getHost() != null) && (myURL.getPort() != -1)) {
return myURL.getHost();
@@ -1258,13 +1258,11 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
return null;
}
- private static JSONObject extractObject(HttpResponse resp)
- throws IOException, JSONException {
+ private static JsonObject extractObject(HttpResponse resp) throws IOException {
InputStream contents = resp.getEntity().getContent();
StringWriter writer = new StringWriter();
IOUtils.copy(contents, writer, "UTF8");
- JSONObject objToReturn = new JSONObject(writer.toString());
- return objToReturn;
+ return JsonUtil.parse(writer.toString());
}
}