You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by srinivasulureddy <sr...@sonata-software.com> on 2012/04/24 15:49:56 UTC
the problem is when I run the command like “ mvn test” then it is executing the test case
I am using testNG test cases for testing cxf webservices as below,
Here the problem is when I run the command like “ mvn test” then it is
executing the test case as below code, it is invoking webservice project
which is deployed in tomcat as a war and as well as invokes same project
source code in eclipse. How avoid the webservice call in project source
code in eclipse while running below test case. Whether it is current
approach to add Soap header to cxf interceptor or any other ways to do it,
please suggest some thing.
@Test(enabled = true)
public void testPassAuthenticationByAddingHeader()
{
JaxWsProxyFactoryBean factory =
new JaxWsProxyFactoryBean();
factory.setServiceClass(PersonService.class);
factory.setAddress("http://172.29.68.62:8080/CXFExampleService/personService");
//factory.
PersonService serviceClient = (PersonService) factory.create();
Client proxy = ClientProxy.getClient(serviceClient);
// Creating SOAP headers to the web service request
// Create a list for holding all SOAP headers
List<Header> headersList = new ArrayList<Header>();
QName qName = new QName("http://172.29.68.62:8080/CXFExampleService",
"Person");
Person person = addAuthentication("test", "test");
JAXBDataBinding dataBinding = getJAXBDataBinding(person);
Header testSoapHeader1 = new Header(qName, person, dataBinding);
// Add SOAP headers to the web service request
headersList.add(testSoapHeader1);
proxy.getRequestContext().put(Header.HEADER_LIST, headersList);
// call the webservice
String message = serviceClient.greetPerson("Test");
System.out.println("Message in testInterceptorPassCase is " + message);
AssertJUnit.assertNotNull(message);
}
in tomcat war execution successful but below error is test case build failed
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Apr 24, 2012 5:19:59 PM
org.springframework.beans.factory.xml.XmlBeanDefinitionR
eader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[service-context.xml
]
Apr 24, 2012 5:19:59 PM
org.springframework.beans.factory.xml.XmlBeanDefinitionR
eader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[META-INF/cxf/cxf.xm
l]
Apr 24, 2012 5:19:59 PM
org.springframework.beans.factory.xml.XmlBeanDefinitionR
eader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[META-INF/cxf/cxf-ex
tension-soap.xml]
Apr 24, 2012 5:19:59 PM
org.springframework.beans.factory.xml.XmlBeanDefinitionR
eader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource
[META-INF/cxf/cxf-ex
tension-http.xml]
Apr 24, 2012 5:19:59 PM
org.springframework.context.support.AbstractApplicationC
ontext prepareRefresh
INFO: Refreshing
org.springframework.context.support.GenericApplicationContext@1
749757: startup date [Tue Apr 24 17:19:59 IST 2012]; root of context
hierarchy
Apr 24, 2012 5:19:59 PM
org.springframework.core.io.support.PropertiesLoaderSupp
ort loadProperties
INFO: Loading properties file from class path resource
[service-test.properties]
Apr 24, 2012 5:19:59 PM
org.springframework.beans.factory.support.DefaultListabl
eBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.
DefaultListableBeanFactory@1afae45: defining beans
[cxf,org.apache.cxf.bus.sprin
g.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProc
essor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.binding
.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.ap
ache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.transport.http.Clien
tOnlyHTTPTransportFactory,propConfig,proxyFactory,headerOutInterceptor,personCli
ent,org.springframework.context.annotation.internalConfigurationAnnotationProces
sor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,
org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.s
pringframework.context.annotation.internalCommonAnnotationProcessor]; root
of fa
ctory hierarchy
Inside the out interceptor
Apr 24, 2012 5:20:00 PM
org.apache.cxf.service.factory.ReflectionServiceFactoryB
ean buildServiceFromClass
INFO: Creating Service
{http://service.secureplatform.threeci.com/}PersonService
Service from class com.threeci.secureplatform.service.PersonService
Apr 24, 2012 5:20:00 PM org.apache.cxf.bus.spring.OldSpringSupport
logWarning
WARNING: Import of META-INF/cxf/cxf-extension-soap.xml has been deprecated
and i
s unnecessary.
Apr 24, 2012 5:20:00 PM org.apache.cxf.bus.spring.OldSpringSupport
logWarning
WARNING: Import of META-INF/cxf/cxf-extension-http.xml has been deprecated
and i
s unnecessary.
Apr 24, 2012 5:20:00 PM
org.apache.cxf.service.factory.ReflectionServiceFactoryB
ean buildServiceFromClass
INFO: Creating Service
{http://service.secureplatform.threeci.com/}PersonService
Service from class com.threeci.secureplatform.service.PersonService
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.218 sec
<<< FA
ILURE!
Results :
Failed tests:
Apr 24, 2012 5:20:00 PM
org.springframework.context.support.AbstractApplicationC
ontext doClose
testPassAuthenticationByAddingHeader(com.threeci.secureplatform.test.UserCentr
icServiceTest): org.apache.cxf.endpoint.ClientImpl cannot be cast to
javax.xml.w
s.BindingProvider
INFO: Closing
org.springframework.context.support.GenericApplicationContext@1749
757: startup date [Tue Apr 24 17:19:59 IST 2012]; root of context hierarchy
Apr 24, 2012 5:20:00 PM
org.springframework.beans.factory.support.DefaultSinglet
onBeanRegistry destroySingletons
INFO: Destroying singletons in
org.springframework.beans.factory.support.Default
ListableBeanFactory@1afae45: defining beans
[cxf,org.apache.cxf.bus.spring.BusWi
ringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,o
rg.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.binding.soap.S
oapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cx
f.binding.soap.customEditorConfigurer,org.apache.cxf.transport.http.ClientOnlyHT
TPTransportFactory,propConfig,proxyFactory,headerOutInterceptor,personClient,org
.springframework.context.annotation.internalConfigurationAnnotationProcessor,org
.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.spr
ingframework.context.annotation.internalRequiredAnnotationProcessor,org.springfr
amework.context.annotation.internalCommonAnnotationProcessor]; root of
factory h
ierarchy
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 3.547s
[INFO] Finished at: Tue Apr 24 17:20:00 IST 2012
[INFO] Final Memory: 6M/11M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-surefire-plugin:2.
7.2:test (default-test) on project CXFExampleService: There are test
failures.
[ERROR]
[ERROR] Please refer to
D:\softwares\cxfSample\CXFInterceptorService\target\sure
fire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e
swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please
rea
d the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
D:\softwares\cxfSample\CXFInterceptorService>
--
View this message in context: http://cxf.547215.n5.nabble.com/the-problem-is-when-I-run-the-command-like-mvn-test-then-it-is-executing-the-test-case-tp5662067p5662067.html
Sent from the cxf-issues mailing list archive at Nabble.com.
Re: the problem is when I run the command like “ mvn test” then it is executing the test case
Posted by Daniel Kulp <dk...@apache.org>.
Any chance you can create a simple test case for this? I don't see the full
stack trace for the exception so I'm not really sure where to look.
However, my gut feeling is that you should change:
PersonService serviceClient = (PersonService) factory.create();
Client proxy = ClientProxy.getClient(serviceClient);
.....
proxy.getRequestContext().put(Header.HEADER_LIST, headersList);
to:
PersonService proxy = (PersonService) factory.create();
...
((BindingProvider)proxy).getRequestContext()
.put(Header.HEADER_LIST, headersList);
The "Client" object is an internal CXF thing and doesn't implement any of
the jaxws interfaces. If you are trying to cast that to the BindingProvider
someplace, that would fail. The actual service object returned from the
factory would implement those interfaces and is thus castable.
Dan
On Tuesday, April 24, 2012 06:49:56 AM srinivasulureddy wrote:
> I am using testNG test cases for testing cxf webservices as below,
>
> Here the problem is when I run the command like “ mvn test” then it is
> executing the test case as below code, it is invoking webservice project
> which is deployed in tomcat as a war and as well as invokes same project
> source code in eclipse. How avoid the webservice call in project source
> code in eclipse while running below test case. Whether it is current
> approach to add Soap header to cxf interceptor or any other ways to do it,
> please suggest some thing.
>
> @Test(enabled = true)
> public void testPassAuthenticationByAddingHeader()
> {
> JaxWsProxyFactoryBean factory =
> new JaxWsProxyFactoryBean();
> factory.setServiceClass(PersonService.class);
>
> factory.setAddress("http://172.29.68.62:8080/CXFExampleService/personServi
> ce"); //factory.
> PersonService serviceClient = (PersonService) factory.create();
> Client proxy = ClientProxy.getClient(serviceClient);
>
> // Creating SOAP headers to the web service request
> // Create a list for holding all SOAP headers
> List<Header> headersList = new ArrayList<Header>();
> QName qName = new
QName("http://172.29.68.62:8080/CXFExampleService",
> "Person");
> Person person = addAuthentication("test", "test");
> JAXBDataBinding dataBinding = getJAXBDataBinding(person);
> Header testSoapHeader1 = new Header(qName, person, dataBinding);
> // Add SOAP headers to the web service request
> headersList.add(testSoapHeader1);
> proxy.getRequestContext().put(Header.HEADER_LIST, headersList);
> // call the webservice
> String message = serviceClient.greetPerson("Test");
> System.out.println("Message in testInterceptorPassCase is " +
message);
> AssertJUnit.assertNotNull(message);
> }
>
>
> in tomcat war execution successful but below error is test case build
> failed
>
> -------------------------------------------------------
> T E S T S
> -------------------------------------------------------
> Running TestSuite
> Apr 24, 2012 5:19:59 PM
> org.springframework.beans.factory.xml.XmlBeanDefinitionR
> eader loadBeanDefinitions
> INFO: Loading XML bean definitions from class path resource
> [service-context.xml
> ]
> Apr 24, 2012 5:19:59 PM
> org.springframework.beans.factory.xml.XmlBeanDefinitionR
> eader loadBeanDefinitions
> INFO: Loading XML bean definitions from class path resource
> [META-INF/cxf/cxf.xm
> l]
> Apr 24, 2012 5:19:59 PM
> org.springframework.beans.factory.xml.XmlBeanDefinitionR
> eader loadBeanDefinitions
> INFO: Loading XML bean definitions from class path resource
> [META-INF/cxf/cxf-ex
> tension-soap.xml]
> Apr 24, 2012 5:19:59 PM
> org.springframework.beans.factory.xml.XmlBeanDefinitionR
> eader loadBeanDefinitions
> INFO: Loading XML bean definitions from class path resource
> [META-INF/cxf/cxf-ex
> tension-http.xml]
> Apr 24, 2012 5:19:59 PM
> org.springframework.context.support.AbstractApplicationC
> ontext prepareRefresh
> INFO: Refreshing
> org.springframework.context.support.GenericApplicationContext@1
> 749757: startup date [Tue Apr 24 17:19:59 IST 2012]; root of context
> hierarchy
> Apr 24, 2012 5:19:59 PM
> org.springframework.core.io.support.PropertiesLoaderSupp
> ort loadProperties
> INFO: Loading properties file from class path resource
> [service-test.properties]
>
> Apr 24, 2012 5:19:59 PM
> org.springframework.beans.factory.support.DefaultListabl
> eBeanFactory preInstantiateSingletons
> INFO: Pre-instantiating singletons in
> org.springframework.beans.factory.support.
> DefaultListableBeanFactory@1afae45: defining beans
> [cxf,org.apache.cxf.bus.sprin
> g.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPo
> stProc
> essor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.
> binding
> .soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory
> ,org.ap
> ache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.transport.htt
> p.Clien
> tOnlyHTTPTransportFactory,propConfig,proxyFactory,headerOutInterceptor,pe
> rsonCli
> ent,org.springframework.context.annotation.internalConfigurationAnnotatio
> nProces
> sor,org.springframework.context.annotation.internalAutowiredAnnotationPro
> cessor,
> org.springframework.context.annotation.internalRequiredAnnotationProcesso
> r,org.s
> pringframework.context.annotation.internalCommonAnnotationProcessor];
> root of fa
> ctory hierarchy
> Inside the out interceptor
> Apr 24, 2012 5:20:00 PM
> org.apache.cxf.service.factory.ReflectionServiceFactoryB
> ean buildServiceFromClass
> INFO: Creating Service
> {http://service.secureplatform.threeci.com/}PersonService
> Service from class com.threeci.secureplatform.service.PersonService
> Apr 24, 2012 5:20:00 PM org.apache.cxf.bus.spring.OldSpringSupport
> logWarning
> WARNING: Import of META-INF/cxf/cxf-extension-soap.xml has been deprecated
> and i
> s unnecessary.
> Apr 24, 2012 5:20:00 PM org.apache.cxf.bus.spring.OldSpringSupport
> logWarning
> WARNING: Import of META-INF/cxf/cxf-extension-http.xml has been deprecated
> and i
> s unnecessary.
> Apr 24, 2012 5:20:00 PM
> org.apache.cxf.service.factory.ReflectionServiceFactoryB
> ean buildServiceFromClass
> INFO: Creating Service
> {http://service.secureplatform.threeci.com/}PersonService
> Service from class com.threeci.secureplatform.service.PersonService
> Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.218 sec
> <<< FA
> ILURE!
>
> Results :
>
> Failed tests:
> Apr 24, 2012 5:20:00 PM
> org.springframework.context.support.AbstractApplicationC
> ontext doClose
>
> testPassAuthenticationByAddingHeader(com.threeci.secureplatform.test.UserC
> entr icServiceTest): org.apache.cxf.endpoint.ClientImpl cannot be cast to
> javax.xml.w
> s.BindingProvider
> INFO: Closing
> org.springframework.context.support.GenericApplicationContext@1749
> 757: startup date [Tue Apr 24 17:19:59 IST 2012]; root of context
> hierarchy Apr 24, 2012 5:20:00 PM
> org.springframework.beans.factory.support.DefaultSinglet
> onBeanRegistry destroySingletons
>
> INFO: Destroying singletons in
> org.springframework.beans.factory.support.Default
> ListableBeanFactory@1afae45: defining beans
> [cxf,org.apache.cxf.bus.spring.BusWi
> ringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProce
> ssor,o
> rg.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.binding
> .soap.S
> oapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.ap
> ache.cx
> f.binding.soap.customEditorConfigurer,org.apache.cxf.transport.http.Clien
> tOnlyHT
> TPTransportFactory,propConfig,proxyFactory,headerOutInterceptor,personCli
> ent,org
> .springframework.context.annotation.internalConfigurationAnnotationProces
> sor,org
> .springframework.context.annotation.internalAutowiredAnnotationProcessor,
> org.spr
> ingframework.context.annotation.internalRequiredAnnotationProcessor,org.s
> pringfr amework.context.annotation.internalCommonAnnotationProcessor];
> root of factory h
> ierarchy
> Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
>
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 3.547s
> [INFO] Finished at: Tue Apr 24 17:20:00 IST 2012
> [INFO] Final Memory: 6M/11M
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-surefire-plugin:2.
> 7.2:test (default-test) on project CXFExampleService: There are test
> failures.
> [ERROR]
> [ERROR] Please refer to
> D:\softwares\cxfSample\CXFInterceptorService\target\sure
> fire-reports for the individual test results.
> [ERROR] -> [Help 1]
> [ERROR]
> [ERROR] To see the full stack trace of the errors, re-run Maven with the
> -e swit
> ch.
> [ERROR] Re-run Maven using the -X switch to enable full debug logging.
> [ERROR]
> [ERROR] For more information about the errors and possible solutions,
> please rea
> d the following articles:
> [ERROR] [Help 1]
> http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
> eption
> D:\softwares\cxfSample\CXFInterceptorService>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/the-problem-is-when-I-run-the-command-lik
> e-mvn-test-then-it-is-executing-the-test-case-tp5662067p5662067.html Sent
> from the cxf-issues mailing list archive at Nabble.com.
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com