Hi Rajani, I had a short investigation into the problem and that test context is quite exciting. (which means I would need a lot more time to find all the details) For a short solution I would recommend you to write another rather than trying to reuse.
On Sat, Mar 29, 2014 at 11:30 AM, Rajani Karuturi < rajani.karut...@citrix.com> wrote: > any help? > > > ~Rajani > > > > On 28-Mar-2014, at 9:48 am, Rajani Karuturi <rajani.karut...@citrix.com> > wrote: > > > Its the testContext.xml we have at server/test/resouces > > > > As the async job dispatcher also comes under server/, i used the same > test context file. > > > > ~Rajani > > > > > > > > On 28-Mar-2014, at 1:23 am, Laszlo Hornyak <laszlo.horn...@gmail.com> > wrote: > > > >> Hi Rajani, > >> > >> Can you share your spring context file? > >> > >> > >> On Thu, Mar 27, 2014 at 10:50 AM, Rajani Karuturi < > >> rajani.karut...@citrix.com> wrote: > >> > >>> Hi All, > >>> > >>> I am trying to write unit tests for ApiAsyncJobDispatcher. This is how > I > >>> defined by Test class @ server/test/com/cloud/api > >>> > >>> @RunWith(SpringJUnit4ClassRunner.class) > >>> @ContextConfiguration(locations = "classpath:/testContext.xml") > >>> public class ApiAsyncJobDispatcherTest { > >>> @Mock > >>> private ApiDispatcher _dispatcher; > >>> > >>> @Mock > >>> private AsyncJobManager _asyncJobMgr; > >>> > >>> @Mock > >>> private EntityManager _entityMgr; > >>> > >>> @InjectMocks > >>> private ApiAsyncJobDispatcher apiAsyncJobDispatcher = new > >>> ApiAsyncJobDispatcher(); > >>> > >>> @Before > >>> public void setUp() throws Exception { > >>> MockitoAnnotations.initMocks(this); > >>> ComponentContext.initComponentsLifeCycle(); > >>> } > >>> > >>> @Test > >>> public void testRunJob() throws Exception { > >>> AsyncJob asyncJob = new AsyncJobVO("", User.UID_SYSTEM, 1, > >>> DetachVolumeCmdByAdmin.class.getCanonicalName(), null, null, null); > >>> apiAsyncJobDispatcher.runJob(asyncJob); > >>> } > >>> } > >>> > >>> > >>> I am getting failed to load ApplicationContext error. The exact error > >>> message is > >>> java.lang.ClassNotFoundException: > >>> org.apache.cloudstack.framework.eventbus.EventBusBase > >>> > >>> I think, that class is moved to > >>> org.apache.cloudstack.framework.events.EventBus. Once I make that > change in > >>> the application context file, I am getting > >>> Caused by: > >>> org.springframework.beans.factory.NoUniqueBeanDefinitionException: No > >>> qualifying bean of type [com.cloud.user.AccountService] is defined: > >>> expected single matching bean but found 4: > >>> mockAccountManagerImpl,accountService,accountManager,acctMgr > >>> > >>> > >>> Am I miss something? > >>> > >>> I did go through > >>> > https://cwiki.apache.org/confluence/display/CLOUDSTACK/Unit+Testing+with+JUnit+and+SpringBut, > didn't understand Note: #4 of it. > >>> > >>> > >>> ~Rajani > >>> > >>> > >>> > >>> > >> > >> > >> -- > >> > >> EOF > > > > -- EOF