From dev-return-2355-apmail-oltu-dev-archive=oltu.apache.org@oltu.apache.org Fri Dec 5 18:46:47 2014 Return-Path: X-Original-To: apmail-oltu-dev-archive@www.apache.org Delivered-To: apmail-oltu-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 B4DA310719 for ; Fri, 5 Dec 2014 18:46:47 +0000 (UTC) Received: (qmail 20943 invoked by uid 500); 5 Dec 2014 18:46:47 -0000 Delivered-To: apmail-oltu-dev-archive@oltu.apache.org Received: (qmail 20908 invoked by uid 500); 5 Dec 2014 18:46:47 -0000 Mailing-List: contact dev-help@oltu.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@oltu.apache.org Delivered-To: mailing list dev@oltu.apache.org Received: (qmail 20894 invoked by uid 99); 5 Dec 2014 18:46:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Dec 2014 18:46:47 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of simone.tripodi@gmail.com designates 209.85.214.169 as permitted sender) Received: from [209.85.214.169] (HELO mail-ob0-f169.google.com) (209.85.214.169) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Dec 2014 18:46:21 +0000 Received: by mail-ob0-f169.google.com with SMTP id vb8so964171obc.28 for ; Fri, 05 Dec 2014 10:44:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=/dhV7+x84AbArA+g69dcwCn7w+a3ZhXOA227H3G1+kU=; b=zcTaCaSPX52zWrtMRRZ8GxnWd80Da6zQCvktfPD/1YFfvuqs+wW3OK3qihD/kUR4xI iKg9mJpz86b1Dk5Ttig9NTDdJYUriJuZRxC4ynlFKvEZ3nbIoTFI1TfF2RgE1bZ1bL/h l/EMF+CM6D51Q+52/A0u0/EoSGt12BlJVr7Ig23rah1XItrLgADUeH6CwzjCxuMaHyS2 a4afPPrbcdo6uQgjtWSxxsnIfNTd1zvAn6hGQcDY+rf5WzQkn9xbjCLC3gy1pcvWNJeG Hf9JrZQJ312RIvWUT0sRuRLu2GlnM9T3KLQOAUVb9x/cVYd0mh7s2gwTZtuNhIPphsQy ElQw== MIME-Version: 1.0 X-Received: by 10.60.103.115 with SMTP id fv19mr11416645oeb.46.1417805045153; Fri, 05 Dec 2014 10:44:05 -0800 (PST) Sender: simone.tripodi@gmail.com Received: by 10.60.145.207 with HTTP; Fri, 5 Dec 2014 10:44:05 -0800 (PST) In-Reply-To: References: Date: Fri, 5 Dec 2014 11:44:05 -0700 X-Google-Sender-Auth: lf9CH_TaZ8PQra5SoB-16U5vUhg Message-ID: Subject: Re: JSON comparison in test case best practice From: Simone Tripodi To: dev@oltu.apache.org Content-Type: multipart/alternative; boundary=089e0116024e13c54405097c766a X-Virus-Checked: Checked by ClamAV on apache.org --089e0116024e13c54405097c766a Content-Type: text/plain; charset=UTF-8 Looks like there's a nice tool called JSONAssert that does the legwork - and I am not surprised someone already thought on doing that :) I am fixing broken tests to make them working but will let the discussion open in order to find a general agreement... please join! All the best, -Simo [1] http://jsonassert.skyscreamer.org/ http://people.apache.org/~simonetripodi/ http://twitter.com/simonetripodi On Fri, Dec 5, 2014 at 11:39 AM, Simone Tripodi wrote: > Hi all mates, > > there are a couple of tests in the oauth-2.0/common codebase failing on > CLI, but succeed in Eclipse, see below for details... > > I honestly think that comparing serialised JSON strings is not thebest way > to assert two JSON documents are representing exactly the same data, we > need to handle that situation... > > Does anybody know a best practice to compare json object, such as XMLDiff > of something else? > I am asking google, in the meanwhile... :) > Best, > -Simo > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > OAuthResponseTest.testErrorResponse:47 expected:<{"[error_uri":" > http://example-uri","error":"error","param":"value","realm":"album","state":"ok","error_description":"error_description]"}> > but > was:<{"[param":"value","error_description":"error_description","realm":"album","state":"ok","error":"error","error_uri":" > http://example-uri]"}> > > WWWAuthHeaderParametersApplierTest.testApplyOAuthParameters:60 > expected:<...ope="s1 s2 s3",error[_uri="http://www.example.com/error",error="invalid_token]"> > but was:<...ope="s1 s2 s3",error[="invalid_token",error_uri=" > http://www.example.com/error]"> > http://people.apache.org/~simonetripodi/ > http://twitter.com/simonetripodi > --089e0116024e13c54405097c766a--