Return-Path: X-Original-To: apmail-cloudstack-dev-archive@www.apache.org Delivered-To: apmail-cloudstack-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A507310D4D for ; Tue, 1 Apr 2014 04:30:24 +0000 (UTC) Received: (qmail 34000 invoked by uid 500); 1 Apr 2014 04:30:23 -0000 Delivered-To: apmail-cloudstack-dev-archive@cloudstack.apache.org Received: (qmail 33504 invoked by uid 500); 1 Apr 2014 04:30:21 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 33494 invoked by uid 99); 1 Apr 2014 04:30:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Apr 2014 04:30:20 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of Rajani.Karuturi@citrix.com designates 103.14.252.240 as permitted sender) Received: from [103.14.252.240] (HELO SMTP.CITRIX.COM.AU) (103.14.252.240) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Apr 2014 04:30:14 +0000 X-IronPort-AV: E=Sophos;i="4.97,769,1389744000"; d="scan'208";a="4216465" Received: from sinaccessns.citrite.net (HELO SINPEX01CL03.citrite.net) ([10.151.60.9]) by sinpip01.citrite.net with ESMTP; 01 Apr 2014 04:29:50 +0000 Received: from SINPEX01CL01.citrite.net ([169.254.1.129]) by SINPEX01CL03.citrite.net ([169.254.3.142]) with mapi id 14.02.0342.004; Tue, 1 Apr 2014 12:29:49 +0800 From: Rajani Karuturi To: "dev@cloudstack.apache.org" Subject: Re: spring unittests Thread-Topic: spring unittests Thread-Index: AQHPSaIA9IP4Qg74pk2Z0foVCXQpKJr00wIAgACNMQCAAfopgIADtLOAgACdlgA= Date: Tue, 1 Apr 2014 04:29:48 +0000 Message-ID: References: <4EE6F831-491A-44DB-8D56-87E1B56FC57B@citrix.com> <7CAF4C35-001C-410D-9506-AE44989CB1BE@citrix.com> <1B64360D-5CCB-40EC-95E9-CA8859DED323@citrix.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.13.107.78] Content-Type: text/plain; charset="iso-8859-1" Content-ID: <35F4078250BC6347B80EB354623CD4F3@citrix.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-DLP: SIN1 X-Virus-Checked: Checked by ClamAV on apache.org I think its not with the context file. The problem is with class level bean= definitions using annotations once the component scan is turned on.=20 I will try injecting a custom context. Thanks Laszlo. ~Rajani On 01-Apr-2014, at 12:35 am, Laszlo Hornyak wrot= e: > Hi Rajani, >=20 > I had a short investigation into the problem and that test context is qui= te > 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 rath= er > than trying to reuse. >=20 >=20 >=20 > On Sat, Mar 29, 2014 at 11:30 AM, Rajani Karuturi < > Rajani.Karuturi@citrix.com> wrote: >=20 >> any help? >>=20 >>=20 >> ~Rajani >>=20 >>=20 >>=20 >> On 28-Mar-2014, at 9:48 am, Rajani Karuturi >> wrote: >>=20 >>> Its the testContext.xml we have at server/test/resouces >>>=20 >>> As the async job dispatcher also comes under server/, i used the same >> test context file. >>>=20 >>> ~Rajani >>>=20 >>>=20 >>>=20 >>> On 28-Mar-2014, at 1:23 am, Laszlo Hornyak >> wrote: >>>=20 >>>> Hi Rajani, >>>>=20 >>>> Can you share your spring context file? >>>>=20 >>>>=20 >>>> On Thu, Mar 27, 2014 at 10:50 AM, Rajani Karuturi < >>>> Rajani.Karuturi@citrix.com> wrote: >>>>=20 >>>>> Hi All, >>>>>=20 >>>>> I am trying to write unit tests for ApiAsyncJobDispatcher. This is ho= w >> I >>>>> defined by Test class @ server/test/com/cloud/api >>>>>=20 >>>>> @RunWith(SpringJUnit4ClassRunner.class) >>>>> @ContextConfiguration(locations =3D "classpath:/testContext.xml") >>>>> public class ApiAsyncJobDispatcherTest { >>>>> @Mock >>>>> private ApiDispatcher _dispatcher; >>>>>=20 >>>>> @Mock >>>>> private AsyncJobManager _asyncJobMgr; >>>>>=20 >>>>> @Mock >>>>> private EntityManager _entityMgr; >>>>>=20 >>>>> @InjectMocks >>>>> private ApiAsyncJobDispatcher apiAsyncJobDispatcher =3D new >>>>> ApiAsyncJobDispatcher(); >>>>>=20 >>>>> @Before >>>>> public void setUp() throws Exception { >>>>> MockitoAnnotations.initMocks(this); >>>>> ComponentContext.initComponentsLifeCycle(); >>>>> } >>>>>=20 >>>>> @Test >>>>> public void testRunJob() throws Exception { >>>>> AsyncJob asyncJob =3D new AsyncJobVO("", User.UID_SYSTEM, 1, >>>>> DetachVolumeCmdByAdmin.class.getCanonicalName(), null, null, null); >>>>> apiAsyncJobDispatcher.runJob(asyncJob); >>>>> } >>>>> } >>>>>=20 >>>>>=20 >>>>> I am getting failed to load ApplicationContext error. The exact error >>>>> message is >>>>> java.lang.ClassNotFoundException: >>>>> org.apache.cloudstack.framework.eventbus.EventBusBase >>>>>=20 >>>>> 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 >>>>>=20 >>>>>=20 >>>>> Am I miss something? >>>>>=20 >>>>> I did go through >>>>>=20 >> https://cwiki.apache.org/confluence/display/CLOUDSTACK/Unit+Testing+with= +JUnit+and+SpringBut, >> didn't understand Note: #4 of it. >>>>>=20 >>>>>=20 >>>>> ~Rajani >>>>>=20 >>>>>=20 >>>>>=20 >>>>>=20 >>>>=20 >>>>=20 >>>> -- >>>>=20 >>>> EOF >>>=20 >>=20 >>=20 >=20 >=20 > --=20 >=20 > EOF