Fluint with Swiz, having trouble

2 views
Skip to first unread message

odoe

unread,
Oct 25, 2009, 12:28:39 PM10/25/09
to Fluint Discussions
Hello, I am having trouble figuring out how to utilize Fluint with a
Swiz framework application. I am just trying to test a Controller.
It seems logical to me that if I am loading beans in override setUp
and have the Controller Autowired in my declarations, there should be
no need to do myController = new Controller()
Am I wrong in that assumption?
Even when I do declare a new Controller, all the controller properties
are null, such as an ArrayCollection in the Controller that is
Autowired in that Controller.
I guess that would be a form of integration testing, if my Controller
pulls from an Autowire value, but then I tried testing the single
ArrayCollection and still no luck.

Here is my ArrayCollection, which is added to my Beans.

package model
{
import mx.collections.ArrayCollection;

import org.swizframework.factory.IInitializingBean;

public class LayerModel implements IInitializingBean
{
[Bindable]
public var layers : ArrayCollection;

public function LayerModel()
{
trace( "start MapModel" );
layers = new ArrayCollection();
layers.addItem( "MockValue1" );
layers.addItem( "MockValue2" );
trace( "end MapModel");
}
public function initialize():void
{
}
}

Here is my attempted test
package tests
{
import model.LayerModel;
import mx.events.CollectionEvent;
import net.digitalprimates.fluint.sequence.SequenceRunner;
import net.digitalprimates.fluint.sequence.SequenceWaiter;
import net.digitalprimates.fluint.tests.TestCase;

import org.swizframework.Swiz;

public class TestLayerModel extends TestCase
{
[Autowire( bean="layerModel" )]
[Bindable]
public var layerModel : LayerModel;
public function TestLayerModel()
{
super();
}
override protected function setUp():void {
try {
Swiz.loadBeans( [Beans] );
}
catch( e : Error ) {
trace( e, "Test error in set up" );
}
}

[Test( Description='Test if the layerModel is null' )]
public function testLayerController() : void {
try {
assertNotNull( layerModel );
if( layerModel ) {
trace( "try sequence" );
var sequence : SequenceRunner = new SequenceRunner( this );
trace( "sequence add waiter" );
sequence.addStep( new SequenceWaiter( layerModel.layers,
CollectionEvent.COLLECTION_CHANGE, 5000 ) );
trace( "sequence add handler" );
sequence.addAssertHandler( checkLayers, null );
trace( "sequence run" );
sequence.run();
// It get this far and passes, but trace shows a null error
}
else {
trace( "layers are still null" );
assertNotNull( layerModel.layers );
}
}
catch( e : Error ) {
trace( e, "errors suck" );
assertNotNull( layerModel );
}

}
private function checkLayers( event : Event ) : void {
trace( "check layerMode.layers" );
assertNotNull( layerModel.layers );
}
}
}
}

The first timer I check, layerModels is null, although before the Test
begins in my trace, I can see it being created. I have a feeling there
might be an EventListener I need to add in setUp, but I can't add it
to layerModel.layers, because it's still null and errors out. If I add

layerModel = new layerModel() in setUp or the Test function,
layerModel.layers is still null.

I know I must be missing something very simple, but I have yet to find
a specific example of using Fluint in a Swiz framework, although I see
it mentioned quite a bit how much they should compliment each other.

Thanks very much for any insight.

odoe

unread,
Oct 31, 2009, 1:12:08 AM10/31/09
to Fluint Discussions
Figured this out.
Had to manually Autowire the test class in the setUp method
Swiz.autowire( this );
Reply all
Reply to author
Forward
0 new messages