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 A40B6D1F6 for ; Mon, 29 Oct 2012 18:30:17 +0000 (UTC) Received: (qmail 62124 invoked by uid 500); 29 Oct 2012 18:30:17 -0000 Delivered-To: apmail-incubator-cloudstack-dev-archive@incubator.apache.org Received: (qmail 62081 invoked by uid 500); 29 Oct 2012 18:30:17 -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 62073 invoked by uid 99); 29 Oct 2012 18:30:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Oct 2012 18:30:17 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [74.125.149.153] (HELO na3sys009aog125.obsmtp.com) (74.125.149.153) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Oct 2012 18:30:09 +0000 Received: from mail-gg0-f197.google.com ([209.85.161.197]) (using TLSv1) by na3sys009aob125.postini.com ([74.125.148.12]) with SMTP ID DSNKUI7LGqOk0KpD0Wyt73cPOkPEi3aoc/KO@postini.com; Mon, 29 Oct 2012 11:29:48 PDT Received: by mail-gg0-f197.google.com with SMTP id y3so9195615ggc.0 for ; Mon, 29 Oct 2012 11:29:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=FJCtDAaNxrqfjTvAx83QI/FeqxCGZUd7kHNgpTny7DU=; b=Qg+9r8PBm8qW+ylWkTqLjmn9GhYadpgSEOgbPLlVvTG1XRoFhrozQsj6DRzIUPtTRM NuMGMFpbpNzhF9QfQHm/8/pzWETxeL8KuD9CvBkpGF4WKofFKog1ib7i+Nxt+vRIFjJK JyB5YrChr0080Y8lCswHgBQHXMLIEtdYMmgXe86+RADc8oe1T5s5GNKniEKEfBs/QF0o wTYnInoxhAyIZFGE9d/aR9rRZaE+v4ujv1Z4ms/sVEupHvTzm+ne5QdPrHYlXuY+7Vop QyeaUFM4JHVuAFdIO8mGhti8AYEuTV6TqYBA6vgzCPk6K5B5RsqGenb8zGkOblZrGq+O 9Cdw== Received: by 10.224.210.66 with SMTP id gj2mr11766969qab.48.1351535386041; Mon, 29 Oct 2012 11:29:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.210.66 with SMTP id gj2mr11766965qab.48.1351535385917; Mon, 29 Oct 2012 11:29:45 -0700 (PDT) Received: by 10.49.84.137 with HTTP; Mon, 29 Oct 2012 11:29:45 -0700 (PDT) In-Reply-To: References: <500347f6872eca60c4bc3e4957422304@mail.gmail.com> Date: Mon, 29 Oct 2012 23:59:45 +0530 Message-ID: Subject: Re: need help for test cases of api/commands From: Meghna Kale To: Alex.Huang@citrix.com Cc: cloudstack-dev@incubator.apache.org Content-Type: multipart/alternative; boundary=20cf300faeab94374904cd36dae1 X-Gm-Message-State: ALoCoQny/bs3P0/TrL17Ue+2uNU/7wZqA22HHrj7Ce6Lv8+mZ4a33OoLxhLQ8ZKcBnjD2XWDojCqtI0VEwKtr05jYt4dmvajv8ChBzKpe0DxSeVIqzViTu36324cDaezJ/ZWGKTCS19BTNVvOQxQhPNuJ086HxXIpW99kI4WeToc4RsHaGd9KjYRTfsqiuAXLAu3X8lXLigr X-Virus-Checked: Checked by ClamAV on apache.org --20cf300faeab94374904cd36dae1 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable 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*; } =85=85=85=85.. } -- - 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 moc= k > 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. > > --20cf300faeab94374904cd36dae1--