fhigit / js-test-driver

Automatically exported from code.google.com/p/js-test-driver
0 stars 0 forks source link

Prototype JS library causes error #32

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add Prototype JS library to com.google.jstestdriver.javascript package
from http://prototypejs.org/assets/2008/9/29/prototype-1.6.0.3.js
2. Run "ant jstestdriver"
3. Observe error

What is the expected output? What do you see instead?

As Prototype is not used in anything, I would expect the output to be the
same as without the library. Instead the test fails with:

     [java] com.google.gson.JsonParseException: The JsonDeserializer
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter@21d9bf04 failed
to deserialized json object "[{"file": {"fileSrc": __lots_of_json__},
"success": true, "message": ""}]" given the type
com.google.gson.ParameterizedTypeImpl@5138c5fa
     [java]     at
com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExc
eptionWrapper.java:63)
     [java]     at
com.google.gson.JsonObjectDeserializationVisitor.visitFieldUsingCustomHandler(Js
onObjectDeserializationVisitor.java:106)
     [java]     at
com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.java:135)
     [java]     at
com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:116)
     [java]     at
com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializa
tionContextDefault.java:75)
     [java]     at
com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializatio
nContextDefault.java:49)
     [java]     at com.google.gson.Gson.fromJson(Gson.java:373)
     [java]     at com.google.gson.Gson.fromJson(Gson.java:321)
     [java]     at com.google.gson.Gson.fromJson(Gson.java:297)
     [java]     at
com.google.jstestdriver.BrowserQueryResponseServlet.service(Unknown Source)
     [java]     at
com.google.jstestdriver.BrowserQueryResponseServlet.doPost(Unknown Source)
     [java]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
     [java]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
     [java]     at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
     [java]     at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
     [java]     at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
     [java]     at org.mortbay.jetty.Server.handle(Server.java:326)
     [java]     at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
     [java]     at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)
     [java]     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
     [java]     at
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
     [java]     at
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
     [java]     at
org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
     [java]     at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
     [java] Caused by: java.lang.ClassCastException:
com.google.gson.JsonPrimitive cannot be cast to com.google.gson.JsonArray
     [java]     at com.google.gson.JsonElement.getAsJsonArray(JsonElement.java:91)
     [java]     at
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.deserialize(DefaultTyp
eAdapters.java:399)
     [java]     at
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.deserialize(DefaultTyp
eAdapters.java:369)
     [java]     at
com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExc
eptionWrapper.java:50)
     [java]     ... 23 more

What version of the product are you using? On what operating system?

Revision 291, Mac OSX 10.5.8, Safari 4.03.

Please provide any additional information below.

Firefox 3 seems to work fine.

Original issue reported on code.google.com by toni.str...@gmail.com on 25 Aug 2009 at 1:09

GoogleCodeExporter commented 9 years ago
Here is what I get from trying to run it (JsTestDriver-1.2.jar   Self-contained 
executable jar   Featured) on chrome 3.0.195.27 and Firefox 3.5.4 on Win Xp 64 
bit 
(including prototype.js version 1.6.1):

Chrome:
30-Oct-2009 16:10:28 org.mortbay.log.Slf4jLog info
INFO: Logging to org.slf4j.impl.JDK14LoggerAdapter(org.mortbay.log) via 
org.mortbay.log.Slf4jLog
30-Oct-2009 16:10:28 org.mortbay.log.Slf4jLog info
INFO: jetty-6.1.x
30-Oct-2009 16:10:28 org.mortbay.log.Slf4jLog info
INFO: Started SocketConnector@0.0.0.0:9876
30-Oct-2009 16:10:29 com.google.jstestdriver.BrowserHunter captureBrowser
INFO: Browser Captured: Chrome version 3.0.195.27 (1)
30-Oct-2009 16:10:30 org.mortbay.log.Slf4jLog warn
SEVERE: /query/1
com.google.gson.JsonParseException: The JsonDeserializer 
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter@1cd280b failed to 
deserialized json object "[{"file": {"fileSrc": 
"/test/C:/Projects/t/modules/adminconsole/src/web/js/prototype.js", 
"timestamp": 
1253182293781}, "success": true, "message": ""}, {"file": {"fileSrc": 
"/test/C:/Projects/t/modules/adminconsole/src/web/js/scriptaculous.js", 
"timestamp": 
1253182293796}, "success": true, "message": ""}, {"file": {"fileSrc": 
"/test/C:/Projects/t/modules/adminconsole/src/web/js/editOrder.js", 
"timestamp": 
1256911955060}, "success": true, "message": ""}, {"file": {"fileSrc": 
"/test/C:/Projects/t/modules/adminconsole/src/web-test/js/editOrderTest.js", 
"timestamp": 1256911339279}, "success": true, "message": ""}]" given the type 
com.google.gson.ParameterizedTypeImpl@1277cac
    at 
