hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1696144 - in /httpcomponents/httpclient/trunk/httpclient-osgi: pom.xml src/test/java/org/apache/http/osgi/impl/MimeExportedIT.java src/test/resources/ src/test/resources/log4j.properties
Date Sun, 16 Aug 2015 14:19:30 GMT
Author: olegk
Date: Sun Aug 16 14:19:30 2015
New Revision: 1696144

URL: http://svn.apache.org/r1696144
Log:
HTTPCLIENT-1673: revert change, which was not necessary
and add test that proves that it's not necessary.
Mostly provide bones of future OSGi tests.

Added:
    httpcomponents/httpclient/trunk/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/MimeExportedIT.java
  (with props)
    httpcomponents/httpclient/trunk/httpclient-osgi/src/test/resources/
    httpcomponents/httpclient/trunk/httpclient-osgi/src/test/resources/log4j.properties  
(with props)
Modified:
    httpcomponents/httpclient/trunk/httpclient-osgi/pom.xml

Modified: httpcomponents/httpclient/trunk/httpclient-osgi/pom.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-osgi/pom.xml?rev=1696144&r1=1696143&r2=1696144&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-osgi/pom.xml (original)
+++ httpcomponents/httpclient/trunk/httpclient-osgi/pom.xml Sun Aug 16 14:19:30 2015
@@ -42,6 +42,10 @@
   <properties>
     <httpcore.osgi.import.version>"[4.4.0, 4.5.0)"</httpcore.osgi.import.version>
     <commons-logging.osgi.import.version>"[1.1.0, 1.3.0)"</commons-logging.osgi.import.version>
+    <pax.url.version>2.4.1</pax.url.version>
+    <pax.exam.version>4.5.0</pax.exam.version>
+    <osgi.framework.version>5.0.0</osgi.framework.version>
+    <slf4j.version>1.7.5</slf4j.version>
   </properties>
 
   <dependencies>
@@ -49,48 +53,49 @@
       <groupId>org.apache.httpcomponents</groupId>
       <artifactId>httpclient</artifactId>
       <version>${project.version}</version>
-      <scope>compile</scope>
     </dependency>
+      <!-- Depend on the OSGi bundle - the bundle plugin knows what to do. -->
     <dependency>
       <groupId>org.apache.httpcomponents</groupId>
-      <artifactId>httpcore</artifactId>
-      <scope>provided</scope>
+      <artifactId>httpcore-osgi</artifactId>
+      <version>${httpcore.version}</version>
+        <exclusions>
+          <exclusion>
+              <groupId>org.apache.httpcomponents</groupId>
+              <artifactId>httpcore-nio</artifactId>
+          </exclusion>
+        </exclusions>
     </dependency>
     <dependency>
       <groupId>commons-codec</groupId>
       <artifactId>commons-codec</artifactId>
       <version>${commons-codec.version}</version>
-      <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.httpcomponents</groupId>
       <artifactId>httpmime</artifactId>
       <version>${project.version}</version>
-      <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.httpcomponents</groupId>
       <artifactId>httpclient-cache</artifactId>
       <version>${project.version}</version>
-      <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.httpcomponents</groupId>
       <artifactId>fluent-hc</artifactId>
       <version>${project.version}</version>
-      <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.core</artifactId>
-      <version>4.2.0</version>
+      <version>${osgi.framework.version}</version>
       <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.compendium</artifactId>
-      <version>4.2.0</version>
-      <scope>provided</scope>
+      <version>${osgi.framework.version}</version>
     </dependency>
     <!-- test dependencies, mainly OSGi runtime environment -->
     <dependency>
