<?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>Fri, 28 Oct 2011 00:48:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: admin</title>
		<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/comment-page-1/#comment-47060</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sun, 10 Apr 2011 01:02:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.brianlegros.com/blog/?p=401#comment-47060</guid>
		<description>@Maurice - Thanks for feedback.  If you send me a github pull request, I&#039;ll work to get the code into the library and release a new version.  Great find.  If you&#039;re interested in helping to produce any other RPC stubs, please let me know; I can always use the help :)</description>
		<content:encoded><![CDATA[<p>@Maurice &#8211; Thanks for feedback.  If you send me a github pull request, I&#8217;ll work to get the code into the library and release a new version.  Great find.  If you&#8217;re interested in helping to produce any other RPC stubs, please let me know; I can always use the help <img src='http://www.brianlegros.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maurice</title>
		<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/comment-page-1/#comment-46862</link>
		<dc:creator>Maurice</dc:creator>
		<pubDate>Thu, 07 Apr 2011 16:39:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.brianlegros.com/blog/?p=401#comment-46862</guid>
		<description>Sorry, the correct code is the following:

var message:RemotingMessage = new RemotingMessage();
message.operation = name;
message.body = args;
token = new AsyncToken(message);</description>
		<content:encoded><![CDATA[<p>Sorry, the correct code is the following:</p>
<p>var message:RemotingMessage = new RemotingMessage();<br />
message.operation = name;<br />
message.body = args;<br />
token = new AsyncToken(message);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maurice</title>
		<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/comment-page-1/#comment-46861</link>
		<dc:creator>Maurice</dc:creator>
		<pubDate>Thu, 07 Apr 2011 16:33:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.brianlegros.com/blog/?p=401#comment-46861</guid>
		<description>Hi, thanks for the RemoteObjectStub. very simple to use.
I found however than the AsyncToken returned by the operation call was too simple
 [ line 90  token = new AsyncToken(null);].
sometimes, the client code will need to access the message and messageId inside the token, for example to recognize calls, to cancel calls  or to display trace/debug messages. 
I thought that you could add the RemoteMessage() to the token, something like:
(copied from  mx.rpc.remoting.Operation.as 
var message:RemotingMessage = new RemotingMessage();
    message.operation = name;
    message.body = args;
    message.source = RemoteObject(service).source;
    token.setMessage(message);

Regards,
Maurice</description>
		<content:encoded><![CDATA[<p>Hi, thanks for the RemoteObjectStub. very simple to use.<br />
I found however than the AsyncToken returned by the operation call was too simple<br />
 [ line 90  token = new AsyncToken(null);].<br />
sometimes, the client code will need to access the message and messageId inside the token, for example to recognize calls, to cancel calls  or to display trace/debug messages.<br />
I thought that you could add the RemoteMessage() to the token, something like:<br />
(copied from  mx.rpc.remoting.Operation.as<br />
var message:RemotingMessage = new RemotingMessage();<br />
    message.operation = name;<br />
    message.body = args;<br />
    message.source = RemoteObject(service).source;<br />
    token.setMessage(message);</p>
<p>Regards,<br />
Maurice</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ropp</title>
		<link>http://www.brianlegros.com/blog/2009/02/21/using-stubs-for-httpservice-and-remoteobject-in-flex/comment-page-1/#comment-24871</link>
		<dc:creator>ropp</dc:creator>
		<pubDate>Thu, 08 Apr 2010 03:41:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.brianlegros.com/blog/?p=401#comment-24871</guid>
		<description>Great job! It&#039;s just what I&#039;m looking for. But a small issue is that the RemoteOperationStub can not response to its event listeners. Some times we need to add event listeners for each operation instead of adding all event listeners to remote object itself. 
I made some change to support adding event listenrs for operation:
-------------------------------------------
result() function of RemoteObjectStub:

methods[methodName].push(new RemoteObjectSignature(args, data));
//added by ropp			operations[methodName]=new RemoteOperationStub(this, methodName, methods[methodName]);

------------------------------------------
getOperation() function of RemoteObjectStub:

//return new RemoteOperationStub(this, name, methods[name]);
// added by ropp
return operations[name];

-------------------------------------------
handleTimer() function of RemoteOperationStub:

//send the result event to the RemoteObject		service.dispatchEvent(resultEvent);
// added by ropp			this.dispatchEvent(resultEvent);

I think it will work better after doing above change.

Best wishes!</description>
		<content:encoded><![CDATA[<p>Great job! It&#8217;s just what I&#8217;m looking for. But a small issue is that the RemoteOperationStub can not response to its event listeners. Some times we need to add event listeners for each operation instead of adding all event listeners to remote object itself.<br />
I made some change to support adding event listenrs for operation:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
result() function of RemoteObjectStub:</p>
<p>methods[methodName].push(new RemoteObjectSignature(args, data));<br />
//added by ropp			operations[methodName]=new RemoteOperationStub(this, methodName, methods[methodName]);</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
getOperation() function of RemoteObjectStub:</p>
<p>//return new RemoteOperationStub(this, name, methods[name]);<br />
// added by ropp<br />
return operations[name];</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
handleTimer() function of RemoteOperationStub:</p>
<p>//send the result event to the RemoteObject		service.dispatchEvent(resultEvent);<br />
// added by ropp			this.dispatchEvent(resultEvent);</p>
<p>I think it will work better after doing above change.</p>
<p>Best wishes!</p>
]]></content:encoded>
	</item>
	<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&#8242;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>
</channel>
</rss>

