GWT を使用して RPC テストを取得しようとしています。ここに記載されているデフォルトの StockWatcher プロジェクトを使用しています。プロジェクトをダウンロードしてインポートすると、すべて正常に動作します。
次に、StockWatcher プロジェクトで junitcreator を実行します。
/Users/stephen/Work/gwt/gwt-mac-1.6.4/junitCreator -junit /Users/stephen/Applications/eclipse/plugins/org.junit_3.8.2.v20080602-1318/junit.jar -module stockwatcher -eclipse StockWatcher com.google.gwt.sample.stockwatcher.StockWatcherTest
これにより、適切なテスト ディレクトリに StockWatcherTest.java が作成され、いくつかのホストされた Web モードの起動ファイルが提供されます。
次に、junit.jar をこのプロジェクトのクラスパスに追加しました。
次に、StockWatcherTest.java を変更して、サーバーに対して非同期要求を行うことができるかどうかをテストします。すべて問題ないように見えますが、ホスト モードで StockWatcherTest.java を実行しようとすると、次のエラーが発生します。
ポート 0 HTTP で HTTP を開始しています
ポート 49569 で待機中
開発シェル サーブレットは、モジュール 'com.google.gwt.sample.stockwatcher.StockWatcher.JUnit.gwt.xml' で 'greet' のリクエストを受け取りました [警告] リソースが見つかりません: 挨拶; (パブリック パスにファイルがないか、モジュール com.google.gwt.sample.stockwatcher.StockWatcher.JUnit.gwt.xml でタグが誤って構成されている可能性がありますか?) com.google.gwt.user.client.rpc.StatusCodeException: できませんモジュール「com.google.gwt.sample.stockwatcher.StockWatcher.JUnit」のパブリックパスでリソース「greet」を見つけます
ここに私の StockWatcherTest.java クラスがあります
package com.google.gwt.sample.stockwatcher.client;
import com.google.gwt.core.client.GWT;
import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* GWT JUnit tests must extend GWTTestCase.
*/
public class StockWatcherTest extends GWTTestCase {
/**
* Must refer to a valid module that sources this class.
*/
public String getModuleName() {
return "com.google.gwt.sample.stockwatcher.StockWatcher";
}
/**
* Add as many tests as you like.
*/
public void testSimple() {
GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
greetingService.greetServer("Bob",
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
// Show the RPC error message to the user
System.out.println(caught);
fail("big time failure");
finishTest();
}
public void onSuccess(String result) {
System.out.println("success, biatch");
assertTrue(true);
}
});
delayTestFinish(1000);
}
}
com/google/gwt/sample/stockwatcher/StockWatcher.gwt.xml はこちら
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.6.2//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.6.2/distro-source/core/src/gwt-module.dtd">
<module rename-to='stockwatcher'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='com.google.gwt.sample.stockwatcher.client.StockWatcher'/>
</module>
そして、ここに私の生成された戦争の web.xml があります
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>StockWatcher.html</welcome-file>
</welcome-file-list>
<!-- Servlets -->
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>com.google.gwt.sample.stockwatcher.server.GreetingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/stockwatcher/greet</url-pattern>
</servlet-mapping>
</web-app>
それで、私は何を間違っていますか?どんな助けでも大歓迎です。ありがとうございました。