com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExc
eptio
nWrapper.java:63)
    at 
com.google.gson.JsonObjectDeserializationVisitor.visitFieldUsingCustomHandler(Js
onObj
ectDeserializationVisitor.java:106)
    at 
com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.java:135)
    at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:116)
    at 
com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializa
tionC
ontextDefault.java:75)
    at 
com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializatio
nCont
extDefault.java:49)
    at com.google.gson.Gson.fromJson(Gson.java:373)
    at com.google.gson.Gson.fromJson(Gson.java:321)
    at com.google.gson.Gson.fromJson(Gson.java:297)
    at com.google.jstestdriver.BrowserQueryResponseServlet.service(Unknown 
Source)
    at com.google.jstestdriver.BrowserQueryResponseServlet.doPost(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
    at 
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at 
org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
    at 
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Caused by: java.lang.ClassCastException: com.google.gson.JsonPrimitive cannot 
be cast 
to com.google.gson.JsonArray
    at com.google.gson.JsonElement.getAsJsonArray(JsonElement.java:91)
    at 
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.deserialize(DefaultTyp
eAdap
ters.java:399)
    at 
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.deserialize(DefaultTyp
eAdap
ters.java:369)
    at 
com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExc
eptio
nWrapper.java:50)
    ... 23 more

Firefox: 
30-Oct-2009 16:12:03 org.mortbay.log.Slf4jLog info
INFO: Logging to org.slf4j.impl.JDK14LoggerAdapter(org.mortbay.log) via 
org.mortbay.log.Slf4jLog
30-Oct-2009 16:12:03 org.mortbay.log.Slf4jLog info
INFO: jetty-6.1.x
30-Oct-2009 16:12:04 org.mortbay.log.Slf4jLog info
INFO: Started SocketConnector@0.0.0.0:9876
30-Oct-2009 16:12:05 com.google.jstestdriver.BrowserHunter captureBrowser
INFO: Browser Captured: Firefox version 3.5.4 (1)
30-Oct-2009 16:12:06 org.mortbay.log.Slf4jLog warn
SEVERE: /query/1
com.google.gson.JsonParseException: The JsonDeserializer 
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter@1958bf9 failed to 
deserialized json object "[{"file": {"fileSrc": 
"/test/C:/Projects/t/modules/adminconsole/src/web/js/prototype.js", 
"timestamp": 
1253182293781}, "success": true, "message": ""}, {"file": {"fileSrc": 
"/test/C:/Projects/t/modules/adminconsole/src/web/js/scriptaculous.js", 
"timestamp": 
1253182293796}, "success": true, "message": ""}, {"file": {"fileSrc": 
"/test/C:/Projects/t/modules/adminconsole/src/web/js/editOrder.js", 
"timestamp": 
1256911955060}, "success": true, "message": ""}, {"file": {"fileSrc": 
"/test/C:/Projects/t/modules/adminconsole/src/web-test/js/editOrderTest.js", 
"timestamp": 1256911339279}, "success": true, "message": ""}]" given the type 
com.google.gson.ParameterizedTypeImpl@1630cfd
    at 
com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExc
eptio
nWrapper.java:63)
    at 
com.google.gson.JsonObjectDeserializationVisitor.visitFieldUsingCustomHandler(Js
onObj
ectDeserializationVisitor.java:106)
    at 
com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.java:135)
    at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:116)
    at 
com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializa
tionC
ontextDefault.java:75)
    at 
