google-code-export / gwt-test-utils

Automatically exported from code.google.com/p/gwt-test-utils
1 stars 0 forks source link

java.lang.UnsatisfiedLinkError: com.google.gwt.json.client.JSONObject.addAllKeys(Ljava/util/Collection;)V #113

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Adding 'new JSONObject().toString();' to a client side code which is unit 
tested.

What is the expected output? What do you see instead?
I would expect that it cause no problem. Instead it gives:
java.lang.UnsatisfiedLinkError: 
com.google.gwt.json.client.JSONObject.addAllKeys(Ljava/util/Collection;)V
    at com.google.gwt.json.client.JSONObject.addAllKeys(Native Method)
    at com.google.gwt.json.client.JSONObject.computeKeys(JSONObject.java:208)
    at com.google.gwt.json.client.JSONObject.toString(JSONObject.java:174)
<...>

What version of the product are you using? On what operating system?
gwt-test-utils-0.35.zip from the Downloads page.
OS: Win XP 32 bit.
Java: 6 update 30.
Eclipse: 3.7 (Indigo) SR 1 with the latest updates.

Please provide any additional information below.
All the other calls on JSON... objects do not seem to cause trouble so far, but 
this one does.

Original issue reported on code.google.com by vangel.a...@gmail.com on 25 Jan 2012 at 9:39

GoogleCodeExporter commented 9 years ago

Original comment by gael.laz...@gmail.com on 26 Jan 2012 at 6:43

GoogleCodeExporter commented 9 years ago
I just fixed the JSONObject.toString() method on trunk, and have deployed a new 
0.36-SNAPSHOT version.

Could you please try it and give me some feedback so I could close this issue ? 
Thanks :)

Original comment by gael.laz...@gmail.com on 31 Jan 2012 at 6:52

GoogleCodeExporter commented 9 years ago
Thanks for the fix.

I'm terribly sorry to not replying earlier, I was way too busy.

I accidentally found the download link at:
http://code.google.com/p/gwt-test-utils/issues/detail?id=74

So I took the latest available jar file 
(gwt-test-utils-0.36-20120205.120430-11.jar) from 
http://forge.octo.com/nexus/content/repositories/snapshots/com/octo/gwt/test/gwt
-test-utils/0.36-SNAPSHOT/ and tested this problem.

Just for the record, I needed to add jackson-core-asl-1.9.4.jar to the build 
path (downloaded from http://jackson.codehaus.org/).

Now there are other problems than the originally reported problem.

Add the following code to GwtTestSample.java:

    @SuppressWarnings("deprecation")
    protected static String rowToJson(String[] ro) {
        String rowId = "0";
        JSONObject jo = new JSONObject();
        JSONArray jsonArr = new JSONArray();
        JSONValue v=null;
        for(int i=0; i < ro.length; i++) {
            if (ro[i] != null) {
                if (ro[i].startsWith("{")) {
                    // expected to contain JSON Object
                    v = JSONParser.parse(ro[i]).isObject();
                } else {
                    v = new JSONString(ro[i]);
                }
            } else {
                System.out.println("### ro[" + i + "] is null!");
            }
            jsonArr.set(i, v);
        }
        jo.put("itemIndex", new JSONNumber(0));
        jo.put("rowData", jsonArr);
        jo.put("identifier", new JSONString(rowId));
        String jsonStr = jo.toString();
        return jsonStr;
    }

Add the following code e.g. at the beginning of OnModuleLoad():

    String[] rows = new String[2];
    rows[0] = "whatever";
    rows[1] = "{text:\"OK\",bgColor:\"ok\",fgColor:\"white\"}";

    String str = rowToJson(ro);
    System.out.println("rowToJson:");
    System.out.println(str);

Add the following to GwtTestSample.gwt.xml:

  <!-- Other module inherits                                      -->
  <inherits name="com.google.gwt.json.JSON" />

May need a clean build at this point.

Now, run or debug GwtTestSample as "Web Application" (as you debug GWT 
projects). In the Console output you will see:

rowToJson:
{"itemIndex":0, "rowData":["whatever",{"text":"OK", "bgColor":"ok", 
"fgColor":"white"}], "identifier":"0"}

Based on this we can create a new test in GwtTestSampleTest.java:

  @Test
  public void testJson() {
    String[] ro = new String[2];
    ro[0] = "whatever";
    ro[1] = "{text:\"OK\",bgColor:\"ok\",fgColor:\"white\"}";

    assertEquals("{\"itemIndex\":0, \"rowData\":[\"whatever\",{\"text\":\"OK\", \"bgColor\":\"ok\", \"fgColor\":\"white\"}], \"identifier\":\"0\"}",
            GwtTestSample.rowToJson(ro));
  }

Then do a Run As -> JUnit test on GwtTestSampleTest.java.
It fails, as rowToJson() running from unit test generates the following output 
(instead of the correct output above):
{itemIndex:0.0, rowData:[whatever,{text:OK, bgColor:ok, fgColor:white}], 
identifier:0}

Could you please the necessary changes so that this test would pass?

Original comment by vangel.a...@gmail.com on 11 Feb 2012 at 4:11

GoogleCodeExporter commented 9 years ago
Thank you very much for your feedback.

I just deploy a new 0.36-SNAPSHOT which should format JSONObject.toString() 
well.
I've also updated the list of thrid party dependencies to include jackson-core 
jar : http://code.google.com/p/gwt-test-utils/wiki/HowToUse#Without_Maven

Could you give it another try ?

Original comment by gael.laz...@gmail.com on 12 Feb 2012 at 2:44

GoogleCodeExporter commented 9 years ago
Thanks for the fast turnaround and for the fix.
I tried with gwt-test-utils-0.36-20120213.140641-13.jar and I am happy to 
confirm that now it works correctly.

Original comment by vangel.a...@gmail.com on 14 Feb 2012 at 9:50

GoogleCodeExporter commented 9 years ago
Thx !

Original comment by gael.laz...@gmail.com on 14 Feb 2012 at 9:52