You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Colm O hEigeartaigh (JIRA)" <ji...@apache.org> on 2019/01/07 16:19:00 UTC

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

     [ https://issues.apache.org/jira/browse/CXF-7937?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Colm O hEigeartaigh resolved CXF-7937.
--------------------------------------
    Resolution: Not A Problem

Please don't create JIRAs to ask questions, JIRAs are for bugs/new features in CXF.

> 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)