jclouds-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xianyi Ye" <yexia...@sina.com>
Subject How to mock up novaApi object?
Date Mon, 01 Dec 2014 06:04:31 GMT
Hi all,

 

I have a question about how to do JClouds mock test.

My target codes are showing as below.

 

ComputeServiceContext context = ContextBuilder.newBuilder(provider)

                .endpoint(endpoint.get())

                .credentials(identity.get(),
password.get()).modules(modules)

                .buildView(ComputeServiceContext.class);

RestContext<NovaApi, NovaAsyncApi> nova = context.unwrap();

compute = context.getComputeService();

novaApi = nova.getApi();

 

 

And I knew that I can mock ComputeService with following codes.

 

ComputeServiceContext context =
ContextBuilder.newBuilder("stub").buildView(ComputeServiceContext.class) ;

compute = context.getComputeService();

 

But how can I mock novaApi? 

 

When I tried to call following codes, it always said to me
"java.lang.ClassCastException: org.jclouds.internal.ContextImpl cannot be
cast to org.jclouds.rest.RestContext"

RestContext<NovaApi, NovaAsyncApi> nova = context.unwrap();

 

Is there anyone aware of any solution?

 

Thanks in advance,

Xianyi Ye


Mime
View raw message