Problem running FlexUnit tests

Hi,

I have created a simple testcase but it fails to execute due to a security error.

Here is the output:

Adobe fdb (Flash Player Debugger) [build 4852]
Copyright (c) 2004-2007 Adobe, Inc. All rights reserved.
Attempting to launch and connect to Player using URL
/home/christophe/IdeaProjects/as3commons/out/production/A/A-flexunit.swf
Player connected; session starting.
[SWF] home/christophe/IdeaProjects/as3commons/out/production/A/A-flexunit.swf - 732,415 bytes after decompression
[trace] Warning: Timeout on xmlsocket://localhost:7832 (at 3 seconds) while waiting for socket policy file.  This should not cause any problems, but see http://www.adobe.com/go/strict_policy_files for an explanation.
[trace] *** Security Sandbox Violation ***
[trace] Connection to localhost:7832 halted - not permitted from file:///home/christophe/IdeaProjects/as3commons/out/production/A/A-flexunit.swf
[trace] Error: Request for resource at xmlsocket://localhost:7832 by requestor from file:///home/christophe/IdeaProjects/as3commons/out/production/A/A-flexunit.swf is denied due to lack of policy file permissions.
[UnloadSWF] home/christophe/IdeaProjects/as3commons/out/production/A/A-flexunit.swf


I tried adding the location of the testsuite swf in the Global Security Settings panel but that does not seem to help. Does anyone know how to fix this?

regards,
Christophe

10 comments
Comment actions Permalink

Hello Christophe,

I got bit by this myself. When compiling your code for tests, you need to set the flex compiler setting "use-network" to false.

From Page 20 (pdf page 26) of the "Adobe Flex 3 - Building And Deploying Adobe Flex 3 Applications":

A SWF file can access one type of external asset: local or over a network; the SWF file cannot access both types.
You determine the type of access allowed by the SWF file by using the use-network flag when you compile your
application. When you set the use-network flag to false, you can access assets in the local file system, but not
over the network. The default value is true, which lets you access assets over the network, but not in the local file
system.
For more information on the use-network flag, see “Using the Flex Compilers” on page 125. For more information
on embedding application assets, see “Embedding Assets” on page 965 in the Adobe Flex 3 Developer
Guide.



You can set this etither in a custom flex compiler config file:

<flex-config>
  <compiler>
     . . .
     <use-network>false</use-network>
     . . .
  </compiler>
</flex-config>

or in IDEA's Flex compiling settings for your Flex module or facet, add  -use-network=false  to the "Additional compiler options" field.

See the above mentioned reference and
http://blogs.adobe.com/flexdoc/2008/06/the_security_sandbox_in_flex_b.html for more info.

Regards,
Mark

0
Comment actions Permalink

Hi Mark,

thanks for your answer. I tried it but it does not seem to work.

I'm trying the FlexUnit support of 9.0M1 and the additional compiler arguments of the Flex module do not seem be copied to the unit test configuration. I also tried adding the setting manually to the generated flex unit mxmlc config, but the settings get overwritten with a clean config when I execute a debug on the tests.

Any idea?

regards,
Christophe

0
Comment actions Permalink

You may want to upgrade to the latest Maia (i.e. IDEA 9) EAP. FlexUnit coverage is new in IDEA 9 and is evolving rapidly. The release notes for the latest build (10597) lists a couple of FlexUnit specific fixes:

[IDEADEV-38278] - Flex Unit: if custom flex compiler config file is used in facet configuration, the settings from it are not considered by created flexunit config
[IDEADEV-38475] - FlexUnit: incorrect launcher file is generated for 'test' package

You might be running into either of those. And there were some other FlexUnit (and Flex) fixes I think in the builds between M1 and 10597.

If you are not aware, you can follow when new EAPs are released in the Announcements (EAP) forum.

Regards,
Mark

0
Comment actions Permalink

Thanks for the info, I'll try the latest build.

0
Comment actions Permalink

