运行 Flexunit 测试时出现 BlazeDS 错误:检测到重复的基于 HTTP 的 FlexSession

发布于 2024-09-29 05:37:28 字数 2292 浏览 2 评论 0原文

我正在使用 Maven Flexmojos 插件在命令行上针对 Jetty/Java/Spring Security/BlazeDS 后端运行一些 FlexUnit4 集成测试。这些集成测试在独立版本的 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.

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

更新:我相信我找到了问题的根源。独立播放器不使用 cookie,因此会混淆 BlazeDS 后端。请参阅此处:http ://www.webappsolution.com/wordpress/2009/11/25/flexunit-4-testing-services-in-flash-player-issue/

I am using the Maven Flexmojos plug-in to run some FlexUnit4 integration tests on the command line against a Jetty/Java/Spring Security/BlazeDS backend. These integration tests run in a stand-alone version of the flash player. One of these tests attempts a few different login scenarios as follows:

    [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));
    }

Either one of these tests pass 100% by itself, but running them both one after each other I am intermittently (about 75% of the time) getting an error:

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.

This also happens if I try to login/logout twice. All login and logout methods are based on a ChannelSet.login and ChannelSet.logout which are making use of an AMFChannelSet.

Update: I believe I found the source of the problem. The standalone player does not make use of cookies and therefore is confusing the BlazeDS backend. See here: http://www.webappsolution.com/wordpress/2009/11/25/flexunit-4-testing-services-in-flash-player-issue/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随心而道 2024-10-06 05:37:28

该问题的间歇性使我猜测正在发生竞争条件。使用 Charles 代理协议调试实用程序,我能够看到 AMF 请求/响应消息。我不确定(现在仍然不确定),但我最好的猜测是,第二次登录尝试发生在服务器有机会完全禁用前一个 FlexSession 之前。

因此,为了在登录尝试之间“争取时间”,我将测试方法分为不同的测试类和中提琴......一切都正常。

也许测试后睡眠/延迟也能达到目的,但我找不到 ActionScript 睡眠功能。

The intermittent nature of the problem, led me to guess that a race condition was happening. Using the Charles proxy protocol debugging utility, I was able to see the AMF request/response messages. I was not (and still am not) sure, but my best guess was that the second login attempt was happening before the server had the chance to completely disable the previous FlexSession.

So to "buy time" in between login attempts I separated the test methods into different test classes and viola...it all Just Worked.

Perhaps a post-test sleep/delay would also have done the trick, but I couldn't find an ActionScript sleep function.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文