incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1053035 - in /sling/trunk/launchpad: integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ test-services/ test-services/src/main/java/org/apache/sling/launchpad/testservices/resource/
Date Mon, 27 Dec 2010 09:56:23 GMT
Author: bdelacretaz
Date: Mon Dec 27 09:56:22 2010
New Revision: 1053035

URL: http://svn.apache.org/viewvc?rev=1053035&view=rev
Log:
SLING-1902 - integration test for ResourceDecorator

Added:
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ResourceDecoratorTest.java
  (with props)
    sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/resource/
    sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/resource/TestResourceDecorator.java
  (with props)
Modified:
    sling/trunk/launchpad/test-services/pom.xml

Added: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ResourceDecoratorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ResourceDecoratorTest.java?rev=1053035&view=auto
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ResourceDecoratorTest.java
(added)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ResourceDecoratorTest.java
Mon Dec 27 09:56:22 2010
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+import org.apache.sling.commons.testing.integration.HttpTestBase;
+
+public class ResourceDecoratorTest extends HttpTestBase {
+    
+    public void testDecoratedResource() throws Exception {
+        final String path = "/testing/TestResourceDecorator/resource" + System.currentTimeMillis();
+        final TestNode tn = new TestNode(HTTP_BASE_URL + path, null);
+        final String content = getContent(tn.nodeUrl + ".txt", CONTENT_TYPE_PLAIN);
+        final String expect = "TEST_RESOURCE_DECORATOR_RESOURCE_TYPE";
+        assertTrue("Expecting content to contain " + expect + " (" + content + ")", content.contains(expect));
+    }
+}

Propchange: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ResourceDecoratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ResourceDecoratorTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: sling/trunk/launchpad/test-services/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/pom.xml?rev=1053035&r1=1053034&r2=1053035&view=diff
==============================================================================
--- sling/trunk/launchpad/test-services/pom.xml (original)
+++ sling/trunk/launchpad/test-services/pom.xml Mon Dec 27 09:56:22 2010
@@ -95,7 +95,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.0.8</version>
+            <version>2.1.0</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>

Added: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/resource/TestResourceDecorator.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/resource/TestResourceDecorator.java?rev=1053035&view=auto
==============================================================================
--- sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/resource/TestResourceDecorator.java
(added)
+++ sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/resource/TestResourceDecorator.java
Mon Dec 27 09:56:22 2010
@@ -0,0 +1,53 @@
+/*
+ * 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.resource;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceDecorator;
+import org.apache.sling.api.resource.ResourceWrapper;
+
+/** Test ResourceDecorator that sets a specific resource type
+ *  for resources having a path that starts
+ *  with /testing + simple name of this class + /
+ */
+@Component
+@Service
+public class TestResourceDecorator implements ResourceDecorator {
+
+    private final String PATH = "/testing/" + getClass().getSimpleName() + "/";
+    private final String RESOURCE_TYPE = "TEST_RESOURCE_DECORATOR_RESOURCE_TYPE";
+    
+    public Resource decorate(Resource resource, HttpServletRequest request) {
+        return decorate(resource);
+    }
+
+    public Resource decorate(Resource resource) {
+        if(resource.getPath().startsWith(PATH)) {
+            return new ResourceWrapper(resource) {
+                @Override
+                public String getResourceType() {
+                    return RESOURCE_TYPE;
+                }
+            };
+        }
+        return resource;
+    }
+}

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

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



Mime
View raw message