p.s. Obviously using EAP (Early Access Program) software has some risk involved since it is basically alpha level software. But given the newness of FlexUnit, you don't have much of a choice. And I have almost always run the latest EAP builds of IDEA for the last 4 or 5 years, and rarely have issues. JetBrains EAP releases are as good as some companies production releases. Occasionally a release has some issues that makes it unusable for my particular needs or current work. In which case I roll back to the previous one until the next one. But that's rare.

0
Comment actions Permalink

Yeah I can live with that since Flex support is still improving with each build apparently. The problem seems to be fixed in the latest build, which is great.

I'm new to IntelliJ (been using Eclipse and Flex/Flash Builder before) and I'm already starting to like it. Great IDE!

0
Comment actions Permalink

Hello Christophe, Mark,
Current version of IDEA FlexUnit test runner connects to IDEA application using sockets. Starting from version 10, Adobe Flash player requires socket policy file to be available at server side before it makes a connection (see http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security.html).

Support for policy files is implemented in Maia since EAP build 10558.

Also, to allow test application make a socket connection to IDEA, you need to compile it for local-with-networking sandbox using by setting the ‘use-network’ flag to true (see references above).

If you need to access local files in your tests (so test app needs both network and local access), you have to register your test swf file as trusted (see http://livedocs.adobe.com/flex/3/html/help.html?content=05B_Security_03.html). Doing this also prevents Flash player 10 from checking socket policy file (at least on my Windows environment).
Thanks and regards,
Kirill

PS Mark, did you really get your non-trusted test application running with use-network=false? What build do you use?

0
Comment actions Permalink

Hello Kirill,

Very interesting... to answer your question "did [I] really get [my] non-trusted test application running with use-network=false", I thought I had, but I now learned that I did not. D'Oh! Due to an almost unworldly set of coincidence and timing , I was under a false impression and therefore I led poor Christophe astray. Sorry Christophe.   Here's what happened...

A little bit ago when I first tried to use FlexUnit -- both using IDEA and via the Maven & the flexmojos-maven-plugin -- I was having one issue after another. Some of it just learning curve of developing in a new technology, some of it due to bugs in the beta versions of FlexUnit 4, the flexmojos-maven-plugin, and IDEA. And I was kind of bouncing back and forth between trying to get this to work in IDEA and via Maven. At one point I tired a workaround to fix one issue I was having. Doing that however resulted in a security error due to trying to access a local file. (As I look through my notes now, I see that it was a different error than what Christophe posted.) When I did some Googling back then, I found a note about setting use-network to false. When I did such, that security error disappeared, but I was still having some issues running the tests.I gave up on it until the next day.


I was also having a side issue with IDEA adding a flex facet to my flex module and then complaining it could not load it. (See IDEADEV-38791). To (temporarily) resolve that problem Alexander (the JetBrains developer working on the issue) recommended I recreate the module as a Java module with a flex facet. Well, breaking the golden rule of not changing two things at the same time, I did that when I installed the latest IDEA EAP (10597). When I started IDEA, I was able to run FlexUnit tests in IDEA. What I didn't realize until you just asked your question what that when I created the new module, I apparently  did not copy that -use-network=false over to the Flex compiler settings for the new IDEA module. In my mind, I still had that set. But in reality, I did not. So it must have been the bug fixes I mentioned above that resolved the final issue I was having, and because I had unintentionally removed the -use-network=false setting I did not run into the socket security problem.

Any way, all in all, I am a bit embarrased to have directed Christophe in the wrong direction and am very appreciative of your updating the thread with correct information.

Thanks and Best Regards,
Mark

0
Comment actions Permalink

Hello Mark,

Thanks a lot for clearing the things out! I'm quite glad that now everyone has a consistent understanding on the issue.

Regards,
  Kirill

0
Comment actions Permalink

Is there any detailed instructions on how to get FlexUnit4 working in IDEA 10?

I looked at this http://www.jetbrains.com/idea/webhelp/unit-testing-support.html
but really doesn't tell me what exactly to do to get up and running, adobes flex unit page is confusing at best.

0

Please sign in to leave a comment.