You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2015/08/26 15:03:16 UTC

svn commit: r1697923 - in /httpcomponents/httpcore/trunk/httpcore-osgi: pom.xml src/test/java/org/apache/http/osgi/ActuallyConnectIT.java src/test/java/org/apache/http/osgi/Common.java src/test/resources/ src/test/resources/logback.xml

Author: olegk
Date: Wed Aug 26 13:03:16 2015
New Revision: 1697923

URL: http://svn.apache.org/r1697923
Log:
HTTPCORE-406: PAX-EXAM tests with an embedded HTTP server
Contributed by Benson Margulies <benson at basistech.com>

Added:
    httpcomponents/httpcore/trunk/httpcore-osgi/src/test/java/org/apache/http/osgi/ActuallyConnectIT.java   (with props)
    httpcomponents/httpcore/trunk/httpcore-osgi/src/test/resources/
    httpcomponents/httpcore/trunk/httpcore-osgi/src/test/resources/logback.xml   (with props)
Modified:
    httpcomponents/httpcore/trunk/httpcore-osgi/pom.xml
    httpcomponents/httpcore/trunk/httpcore-osgi/src/test/java/org/apache/http/osgi/Common.java

Modified: httpcomponents/httpcore/trunk/httpcore-osgi/pom.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-osgi/pom.xml?rev=1697923&r1=1697922&r2=1697923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-osgi/pom.xml (original)
+++ httpcomponents/httpcore/trunk/httpcore-osgi/pom.xml Wed Aug 26 13:03:16 2015
@@ -39,9 +39,10 @@
   <url>http://hc.apache.org/httpcomponents-core-ga</url>
   <packaging>bundle</packaging>
   <properties>
-      <pax.url.version>2.0.0</pax.url.version>
-      <pax.exam.version>3.5.0</pax.exam.version>
-      <slf4j.version>1.5.4</slf4j.version>
+    <pax.url.version>2.0.0</pax.url.version>
+    <pax.exam.version>3.5.0</pax.exam.version>
+    <slf4j.version>1.5.4</slf4j.version>
+    <logback.version>1.0.1</logback.version>
   </properties>
   <dependencies>
     <dependency>
@@ -50,63 +51,88 @@
       <version>${project.version}</version>
     </dependency>
     <dependency>
-        <groupId>org.apache.httpcomponents</groupId>
-        <artifactId>httpcore</artifactId>
-        <version>${project.version}</version>
-        <type>test-jar</type>
-        <scope>test</scope>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpcore</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.httpcomponents</groupId>
       <artifactId>httpcore-nio</artifactId>
       <version>${project.version}</version>
     </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.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-api</artifactId>
