Return-Path: X-Original-To: apmail-incubator-cloudstack-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-cloudstack-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 68C5DD517 for ; Mon, 29 Oct 2012 19:24:18 +0000 (UTC) Received: (qmail 18902 invoked by uid 500); 29 Oct 2012 19:24:18 -0000 Delivered-To: apmail-incubator-cloudstack-dev-archive@incubator.apache.org Received: (qmail 18835 invoked by uid 500); 29 Oct 2012 19:24:18 -0000 Mailing-List: contact cloudstack-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cloudstack-dev@incubator.apache.org Delivered-To: mailing list cloudstack-dev@incubator.apache.org Received: (qmail 18827 invoked by uid 99); 29 Oct 2012 19:24:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Oct 2012 19:24:18 +0000 X-ASF-Spam-Status: No, hits=1.1 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_NEUTRAL,TO_NO_BRKTS_MSFT X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [74.125.149.73] (HELO na3sys009aog104.obsmtp.com) (74.125.149.73) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Oct 2012 19:24:12 +0000 Received: from mail-yh0-f69.google.com ([209.85.213.69]) (using TLSv1) by na3sys009aob104.postini.com ([74.125.148.12]) with SMTP ID DSNKUI7Xxy+NUeIhRSg45awJ7ulnVZRALsB3@postini.com; Mon, 29 Oct 2012 12:23:52 PDT Received: by mail-yh0-f69.google.com with SMTP id 47so9123421yhr.0 for ; Mon, 29 Oct 2012 12:23:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:references:in-reply-to:mime-version:x-mailer:thread-index:date :message-id:subject:to:cc:content-type:content-transfer-encoding :x-gm-message-state; bh=K3LV9bSx09kr0uT/83csvaTUjE589BBxjj7DnTbxMX0=; b=pSW/Qo1MlqqAHOOwrzUCJR+fyTI2OtgrRII78xCU4lOTiSy5hedHjJ6sgAFb+Sk/xe ZrJnL4cCiwuxCGfPl1OnTcMJCOC2WWOmYoTR20FV63FK2bK1nDdDqFJD55ccaulezhOx Ug8gHMvjBkpA1P4LJhL1nc5dUDWUdjL4ufai7ssfl5plF+KXl+oWdh36r6ffsIDBYhdl 1cbD+lvIDdTrHct06JS46fYn2toRiTQ5s6A8xl9VNo4Ypk1BsHjJ9BOIGtvgShm0mWgt dhznxGDQ/BFovAkFHdPTxm1qjnqaHSyDEkKgkt7TSaCKCNFQCx+sVHP13j+wgzXl4xCg R6eA== Received: by 10.224.176.201 with SMTP id bf9mr18584902qab.80.1351538630607; Mon, 29 Oct 2012 12:23:50 -0700 (PDT) Received: by 10.224.176.201 with SMTP id bf9mr18584890qab.80.1351538630434; Mon, 29 Oct 2012 12:23:50 -0700 (PDT) From: Meghna Kale References: In-Reply-To: MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQJc94vQhYI6hfRL6Sz9F1GYA0X3VZayJjXg Date: Tue, 30 Oct 2012 00:53:00 +0530 Message-ID: <8fc17bc8e4f34d5b681cafcdc4188e09@mail.gmail.com> Subject: RE: need help for test cases of api/commands To: Chiradeep.Vittal@citrix.com Cc: cloudstack-dev@incubator.apache.org, Alex Huang Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQlZNnLGX1N5IlVbUecbab74kFdjUR5G7oOOWk2xrDxCw41txESX0rE7EizqleisrdKOnXYV47Wg6lbRrQw0HpeNvydkbyGA8Bzg3niNE1nSrw+mc6JLz3wZpfy1eQs0dBMY+IN433zyM3g4cSjgxXx7EraZlYkSYbDXfj6zfe5ZjMDm8AuxJxM5cdvKaStYCo+r6f0A X-Virus-Checked: Checked by ClamAV on apache.org I was trying with mocks. -----Original Message----- From: Chiradeep Vittal [mailto:Chiradeep.Vittal@citrix.com] Sent: Tuesday, October 30, 2012 12:04 AM To: CloudStack DeveloperList; Alex Huang Subject: Re: need help for test cases of api/commands Are you writing mocks, or are you planning to use a framework like Mockito? On 10/29/12 11:29 AM, "Meghna Kale" wrote: >Alex, > >A method from ActivateProjectCmd.java, the projectService call. > > @Override > > public long getEntityOwnerId() { > > Project project=3D _projectService.getProject(id); > > //verify input parameters > > if (project =3D=3D null) { > > throw new InvalidParameterValueException("Unable >to find project by id " + id); > > } > > return _projectService.getProjectOwner(id).getId(); > > } > > > > I created a mock class of the service > > > >@Local(value =3D { ProjectService.*class* }) > >*public* *class* MockProjectServiceImpl *implements* ProjectService, >Manager{ > > public static final Logger s_logger =3D >Logger.getLogger(MockProjectServiceImpl.class); > > > > @Override > > *public* *boolean* deleteProject(*long* id) { > > // *TODO* Auto-generated method stub > > *return* *false*; > > } > > > > @Override > > *public* Project getProject(*long* id) { > > // *TODO* Auto-generated method stub > > > > // We Cannot mock the Project object as it an interface and >return from this method. > > *return* *null*; > > } > >=C5=A0=C5=A0=C5=A0=C5=A0.. > > > >} > > > >-- - Meghna. > > > > >On Mon, Oct 29, 2012 at 11:42 PM, Alex Huang >wrote: > >> Meghna, >> >> Can you give an example of which call you're talking about and point >> out the specific line of code you're having problem with? >> >> Thanks. >> >> --Alex >> >> > -----Original Message----- >> > From: Meghna Kale [mailto:meghna.kale@sungard.com] >> > Sent: Monday, October 29, 2012 9:51 AM >> > To: cloudstack-dev@incubator.apache.org >> > Subject: need help for test cases of api/commands >> > >> > Hi All, >> > >> > >> > >> > I was writing some test cases for the API layer >> > api\src\com\cloud\api\commands. >> > >> > I facing some issue can someone help me. >> > >> > >> > >> > There are some service layer calls in the classes , I tried to mock >>the >> service >> > layer. >> > >> > The Service layer internally calls the DAO, rather than calling the >>mock >> DAO I >> > was thinking of returning the object from the service layer. >> > >> > But as the return value of the DAO is an interface in the service >>layer >> I'm not >> > able to mock the object and pass it on to the API layer. >> > >> > >> > >> > Is any other way or I will have to mock the DAO layer also ? >> > >> > >> > >> > - Meghna. >> >>