incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r814589 - in /sling/trunk/launchpad: test-services/src/main/java/org/apache/sling/launchpad/testservices/servlets/ testing/ testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/
Date Mon, 14 Sep 2009 11:38:51 GMT
Author: bdelacretaz
Date: Mon Sep 14 11:38:50 2009
New Revision: 814589

URL: http://svn.apache.org/viewvc?rev=814589&view=rev
Log:
(basic) OptingServlet integration test

Added:
    sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/servlets/RequestUriOptingServlet.java
  (with props)
    sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/RequestUriOptingServletTest.java
  (with props)
Modified:
    sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/servlets/TestServlet.java
    sling/trunk/launchpad/testing/pom.xml
    sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/ResolutionTestBase.java

Added: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/servlets/RequestUriOptingServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/servlets/RequestUriOptingServlet.java?rev=814589&view=auto
==============================================================================
--- sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/servlets/RequestUriOptingServlet.java
(added)
+++ sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/servlets/RequestUriOptingServlet.java
Mon Sep 14 11:38:50 2009
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.launchpad.testservices.servlets;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.servlets.OptingServlet;
+
+/** OptingServlet that uses the RequestURI to opt in
+ *  
+ *  @scr.component immediate="true" metatype="no"
+ *  @scr.service interface="javax.servlet.Servlet"
+ * 
+ *  @scr.property name="service.description" value="Request URI Opting Test Servlet"
+ *  @scr.property name="service.vendor" value="The Apache Software Foundation"
+ * 
+ *  @scr.property name="sling.servlet.resourceTypes"
+ *                  values.0="sling/servlet/default"
+ *                  values.1="sling/nonexisting"
+ *  @scr.property name="sling.servlet.methods" 
+ *                  values.0="POST" 
+ *                  values.1="GET" 
+ */
+@SuppressWarnings("serial")
+public class RequestUriOptingServlet extends TestServlet implements OptingServlet {
+
+    public boolean accepts(SlingHttpServletRequest request) {
+        // Use a fake selector to opt in. Not really useful, this
+    	// is just a test of the opting mechanism.
+        return request.getRequestURI().contains(".RequestUriOptingServlet.html");
+    }
+}

Propchange: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/servlets/RequestUriOptingServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/servlets/RequestUriOptingServlet.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/servlets/TestServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/servlets/TestServlet.java?rev=814589&r1=814588&r2=814589&view=diff
==============================================================================
--- sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/servlets/TestServlet.java
(original)
+++ sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/servlets/TestServlet.java
Mon Sep 14 11:38:50 2009
@@ -39,6 +39,12 @@
     dumpRequestAsProperties(request, response);
   }
   
+  @Override
+  protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)

+  throws ServletException, IOException {
+    dumpRequestAsProperties(request, response);
+  }
+  
   protected void dumpRequestAsProperties(SlingHttpServletRequest request, SlingHttpServletResponse
response) throws IOException {
     final Properties props = new Properties();
     response.setContentType("text/plain");

Modified: sling/trunk/launchpad/testing/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/pom.xml?rev=814589&r1=814588&r2=814589&view=diff
==============================================================================
--- sling/trunk/launchpad/testing/pom.xml (original)
+++ sling/trunk/launchpad/testing/pom.xml Mon Sep 14 11:38:50 2009
@@ -494,7 +494,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.launchpad.test-services</artifactId>
-            <version>2.0.6-incubator</version>
+            <version>2.0.7-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

Added: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/RequestUriOptingServletTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/RequestUriOptingServletTest.java?rev=814589&view=auto
==============================================================================
--- sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/RequestUriOptingServletTest.java
(added)
+++ sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/RequestUriOptingServletTest.java
Mon Sep 14 11:38:50 2009
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.launchpad.webapp.integrationtest.servlets.resolution;
+
+import org.apache.commons.httpclient.methods.PostMethod;
+
+/** Test the RequestUriOptingServlet resolution */
+public class RequestUriOptingServletTest extends ResolutionTestBase {
+    public static final String TEST_URL_SUFFIX = ".RequestUriOptingServlet.html";
+    
+    public void testPostMethodExistingResource() throws Exception {
+        final PostMethod post = new PostMethod(testNodeNORT.nodeUrl + TEST_URL_SUFFIX);
+        final int status = httpClient.executeMethod(post);
+        assertEquals("PUT should return 200", 200, status);
+        final String content = post.getResponseBodyAsString();
+        assertServlet(content, REQUEST_URI_OPTING_SERVLET_SUFFIX);
+    }
+    
+    public void testPuttMethodNonExistingResource() throws Exception {
+        final PostMethod post = new PostMethod(NONEXISTING_RESOURCE_URL + TEST_URL_SUFFIX);
+        final int status = httpClient.executeMethod(post);
+        assertEquals("PUT should return 200", 200, status);
+        final String content = post.getResponseBodyAsString();
+        assertServlet(content, REQUEST_URI_OPTING_SERVLET_SUFFIX);
+    }
+    
+    public void testGetMethodExistingResource() throws Exception {
+        assertServlet(
+                getContent(testNodeNORT.nodeUrl + TEST_URL_SUFFIX, CONTENT_TYPE_PLAIN),
+                REQUEST_URI_OPTING_SERVLET_SUFFIX);
+    }
+    
+    public void testGetMethodNonExistingResource() throws Exception {
+        assertServlet(
+                getContent(NONEXISTING_RESOURCE_URL + TEST_URL_SUFFIX, CONTENT_TYPE_PLAIN),
+                REQUEST_URI_OPTING_SERVLET_SUFFIX);
+    }
+}
\ No newline at end of file

Propchange: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/RequestUriOptingServletTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/RequestUriOptingServletTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/ResolutionTestBase.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/ResolutionTestBase.java?rev=814589&r1=814588&r2=814589&view=diff
==============================================================================
--- sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/ResolutionTestBase.java
(original)
+++ sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolution/ResolutionTestBase.java
Mon Sep 14 11:38:50 2009
@@ -31,12 +31,14 @@
   public static final String TEST_SERVLET_MARKER = "created by org.apache.sling.launchpad.testservices.servlets";
   public static final String TEST_RESOURCE_TYPE = "LAUNCHPAD_TEST_ResourceType";
   public static final String TEST_PATH = "/servlet-resolution-tests/" + System.currentTimeMillis();
+  public static final String NONEXISTING_RESOURCE_URL = HTTP_BASE_URL + TEST_PATH + "/NonExistingResource";

    
   public static final String EXT_SERVLET_SUFFIX = "testservices.servlets.ExtensionServlet";
   public static final String SEL_SERVLET_SUFFIX = "testservices.servlets.SelectorServlet";
   public static final String PREFIX_0_SERVLET_SUFFIX = "testservices.servlets.PrefixServletZero";
   public static final String PREFIX_M1_SERVLET_SUFFIX = "testservices.servlets.PrefixServletMinusOne";
   public static final String PUT_SERVLET_SUFFIX = "testservices.servlets.PutMethodServlet";
+  public static final String REQUEST_URI_OPTING_SERVLET_SUFFIX = "testservices.servlets.RequestUriOptingServlet";
   
   protected TestNode testNodeNORT;
   protected TestNode testNodeRT;



Mime
View raw message