@@ -98,6 +103,42 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+      <dependency>
+          <groupId>org.ops4j.pax.exam</groupId>
+          <artifactId>pax-exam-container-native</artifactId>
+          <version>${pax.exam.version}</version>
+          <scope>test</scope>
+      </dependency>
+      <dependency>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>org.apache.felix.framework</artifactId>
+          <version>5.0.1</version>
+          <scope>test</scope>
+      </dependency>
+      <dependency>
+          <groupId>org.ops4j.pax.exam</groupId>
+          <artifactId>pax-exam-junit4</artifactId>
+          <scope>test</scope>
+          <version>${pax.exam.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>org.ops4j.pax.exam</groupId>
+          <artifactId>pax-exam-link-mvn</artifactId>
+          <scope>test</scope>
+          <version>${pax.exam.version}</version>
+      </dependency>
+      <dependency>
+          <groupId>org.ops4j.pax.url</groupId>
+          <artifactId>pax-url-aether</artifactId>
+          <version>${pax.url.version}</version>
+          <scope>test</scope>
+      </dependency>
+      <dependency>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-log4j12</artifactId>
+          <version>${slf4j.version}</version>
+          <scope>test</scope>
+      </dependency>
   </dependencies>
 
   <build>
@@ -107,6 +148,29 @@
       </resource>
     </resources>
     <plugins>
+        <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-dependency-plugin</artifactId>
+            <executions>
+                <execution>
+                    <id>copy-bundles</id>
+                    <phase>generate-test-resources</phase>
+                    <goals>
+                        <goal>copy-dependencies</goal>
+                    </goals>
+                    <configuration>
+                        <outputDirectory>${project.build.directory}/bundles</outputDirectory>
+                        <!--
+                          Exclude the ones that are not OSGi
+                          components, plus OSGi itself.
+                      -->
+                        <excludeGroupIds>org.slf4j</excludeGroupIds>
+                        <excludeArtifactIds>httpclient,httpmime,httpclient-cache,fluent-hc,httpcore,org.osgi.core</excludeArtifactIds>
+                        <includeScope>compile</includeScope>
+                    </configuration>
+                </execution>
+            </executions>
+        </plugin>
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
@@ -173,6 +237,26 @@
           <skip>true</skip>
         </configuration>
       </plugin>
+        <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-failsafe-plugin</artifactId>
+            <version>2.18.1</version>
+            <executions>
+                <execution>
+                    <goals>
+                        <goal>integration-test</goal>
+                        <goal>verify</goal>
+                    </goals>
+                    <configuration>
+                        <systemPropertyVariables>
+                            <java.awt.headless>true</java.awt.headless>
+                            <project.build.directory>${project.build.directory}</project.build.directory>
+                            <project.version>${project.version}</project.version>
+                        </systemPropertyVariables>
+                    </configuration>
+                </execution>
+            </executions>
+        </plugin>
     </plugins>
     <finalName>org.apache.httpcomponents.httpclient_${project.version}</finalName>
   </build>

Added: httpcomponents/httpclient/trunk/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/MimeExportedIT.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/MimeExportedIT.java?rev=1696144&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/MimeExportedIT.java
(added)
+++ httpcomponents/httpclient/trunk/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/MimeExportedIT.java
Sun Aug 16 14:19:30 2015
@@ -0,0 +1,93 @@
+/*
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.osgi.impl;
+
+import org.apache.http.entity.mime.content.ByteArrayBody;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+/**
+ * pax-exam test for the OSGi packaging of the client.
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class MimeExportedIT {
+
+    @Configuration
+    public Option[] config() {
+        final String projectBuildDirectory = System.getProperty("project.build.directory",
"target");
+        final String projectVersion = System.getProperty("project.version");
+
+        final List<String> bundleUrls = new ArrayList<String>();
+        final File bundleDir = new File(projectBuildDirectory, "bundles");
+        final File[] bundleFiles = bundleDir.listFiles(new FilenameFilter() {
+            @Override
+            public boolean accept(final File dir, final String name) {
+                return name.endsWith(".jar");
+            }
+        });
+        for (File bundleFile : bundleFiles) {
+            try {
+                bundleUrls.add(bundleFile.toURI().toURL().toExternalForm());
+            } catch (MalformedURLException e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+        bundleUrls.add(String.format("file:%s/org.apache.httpcomponents.httpclient_%s.jar",
projectBuildDirectory, projectVersion));
+
+        final String[] bundles = bundleUrls.toArray(new String[bundleUrls.size()]);
+        return options(
+                provision(bundles),
+                junitBundles(),
+                systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
+                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+        );
+    }
+
+    @Test
+    public void useContentBody() {
+       new ByteArrayBody(new byte[0], "filename.txt");
+    }
+}

Propchange: httpcomponents/httpclient/trunk/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/MimeExportedIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/MimeExportedIT.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient-osgi/src/test/java/org/apache/http/osgi/impl/MimeExportedIT.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: httpcomponents/httpclient/trunk/httpclient-osgi/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-osgi/src/test/resources/log4j.properties?rev=1696144&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-osgi/src/test/resources/log4j.properties (added)
+++ httpcomponents/httpclient/trunk/httpclient-osgi/src/test/resources/log4j.properties Sun
Aug 16 14:19:30 2015
@@ -0,0 +1,27 @@
+# * ====================================================================
+# * 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.
+# * ====================================================================\
+
+log4j.rootLogger=WARN, A1
+
+# A1 is set to be a ConsoleAppender.
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

Propchange: httpcomponents/httpclient/trunk/httpclient-osgi/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient-osgi/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient-osgi/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message