• Post Reply Bookmark Topic Watch Topic
  • New Topic

beanContainer.getBeanByType(..) works from Main but not from test  RSS feed

 
Elk Moosling
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a factory class that returns a bean fine using org.cdisource.beancontainer.BeanContainer calling beanContainer.getBeanByType(..) when I run it from a ..Main class.
If I run the same lines of code in a test I get ...

org.cdisource.beancontainer.BeanNotFoundException: Could not locate a bean of type xxxxx

Is there some step I've missed to get this working from a unit test (.. really an integration test - strictly speaking)?
I have a beans.xml in src/main/resources/META-INF
I've tried putting the same in src/test/resources/META-INF - but this makes no difference.
As far as I understand though this shouldn't be necessary anyway as there is no CDI use in the test itself - only in the factory class that is used in the test.

I've compared the runtime and compile classpaths for main and test and apart from the mocking related dependencies there is no difference.

Could someone give me any pointers of where to look next?

Regards

E
 
Balagopal Kannampallil
Ranch Hand
Posts: 136
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please paste the code snippet for the bean lookup?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!