aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>2014-01-05 19:01:10 +0100
committerManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>2014-01-05 19:01:10 +0100
commitc05283e47175f11d99f3f5a6784468e62ac71724 (patch)
treeae44b4f9f90218120f73aab380c3dc843435aa5e
parentaca58c8c0c56f28b7038012832b4c37c9f2abf5a (diff)
downloadgwtquery-c05283e47175f11d99f3f5a6784468e62ac71724.tar.gz
gwtquery-c05283e47175f11d99f3f5a6784468e62ac71724.zip
Fix tests, and clean servlet output
-rw-r--r--gwtquery-core/pom.xml14
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/Binder.java11
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java5
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/dev/shell/BrowserChannelPatched.java (renamed from gwtquery-core/src/test/java/com/google/gwt/dev/shell/BrowserChannel.java)98
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/junit/RunStyleHtmlUnitPatched.java (renamed from gwtquery-core/src/main/java/com/google/gwt/junit/RunStyleHtmlUnit.java)4
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTestGwt.java2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTestGwt.java2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryDeferredTestGwt.java2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java7
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryGwtSuiteTest.java8
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTestGwt.java2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTestGwt.java2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/ajax/AjaxCommon.java15
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTest.java6
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestGwt.java2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/deferred/DeferredTestGwt.java2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTestGwt.java2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/servlet/GQAjaxTestServlet.java15
23 files changed, 124 insertions, 89 deletions
diff --git a/gwtquery-core/pom.xml b/gwtquery-core/pom.xml
index 7bfbbb9a..6ccb811b 100644
--- a/gwtquery-core/pom.xml
+++ b/gwtquery-core/pom.xml
@@ -18,12 +18,14 @@
<version>4.7</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>net.sourceforge.htmlunit</groupId>
- <artifactId>htmlunit</artifactId>
- <version>2.13</version>
- <scope>test</scope>
- </dependency>
+ <!-- Commented in order not to depend on it, but useful when we want test ajax CORS
+ <dependency>
+ <groupId>net.sourceforge.htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>2.13</version>
+ <scope>test</scope>
+ </dependency>
+ -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Binder.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Binder.java
index c43122ac..ba45ceb1 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Binder.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Binder.java
@@ -52,11 +52,20 @@ public interface Binder {
String[] getFieldNames();
/**
- * return a string which represents the object with an alias for the className
+ * return a json string which represents the object.
+ * Example {"name":"manolo","surname":"carrasco"}
*/
String toJson();
/**
+ * return a string which represents the object with an alias for the
+ * className useful for serialization.
+ *
+ * Example {"user":{"name":"manolo","surname":"carrasco"}}
+ */
+ String toJsonWithName();
+
+ /**
* return a string which represents the object in a queryString format.
*/
String toQueryString();
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java
index b8e341c4..b367e19f 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java
@@ -220,6 +220,10 @@ public class Properties extends JavaScriptObject implements Binder {
public final String toJson() {
return toJsonString();
}
+
+ public final String toJsonWithName() {
+ return "{\"properties\":{" + toJson() + "}";
+ }
@SuppressWarnings("unchecked")
public final <J> J getBound() {
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java
index 61cca6f3..dd45ec7d 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java
@@ -93,6 +93,10 @@ public abstract class JsonBuilderBase<J extends JsonBuilderBase<?>> implements J
@Override
public String toJson() {
+ return p.tostring();
+ }
+
+ public String toJsonWithName() {
return "{\"" + getName() + "\":" + p.tostring() + "}";
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java
index de07995a..d3820772 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/vm/JsonFactoryJre.java
@@ -173,9 +173,10 @@ public class JsonFactoryJre implements JsonFactory {
jsonObject = new JSONObject(String.valueOf(args[0]));
} else if (mname.matches("toString")) {
return jsonObject.toString();
+ } else if (mname.matches("toJsonWithName")) {
+ String jsonName = JsonBuilderGenerator.classNameToJsonName(getDataBindingClassName(proxy.getClass()));
+ return "{\"" + jsonName + "\":"+ jsonObject.toString() + "}";
} else if (mname.matches("toJson")) {
-// String jsonName = JsonBuilderGenerator.classNameToJsonName(getDataBindingClassName(proxy.getClass()));
-// return "{\"" + jsonName + "\":"+ jsonObject.toString() + "}";
return jsonObject.toString() ;
} else if ("toQueryString".equals(mname)) {
return param(jsonObject);
diff --git a/gwtquery-core/src/test/java/com/google/gwt/dev/shell/BrowserChannel.java b/gwtquery-core/src/test/java/com/google/gwt/dev/shell/BrowserChannelPatched.java
index 9a5a925e..dc357d6f 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/dev/shell/BrowserChannel.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/dev/shell/BrowserChannelPatched.java
@@ -15,9 +15,9 @@
*/
package com.google.gwt.dev.shell;
-import com.google.gwt.dev.shell.BrowserChannel.SessionHandler.ExceptionOrReturnValue;
-import com.google.gwt.dev.shell.BrowserChannel.SessionHandler.SpecialDispatchId;
-import com.google.gwt.dev.shell.BrowserChannel.Value.ValueType;
+import com.google.gwt.dev.shell.BrowserChannelPatched.SessionHandler.ExceptionOrReturnValue;
+import com.google.gwt.dev.shell.BrowserChannelPatched.SessionHandler.SpecialDispatchId;
+import com.google.gwt.dev.shell.BrowserChannelPatched.Value.ValueType;
import com.google.gwt.util.tools.Utility;
import java.io.BufferedInputStream;
@@ -34,7 +34,7 @@ import java.util.Set;
/**
*
*/
-public abstract class BrowserChannel {
+public abstract class BrowserChannelPatched {
/**
* An error indicating that the remote side died and we should unroll the
@@ -197,7 +197,7 @@ public abstract class BrowserChannel {
/**
* Hook interface for responding to messages.
*/
- public abstract static class SessionHandler<T extends BrowserChannel> {
+ public abstract static class SessionHandler<T extends BrowserChannelPatched> {
/**
* Wrapper to return both a return value/exception and a flag as to whether
@@ -612,7 +612,7 @@ public abstract class BrowserChannel {
*/
protected static class CheckVersionsMessage extends Message {
- public static CheckVersionsMessage receive(BrowserChannel channel)
+ public static CheckVersionsMessage receive(BrowserChannelPatched channel)
throws IOException {
DataInputStream stream = channel.getStreamFromOtherSide();
int minVersion = stream.readInt();
@@ -628,7 +628,7 @@ public abstract class BrowserChannel {
private final int minVersion;
- public CheckVersionsMessage(BrowserChannel channel, int minVersion,
+ public CheckVersionsMessage(BrowserChannelPatched channel, int minVersion,
int maxVersion, String hostedHtmlVersion) {
super(channel);
this.minVersion = minVersion;
@@ -665,7 +665,7 @@ public abstract class BrowserChannel {
*/
protected static class ChooseTransportMessage extends Message {
- public static ChooseTransportMessage receive(BrowserChannel channel)
+ public static ChooseTransportMessage receive(BrowserChannelPatched channel)
throws IOException {
DataInputStream stream = channel.getStreamFromOtherSide();
int n = stream.readInt();
@@ -678,7 +678,7 @@ public abstract class BrowserChannel {
private final String[] transports;
- public ChooseTransportMessage(BrowserChannel channel,
+ public ChooseTransportMessage(BrowserChannelPatched channel,
String[] transports) {
super(channel);
this.transports = transports;
@@ -704,7 +704,7 @@ public abstract class BrowserChannel {
*/
protected static class FatalErrorMessage extends Message {
- public static FatalErrorMessage receive(BrowserChannel channel)
+ public static FatalErrorMessage receive(BrowserChannelPatched channel)
throws IOException {
DataInputStream stream = channel.getStreamFromOtherSide();
// NOTE: Tag has already been read.
@@ -714,7 +714,7 @@ public abstract class BrowserChannel {
private final String error;
- public FatalErrorMessage(BrowserChannel channel, String error) {
+ public FatalErrorMessage(BrowserChannelPatched channel, String error) {
super(channel);
this.error = error;
}
@@ -737,7 +737,7 @@ public abstract class BrowserChannel {
* before an Invoke or Return message.
*/
protected static class FreeMessage extends Message {
- public static FreeMessage receive(BrowserChannel channel)
+ public static FreeMessage receive(BrowserChannelPatched channel)
throws IOException {
DataInputStream stream = channel.getStreamFromOtherSide();
int numIds = stream.readInt();
@@ -749,7 +749,7 @@ public abstract class BrowserChannel {
return new FreeMessage(channel, ids);
}
- public static void send(BrowserChannel channel, int[] ids)
+ public static void send(BrowserChannelPatched channel, int[] ids)
throws IOException {
DataOutputStream stream = channel.getStreamToOtherSide();
stream.writeByte(MessageType.FREE_VALUE.getId());
@@ -762,7 +762,7 @@ public abstract class BrowserChannel {
private final int ids[];
- public FreeMessage(BrowserChannel channel, int[] ids) {
+ public FreeMessage(BrowserChannelPatched channel, int[] ids) {
super(channel);
this.ids = ids;
}
@@ -791,7 +791,7 @@ public abstract class BrowserChannel {
* name).
*/
protected static class InvokeOnClientMessage extends Message {
- public static InvokeOnClientMessage receive(BrowserChannel channel)
+ public static InvokeOnClientMessage receive(BrowserChannelPatched channel)
throws IOException {
DataInputStream stream = channel.getStreamFromOtherSide();
// NOTE: Tag has already been read.
@@ -809,7 +809,7 @@ public abstract class BrowserChannel {
private final String methodName;
private final Value thisRef;
- public InvokeOnClientMessage(BrowserChannel channel, String methodName,
+ public InvokeOnClientMessage(BrowserChannelPatched channel, String methodName,
Value thisRef, Value[] args) {
super(channel);
this.thisRef = thisRef;
@@ -853,7 +853,7 @@ public abstract class BrowserChannel {
* name).
*/
protected static class InvokeOnServerMessage extends Message {
- public static InvokeOnServerMessage receive(BrowserChannel channel)
+ public static InvokeOnServerMessage receive(BrowserChannelPatched channel)
throws IOException {
DataInputStream stream = channel.getStreamFromOtherSide();
// NOTE: Tag has already been read.
@@ -872,7 +872,7 @@ public abstract class BrowserChannel {
private final int methodDispatchId;
private final Value thisRef;
- public InvokeOnServerMessage(BrowserChannel channel, int methodDispatchId,
+ public InvokeOnServerMessage(BrowserChannelPatched channel, int methodDispatchId,
Value thisRef, Value[] args) {
super(channel);
this.thisRef = thisRef;
@@ -911,7 +911,7 @@ public abstract class BrowserChannel {
* A request from the to invoke a function on the other side.
*/
protected static class InvokeSpecialMessage extends Message {
- public static InvokeSpecialMessage receive(BrowserChannel channel)
+ public static InvokeSpecialMessage receive(BrowserChannelPatched channel)
throws IOException, BrowserChannelException {
final DataInputStream stream = channel.getStreamFromOtherSide();
// NOTE: Tag has already been read.
@@ -933,7 +933,7 @@ public abstract class BrowserChannel {
private final Value[] args;
private final SpecialDispatchId dispatchId;
- public InvokeSpecialMessage(BrowserChannel channel,
+ public InvokeSpecialMessage(BrowserChannelPatched channel,
SpecialDispatchId dispatchId, Value[] args) {
super(channel);
this.dispatchId = dispatchId;
@@ -968,14 +968,14 @@ public abstract class BrowserChannel {
* Return message.
*/
protected static class LoadJsniMessage extends Message {
- public static LoadJsniMessage receive(BrowserChannel channel)
+ public static LoadJsniMessage receive(BrowserChannelPatched channel)
throws IOException {
DataInputStream stream = channel.getStreamFromOtherSide();
String js = readUtf8String(stream);
return new LoadJsniMessage(channel, js);
}
- public static void send(BrowserChannel channel, String js)
+ public static void send(BrowserChannelPatched channel, String js)
throws IOException {
DataOutputStream stream = channel.getStreamToOtherSide();
stream.write(MessageType.LOAD_JSNI.getId());
@@ -985,7 +985,7 @@ public abstract class BrowserChannel {
private final String js;
- public LoadJsniMessage(BrowserChannel channel, String js) {
+ public LoadJsniMessage(BrowserChannelPatched channel, String js) {
super(channel);
this.js = js;
}
@@ -1010,7 +1010,7 @@ public abstract class BrowserChannel {
* module.
*/
protected static class LoadModuleMessage extends Message {
- public static LoadModuleMessage receive(BrowserChannel channel)
+ public static LoadModuleMessage receive(BrowserChannelPatched channel)
throws IOException {
DataInputStream stream = channel.getStreamFromOtherSide();
String url = readUtf8String(stream);
@@ -1044,7 +1044,7 @@ public abstract class BrowserChannel {
* @param moduleName name of GWT module to load - may not be null
* @param userAgent user agent identifier of the browser - may not be null
*/
- public LoadModuleMessage(BrowserChannel channel, String url,
+ public LoadModuleMessage(BrowserChannelPatched channel, String url,
String tabKey, String sessionKey, String moduleName, String userAgent) {
super(channel);
assert url != null;
@@ -1108,13 +1108,13 @@ public abstract class BrowserChannel {
return types[type];
}
- private final BrowserChannel channel;
+ private final BrowserChannelPatched channel;
- public Message(BrowserChannel channel) {
+ public Message(BrowserChannelPatched channel) {
this.channel = channel;
}
- public final BrowserChannel getBrowserChannel() {
+ public final BrowserChannelPatched getBrowserChannel() {
return channel;
}
@@ -1154,7 +1154,7 @@ public abstract class BrowserChannel {
* module (original v1 version).
*/
protected static class OldLoadModuleMessage extends Message {
- public static OldLoadModuleMessage receive(BrowserChannel channel)
+ public static OldLoadModuleMessage receive(BrowserChannelPatched channel)
throws IOException {
DataInputStream stream = channel.getStreamFromOtherSide();
int protoVersion = stream.readInt();
@@ -1170,7 +1170,7 @@ public abstract class BrowserChannel {
private final String userAgent;
- public OldLoadModuleMessage(BrowserChannel channel, int protoVersion,
+ public OldLoadModuleMessage(BrowserChannelPatched channel, int protoVersion,
String moduleName, String userAgent) {
super(channel);
this.protoVersion = protoVersion;
@@ -1206,7 +1206,7 @@ public abstract class BrowserChannel {
*/
protected static class ProtocolVersionMessage extends Message {
- public static ProtocolVersionMessage receive(BrowserChannel channel)
+ public static ProtocolVersionMessage receive(BrowserChannelPatched channel)
throws IOException {
DataInputStream stream = channel.getStreamFromOtherSide();
int protocolVersion = stream.readInt();
@@ -1215,7 +1215,7 @@ public abstract class BrowserChannel {
private final int protocolVersion;
- public ProtocolVersionMessage(BrowserChannel channel, int protocolVersion) {
+ public ProtocolVersionMessage(BrowserChannelPatched channel, int protocolVersion) {
super(channel);
this.protocolVersion = protocolVersion;
}
@@ -1237,17 +1237,17 @@ public abstract class BrowserChannel {
* A message signifying a soft close of the communications channel.
*/
protected static class QuitMessage extends Message {
- public static QuitMessage receive(BrowserChannel channel) {
+ public static QuitMessage receive(BrowserChannelPatched channel) {
return new QuitMessage(channel);
}
- public static void send(BrowserChannel channel) throws IOException {
+ public static void send(BrowserChannelPatched channel) throws IOException {
final DataOutputStream stream = channel.getStreamToOtherSide();
stream.writeByte(MessageType.QUIT.getId());
stream.flush();
}
- public QuitMessage(BrowserChannel channel) {
+ public QuitMessage(BrowserChannelPatched channel) {
super(channel);
}
@@ -1269,19 +1269,19 @@ public abstract class BrowserChannel {
*
* @throws IOException
*/
- public static RequestIconMessage receive(BrowserChannel channel)
+ public static RequestIconMessage receive(BrowserChannelPatched channel)
throws IOException {
return new RequestIconMessage(channel);
}
- public static void send(BrowserChannel channel)
+ public static void send(BrowserChannelPatched channel)
throws IOException {
DataOutputStream stream = channel.getStreamToOtherSide();
stream.writeByte(MessageType.REQUEST_ICON.getId());
stream.flush();
}
- public RequestIconMessage(BrowserChannel channel) {
+ public RequestIconMessage(BrowserChannelPatched channel) {
super(channel);
}
@@ -1295,7 +1295,7 @@ public abstract class BrowserChannel {
* Signifies a return from a previous invoke.
*/
protected static class ReturnMessage extends Message {
- public static ReturnMessage receive(BrowserChannel channel)
+ public static ReturnMessage receive(BrowserChannelPatched channel)
throws IOException {
final DataInputStream stream = channel.getStreamFromOtherSide();
final boolean isException = stream.readBoolean();
@@ -1303,7 +1303,7 @@ public abstract class BrowserChannel {
return new ReturnMessage(channel, isException, returnValue);
}
- public static void send(BrowserChannel channel, boolean isException,
+ public static void send(BrowserChannelPatched channel, boolean isException,
Value returnValue) throws IOException {
final DataOutputStream stream = channel.getStreamToOtherSide();
stream.writeByte(MessageType.RETURN.getId());
@@ -1312,7 +1312,7 @@ public abstract class BrowserChannel {
stream.flush();
}
- public static void send(BrowserChannel channel,
+ public static void send(BrowserChannelPatched channel,
ExceptionOrReturnValue returnOrException) throws IOException {
send(channel, returnOrException.isException(),
returnOrException.getReturnValue());
@@ -1321,7 +1321,7 @@ public abstract class BrowserChannel {
private final boolean isException;
private final Value returnValue;
- public ReturnMessage(BrowserChannel channel, boolean isException,
+ public ReturnMessage(BrowserChannelPatched channel, boolean isException,
Value returnValue) {
super(channel);
this.returnValue = returnValue;
@@ -1348,7 +1348,7 @@ public abstract class BrowserChannel {
*/
protected static class SwitchTransportMessage extends Message {
- public static SwitchTransportMessage receive(BrowserChannel channel)
+ public static SwitchTransportMessage receive(BrowserChannelPatched channel)
throws IOException {
DataInputStream stream = channel.getStreamFromOtherSide();
String transport = readUtf8String(stream);
@@ -1360,7 +1360,7 @@ public abstract class BrowserChannel {
private final String transportArgs;
- public SwitchTransportMessage(BrowserChannel channel,
+ public SwitchTransportMessage(BrowserChannelPatched channel,
String transport, String transportArgs) {
super(channel);
// Change nulls to empty strings
@@ -1398,7 +1398,7 @@ public abstract class BrowserChannel {
* <p>See {@link RequestIconMessage}.
*/
protected static class UserAgentIconMessage extends Message {
- public static UserAgentIconMessage receive(BrowserChannel channel)
+ public static UserAgentIconMessage receive(BrowserChannelPatched channel)
throws IOException {
byte[] iconBytes = null;
DataInputStream stream = channel.getStreamFromOtherSide();
@@ -1412,7 +1412,7 @@ public abstract class BrowserChannel {
return new UserAgentIconMessage(channel, iconBytes);
}
- public static void send(BrowserChannel channel, byte[] iconBytes)
+ public static void send(BrowserChannelPatched channel, byte[] iconBytes)
throws IOException {
DataOutputStream stream = channel.getStreamToOtherSide();
stream.writeByte(MessageType.USER_AGENT_ICON.getId());
@@ -1429,7 +1429,7 @@ public abstract class BrowserChannel {
private byte[] iconBytes;
- public UserAgentIconMessage(BrowserChannel channel, byte[] iconBytes) {
+ public UserAgentIconMessage(BrowserChannelPatched channel, byte[] iconBytes) {
super(channel);
this.iconBytes = iconBytes;
}
@@ -1574,7 +1574,7 @@ public abstract class BrowserChannel {
private final DataOutputStream streamToOtherSide;
- public BrowserChannel(Socket socket, ObjectRefFactory objectRefFactory)
+ public BrowserChannelPatched(Socket socket, ObjectRefFactory objectRefFactory)
throws IOException {
this(new BufferedInputStream(socket.getInputStream()),
new BufferedOutputStream(socket.getOutputStream()),
@@ -1582,7 +1582,7 @@ public abstract class BrowserChannel {
this.socket = socket;
}
- protected BrowserChannel(InputStream inputStream, OutputStream outputStream,
+ protected BrowserChannelPatched(InputStream inputStream, OutputStream outputStream,
ObjectRefFactory objectRefFactory) {
streamFromOtherSide = new DataInputStream(inputStream);
streamToOtherSide = new DataOutputStream(outputStream);
diff --git a/gwtquery-core/src/main/java/com/google/gwt/junit/RunStyleHtmlUnit.java b/gwtquery-core/src/test/java/com/google/gwt/junit/RunStyleHtmlUnitPatched.java
index 0d8b5fe1..c7644868 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/junit/RunStyleHtmlUnit.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/junit/RunStyleHtmlUnitPatched.java
@@ -52,7 +52,7 @@ import java.util.Set;
/**
* Launches a web-mode test via HTMLUnit.
*/
-public class RunStyleHtmlUnit extends RunStyle {
+public class RunStyleHtmlUnitPatched extends RunStyle {
/**
* Runs HTMLUnit in a separate thread.
@@ -248,7 +248,7 @@ public class RunStyleHtmlUnit extends RunStyle {
/**
* Create a RunStyle instance with the passed-in browser targets.
*/
- public RunStyleHtmlUnit(JUnitShell shell) {
+ public RunStyleHtmlUnitPatched(JUnitShell shell) {
super(shell);
}
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTestGwt.java
index f22ce1e3..188e516e 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryAjaxTestGwt.java
@@ -40,7 +40,7 @@ public class GQueryAjaxTestGwt extends GWTTestCase {
static HTML testPanel = null;
public String getModuleName() {
- return "com.google.gwt.query.Query";
+ return "com.google.gwt.query.QueryTest";
}
public void gwtTearDown() {
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java
index 50f99d6f..f5a5d157 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java
@@ -82,7 +82,7 @@ public class GQueryCoreTestGwt extends GWTTestCase {
int done = 0;
public String getModuleName() {
- return "com.google.gwt.query.Query";
+ return "com.google.gwt.query.QueryTest";
}
public void gwtTearDown() {
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTestGwt.java
index ea9b91dd..90654507 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTestGwt.java
@@ -68,7 +68,7 @@ public class GQueryCssTestGwt extends GWTTestCase {
static HTML testPanel = null;
public String getModuleName() {
- return "com.google.gwt.query.Query";
+ return "com.google.gwt.query.QueryTest";
}
public void gwtTearDown() {
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryDeferredTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryDeferredTestGwt.java
index 1ad4e907..2e0c6821 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryDeferredTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryDeferredTestGwt.java
@@ -39,7 +39,7 @@ public class GQueryDeferredTestGwt extends GWTTestCase {
static HTML testPanel = null;
public String getModuleName() {
- return "com.google.gwt.query.Query";
+ return "com.google.gwt.query.QueryTest";
}
public void gwtTearDown() {
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java
index 8cf497db..ac79febe 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java
@@ -41,7 +41,7 @@ public class GQueryEffectsTestGwt extends GWTTestCase {
static HTML testPanel = null;
public String getModuleName() {
- return "com.google.gwt.query.Query";
+ return "com.google.gwt.query.QueryTest";
}
public void gwtTearDown() {
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java
index b781d1d9..681faa78 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java
@@ -14,6 +14,7 @@
package com.google.gwt.query.client;
import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.NodeList;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.junit.DoNotRunWith;
@@ -68,7 +69,7 @@ public class GQueryEventsTestGwt extends GWTTestCase {
int testSubmitEventCont = 0;
public String getModuleName() {
- return "com.google.gwt.query.Query";
+ return "com.google.gwt.query.QueryTest";
}
public void gwtSetUp() {
@@ -996,17 +997,13 @@ public class GQueryEventsTestGwt extends GWTTestCase {
public void testRebind() {
final GQuery b = $("<p>content</p>");
assertEquals(1, b.size());
- assertEquals(1, b.get().getLength());
b.click(new Function() {
public void f(Element e) {
b.css(CSS.COLOR.with(RGBColor.RED));
}
});
$(e).append(b);
- // TODO: dom manipulations some times modifies gquery nodelist,
- // we could remove the nodelist since we maintain a list of elements.
assertEquals(1, b.size());
- assertEquals(1, b.get().getLength());
b.click();
assertEquals("red", b.css("color", false));
}
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryGwtSuiteTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryGwtSuiteTest.java
index 60b62360..e94d27eb 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryGwtSuiteTest.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryGwtSuiteTest.java
@@ -3,6 +3,7 @@ package com.google.gwt.query.client;
import junit.framework.Test;
import com.google.gwt.junit.tools.GWTTestSuite;
+import com.google.gwt.query.client.ajax.AjaxTestGwt;
import com.google.gwt.query.client.dbinding.DataBindingTestGwt;
import com.google.gwt.query.client.deferred.DeferredTestGwt;
import com.google.gwt.query.client.impl.SelectorEnginesTestGwt;
@@ -11,13 +12,12 @@ import com.google.gwt.query.client.impl.SelectorEnginesTestGwt;
* Class to run all Gwt test in a jvm instance.
* It speeds up maven testing phase.
*/
-public class GQueryGwtSuiteTest extends GWTTestSuite
-{
- public static Test suite()
- {
+public class GQueryGwtSuiteTest extends GWTTestSuite {
+ public static Test suite() {
GWTTestSuite suite = new GWTTestSuite( "GQuery Suite" );
suite.addTestSuite(DataBindingTestGwt.class);
suite.addTestSuite(GQueryAjaxTestGwt.class);
+ suite.addTestSuite(AjaxTestGwt.class);
suite.addTestSuite(GQueryDeferredTestGwt.class);
suite.addTestSuite(DeferredTestGwt.class);
suite.addTestSuite(GQuerySelectorsTestGwt.class);
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTestGwt.java
index 74f91d12..a15af268 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTestGwt.java
@@ -34,7 +34,7 @@ public class GQueryJsTestGwt extends GWTTestCase {
static HTML testPanel = null;
public String getModuleName() {
- return "com.google.gwt.query.Query";
+ return "com.google.gwt.query.QueryTest";
}
public void gwtSetUp() {
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTestGwt.java
index 36083eee..d60eb9a0 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTestGwt.java
@@ -175,7 +175,7 @@ public class GQuerySelectorsTestGwt extends GWTTestCase {
}-*/;
public String getModuleName() {
- return "com.google.gwt.query.Query";
+ return "com.google.gwt.query.QueryTest";
}
public void gwtTearDown() {
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java
index c5399e83..b509fa00 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryWidgetsTestGwt.java
@@ -44,7 +44,7 @@ public class GQueryWidgetsTestGwt extends GWTTestCase {
int testSubmitEventCont = 0;
public String getModuleName() {
- return "com.google.gwt.query.Query";
+ return "com.google.gwt.query.QueryTest";
}
public void testGWTQueryCoreWidgets() {
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/ajax/AjaxCommon.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/ajax/AjaxCommon.java
index fa790236..9c03b823 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/ajax/AjaxCommon.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/ajax/AjaxCommon.java
@@ -83,7 +83,15 @@ public abstract class AjaxCommon extends GWTTestCase {
performAjaxJsonTest(s);
}
-
+
+ // This test needs htmlunit at least 2.11
+ // https://groups.google.com/forum/#!msg/google-web-toolkit/dmyTt1Bh0pM/lBTIFiTyrpkJ
+ //
+ // It is necessary to patch RunStyleHtmlUnit because GWT default browser is FF3 since
+ // minimun version in htmlunit-2.1x is FF3.6
+ // It is necessary to patch BrowserChannel as well because convertFromJavaValue receives
+ // non string objects under certain circumstances.
+ @DoNotRunWith(Platform.HtmlUnitBug)
public void testAjaxJsonPost_CORS() {
delayTestFinish(5000);
Settings s = Ajax.createSettings()
@@ -104,6 +112,7 @@ public abstract class AjaxCommon extends GWTTestCase {
performAjaxJsonTest(s);
}
+ @DoNotRunWith(Platform.HtmlUnitBug)
public void testAjaxJsonGet_CORS() {
Settings s = Ajax.createSettings()
.setType("get")
@@ -167,7 +176,9 @@ public abstract class AjaxCommon extends GWTTestCase {
.fail(finishFunction);
}
- @DoNotRunWith(Platform.HtmlUnitBug)
+ // For some reason htmlunit 2.16 does not raises a timeout, 2.9 does though,
+ // when server sleeps or connection lasts a while. Tested with htmlunit 2.16
+ // @DoNotRunWith(Platform.HtmlUnitBug)
public void testAjaxTimeout() {
delayTestFinish(5000);
Settings s = Ajax.createSettings()
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTest.java
index d94b706a..04bae0b9 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTest.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTest.java
@@ -105,10 +105,12 @@ public class DataBindingTest extends GWTTestCase {
assertEquals(2000l, c.getItems().get(0).getDate().getTime());
assertEquals(3000l, c.getItems().get(1).getDate().getTime());
- assertTrue(c.toJson().startsWith("{\"jsonExample\":{"));
+ assertFalse(c.toJson().startsWith("{\"jsonExample\":"));
+ assertTrue(c.toJsonWithName().startsWith("{\"jsonExample\":"));
assertTrue(c.toJson().contains("\"items\":[{\"date\":"));
assertTrue(c.toQueryString().contains("t[]=bar"));
- assertTrue(c.toQueryString().contains("a=2"));
+ assertTrue(c.toQueryString().contains("a=1"));
+ assertTrue(c.toQueryString().contains("\"a\":2"));
assertEquals(1, c.<Number>get("a").intValue());
}
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestGwt.java
index c01e6c5c..bcd697b1 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestGwt.java
@@ -23,7 +23,7 @@ public class DataBindingTestGwt extends DataBindingTest {
@Override
public String getModuleName() {
- return "com.google.gwt.query.Query";
+ return "com.google.gwt.query.QueryTest";
}
}
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/deferred/DeferredTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/deferred/DeferredTestGwt.java
index de6375db..f972d3db 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/deferred/DeferredTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/deferred/DeferredTestGwt.java
@@ -23,7 +23,7 @@ public class DeferredTestGwt extends DeferredTest {
@Override
public String getModuleName() {
- return "com.google.gwt.query.Query";
+ return "com.google.gwt.query.QueryTest";
}
}
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTestGwt.java
index 57c7749a..8dd79411 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTestGwt.java
@@ -23,7 +23,7 @@ public class SelectorEnginesTestGwt extends SelectorEnginesTest {
@Override
public String getModuleName() {
- return "com.google.gwt.query.Query";
+ return "com.google.gwt.query.QueryTest";
}
}
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/servlet/GQAjaxTestServlet.java b/gwtquery-core/src/test/java/com/google/gwt/query/servlet/GQAjaxTestServlet.java
index 6f4fc1a4..a41dd1d7 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/servlet/GQAjaxTestServlet.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/servlet/GQAjaxTestServlet.java
@@ -13,17 +13,22 @@ import javax.servlet.http.HttpServletResponse;
public class GQAjaxTestServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
- String name = this.getClass().getSimpleName() + " ";
-
- @Override
- protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ private String name = this.getClass().getSimpleName() + " ";
+
+ @SuppressWarnings("unused")
+ private void dumpHeaders(HttpServletRequest req) {
System.out.println(name + req.getMethod() + " " + req.getContentType());
+
+ @SuppressWarnings("unchecked")
Enumeration<String> en = req.getHeaderNames();
while (en.hasMoreElements()) {
String s = (String) en.nextElement();
System.out.println(name + s + " " + req.getHeader(s));
}
-
+ }
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String t = req.getParameter("timeout");
if (t != null && t.matches("\\d+")) {