This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.commons.contentdetection-1.0.2 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-contentdetection.git
commit 3924f4776d86f77916b0664e4b49e6280d7c54b3 Author: Bertrand Delacretaz <[email protected]> AuthorDate: Mon Jun 1 12:33:57 2015 +0000 SLING-4757 - new integration tests for commons.contentdetection, contributed by Petr Shypila, thanks! git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/contentdetection@1682886 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 75 +++++++++++++++++++++- .../it/ContentAwareMimeTypeServiceImplIT.java | 56 ++++++++++++++++ .../internal/it/FileNameExtractorImplIT.java | 56 ++++++++++++++++ 3 files changed, 186 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 402731b..97b87ea 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,6 @@ <relativePath>../../../parent/pom.xml</relativePath> </parent> - <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.commons.contentdetection</artifactId> <version>0.9.9-SNAPSHOT</version> <packaging>bundle</packaging> @@ -37,6 +36,12 @@ <description>Content-based MIME type detection</description> <properties> + <exam.version>3.4.0</exam.version> + <url.version>1.5.2</url.version> + <org.ops4j.pax.logging.DefaultServiceLog.level>INFO</org.ops4j.pax.logging.DefaultServiceLog.level> + <bundle.file.name>${basedir}/target/${project.build.finalName}.jar</bundle.file.name> + <sling.java.version>6</sling.java.version> + <sling.launchpad.version>7</sling.launchpad.version> <powermock.version>1.6.2</powermock.version> </properties> @@ -96,6 +101,48 @@ <version>${powermock.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.launchpad</artifactId> + <version>${sling.launchpad.version}</version> + <type>xml</type> + <classifier>bundlelist</classifier> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.paxexam.util</artifactId> + <version>1.0.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-container-native</artifactId> + <version>${exam.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>pax-exam-link-mvn</artifactId> + <version>${exam.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.framework</artifactId> + <version>4.2.1</version> + <scope>test</scope> + </dependency> </dependencies> <build> @@ -116,6 +163,32 @@ <artifactId>apache-rat-plugin</artifactId> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + <configuration> + <systemPropertyVariables> + <org.ops4j.pax.logging.DefaultServiceLog.level>${org.ops4j.pax.logging.DefaultServiceLog.level}</org.ops4j.pax.logging.DefaultServiceLog.level> + <pax.exam.log.level>${pax.exam.log.level}</pax.exam.log.level> + <java.protocol.handler.pkgs>org.ops4j.pax.url</java.protocol.handler.pkgs> + <bundle.file.name>${bundle.file.name}</bundle.file.name> + <sling.launchpad.version>${sling.launchpad.version}</sling.launchpad.version> + </systemPropertyVariables> + <classpathDependencyExcludes> + <!-- The osgi.org dependencies cause trouble with pax exam --> + <classpathDependencyExcludes>org.osgi:org.osgi.core</classpathDependencyExcludes> + <classpathDependencyExcludes>org.osgi:org.osgi.compendium</classpathDependencyExcludes> + </classpathDependencyExcludes> + </configuration> + </plugin> </plugins> </build> diff --git a/src/test/java/org/apache/sling/commons/contentdetection/internal/it/ContentAwareMimeTypeServiceImplIT.java b/src/test/java/org/apache/sling/commons/contentdetection/internal/it/ContentAwareMimeTypeServiceImplIT.java new file mode 100644 index 0000000..82fe4b9 --- /dev/null +++ b/src/test/java/org/apache/sling/commons/contentdetection/internal/it/ContentAwareMimeTypeServiceImplIT.java @@ -0,0 +1,56 @@ +/* + * 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.commons.contentdetection.internal.it; + +import org.apache.sling.commons.contentdetection.ContentAwareMimeTypeService; +import org.apache.sling.paxexam.util.SlingPaxOptions; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.CoreOptions; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.options.DefaultCompositeOption; + +import javax.inject.Inject; +import java.io.File; + +import static org.junit.Assert.*; + +@RunWith(PaxExam.class) +public class ContentAwareMimeTypeServiceImplIT { + + @Inject + private ContentAwareMimeTypeService contentAwaremimeTypeService; + + @Test + public void testContentAwareMimeTypeService(){ + String mimeTypeName = "test.mp3"; + String mimeType = "audio/mpeg"; + assertEquals(mimeType, contentAwaremimeTypeService.getMimeType(mimeTypeName)); + } + + @org.ops4j.pax.exam.Configuration + public Option[] config() { + final File thisProjectsBundle = new File(System.getProperty( "bundle.file.name", "BUNDLE_FILE_NOT_SET" )); + final String launchpadVersion = System.getProperty("sling.launchpad.version", "LAUNCHPAD_VERSION_NOT_SET"); + return new DefaultCompositeOption( + SlingPaxOptions.defaultLaunchpadOptions(launchpadVersion), + CoreOptions.provision(CoreOptions.bundle(thisProjectsBundle.toURI().toString())) + ).getOptions(); + } +} diff --git a/src/test/java/org/apache/sling/commons/contentdetection/internal/it/FileNameExtractorImplIT.java b/src/test/java/org/apache/sling/commons/contentdetection/internal/it/FileNameExtractorImplIT.java new file mode 100644 index 0000000..e0e55fb --- /dev/null +++ b/src/test/java/org/apache/sling/commons/contentdetection/internal/it/FileNameExtractorImplIT.java @@ -0,0 +1,56 @@ +/* + * 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.commons.contentdetection.internal.it; + +import org.apache.sling.commons.contentdetection.FileNameExtractor; +import org.apache.sling.paxexam.util.SlingPaxOptions; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.CoreOptions; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.options.DefaultCompositeOption; + +import javax.inject.Inject; +import java.io.File; + +import static org.junit.Assert.*; + +@RunWith(PaxExam.class) +public class FileNameExtractorImplIT { + + @Inject + private FileNameExtractor fileNameExtractor; + + @Test + public void testFileNameExtractor(){ + String rawPath = "http://midches.com/images/uploads/default/demo.jpg#anchor?query=test"; + String expectedFileName = "demo.jpg"; + assertEquals(expectedFileName, fileNameExtractor.extract(rawPath)); + } + + @org.ops4j.pax.exam.Configuration + public Option[] config() { + final File thisProjectsBundle = new File(System.getProperty( "bundle.file.name", "BUNDLE_FILE_NOT_SET" )); + final String launchpadVersion = System.getProperty("sling.launchpad.version", "LAUNCHPAD_VERSION_NOT_SET"); + return new DefaultCompositeOption( + SlingPaxOptions.defaultLaunchpadOptions(launchpadVersion), + CoreOptions.provision(CoreOptions.bundle(thisProjectsBundle.toURI().toString())) + ).getOptions(); + } +} -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
