I'm having problems setting up a JUnit test using JSON objects.
Here's my test case :
----------
package cern.ppt.ram.gwt.client;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.junit.client.GWTTestCase;
public class TestJsonSetup extends GWTTestCase {
protected void setUp() throws Exception {
// Moving this line to testJsonObjectCreation : the test
will work fine
// Here, it produces an exception
JSONObject json = new JSONObject();
}
public void testJsonObjectCreation() {
}
(...)
}
-----------
It produces the following stack trace - of course, if I move the
offending line to a test method, it works fine.
java.lang.UnsatisfiedLinkError: createBlankObject
at com.google.gwt.json.client.JSONObject.createBlankObject(Native
Method)
at com.google.gwt.json.client.JSONObject.<init>(JSONObject.java:157)
(...)
What am I missing ? is it possible to set up test JSON objects in the
setUp() method at all ?
Thanks,
Brice
I do not use JUnit but I have exactly the same problem with this object
method:
public JSONObject jsonGet(){
JSONObject jsonObject = new JSONObject(); // problem here
jsonObject.put("iUserId", new JSONNumber(this.iUserId));
...
return jsonObject;
}
I can not create jsonObject...
Thanks for all,
Geoffrey
> ------=_Part_63996_20390647.1161013942161
> Content-Type: text/html; charset=ISO-8859-1
> X-Google-AttachSize: 2235
>
> Hi Brice,<br><br>There are currently some limitations in the way setUp and tearDown work in GWTTestCase. The way we interact with jUnit under the hood makes it impossible to instantiate any client classes during setUp and tearDown.
> <br><br>/kel<br><br><div><span class="gmail_quote">On 10/16/06, <b class="gmail_sendername">Brice</b> <<a href="mailto:brice...@gmail.com">brice...@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> <br>Hello,<br><br>I'm having problems setting up a JUnit test using JSON objects.<br><br>Here's my test case :<br><br>----------<br>package cern.ppt.ram.gwt.client;<br>import com.google.gwt.json.client.JSONObject;<br>import
> com.google.gwt.junit.client.GWTTestCase;<br><br>public class TestJsonSetup extends GWTTestCase {<br> protected void setUp() throws Exception {<br> // Moving this line to testJsonObjectCreation : the test
> <br>will work fine<br> // Here, it produces an exception<br> JSONObject json = new JSONObject();<br> }<br> public void testJsonObjectCreation() {<br> }<br> (...)<br>}<br>
> -----------<br><br>It produces the following stack trace - of course, if I move the<br>offending line to a test method, it works fine.<br><br>java.lang.UnsatisfiedLinkError: createBlankObject<br> at com.google.gwt.json.client.JSONObject.createBlankObject
> (Native<br>Method)<br> at com.google.gwt.json.client.JSONObject.<init>(JSONObject.java:157)<br>(...)<br><br>What am I missing ? is it possible to set up test JSON objects in the<br>setUp() method at all ?<br>
> <br>Thanks,<br><br>Brice<br><br><br></blockquote></div><br>
>
> ------=_Part_63996_20390647.1161013942161--
import com.google.gwt.json.client.JSONNumber;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
...
public class UserIDcard {
private Integer iUserId;
...
public JSONObject jsonGet(){
JSONObject jsonObject= new JSONObject(); // problem
here (line 84)
jsonObject.put("iUserId", new JSONNumber(this.iUserId));
...
return jsonObject;
}
}
-------------------
When process try "JSONObject jsonObject= new JSONObject();", I receive
this error message
[WARN] StandardContext[]Exception while dispatching incoming RPC call
java.lang.UnsatisfiedLinkError: createBlankObject
at com.google.gwt.json.client.JSONObject.<init>(JSONObject.java:157)
at server.UserIDcard.jsonGet(UserIDcard.java:84)
.....
------------------
I hope it is more descriptive,
Thanks for your patience,
Geoffrey
Thanks for help,
Geoffrey