com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializatio
nCont
extDefault.java:49)
    at com.google.gson.Gson.fromJson(Gson.java:373)
    at com.google.gson.Gson.fromJson(Gson.java:321)
    at com.google.gson.Gson.fromJson(Gson.java:297)
    at com.google.jstestdriver.BrowserQueryResponseServlet.service(Unknown 
Source)
    at com.google.jstestdriver.BrowserQueryResponseServlet.doPost(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
    at 
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at 
org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
    at 
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Caused by: java.lang.ClassCastException: com.google.gson.JsonPrimitive cannot 
be cast 
to com.google.gson.JsonArray
    at com.google.gson.JsonElement.getAsJsonArray(JsonElement.java:91)
    at 
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.deserialize(DefaultTyp
eAdap
ters.java:399)
    at 
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.deserialize(DefaultTyp
eAdap
ters.java:369)
    at 
com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExc
eptio
nWrapper.java:50)
    ... 23 more

Original comment by Mors...@gmail.com on 30 Oct 2009 at 3:15

GoogleCodeExporter commented 9 years ago
I appear to be having same issues as above:

I'm on mac 10.4.11 using prototype 1.6

imac:~/Desktop/JsTestDriver-1.2$ java -jar JsTestDriver-1.2.jar --port 9876
Nov 4, 2009 5:32:18 PM org.mortbay.log.Slf4jLog info
INFO: Logging to org.slf4j.impl.JDK14LoggerAdapter(org.mortbay.log) via
org.mortbay.log.Slf4jLog
Nov 4, 2009 5:32:18 PM org.mortbay.log.Slf4jLog info
INFO: jetty-6.1.x
Nov 4, 2009 5:32:18 PM org.mortbay.log.Slf4jLog info
INFO: Started SocketConnector@0.0.0.0:9876
Nov 4, 2009 5:32:21 PM com.google.jstestdriver.BrowserHunter captureBrowser
INFO: Browser Captured: Firefox version 3.5.3 (1)
Nov 4, 2009 5:32:27 PM org.mortbay.log.Slf4jLog warn
SEVERE: /query/1
com.google.gson.JsonParseException: The JsonDeserializer
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter@748417 failed to
deserialized json object "[{"file": {"fileSrc":
"/test//Users/daviddevalk/Desktop/BlindRebel/apps/prototype/media/js/prototype_1
.6.1.js",
"timestamp": 1252758450000}, "success": true, "message": ""}, {"file": 
{"fileSrc":
"/test//Users/daviddevalk/Desktop/BlindRebel/apps/lists/media/js/lists.js",
"timestamp": 1257373402000}, "success": true, "message": ""}]" given the type
com.google.gson.ParameterizedTypeImpl@6785f0
        at
com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExc
eptionWrapper.java:63)
        at
com.google.gson.JsonObjectDeserializationVisitor.visitFieldUsingCustomHandler(Js
onObjectDeserializationVisitor.java:106)
        at com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.java:135)
        at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:116)
        at
com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializa
tionContextDefault.java:75)
        at
com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializatio
nContextDefault.java:49)
        at com.google.gson.Gson.fromJson(Gson.java:373)
        at com.google.gson.Gson.fromJson(Gson.java:321)
        at com.google.gson.Gson.fromJson(Gson.java:297)
        at com.google.jstestdriver.BrowserQueryResponseServlet.service(Unknown Source)
        at com.google.jstestdriver.BrowserQueryResponseServlet.doPost(Unknown Source)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:326)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
        at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Caused by: java.lang.ClassCastException: com.google.gson.JsonPrimitive
        at com.google.gson.JsonElement.getAsJsonArray(JsonElement.java:91)
        at
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.deserialize(DefaultTyp
eAdapters.java:399)
        at
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.deserialize(DefaultTyp
eAdapters.java:369)
        at
com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExc
eptionWrapper.java:50)
        ... 23 more

Original comment by ddev...@gmail.com on 4 Nov 2009 at 10:33

GoogleCodeExporter commented 9 years ago
Please solve this problem!

In the meantime I found out that commenting out Array.toJSON (lines 1061 
through 1068) of prototype solves 
the problem, because the JSON.stringify method tries to call any toJSON method 
provided by JavaScript objects. I 
haven't got any more time to investigate, but this should help to solve the 
issue.

Original comment by bobo%elb...@gtempaccount.com on 5 Nov 2009 at 5:17

GoogleCodeExporter commented 9 years ago
The same problem. Ubuntu 9.10, Prototype 1.6.1

Original comment by lubos.ra...@gmail.com on 6 Nov 2009 at 3:04

GoogleCodeExporter commented 9 years ago
With mootools 1.2.4 on ubuntu 9.10 similar problem.
It looks bed, js-test-driver not working with few most popular jsframework.
(I've also encounter a problem with jquery when i've tried to use $ not jquery.)
Its a pity because that tool looks very nice.

