Return-Path: Delivered-To: apmail-sling-commits-archive@www.apache.org Received: (qmail 33710 invoked from network); 19 Apr 2010 09:01:56 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 19 Apr 2010 09:01:56 -0000 Received: (qmail 54441 invoked by uid 500); 19 Apr 2010 09:01:56 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 54380 invoked by uid 500); 19 Apr 2010 09:01:54 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 54371 invoked by uid 99); 19 Apr 2010 09:01:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Apr 2010 09:01:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Apr 2010 09:01:51 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 98ED523889DE; Mon, 19 Apr 2010 09:01:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r935479 - in /sling/trunk/bundles/api/src: main/java/org/apache/sling/api/resource/ResourceUtil.java test/java/org/apache/sling/api/resource/ResourceUtilTest.java Date: Mon, 19 Apr 2010 09:01:08 -0000 To: commits@sling.apache.org From: bdelacretaz@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100419090108.98ED523889DE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bdelacretaz Date: Mon Apr 19 09:01:08 2010 New Revision: 935479 URL: http://svn.apache.org/viewvc?rev=935479&view=rev Log: SLING-1492 - ResourceUtil.isSyntheticResource should take ResourceWrapper into account Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java?rev=935479&r1=935478&r2=935479&view=diff ============================================================================== --- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java (original) +++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java Mon Apr 19 09:01:08 2010 @@ -212,7 +212,12 @@ public class ResourceUtil { * org.apache.sling.resource.SyntheticResource class. */ public static boolean isSyntheticResource(Resource res) { - return res instanceof SyntheticResource; + if(res instanceof SyntheticResource) { + return true; + } else if(res instanceof ResourceWrapper) { + return ((ResourceWrapper)res).getResource() instanceof SyntheticResource; + } + return false; } /** Modified: sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java?rev=935479&r1=935478&r2=935479&view=diff ============================================================================== --- sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java (original) +++ sling/trunk/bundles/api/src/test/java/org/apache/sling/api/resource/ResourceUtilTest.java Mon Apr 19 09:01:08 2010 @@ -377,4 +377,35 @@ public class ResourceUtilTest { } return count; } + + @Test public void testIsStarResource() { + final Resource nonStar = context.mock(Resource.class); + final String starPath = "/foo/*"; + final Resource star = context.mock(Resource.class); + final String nonStarPath = "/foo/*"; + this.context.checking(new Expectations() {{ + allowing(star).getPath(); will(returnValue(starPath)); + allowing(nonStar).getPath(); will(returnValue(nonStarPath)); + }}); + + assertTrue("expecting star==true for path" + starPath, + ResourceUtil.isStarResource(star)); + assertTrue("expecting star==false for path" + starPath, + ResourceUtil.isStarResource(nonStar)); + } + @Test public void testIsSyntheticResource() { + final Resource synth = new SyntheticResource(null, "foo", "bar"); + final Resource star = context.mock(Resource.class); + this.context.checking(new Expectations() {{ + allowing(star).getPath(); will(returnValue("/foo/*")); + }}); + final Resource wrapped = new ResourceWrapper(synth); + + assertTrue("expecting synthetic==true for SyntheticResource", + ResourceUtil.isSyntheticResource(synth)); + assertFalse("expecting synthetic==false for star resource", + ResourceUtil.isSyntheticResource(star)); + assertTrue("expecting synthetic==true for wrapped Resource", + ResourceUtil.isSyntheticResource(wrapped)); + } }