Hi
Sorry for a delay. I do not recall us changing anything in this area.
I wonder if it may be to do with new Spring dependencies ?
Perhaps you can experiment with stopping the servers in between the
individual tests ?
Cheers, Sergey
On 30/04/14 15:52, Knoll, Matthias wrote:
Hi everybody,
today I upgraded an application from cxf 2.5.5 to 2.7.11 and encountered a
small obstacle in the JAXRSServerFactoryBean.
The application uses spring and initializes a lot of endpoints and clients in
the test cases through some common spring configuration files that use the
jaxrs namespace and the jaxrs:server tag. In the test case the factories are
reconfigured and create is explicitly called and depending on the test case
stop at different times in the process.
The problem I ran into was that in the past it seems the default value of the
JAXRSServerFactoryBean variable "start" was false.
So the Junit test cases fetched the pre-configured JAXRSServerFactoryBean like
this:
final JAXRSServerFactoryBean sfserver = (JAXRSServerFactoryBean)
applicationContext.getBean("beanname");
modified it for the specific test case and then creates a Server by calling
final Server server = sfserver.create();
the problem now is that with the default value of "start" set to true as it is now the
JAXRSServerFactoryBeanDefinitionParser builds the JAXRSServerFactoryBean and immediately calls
"init()" which calls "create()" and creates the server and starts it during the
initialization of the spring context.
If now the Junit test calls "create()" a second time to fetch the Server instance "create()" throws
a runtime exception because the port is already in use. But the JAXRSServerFactoryBean provides no getter for the
"server" member nor does the schema provide me a way to set "start" to false. Or at least I did not
see it.
Right now I partly solved this by reflection but that's not a long term
solution:
final JAXRSServerFactoryBean sfserver = (JAXRSServerFactoryBean)
applicationContext.getBean("syncRSserver");
// final Server masterServer = sfserver.create();
final Field serverField =
JAXRSServerFactoryBean.class.getDeclaredField("server");
serverField.setAccessible(true);
final Server masterServer = (Server) serverField.get(sfserver);
//some test case logic
masterServer.stop();
//more test case logic
Maybe I did miss a way to fetch the server from the factory bean and thanks
for any other suggestions.
Greetings
Matthias