我使用Maven的的Flexmojos插件进行针对码头/的Java / Spring Security的命令行上一些FlexUnit4中集成测试/ BlazeDS的后端。这些集成测试在Flash播放器的单机版本上运行。一个这些试验尝试了几个不同的登录场景如下:

    [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.

如果我尝试登录/注销两次也会出现这种情况。所有登录和注销方法是基于ChannelSet.login和ChannelSet.logout这些都使得使用AMFChannelSet的。

<强>更新我相信我发现这个问题的根源。独立播放器不使用的cookies,因此是混淆BlazeDS的后端。在这里看到: HTTP ://www.webappsolution.com/wordpress/2009/11/25/flexunit-4-testing-services-in-flash-player-issue/

有帮助吗?

解决方案

这个问题的间歇性,导致我猜测,竞争条件发生了什么。使用查尔斯代理协议调试工具,我能够看到AMF请求/响应消息。我不是(现在仍然我不是)确定,但我最好的猜测是,该服务器有机会完全禁用前面FlexSession前第二次登录尝试发生了什么。

因此在登录尝试之间的“买时间”我分开的测试方法为不同的测试类和中提琴...这一切只是工作。

也许后测睡眠/延迟也会做的伎俩,但我无法找到一个ActionScript睡眠功能。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top