Author: markt
Date: Wed Jul 30 06:44:00 2014
New Revision: 1614560

URL: http://svn.apache.org/r1614560
Log:
Make the execution of the OpenSSL tests depend on the presence of an OpenSSL 
binary.
By default, the tests look on the current path for the binary but an option 
exists to explicitly define the path as well.

Modified:
    tomcat/trunk/build.xml
    tomcat/trunk/test/org/apache/tomcat/util/net/jsse/openssl/TestCipher.java

Modified: tomcat/trunk/build.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/build.xml?rev=1614560&r1=1614559&r2=1614560&view=diff
==============================================================================
--- tomcat/trunk/build.xml (original)
+++ tomcat/trunk/build.xml Wed Jul 30 06:44:00 2014
@@ -1336,25 +1336,25 @@
   </target>
 
   <target name="test-bio" description="Runs the JUnit test cases for BIO. Does 
not stop on errors."
-          depends="test-compile,deploy,cobertura-instrument" 
if="${execute.test.bio}">
+          
depends="test-compile,deploy,cobertura-instrument,test-openssl-exists" 
if="${execute.test.bio}">
     <runtests protocol="org.apache.coyote.http11.Http11Protocol"
               extension=".BIO" />
   </target>
 
   <target name="test-nio" description="Runs the JUnit test cases for NIO. Does 
not stop on errors."
-          depends="test-compile,deploy,cobertura-instrument" 
if="${execute.test.nio}">
+          
depends="test-compile,deploy,cobertura-instrument,test-openssl-exists" 
if="${execute.test.nio}">
     <runtests protocol="org.apache.coyote.http11.Http11NioProtocol"
               extension=".NIO" />
   </target>
 
   <target name="test-nio2" description="Runs the JUnit test cases for NIO2. 
Does not stop on errors."
-          depends="test-compile,deploy,cobertura-instrument" 
if="${execute.test.nio2}">
+          
depends="test-compile,deploy,cobertura-instrument,test-openssl-exists" 
if="${execute.test.nio2}">
     <runtests protocol="org.apache.coyote.http11.Http11Nio2Protocol"
               extension=".NIO2" />
   </target>
 
   <target name="test-apr" description="Runs the JUnit test cases for APR. Does 
not stop on errors."
-          depends="test-compile,deploy,test-apr-exists,cobertura-instrument"
+          
depends="test-compile,deploy,test-apr-exists,cobertura-instrument,test-openssl-exists"
           if="${apr.exists}">
     <runtests protocol="org.apache.coyote.http11.Http11AprProtocol"
               extension=".APR" />
@@ -1365,6 +1365,24 @@
     <available file="${test.apr.loc}" property="apr.exists" />
   </target>
 
+  <target name="test-openssl-exists" description="Checks for the OpenSSL 
binary">
+    <property environment="env" />
+    <condition property="test.openssl.exists">
+      <or>
+        <and>
+          <isset property="test.openssl.path"/>
+          <available file="${test.openssl.path}" 
property="test.openssl.exists"/>
+        </and>
+        <and>
+          <not>
+            <isset property="test.openssl.path"/>
+          </not>
+          <available file="openssl" filepath="${env.PATH}" 
property="test.openssl.exists"/>
+        </and>
+      </or>
+    </condition>
+  </target>
+
   <macrodef name="runtests"
             description="Runs the unit tests using the specified connector.
               Does not stop on errors, but sets 'test.result.error' and 
'test.result.failure' properties.">
@@ -1393,6 +1411,7 @@
         <sysproperty key="tomcat.test.protocol" value="@{protocol}" />
         <sysproperty key="tomcat.test.accesslog" value="${test.accesslog}" />
         <sysproperty key="tomcat.test.reports" value="${test.reports}" />
+        <sysproperty key="tomcat.test.openssl.path" 
value="${test.openssl.path}" />
         <!-- File for Cobertura to write coverage results to -->
         <sysproperty key="net.sourceforge.cobertura.datafile" 
file="${cobertura.datafile}" />
 
@@ -1415,6 +1434,8 @@
             <exclude name="**/Tester*.java" />
             <!-- Exclude the tests known to fail -->
             <exclude name="org/apache/catalina/tribes/test/**" />
+            <!-- Exclude the OpenSSL tests unless OpenSSL is available -->
+            <exclude name="org/apache/tomcat/util/net/jsse/openssl/**" 
unless="${test.openssl.exists}"/>
           </fileset>
         </batchtest>
       </junit>

Modified: 
tomcat/trunk/test/org/apache/tomcat/util/net/jsse/openssl/TestCipher.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/net/jsse/openssl/TestCipher.java?rev=1614560&r1=1614559&r2=1614560&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/net/jsse/openssl/TestCipher.java 
(original)
+++ tomcat/trunk/test/org/apache/tomcat/util/net/jsse/openssl/TestCipher.java 
Wed Jul 30 06:44:00 2014
@@ -24,7 +24,6 @@ import java.util.List;
 import java.util.Set;
 
 import org.junit.Assert;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import org.apache.catalina.util.IOTools;
@@ -38,8 +37,7 @@ public class TestCipher {
      * not to be supported by JSSE.
      */
     @Test
-    @Ignore //FIXME: enable the test
-    public void testAllOpenSSlCiphersMapped() throws Exception {
+    public void testAllOpenSSLCiphersMapped() throws Exception {
         Set<String> openSSLCipherSuites = getOpenSSLCiphersAsSet("ALL");
 
         for (String openSSLCipherSuite : openSSLCipherSuites) {
@@ -81,8 +79,8 @@ public class TestCipher {
 
 
     private static String getOpenSSLCiphersAsExpression(String specification) 
throws Exception {
-        // TODO The path to OpenSSL needs to be made configurable
-        StringBuilder cmd = new StringBuilder("/opt/local/bin/openssl 
ciphers");
+        String openSSLPath = System.getProperty("test.openssl.path","openssl");
+        StringBuilder cmd = new StringBuilder(openSSLPath + " ciphers");
         if (specification != null) {
             cmd.append(' ');
             cmd.append(specification);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to