How to mock a Auto generated BlazeDS Service

65 views
Skip to first unread message

Priya

unread,
Apr 20, 2012, 5:46:01 PM4/20/12
to Mockolate
I'm using Blaze DS to remote connect to my service layer in Java. I
tried this ,but getting errors:

mock(dealService).method("findDeals").args(dealArray).returns(token).answers(new
ResultAnswer(token,resultEvent));
proxy.dealServiceDelegate = dealService;


The Blaze ds autogenerates the class for me like below:

Could you please direct me in how would it be possible to Mock this
DealService ?

Thanks..


public class DealService extends _Super_DealService
{
public function DealService()
{
super();
}

}

-----------------------------------------------------------

ExcludeClass]
internal class _Super_DealService extends
com.adobe.fiber.services.wrapper.RemoteObjectServiceWrapper
{

public function _Super_DealService()
{
// initialize service control
//com.jpmc.sales.deal.model.vo.DealDetailVO._initRemoteClassAlias();
_serviceControl = new mx.rpc.remoting.RemoteObject();

var operations:Object = new Object();
var operation:mx.rpc.remoting.Operation;

operation = new mx.rpc.remoting.Operation(null, "findDeals");
operations["createDealDetail"] = operation;
_serviceControl.operations = operations;
_serviceControl.convertResultHandler =
com.adobe.serializers.utility.TypeUtility.convertResultHandler;
destination = "dealService";

model_internal::initialize();
}

public function findDeals(arg0:Object) : mx.rpc.AsyncToken
{
var _internal_operation:mx.rpc.AbstractOperation =
_serviceControl.getOperation("findDeals");
var _internal_token:mx.rpc.AsyncToken =
_internal_operation.send(arg0) ;

return _internal_token;
}
}

----------------------------------------------------------------------------------

Drew Bourne

unread,
Apr 25, 2012, 1:45:59 PM4/25/12
to mock...@googlegroups.com
Because the _Super_DealService class is internal the current reflection information is insufficient to know what the public methods are in order to proxy them. 

I suggest you introduced an IDealService interface with the methods you need and use that interface instead of the class generated by BlazeDS. 

In the near future it should be possible to proxy these generated classes, however I am still working on integrating the as3-commons-bytecode library to improve the reflection and proxy generation features of Mockolate. 

cheers,
Drew

Roland Zwaga

unread,
Apr 25, 2012, 2:14:51 PM4/25/12
to mock...@googlegroups.com
Hey Drew,

I'm already seeing a problem in the current implementation of the
ProxyFactory for generating proxies for internal classes. Right now
the proxy class is generated like this:
<OriginalPacke>.<20CharacterRandomString>.<OriginalClassname>
To generate a subclass for an internal class we'll have to generate a
fully qualified classname in the SAME package as the internal class.
So this won 't work.
I'll add an event that'll let you specify the fully qualified class
name for the proxy class (overriding the default behaviour), that way
it'll be possible.
Whatyathink?

Roland

Priya

unread,
May 2, 2012, 2:45:13 PM5/2/12
to Mockolate
I was able to overcome this using interfaces.Thanks.

On Apr 25, 12:45 pm, Drew Bourne <d...@firstbourne.com> wrote:
> Because the _Super_DealService class is internal the current reflection
> information is insufficient to know what the public methods are in order to
> proxy them.
>
> I suggest you introduced an IDealService interface with the methods you
> need and use that interface instead of the class generated by BlazeDS.
>
> In the near future it should be possible to proxy these generated classes,
> however I am still working on integrating the as3-commons-bytecode library
> to improve the reflection and proxy generation features of Mockolate.
>
> cheers,
> Drew
>
>
>
> On Fri, Apr 20, 2012 at 9:46 PM, Priya <var...@gmail.com> wrote:
> > I'm using Blaze DS to remote connect to my service layer in Java. I
> > tried this ,but getting errors:
>
> > mock(dealService).method("findDeals").args(dealArray).returns(token).answer­s(new
> > ---------------------------------------------------------------------------­-------- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages