这里有人使用 GWT SyncProxy 吗?
我尝试测试一个异步rpc,但是onFailure和onSuccess下的代码没有测试。不幸的是,没有错误日志,但也许有人可以帮助我。该示例来自此页面:http ://code.google.com/p/gwt-syncproxy/
编辑:
我希望测试失败。所以我添加了'assertNull(result);'。奇怪的是控制台给出的结果首先是“异步好”,然后是“异步坏”。所以函数运行了两次?!Junit 给出了绿色的结果。
public class Greeet extends TestCase {
@Test
public void testGreetingServiceAsync() throws Exception {
GreetingServiceAsync rpcServiceAsync = (GreetingServiceAsync) SyncProxy.newProxyInstance(
GreetingServiceAsync.class,
"http://127.0.0.1:8888/greettest/", "greet");
rpcServiceAsync.greetServer("SyncProxy", new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
System.out.println("Async bad " );
}
public void onSuccess(String result) {
System.out.println("Async good " );
assertNull(result);
}
});
Thread.sleep(100); // configure a sleep time similar to the time spend by the request
}
}