Maven Flexmojosプラグインを使用して、Jetty / Java / Spring Security/BlazeDSバックエンドに対してコマンドラインでいくつかのFlexUnit4統合テストを実行しています。これらの統合テストは、スタンドアロンバージョンのFlashPlayerで実行されます。これらのテストの1つは、次のようにいくつかの異なるログインシナリオを試みます。
[Test(async)]
public function userLogin_badCredentials_FailedLogin():void {
var username:String = "guest";
var password:String = "not_the_right_password";
var token:AsyncToken = authenticationService.userLogin(username, password);
token.addResponder(Async.asyncResponder(this, new TestResponder(handleRemoteObjectNoExpectedResult, handleRemoteObjectExpectedFaultBadCredentials), TIMEOUT, username, handleTestTimeout));
}
[Test(async)]
public function userLoginLogout_UserLoggedIn_SuccessfulLoginLogout():void {
var username:String = "admin";
var password:String = "admin";
var token:AsyncToken = authenticationService.userLogin(username, password);;
token.addResponder(Async.asyncResponder(this, new TestResponder(userLoginLogout2_UserLoggedIn_SuccessfulLoginLogout, handleUnexpectedFault), TIMEOUT, username, handleTestTimeout));
}
public function userLoginLogout2_UserLoggedIn_SuccessfulLoginLogout(event:ResultEvent, passThroughData:Object):void {
// Must have logged in correctly
assertTrue(serviceManager.channelSet.authenticated);
// Now lets test logout
var token:AsyncToken = authenticationService.userLogout();
token.addResponder(Async.asyncResponder(this, new TestResponder(handleExpectedResult, handleUnexpectedFault), TIMEOUT, null, handleTestTimeout));
}
これらのテストのいずれかが単独で100%合格しますが、両方を次々に実行すると、断続的に(約75%の確率で)エラーが発生します。
Channel.Ping.Failed error Detected duplicate HTTP-based FlexSessions, generally
due to the remote host disabling session cookies. Session cookies must be enabled
to manage the client connection correctly.
これは、ログイン/ログアウトを2回試みた場合にも発生します。すべてのログインおよびログアウトメソッドは、AMFChannelSetを使用しているChannelSet.loginおよびChannelSet.logoutに基づいています。
更新:問題の原因を見つけたと思います。スタンドアロンプレーヤーはCookieを使用しないため、BlazeDSバックエンドを混乱させます。ここを参照してください: http ://www.webappsolution.com/wordpress/2009/11/25/flexunit-4-testing-services-in-flash-player-issue/