[jira] [Commented] (CXF-7937) Unable to mock stub and JaxWsProxyFactoryBean in jax rs service

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (CXF-7937) Unable to mock stub and JaxWsProxyFactoryBean in jax rs service

JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/CXF-7937?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16736923#comment-16736923 ]

Colm O hEigeartaigh commented on CXF-7937:
------------------------------------------

You could try mailing the dev mailing list. Alternatively look at the source to see where Mockito is used, you may find a few examples to help you.

> Unable to mock stub and JaxWsProxyFactoryBean in jax rs service
> ---------------------------------------------------------------
>
>                 Key: CXF-7937
>                 URL: https://issues.apache.org/jira/browse/CXF-7937
>             Project: CXF
>          Issue Type: Test
>            Reporter: Srikanth Krishnamurthy
>            Priority: Minor
>
> Hello team, I am trying to test a jax rs service and trying to write junit for the same. It is failing because I am unable to mock the proxy object and it throws me an error mentioning "not a proxy instance". I am using mockito junit framework.
> Here is my code for the creating the proxy and the junit that I am trying 
> public void getService(String endpoint){
> ClientProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
>  proxyFactory.setServiceClass(Service.class);
> proxyFactory.setAddress(endpoint);
> service = (Service) proxyFactory.create();
> Client proxy = ClientProxy.getClient(service );
> }
> junit: 
> @Mock
> private Service service;
> @Mock
>  private ClientProxyFactoryBean factoryBean;
> @Test
>  public void testGetServiceObj() throws Exception {
> factoryBean.setServiceClass(Service.class);
> factoryBean.setAddress(endpoint);
> assertThat(getService("http://test.com//api")
> }
>  
> when i try to run test method, it returns "not a proxy instance" error. Please help to resolve the issue.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)