You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2015/12/07 17:08:48 UTC
svn commit: r1718418 - in /sling/whiteboard/bdelacretaz/testing-techniques:
./ http-and-teleported/ http-and-teleported/src/
http-and-teleported/src/main/ http-and-teleported/src/main/java/
http-and-teleported/src/main/java/org/ http-and-teleported/src...
Author: bdelacretaz
Date: Mon Dec 7 16:08:47 2015
New Revision: 1718418
URL: http://svn.apache.org/viewvc?rev=1718418&view=rev
Log:
Testing techniques sample, work in progress
Added:
sling/whiteboard/bdelacretaz/testing-techniques/ (with props)
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/ (with props)
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/pom.xml
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/ResourceMimeTypeDetector.java
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/impl/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/impl/MimeTypeServlet.java
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/impl/ResourceMimeTypeDetectorImpl.java
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/test/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/test/java/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/test/java/org/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/test/java/org/apache/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/test/java/org/apache/sling/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/test/java/org/apache/sling/sample/
sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/test/java/org/apache/sling/sample/testingtechniques/
sling/whiteboard/bdelacretaz/testing-techniques/pom.xml
Propchange: sling/whiteboard/bdelacretaz/testing-techniques/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Dec 7 16:08:47 2015
@@ -0,0 +1,14 @@
+target
+bin
+derby.log
+*.iml
+*.ipr
+*.iws
+.settings
+.project
+.classpath
+.externalToolBuilders
+maven-eclipse.xml
+
+
+
Propchange: sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Dec 7 16:08:47 2015
@@ -0,0 +1,14 @@
+target
+bin
+derby.log
+*.iml
+*.ipr
+*.iws
+.settings
+.project
+.classpath
+.externalToolBuilders
+maven-eclipse.xml
+
+
+
Added: sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/pom.xml?rev=1718418&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/pom.xml (added)
+++ sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/pom.xml Mon Dec 7 16:08:47 2015
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>25</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.samples.testing.techniques.http-and-teleported</artifactId>
+ <version>0.9.9-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <name>Apache Sling Testing Techniques Samples - HTTP and Teleported tests</name>
+
+ <description>
+ This sample module shows how to use both HTTP and teleported tests
+ to validate both a service and a servlet in its Sling bundle.
+ </description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.4.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.mime</artifactId>
+ <version>2.1.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/ResourceMimeTypeDetector.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/ResourceMimeTypeDetector.java?rev=1718418&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/ResourceMimeTypeDetector.java (added)
+++ sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/ResourceMimeTypeDetector.java Mon Dec 7 16:08:47 2015
@@ -0,0 +1,26 @@
+/*
+ * 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.sample.testingtechniques;
+
+import org.apache.sling.api.resource.Resource;
+
+/** A simplistic service that computes the mime-type of
+ * a Resource based on its path.
+ */
+public interface ResourceMimeTypeDetector {
+ String getMimeType(Resource r);
+}
Added: sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/impl/MimeTypeServlet.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/impl/MimeTypeServlet.java?rev=1718418&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/impl/MimeTypeServlet.java (added)
+++ sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/impl/MimeTypeServlet.java Mon Dec 7 16:08:47 2015
@@ -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.sample.testingtechniques.impl;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.sling.SlingServlet;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
+import org.apache.sling.sample.testingtechniques.ResourceMimeTypeDetector;
+
+/** Servlet that uses the ResourceMimeTypeDetector to output
+ * the mime-type of the current Resource.
+ */
+@SlingServlet(
+ resourceTypes="sling/servlet/default",
+ selectors="mimetype",
+ extensions="txt",
+ methods="GET")
+public class MimeTypeServlet extends SlingSafeMethodsServlet {
+ private static final long serialVersionUID = 7373752152329079226L;
+
+ @Reference
+ ResourceMimeTypeDetector detector;
+
+ @Override
+ protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/plain");
+ response.setCharacterEncoding("UTF-8");
+ final String mimeType = detector.getMimeType(request.getResource());
+ response.getWriter().write(String.valueOf(mimeType));
+ }
+}
\ No newline at end of file
Added: sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/impl/ResourceMimeTypeDetectorImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/impl/ResourceMimeTypeDetectorImpl.java?rev=1718418&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/impl/ResourceMimeTypeDetectorImpl.java (added)
+++ sling/whiteboard/bdelacretaz/testing-techniques/http-and-teleported/src/main/java/org/apache/sling/sample/testingtechniques/impl/ResourceMimeTypeDetectorImpl.java Mon Dec 7 16:08:47 2015
@@ -0,0 +1,39 @@
+/*
+ * 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.sample.testingtechniques.impl;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.commons.mime.MimeTypeService;
+import org.apache.sling.sample.testingtechniques.ResourceMimeTypeDetector;
+
+/** ResourceMimeTypeDetector that uses the Sling
+ * MimeTypeService.
+ */
+@Component
+@Service(value=ResourceMimeTypeDetector.class)
+public class ResourceMimeTypeDetectorImpl implements ResourceMimeTypeDetector {
+
+ @Reference
+ MimeTypeService mimeTypeService;
+
+ public String getMimeType(Resource r) {
+ return mimeTypeService.getMimeType(r.getPath());
+ }
+}
Added: sling/whiteboard/bdelacretaz/testing-techniques/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/testing-techniques/pom.xml?rev=1718418&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/testing-techniques/pom.xml (added)
+++ sling/whiteboard/bdelacretaz/testing-techniques/pom.xml Mon Dec 7 16:08:47 2015
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>25</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.samples.testing.techniques.reactor</artifactId>
+ <version>0.9.9-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>Apache Sling Testing Techniques Samples - Reactor</name>
+ <description>
+ The modules found under this folder demonstrate
+ various Sling testing techniques.
+ </description>
+
+ <modules>
+ <module>http-and-teleported</module>
+ </modules>
+</project>