com.google.gson.JsonParseException: The JsonDeserializer
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter@39203412 failed to
deserialized json object
"[{"file":{"fileSrc":"/test//home/sebastian/workspaces/fake/jsTests/lib/mootools
-1.2.4-core-nc.js","timestamp":1262173017000},"success":true,"message":""},{"fil
e":{"fileSrc":"/test//home/sebastian/workspaces/fake/jsTests/lib/mootools-1.2.4.
2-more.js","timestamp":1262102699000},"success":true,"message":""},{"file":{"fil
eSrc":"/test//home/sebastian/workspaces/fake/jsTests/src/Greeter.js","timestamp"
:1261441020000},"success":true,"message":""},{"file":{"fileSrc":"/test//home/seb
astian/workspaces/fake/jsTests/settings/jquery.js","timestamp":1262111120000},"s
uccess":false,"message":"error
loading file: 
/test//home/sebastian/workspaces/fake/jsTests/settings/jquery.js:2:
jQuery is
undefined"},{"file":{"fileSrc":"/test//home/sebastian/workspaces/fake/jsTests/sr
c-test/TryTest.js","timestamp":1262175170000},"success":true,"message":""}]"
given the type com.google.gson.ParameterizedTypeImpl@743bd42e
    at
com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExc
eptionWrapper.java:63)
    at
com.google.gson.JsonObjectDeserializationVisitor.visitFieldUsingCustomHandler(Js
onObjectDeserializationVisitor.java:106)
    at com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.java:135)
    at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:116)
    at
com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializa
tionContextDefault.java:75)
    at
com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializatio
nContextDefault.java:49)
    at com.google.gson.Gson.fromJson(Gson.java:373)
    at com.google.gson.Gson.fromJson(Gson.java:321)
    at com.google.gson.Gson.fromJson(Gson.java:297)
    at com.google.jstestdriver.BrowserQueryResponseServlet.service(Unknown Source)
    at com.google.jstestdriver.BrowserQueryResponseServlet.doPost(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Caused by: java.lang.ClassCastException: com.google.gson.JsonPrimitive cannot 
be cast
to com.google.gson.JsonArray
    at com.google.gson.JsonElement.getAsJsonArray(JsonElement.java:91)
    at
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.deserialize(DefaultTyp
eAdapters.java:399)
    at
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.deserialize(DefaultTyp
eAdapters.java:369)
    at
com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExc
eptionWrapper.java:50)
    ... 23 more

Original comment by sebastia...@gmail.com on 30 Dec 2009 at 12:22

GoogleCodeExporter commented 9 years ago
I'm seeing this issue (with prototype.js) on Mac OS X 10.6.2 with Firefox 3.5.7 
as
well. I hope it's not too hard to fix, because I definitely want to start using 
this.

Original comment by petterma...@gmail.com on 8 Jan 2010 at 2:20

GoogleCodeExporter commented 9 years ago
The same problem, mootools 1.2.4 +  Mac OS 10.6.2 + any browser.

Original comment by kmik...@gmail.com on 25 Jan 2010 at 4:46

GoogleCodeExporter commented 9 years ago
I'm getting the same issue on Windows 7. It's definitely a problem with Google 
Gson
library (in the deserialize method in some class implementing 
JsonDeserializer<T>
interface).

I can get around the issue by doing the same as 'andreabobobaron' did. 
Actually, I
renamed that function to something else (i.e. 'toGSON') and also in the
Object.extend(arrayProto, {....});

Although, we'd like this issue to be solved as is forcing me to rename any 
usage of
Array.toJSON in my scripts.

Original comment by benjamin...@gmail.com on 24 Mar 2010 at 5:25

GoogleCodeExporter commented 9 years ago
Hey guys!