-          <scope>test</scope>
-          <version>${slf4j.version}</version>
-      </dependency>
-      <dependency>
-          <groupId>org.slf4j</groupId>
-          <artifactId>slf4j-log4j12</artifactId>
-          <scope>test</scope>
-          <version>${slf4j.version}</version>
-      </dependency>
-      <dependency>
-          <groupId>org.mockito</groupId>
-          <artifactId>mockito-core</artifactId>
-          <scope>test</scope>
-      </dependency>
-      <dependency>
-          <groupId>commons-logging</groupId>
-          <artifactId>commons-logging</artifactId>
-          <scope>test</scope>
-      </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-container-native</artifactId>
+      <version>${pax.exam.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.osgi</groupId>
+          <artifactId>org.osgi.core</artifactId>
+        </exclusion>
+      </exclusions>
+      <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.ops4j.pax.url</groupId>
+      <artifactId>pax-url-wrap</artifactId>
+      <version>${pax.url.version}</version>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.osgi</groupId>
+          <artifactId>org.osgi.core</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>1.6.4</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-classic</artifactId>
+      <version>${logback.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-core</artifactId>
+      <version>${logback.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.framework</artifactId>
+      <version>4.2.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

Added: httpcomponents/httpcore/trunk/httpcore-osgi/src/test/java/org/apache/http/osgi/ActuallyConnectIT.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-osgi/src/test/java/org/apache/http/osgi/ActuallyConnectIT.java?rev=1697923&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-osgi/src/test/java/org/apache/http/osgi/ActuallyConnectIT.java (added)
+++ httpcomponents/httpcore/trunk/httpcore-osgi/src/test/java/org/apache/http/osgi/ActuallyConnectIT.java Wed Aug 26 13:03:16 2015
@@ -0,0 +1,49 @@
+/*
+ * ====================================================================
+ * 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;
+
+import org.apache.http.integration.TestSyncHttp;
+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;
+
+/**
+ * Use the test methods from TestSyncHttp.
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class ActuallyConnectIT extends TestSyncHttp {
+
+    @Configuration
+    public static Option[] options() {
+        return Common.config();
+    }
+}

Propchange: httpcomponents/httpcore/trunk/httpcore-osgi/src/test/java/org/apache/http/osgi/ActuallyConnectIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore-osgi/src/test/java/org/apache/http/osgi/ActuallyConnectIT.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

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

Modified: httpcomponents/httpcore/trunk/httpcore-osgi/src/test/java/org/apache/http/osgi/Common.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-osgi/src/test/java/org/apache/http/osgi/Common.java?rev=1697923&r1=1697922&r2=1697923&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-osgi/src/test/java/org/apache/http/osgi/Common.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-osgi/src/test/java/org/apache/http/osgi/Common.java Wed Aug 26 13:03:16 2015
@@ -27,8 +27,13 @@
 
 package org.apache.http.osgi;
 
+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 org.ops4j.pax.exam.util.PathUtils;
 
 import java.io.IOException;
 import java.net.URL;
@@ -38,17 +43,18 @@ import static org.ops4j.pax.exam.CoreOpt
 import static org.ops4j.pax.exam.CoreOptions.junitBundles;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.systemPackages;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
 
 /**
  * Test inherit from this.
  */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
 public class Common {
 
     public static String getDependencyVersion(final String groupId, final String artifactId) {
-        final URL depPropsUrl = BasicIT.class.getResource("META-INF/maven/dependencies.properties");
+        final URL depPropsUrl = Common.class.getResource("/META-INF/maven/dependencies.properties");
         final Properties depProps = new Properties();
         try {
             depProps.load(depPropsUrl.openStream());
@@ -65,26 +71,36 @@ public class Common {
 
 
     @Configuration
-    public Option[] config() {
+    public static Option[] config() {
         final String projectVersion = System.getProperty("project.version");
         final String buildDir = System.getProperty("project.build.directory", "target");
         final String paxLoggingLevel = System.getProperty("bt.osgi.pax.logging.level", "WARN");
 
         return options(
-                bundle(String.format("%s/org.apache.httpcomponents.httpcore_%s",
+                bundle(String.format("file:%s/org.apache.httpcomponents.httpcore_%s.jar",
                         buildDir,
                         projectVersion)),
                 wrappedBundle(mavenBundle().groupId("org.apache.httpcomponents")
-                  .artifactId("httpcore")
-                  .version(projectVersion)
-                  .type("test-jar")),
-                mavenBundle("org.mockito", "mockito-core", getDependencyVersion("org.mockito", "mockito-core")),
-                systemPackages(
-                        String.format("org.slf4j;version=\"%s\"", getDependencyVersion("org.slf4j", "slf4j-api"))
-                ),
+                        .artifactId("httpcore")
+                        .version(projectVersion)
+                        .classifier("tests"))
+                .exports("org.apache.http.integration")
+                .imports("org.apache.http.protocol",
+                        "org.apache.http",
+                        "org.apache.http.config",
+                        "org.apache.http.entity",
+                        "org.apache.http.impl",
+                        "org.apache.http.impl.bootstrap",
+                        "org.apache.http.util",
+                        "org.apache.http.message",
+                        "org.apache.commons.logging; provider=paxlogging",
+                        "org.junit"),
                 junitBundles(),
                 systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
-                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(paxLoggingLevel)
+                systemProperty("pax.exam.logging").value("none"),
+                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value(paxLoggingLevel),
+                systemProperty("logback.configurationFile")
+                        .value("file:" + PathUtils.getBaseDir() + "/src/test/resources/logback.xml")
         );
     }
 }

Added: httpcomponents/httpcore/trunk/httpcore-osgi/src/test/resources/logback.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-osgi/src/test/resources/logback.xml?rev=1697923&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-osgi/src/test/resources/logback.xml (added)
+++ httpcomponents/httpcore/trunk/httpcore-osgi/src/test/resources/logback.xml Wed Aug 26 13:03:16 2015
@@ -0,0 +1,36 @@
+<?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.
+   ====================================================================
+
+   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 />.
+ -->
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
+        </encoder>
+    </appender>
+    <root level="INFO">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>

Propchange: httpcomponents/httpcore/trunk/httpcore-osgi/src/test/resources/logback.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore-osgi/src/test/resources/logback.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpcore/trunk/httpcore-osgi/src/test/resources/logback.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml