You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Mandy Warren <ma...@gmail.com> on 2013/10/23 01:11:49 UTC

No MessageObserver issue when running multiple JUnits which load Spring context and use local transport

Hi,

I have a Spring config which defines my jaws:server to be listening on a local transport. I load this config in my JUnit as follows:

@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:conf/spring/AppContext.xml" })
@ActiveProfiles(profiles = { "integration-tests" })


 Within the JUnit I have a test which creates a JaxWsProxyBean and sends a request in..

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(Test.class);
factory.setAddress("local://test");
…..

All works fine if this is the only JUnit in my Maven project but as soon as I have another JUnit which also loads the Spring config using the above annotations, I get an error stating:

"Local destination does not have a MessageObserver on address local://test"..

It seems the 2 tests are interfering with each other.

I have added a teardown method to try & shutdown all the cxf stuff but this doesn't seem to help. 

	@After
	public void teardown() throws Exception {
		EndpointImpl endpoint = (EndpointImpl) applicationContext
				.getBean("myEndPoint");
		endpoint.getServer().destroy();
		LocalTransportFactory localFactory = applicationContext.getBean(LocalTransportFactory.class);
		localFactory.getBus().shutdown(true);
		localFactory.unregister();

	}

Any help would be very much appreciated!

Thanks
Mandy



Re: No MessageObserver issue when running multiple JUnits which load Spring context and use local transport

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Mandy

Sorry for a delay.
JAXRSLocalTransportTest starts a new Server per every test I've just 
debugged, and it works just fine. But in my case it is a sequential 
execution, I wonder if it is some race condition that you see in your 
test setup ?
For example, just a theory: Server has a stopped flag, it might be that 
multiple tests running in parallel interfere with each other at this 
flag level and preventing a proper Server shutdown, but it is just a theory.
I'm not sure if CXF needs to be fixed a bit to prevent it as it is 
difficult to reproduce the issue. Can you consider doing a simple Maven 
project with some HelloWorld kind of setup, and attach it to JIRA ? We 
can then have a closer look
Thanks, Sergey

On 23/10/13 00:11, Mandy Warren wrote:
> Hi,
>
> I have a Spring config which defines my jaws:server to be listening on a local transport. I load this config in my JUnit as follows:
>
> @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
> @RunWith(SpringJUnit4ClassRunner.class)
> @ContextConfiguration(locations = { "classpath:conf/spring/AppContext.xml" })
> @ActiveProfiles(profiles = { "integration-tests" })
>
>
>   Within the JUnit I have a test which creates a JaxWsProxyBean and sends a request in..
>
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> factory.setServiceClass(Test.class);
> factory.setAddress("local://test");
> …..
>
> All works fine if this is the only JUnit in my Maven project but as soon as I have another JUnit which also loads the Spring config using the above annotations, I get an error stating:
>
> "Local destination does not have a MessageObserver on address local://test"..
>
> It seems the 2 tests are interfering with each other.
>
> I have added a teardown method to try & shutdown all the cxf stuff but this doesn't seem to help.
>
> 	@After
> 	public void teardown() throws Exception {
> 		EndpointImpl endpoint = (EndpointImpl) applicationContext
> 				.getBean("myEndPoint");
> 		endpoint.getServer().destroy();
> 		LocalTransportFactory localFactory = applicationContext.getBean(LocalTransportFactory.class);
> 		localFactory.getBus().shutdown(true);
> 		localFactory.unregister();
>
> 	}
>
> Any help would be very much appreciated!
>
> Thanks
> Mandy
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com