I had the same issue today and I figured I'd sniff around and see if I could 
fix the
problem. Well! Good news is that I figured out the issue. It's simply a 
namespace
issue that messes with the other frameworks. I have it working for both Mootools
1.2.4 and Prototype 1.6.1 (OS shouldn't matter). It's not battle tested or 
anything,
but the problem is simple enough to fix so I would assume that my fix will get 
rid of
the current problem. This only fixes version 1.2.1 on Linux/Unix+Mac

I'd like to just apply the fix to the repo, but I'm not sure how you would do 
that on
for a project hosted by google. I packaged everything in a tar. Unpack the tar 
in the
same directory as JsTestDriver-1.2.1.jar and run the fix.sh script. The script 
will
make a backup of the original jar file, just in case. You need the jar command 
to be
on your path. 

Hope this helps someone!

-Reuven

Original comment by somnium...@gmail.com on 25 Mar 2010 at 5:35

Attachments:

GoogleCodeExporter commented 9 years ago
Good spot Reuven!
I've included another version of your fix to be applied in Windows (not a big 
deal :) ).
Thanks!

Original comment by benjamin...@gmail.com on 25 Mar 2010 at 9:16

Attachments:

GoogleCodeExporter commented 9 years ago
Hi people!

I tried the fix and works fine, I try loading mootools-1.2.4-core.js under 
Linux and works perfectly, now I have a simple question, always I use Eclipse 
and Js Test Driver plugin for Eclipse to do tests ... anyone knows if the 
plugin support this fix?

Thanks!

Here my config file:

server: http://localhost:9876

