0

I have an spring application deployed on tomcat.

I want to run my integration tests and not to use webservices. I want to use beans instead.

I understand that it is a bit strange, usually WS's should be used for this purposes, however Question - how can I access to spring context in order to get beans from it?

Can you advise me some direction where to look?

liotur
  • 645
  • 1
  • 9
  • 29

1 Answers1

0

You can call getBean method on your spring context, e.g. AnnotationConfigWebApplicationContext object (or XML, which implements BeanFactory)

If getContext() return you the spring context, get bean:

 (MyBeanObject) getContext().getBean("myBeanName")
user7294900
  • 52,490
  • 20
  • 92
  • 189
  • but how can I access it remotely? I have my IT's on my local machine, and the application with its context is deployed on some env – liotur Mar 04 '18 at 13:58
  • using serialization, see https://stackoverflow.com/questions/38457074/spring-mvc-should-my-domain-classes-implement-serializable-for-over-the-wire-t – user7294900 Mar 04 '18 at 14:00