<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Using Stubs for HTTPService and RemoteObject in Flex</title>
	<atom:link href="http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/</link>
	<description>eat, program, and be merry</description>
	<lastBuildDate>Tue, 23 Feb 2010 05:56:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Link Dump: 022210_1928</title>
		<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/comment-page-1/#comment-23091</link>
		<dc:creator>Link Dump: 022210_1928</dc:creator>
		<pubDate>Tue, 23 Feb 2010 05:56:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.brianlegros.com/blog/?p=401#comment-23091</guid>
		<description>[...] cookies and code &#187; Blog Archive &#187; Using Stubs for HTTPService and RemoteObject in Flex &#8211; [...]</description>
		<content:encoded><![CDATA[<p>[...] cookies and code &raquo; Blog Archive &raquo; Using Stubs for HTTPService and RemoteObject in Flex &#8211; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian LeGros</title>
		<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/comment-page-1/#comment-19500</link>
		<dc:creator>Brian LeGros</dc:creator>
		<pubDate>Tue, 08 Dec 2009 16:29:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.brianlegros.com/blog/?p=401#comment-19500</guid>
		<description>@Bhuvana - Couple of more suggestions that I overlooked from your comment.  Currently, clearSession() isn&#039;t testable, since it creates its own HTTPService class.  You may want to pass the httpService into the clearSession() method so that you can inject the HTTPServiceStub for testing.  Use the example in this blog post as a guideline, substituting ClassWithHTTPServiceDependency for your clearSession() function.  If you would like to learn more about FlexUnit4 and how to write unit tests you can check out http://opensource.adobe.com/wiki/display/flexunit/FlexUnit+4+feature+overview and http://opensource.adobe.com/wiki/display/flexunit/Developer+Documentation.</description>
		<content:encoded><![CDATA[<p>@Bhuvana &#8211; Couple of more suggestions that I overlooked from your comment.  Currently, clearSession() isn&#8217;t testable, since it creates its own HTTPService class.  You may want to pass the httpService into the clearSession() method so that you can inject the HTTPServiceStub for testing.  Use the example in this blog post as a guideline, substituting ClassWithHTTPServiceDependency for your clearSession() function.  If you would like to learn more about FlexUnit4 and how to write unit tests you can check out <a href="http://opensource.adobe.com/wiki/display/flexunit/FlexUnit+4+feature+overview" rel="nofollow">http://opensource.adobe.com/wiki/display/flexunit/FlexUnit+4+feature+overview</a> and <a href="http://opensource.adobe.com/wiki/display/flexunit/Developer+Documentation" rel="nofollow">http://opensource.adobe.com/wiki/display/flexunit/Developer+Documentation</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bhuvana</title>
		<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/comment-page-1/#comment-19486</link>
		<dc:creator>Bhuvana</dc:creator>
		<pubDate>Tue, 08 Dec 2009 11:54:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.brianlegros.com/blog/?p=401#comment-19486</guid>
		<description>Thank you very much for your immediate reply.
could you please write a sample code for that block of code.??
I am new to flex as well as flexunit.

Regards,
Bhuvana</description>
		<content:encoded><![CDATA[<p>Thank you very much for your immediate reply.<br />
could you please write a sample code for that block of code.??<br />
I am new to flex as well as flexunit.</p>
<p>Regards,<br />
Bhuvana</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian LeGros</title>
		<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/comment-page-1/#comment-19446</link>
		<dc:creator>Brian LeGros</dc:creator>
		<pubDate>Mon, 07 Dec 2009 14:09:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.brianlegros.com/blog/?p=401#comment-19446</guid>
		<description>@Bhuvana - Thanks for stopping by.  

Based on the example code above, I&#039;d suggest 2 integration tests using the HTTPServiceStub to test clearSession(); one for success and one for failure.  The [Before], or setUp(), for each should setup the stub just as you have at the begging of the clearSession() function, minus the event listeners.  Since you don&#039;t use any data from the event (from what I can tell from your example code), the success test should call result(null, null) on the stub instance which will generate a ResultEvent.  For failure, call fault(null, null, null, null) on the stub instance which will generate a FaultEvent.  

From there, for good practice, you should probably have another test that mocks out validateUser() and mainResult so that you know when clearSession() or its dependencies are broken.  There are good mocking frameworks out there.  I like mock-as3, but there is also mockito-flex, and asmock.  If you&#039;re not familiar with mock objects, check out http://mockobjects.com and http://martinfowler.com/articles/mocksArentStubs.html.

Best of luck.</description>
		<content:encoded><![CDATA[<p>@Bhuvana &#8211; Thanks for stopping by.  </p>
<p>Based on the example code above, I&#8217;d suggest 2 integration tests using the HTTPServiceStub to test clearSession(); one for success and one for failure.  The [Before], or setUp(), for each should setup the stub just as you have at the begging of the clearSession() function, minus the event listeners.  Since you don&#8217;t use any data from the event (from what I can tell from your example code), the success test should call result(null, null) on the stub instance which will generate a ResultEvent.  For failure, call fault(null, null, null, null) on the stub instance which will generate a FaultEvent.  </p>
<p>From there, for good practice, you should probably have another test that mocks out validateUser() and mainResult so that you know when clearSession() or its dependencies are broken.  There are good mocking frameworks out there.  I like mock-as3, but there is also mockito-flex, and asmock.  If you&#8217;re not familiar with mock objects, check out <a href="http://mockobjects.com" rel="nofollow">http://mockobjects.com</a> and <a href="http://martinfowler.com/articles/mocksArentStubs.html" rel="nofollow">http://martinfowler.com/articles/mocksArentStubs.html</a>.</p>
<p>Best of luck.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bhuvana</title>
		<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/comment-page-1/#comment-19444</link>
		<dc:creator>Bhuvana</dc:creator>
		<pubDate>Mon, 07 Dec 2009 13:13:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.brianlegros.com/blog/?p=401#comment-19444</guid>
		<description>Hi,
This blog entry is very useful for me….
I want to write test case for my application.
and my code is below.

var req :mainRequest = new mainRequest();

req.clearSession();

***************

public function clearSession():void
{

var _remoteHttp : HTTPService = new HTTPService();
_remoteHttp.url = ApplicationCommonModel.getInstance().serverContextUrl+’logout’;
_remoteHttp.method = “POST”;
_remoteHttp.resultFormat = “e4x”;

_remoteHttp.addEventListener(
ResultEvent.RESULT, function (event:ResultEvent):void{
validateUser(mainResult.getInstance()._loginParams);
} );
_remoteHttp.addEventListener(
FaultEvent.FAULT, function (event:FaultEvent):void{
validateUser(mainResult.getInstance()._loginParams);
} );
_remoteHttp.send();

}

could u please tel me how write test case for this block of code.?

Thanks &amp; Regards,
Bhuvana</description>
		<content:encoded><![CDATA[<p>Hi,<br />
This blog entry is very useful for me….<br />
I want to write test case for my application.<br />
and my code is below.</p>
<p>var req :mainRequest = new mainRequest();</p>
<p>req.clearSession();</p>
<p>***************</p>
<p>public function clearSession():void<br />
{</p>
<p>var _remoteHttp : HTTPService = new HTTPService();<br />
_remoteHttp.url = ApplicationCommonModel.getInstance().serverContextUrl+’logout’;<br />
_remoteHttp.method = “POST”;<br />
_remoteHttp.resultFormat = “e4x”;</p>
<p>_remoteHttp.addEventListener(<br />
ResultEvent.RESULT, function (event:ResultEvent):void{<br />
validateUser(mainResult.getInstance()._loginParams);<br />
} );<br />
_remoteHttp.addEventListener(<br />
FaultEvent.FAULT, function (event:FaultEvent):void{<br />
validateUser(mainResult.getInstance()._loginParams);<br />
} );<br />
_remoteHttp.send();</p>
<p>}</p>
<p>could u please tel me how write test case for this block of code.?</p>
<p>Thanks &amp; Regards,<br />
Bhuvana</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian LeGros</title>
		<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/comment-page-1/#comment-16972</link>
		<dc:creator>Brian LeGros</dc:creator>
		<pubDate>Sat, 24 Oct 2009 18:41:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.brianlegros.com/blog/?p=401#comment-16972</guid>
		<description>@Joel - Great catch.  I totally missed it; when the method completes it&#039;s going to be marked to be cleaned up and if the handler hasn&#039;t executed yet, it&#039;ll be cleaned up as well since I&#039;m using a weak reference.  I have updated the post to reflect your changes.  I&#039;m hoping to include these in mock-as3&#039;s latest rendition so we have a way to distribute them.  If you have any feedback on how they could be improved, please don&#039;t hesitate to let me know.

Thanks again for the help.  It&#039;s great to hear these have helped some people.</description>
		<content:encoded><![CDATA[<p>@Joel &#8211; Great catch.  I totally missed it; when the method completes it&#8217;s going to be marked to be cleaned up and if the handler hasn&#8217;t executed yet, it&#8217;ll be cleaned up as well since I&#8217;m using a weak reference.  I have updated the post to reflect your changes.  I&#8217;m hoping to include these in mock-as3&#8217;s latest rendition so we have a way to distribute them.  If you have any feedback on how they could be improved, please don&#8217;t hesitate to let me know.</p>
<p>Thanks again for the help.  It&#8217;s great to hear these have helped some people.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel Hooks</title>
		<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/comment-page-1/#comment-16970</link>
		<dc:creator>Joel Hooks</dc:creator>
		<pubDate>Sat, 24 Oct 2009 17:32:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.brianlegros.com/blog/?p=401#comment-16970</guid>
		<description>I&#039;ve been using this in a project, and found that the inline timer function with weak references fails unexpectedly on occasion. Moving this to a named function with strong reference has solved the issue. I thought perhaps it was the timing, but it would stall even with the timer value set fairly high (3000ms+).

here are the changes I&#039;ve made, it is much more reliablle for me now:

http://github.com/joelhooks/utilities-AsyncServiceStubs/commit/a317e3a1303d8b4508d34d1026525324ba617911#diff-2</description>
		<content:encoded><![CDATA[<p>I&#8217;ve been using this in a project, and found that the inline timer function with weak references fails unexpectedly on occasion. Moving this to a named function with strong reference has solved the issue. I thought perhaps it was the timing, but it would stall even with the timer value set fairly high (3000ms+).</p>
<p>here are the changes I&#8217;ve made, it is much more reliablle for me now:</p>
<p><a href="http://github.com/joelhooks/utilities-AsyncServiceStubs/commit/a317e3a1303d8b4508d34d1026525324ba617911#diff-2" rel="nofollow">http://github.com/joelhooks/utilities-AsyncServiceStubs/commit/a317e3a1303d8b4508d34d1026525324ba617911#diff-2</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Moore</title>
		<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/comment-page-1/#comment-11317</link>
		<dc:creator>Scott Moore</dc:creator>
		<pubDate>Mon, 08 Jun 2009 16:51:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.brianlegros.com/blog/?p=401#comment-11317</guid>
		<description>Brian,

Aha! Thanks for the quick reply.

Yeah, I probably should have read a bit closer, and noticed that you introduce the code samples with &quot;...in a test case written using fluint:&quot;

Thanks,
Scott</description>
		<content:encoded><![CDATA[<p>Brian,</p>
<p>Aha! Thanks for the quick reply.</p>
<p>Yeah, I probably should have read a bit closer, and noticed that you introduce the code samples with &#8220;&#8230;in a test case written using fluint:&#8221;</p>
<p>Thanks,<br />
Scott</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian LeGros</title>
		<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/comment-page-1/#comment-11266</link>
		<dc:creator>Brian LeGros</dc:creator>
		<pubDate>Sat, 06 Jun 2009 13:28:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.brianlegros.com/blog/?p=401#comment-11266</guid>
		<description>@Scott - Thanks for stopping by. The examples using the stubs are written using Fluint 1.x; I&#039;m unsure of the synax that would be required for FlexUnit.  Fluint has traditionally had better support for async testing that FlexUnit from what I&#039;ve heard, but the Fluint team has joined forced with the FlexUnit team to make FlexUnit 4 which has some great features including Fluint&#039;s async testing support. It&#039;s currently in beta, but worth using IMO.  Hope this helps; glad to hear the stubs are working out.</description>
		<content:encoded><![CDATA[<p>@Scott &#8211; Thanks for stopping by. The examples using the stubs are written using Fluint 1.x; I&#8217;m unsure of the synax that would be required for FlexUnit.  Fluint has traditionally had better support for async testing that FlexUnit from what I&#8217;ve heard, but the Fluint team has joined forced with the FlexUnit team to make FlexUnit 4 which has some great features including Fluint&#8217;s async testing support. It&#8217;s currently in beta, but worth using IMO.  Hope this helps; glad to hear the stubs are working out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Moore</title>
		<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/comment-page-1/#comment-11256</link>
		<dc:creator>Scott Moore</dc:creator>
		<pubDate>Fri, 05 Jun 2009 21:24:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.brianlegros.com/blog/?p=401#comment-11256</guid>
		<description>Brian,

Thanks for posting the code! I&#039;m working through setting up some unit tests for a Flex app that uses HTTPService and the HTTPServiceStub has provided useful guidance.

Question: in your example, you use a method, asyncHandler() that I&#039;m presuming is on FlexUnit&#039;s TestCase object. However, I don&#039;t see this method on TestCase in the current FlexUnit SWC I&#039;m using (version unknown--someone on my team pulled it down a long time ago, never recorded the version), nor do I see it in FlexUnit 0.9 available at http://opensource.adobe.com/wiki/display/flexunit/Downloads .

What would you recommend? I do see some classes in FlexUnit 0.9 related to async tests--perhaps theres something there I should use instead of asyncHandler()?

Thanks,
Scott</description>
		<content:encoded><![CDATA[<p>Brian,</p>
<p>Thanks for posting the code! I&#8217;m working through setting up some unit tests for a Flex app that uses HTTPService and the HTTPServiceStub has provided useful guidance.</p>
<p>Question: in your example, you use a method, asyncHandler() that I&#8217;m presuming is on FlexUnit&#8217;s TestCase object. However, I don&#8217;t see this method on TestCase in the current FlexUnit SWC I&#8217;m using (version unknown&#8211;someone on my team pulled it down a long time ago, never recorded the version), nor do I see it in FlexUnit 0.9 available at <a href="http://opensource.adobe.com/wiki/display/flexunit/Downloads" rel="nofollow">http://opensource.adobe.com/wiki/display/flexunit/Downloads</a> .</p>
<p>What would you recommend? I do see some classes in FlexUnit 0.9 related to async tests&#8211;perhaps theres something there I should use instead of asyncHandler()?</p>
<p>Thanks,<br />
Scott</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.266 seconds -->
