0 Replies Latest reply on Dec 6, 2011 7:47 AM by clem_c_rok

    Flexunit + Parsley - re-creating error: "Object of type is already managed"



         This may sound a bit strange but I'm trying to force an "Object of type is already managed" error to recreate a bug we had in our app for

         flexunit testing purposes.   The problem arised when we upgraded to FB 4.5 and had a double parsley configuration in a popup launched from a module.

         Here's my flexunit test:





      public function testReportsPrintDialog1():void


                rpDialog = new ReportsPrintDialog();


                //attempting to forcibly re-create the project-70 bug:

                //"Object of type reportsDirectoryModule.views::ReportsPrintDialog is already managed"




                trace("rpDialog: " + GlobalState.objects.isManaged(rpDialog));

                trace("reportsDirectoryBase: " + GlobalState.objects.isManaged(reportsDirectoryBase));


                rpDialog.addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete, false, 0, true);

                PopUpManager.addPopUp(rpDialog, DisplayObject(FlexGlobals.topLevelApplication));





      Unfortunatly, my attempts at 'forcing' the extra parsley object managment by using addViewRoot is not reproducing the error.



      In my test suite I am setting up my main and module scoped parsley context in the next code snippit and it has

      been working very well for other tests so far. Here's the context setup code:




      import reportsDirectoryModule.parsleyConfig.ParsleyConfig;

      public var context:Context;

      public var childContext:Context;



      //create base TDMSE parsley context

      this.context = ContextBuilder.newBuilder()






      this.childContext = ContextBuilder











      The ReportsPrintDialog actually inherits from a base popup class called ReportsDirectoryBase which has this parsley declaration:


      <s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"







                          <parsley:ContextBuilder id="childContext"

                                    parents="{app.module.getContext()}" domain="{app.applicationDomain}"/>

                          <parsley:Configure />




                                    import mx.core.FlexGlobals;


                                    private static var app:Object = FlexGlobals.topLevelApplication;




      And the 'Object of type is already managed' exception was because ReportsPrintDialog had the following Configure declaration:




      <rdv:ReportsDirectoryBase xmlns:fx="http://ns.adobe.com/mxml/2009"






                                              title="Print Reports Confirmation"












      I know this is a bit strange, but if nothing else, I'm chalking it down as a good flexunit/parsley learning experience.




      Eric H