load:
  - lib/mootools-1.2.4-core.js

  - src/*.js
  - src-test/*.js

My JS file:

var L = new Class({
    initialize : function(log) {
        this.log = log;
    }
});

Logs = {};

Logs.Search = function() {
    this.SEARCH_TYPE = 1;
};

Logs.Search.prototype = {
    logs : [],

    addLog : function(log) {
        var l = new Log(log);
        this.logs.push(l);
    },

    getSearchType : function() {
        return this.SEARCH_TYPE;
    },

    setSearchType : function(type) {
        this.SEARCH_TYPE = type;
    },

    doSearch : function() {
        return 'doSearch';
    },

    find : function() {
        return 'find';
    }
};

My JS tests file:

LogsTest = TestCase("LogsTest");

LogsTest.prototype.setUp = function() {
    this.div = new Element('div', {
        id : 'foo'
    });
    document.id(document.body).adopt(this.div);
};

LogsTest.prototype.testSearchFind = function() {
    var Search = new Logs.Search();
    assertEquals("find", Search.find());
};

LogsTest.prototype.testSearchDoSearch = function() {
    var Search = new Logs.Search();
    assertEquals("doSearch", Search.doSearch());
};

LogsTest.prototype.testSearchGetSearchType = function() {
    var Search = new Logs.Search();
    Search.setSearchType(2);
    assertEquals(2, Search.getSearchType());
};

LogsTest.prototype.testDOMFoo = function() {
    assertNotNull(document.id('foo'));
};

Original comment by epplestun on 11 Jun 2010 at 12:43

GoogleCodeExporter commented 9 years ago
Another hacky solution which worked because I wasn't testing anything using the 
toJSON function. 

Config file includes these lines:

load:
  - js/scriptaculous/prototype.js
  - test/js/prototype_fix_for_jstestdriver.js

where prototype_fix_for_jstestdriver.js:

  if (Array.prototype.toJSON) {
    delete Array.prototype.toJSON;
  }

Fragile and clumsy but it got the job done without hacking jsTestDriver or 
prototype

Original comment by julian.b...@gmail.com on 16 Jun 2010 at 12:40

GoogleCodeExporter commented 9 years ago
Hi all, 
Since this issue hasn't been solved for version 1.2.2 I've updated the patch.

Regards.

   Benjamin Arroyo.

Original comment by benjamin...@gmail.com on 5 Jul 2010 at 4:36

Attachments:

GoogleCodeExporter commented 9 years ago
attached a patch to fix this in the trunk @760

Original comment by willhol...@gmail.com on 1 Nov 2010 at 9:47

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by corbinrs...@gmail.com on 5 Jan 2011 at 10:02

GoogleCodeExporter commented 9 years ago

Original comment by corbinrs...@gmail.com on 5 Jan 2011 at 10:03

GoogleCodeExporter commented 9 years ago
When trying to use Prototype 1.6.1 with js-test-driver 1.3.1 I'm getting almost 
the same error as in the original post

Stack trace:

FINE: sending command 
{"command":"loadTest","parameters":["[{\"fileSrc\":\"/test/lib/prototype/prototy
pe.js\",\"timestamp\":1297714089000},{\"fileSrc\":\"/test/src-test/tests.js\",\"
timestamp\":1299360531000}]","false"]}
06.03.2011 9:20:54 
com.google.jstestdriver.server.handlers.BrowserQueryResponseHandler 
serviceBrowser
FINE: response type: FILE_LOAD_RESULT
06.03.2011 9:20:54 com.google.jstestdriver.requesthandlers.RequestDispatcher 
dispatch
SEVERE: Error in request {}
java.lang.RuntimeException: Unable to parse: 
{"type":"FILE_LOAD_RESULT","response":"{\"loadedFiles\":\"[{\\\"file\\\": 
{\\\"fileSrc\\\": \\\"/test/lib/prototype/prototype.js\\\", \\\"timestamp\\\": 
1297714089000}, \\\"success\\\": true, \\\"message\\\": \\\"\\\", 
\\\"elapsed\\\": 76}, {\\\"file\\\": {\\\"fileSrc\\\": 
\\\"/test/src-test/tests.js\\\", \\\"timestamp\\\": 1299360531000}, 
\\\"success\\\": true, \\\"message\\\": \\\"\\\", \\\"elapsed\\\": 
4}]\"}","browser":{"id":1299396046958}}
    at com.google.jstestdriver.server.handlers.BrowserQueryResponseHandler.service(BrowserQueryResponseHandler.java:108)
    at com.google.jstestdriver.server.handlers.BrowserQueryResponseHandler.handleIt(BrowserQueryResponseHandler.java:87)
    at com.google.jstestdriver.requesthandlers.RequestDispatcher.dispatch(RequestDispatcher.java:68)
    at com.google.jstestdriver.requesthandlers.RequestHandlerServlet.service(RequestHandlerServlet.java:50)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:389)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Caused by: com.google.gson.JsonParseException: The JsonDeserializer 
com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter@71412b61 failed to 
deserialized json object "[{\"file\": {\"fileSrc\": 
\"/test/lib/prototype/prototype.js\", \"timestamp\": 1297714089000}, 
\"success\": true, \"message\": \"\", \"elapsed\": 76}, {\"file\": 
{\"fileSrc\": \"/test/src-test/tests.js\", \"timestamp\": 1299360531000}, 
\"success\": true, \"message\": \"\", \"elapsed\": 4}]" given the type 
com.google.gson.ParameterizedTypeImpl@8335d86
    at com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExceptionWrapper.java:63)
    at com.google.gson.JsonDeserializationVisitor.invokeCustomDeserializer(JsonDeserializationVisitor.java:88)
    at com.google.gson.JsonObjectDeserializationVisitor.visitFieldUsingCustomHandler(JsonObjectDeserializationVisitor.java:116)
    at com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.java:158)
    at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:131)
    at com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializationContextDefault.java:73)
    at com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializationContextDefault.java:51)
    at com.google.gson.Gson.fromJson(Gson.java:568)
    at com.google.gson.Gson.fromJson(Gson.java:515)
    at com.google.gson.Gson.fromJson(Gson.java:484)
    at com.google.gson.Gson.fromJson(Gson.java:434)
    at com.google.jstestdriver.server.handlers.BrowserQueryResponseHandler.serviceBrowser(BrowserQueryResponseHandler.java:135)
    at com.google.jstestdriver.server.handlers.BrowserQueryResponseHandler.service(BrowserQueryResponseHandler.java:104)
    ... 17 more
Caused by: java.lang.IllegalStateException: This is not a JSON Array.
    at com.google.gson.JsonElement.getAsJsonArray(JsonElement.java:99)
    at com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.deserialize(DefaultTypeAdapters.java:544)
    at com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter.deserialize(DefaultTypeAdapters.java:510)
    at com.google.gson.JsonDeserializerExceptionWrapper.deserialize(JsonDeserializerExceptionWrapper.java:50)
    ... 29 more

jsTestDriver.js contest:

server: http://localhost:4433

load:
  - "lib/prototype/prototype.js"
  - "src-test/tests.js"

Content of tests.js

GreeterTest = TestCase("GreeterTest");

GreeterTest.prototype.testGreet = function() {
  var array = [1, 1, 1];
  array.each(function(el) {
    assertEquals(el, 1);
  });
};

GreeterTest.prototype.testGreet = function() {
  var array = [1, 1, 2];
  array.each(function(el) {
    assertEquals(el, 1);
  });
};

Original comment by andriy.g...@gmail.com on 6 Mar 2011 at 7:23