Return-Path: X-Original-To: apmail-cxf-users-archive@www.apache.org Delivered-To: apmail-cxf-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 325829DA2 for ; Thu, 16 Feb 2012 02:54:57 +0000 (UTC) Received: (qmail 36121 invoked by uid 500); 16 Feb 2012 02:54:56 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 36070 invoked by uid 500); 16 Feb 2012 02:54:55 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 36047 invoked by uid 99); 16 Feb 2012 02:54:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2012 02:54:55 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.212.41] (HELO mail-vw0-f41.google.com) (209.85.212.41) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2012 02:54:47 +0000 Received: by vbip1 with SMTP id p1so1551556vbi.0 for ; Wed, 15 Feb 2012 18:54:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.220.156.204 with SMTP id y12mr394531vcw.12.1329360866739; Wed, 15 Feb 2012 18:54:26 -0800 (PST) Received: by 10.52.101.202 with HTTP; Wed, 15 Feb 2012 18:54:26 -0800 (PST) In-Reply-To: <4F2C1C95.6000507@gmail.com> References: <1328125304955-5448539.post@n5.nabble.com> <4F2B04EB.6090008@talend.com> <4F2C1C95.6000507@gmail.com> Date: Wed, 15 Feb 2012 18:54:26 -0800 Message-ID: Subject: Re: Unit testing JAX-RS services From: Jeff Wang To: users@cxf.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQk1xJh63c/anicoOMaYlGYxi68WtjnTpOKiIcrGqTfFk22xEpu7xiDfVMgUEDWzP0Y/I1NG X-Virus-Checked: Checked by ClamAV on apache.org Sorry, didn't see this message until just now... On Fri, Feb 3, 2012 at 9:42 AM, Sergey Beryozkin wro= te: > On 03/02/12 03:02, Jeff Wang wrote: >> >> I'm having two difficulties with testing. =C2=A0One practical, one theor= etical. >> >> practical: >> If I have any @Context annotations, I can't actually call the service >> via a client proxy. =C2=A0I need to code the call separately (and >> manually.) >> > I updated the proxies to simply ignore explicit Context parameters, they = are > only populated on the server side...You'd need to pass 'null' if you have > explicit Context params, in meantime try injecting Contexts into fields..= . I've had @Context UriInfo turn up null before when field-injected (same code works method injected), but that was a long time ago. I'll try this later today. >> theoretical: >> Using the same JSON compile unit on the service and the test seems to >> defeat the purpose. =C2=A0If I have a webpage hitting my JAX-RS server, = and >> I change the name of a field, I'd like to have my test point that out, >> so that when I fix my test, I can let my web team know. =C2=A0But if I u= se >> the same compile unit, whatever I change, even accidentally, will >> marshall and unmarshall correctly, the actual user of the API may then >> run into issues. >> > I'm not sure I understand completely, but just in case, it's possible to > adapt the in/out JSON sequences to the expected ones with the help of > TransformFeature, but only if the default JSONProvider is used What I mean is, let's say I have a Book object. And I accidentally add "asdf" to the name element of a field. I would have broken every single one of the actual clients that called Bookstore.findBook(id), but if I use either a direct client call or a proxy, the tests would pass. Essentially, if you're using the same class file on the client side and the server side, all you're really doing is testing that marshall and unmarshall works (the framework.) Not that your JAXB mapping or CXF annotation is correct (the actual code that you need to write.) While testing the framework is useful and have pointed out some mapping mistakes to me, I would bet that the majority of programmer errors lie in the actual code, and not in the framework. Jeff > > Sergey > > >> Jeff