Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 49281 invoked from network); 5 May 2008 11:14:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 May 2008 11:14:34 -0000 Received: (qmail 70853 invoked by uid 500); 5 May 2008 11:14:36 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 70798 invoked by uid 500); 5 May 2008 11:14:36 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 70789 invoked by uid 99); 5 May 2008 11:14:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 May 2008 04:14:36 -0700 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, 05 May 2008 11:13:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3B5D5238896B; Mon, 5 May 2008 04:14:11 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r653425 - /incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java Date: Mon, 05 May 2008 11:14:11 -0000 To: sling-commits@incubator.apache.org From: bdelacretaz@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080505111411.3B5D5238896B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bdelacretaz Date: Mon May 5 04:14:10 2008 New Revision: 653425 URL: http://svn.apache.org/viewvc?rev=653425&view=rev Log: SLING-387 - ScriptSelectionTest, more test cases Modified: incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java Modified: incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java?rev=653425&r1=653424&r2=653425&view=diff ============================================================================== --- incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java (original) +++ incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java Mon May 5 04:14:10 2008 @@ -28,12 +28,14 @@ */ public class ScriptSelectionTest extends LocationTestBase { - /** A set of available scripts */ + /** Test set of available scripts */ protected final String [] SET_A = { "/apps/foo/bar/html.esp", "/apps/foo/bar/POST.esp", "/apps/foo/bar/print.esp", - "/apps/foo/bar/print/POST.esp" + "/apps/foo/bar/print/POST.esp", + "/apps/foo/bar/xml.esp", + "/apps/foo/bar/print.xml.esp" }; /** Given a list of available scripts and the request method, selectors @@ -54,10 +56,14 @@ final LocationUtil u = LocationUtil.create(req); final Collection s = u.getScripts(req); - // Verify that the expected script is the first in the list of candidates - assertTrue("Script must be found", s.iterator().hasNext()); - final String scriptPath = s.iterator().next().getResource().getPath(); - assertEquals("First script is the expected one", expectedScript, scriptPath); + if(expectedScript == null) { + assertFalse("No script must be found", s.iterator().hasNext()); + } else { + // Verify that the expected script is the first in the list of candidates + assertTrue("A script must be found", s.iterator().hasNext()); + final String scriptPath = s.iterator().next().getResource().getPath(); + assertEquals("First script is the expected one", expectedScript, scriptPath); + } } public void testHtmlGet() { @@ -68,10 +74,81 @@ assertScript("GET", "print.a4", "html", SET_A, "/apps/foo/bar/print.esp"); } + public void testHtmlGetSingleSelector() { + assertScript("GET", "print", "html", SET_A, "/apps/foo/bar/print.esp"); + } + + public void testHtmlGetHtmlHasPriorityA() { + final String [] scripts = { + "/apps/foo/bar/html.esp", + "/apps/foo/bar/bar.esp" + }; + assertScript("GET", null, "html", scripts, "/apps/foo/bar/html.esp"); + } + + public void testHtmlGetHtmlHasPriorityB() { + final String [] scripts = { + "/apps/foo/bar/bar.esp", + "/apps/foo/bar/html.esp" + }; + assertScript("GET", null, "html", scripts, "/apps/foo/bar/html.esp"); + } + + public void testHtmlGetBarUsedIfFound() { + final String [] scripts = { + "/apps/foo/bar/bar.esp", + "/apps/foo/bar/pdf.esp" + }; + assertScript("GET", null, "html", scripts, "/apps/foo/bar/bar.esp"); + } + + public void testXmlGetSetC() { + assertScript("GET", null, "xml", SET_A, "/apps/foo/bar/xml.esp"); + } + + public void testXmlGetSelectors() { + assertScript("GET", "print.a4", "xml", SET_A, "/apps/foo/bar/print.xml.esp"); + } + + public void testXmlGetSingleSelector() { + assertScript("GET", "print", "xml", SET_A, "/apps/foo/bar/print.xml.esp"); + } + + public void testHtmlGetAppsOverridesLibsA() { + final String [] scripts = { + "/apps/foo/bar/bar.esp", + "/libs/foo/bar/bar.esp" + }; + assertScript("GET", null, "html", scripts, "/apps/foo/bar/bar.esp"); + } + + public void testHtmlGetAppsOverridesLibsB() { + final String [] scripts = { + "/libs/foo/bar/bar.esp", + "/apps/foo/bar/bar.esp" + }; + assertScript("GET", null, "html", scripts, "/apps/foo/bar/bar.esp"); + } + + public void testHtmlGetLibUsedIfFound() { + final String [] scripts = { + "/libs/foo/bar/bar.esp" + }; + assertScript("GET", null, "html", scripts, "/libs/foo/bar/bar.esp"); + } + public void testHtmlPost() { assertScript("POST", null, "html", SET_A, "/apps/foo/bar/POST.esp"); } + public void testHtmlPostBadCaseFindsNoScript() { + final String [] scripts = { + "/apps/foo/bar/html.esp", + "/apps/foo/bar/POst.esp" + }; + assertScript("POST", null, "html", scripts, null); + } + /** CURRENTLY FAILS, SLING-387 public void testHtmlPostSelectors() { assertScript("POST", "print.a4", "html", SET_A, "/apps/foo/bar/print/POST.esp");