jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From juanpa...@apache.org
Subject svn commit: r1410091 - in /incubator/jspwiki/trunk/tests/org/apache/wiki/util: MailUtilTest.java UtilJ2eeCompatTest.java
Date Thu, 15 Nov 2012 23:02:28 GMT
Author: juanpablo
Date: Thu Nov 15 23:02:27 2012
New Revision: 1410091

URL: http://svn.apache.org/viewvc?rev=1410091&view=rev
Log:
Fixed a couple of tests which could fail under certain circumstances:

- UtilJ2eeCompatTest: tests were order-dependent.

- MailUtilTest#testSendMail(): didn't pass if the JVM needs but doesn't have a required cert
needed to connect to the mail server (added extra catch to not fail the test, as is already
done when we can't connect to the mail server).

with the following exception:
javax.mail.MessagingException: Can't send command to SMTP host;
  nested exception is:
    javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path
building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target
[...]

This is needed in order to have a Sonar analysis at Apache infra [cfr. INFRA-5441]

Modified:
    incubator/jspwiki/trunk/tests/org/apache/wiki/util/MailUtilTest.java
    incubator/jspwiki/trunk/tests/org/apache/wiki/util/UtilJ2eeCompatTest.java

Modified: incubator/jspwiki/trunk/tests/org/apache/wiki/util/MailUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/org/apache/wiki/util/MailUtilTest.java?rev=1410091&r1=1410090&r2=1410091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/org/apache/wiki/util/MailUtilTest.java (original)
+++ incubator/jspwiki/trunk/tests/org/apache/wiki/util/MailUtilTest.java Thu Nov 15 23:02:27
2012
@@ -23,6 +23,7 @@ import java.net.ConnectException;
 import java.util.Properties;
 
 import javax.mail.MessagingException;
+import javax.net.ssl.SSLHandshakeException;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -125,6 +126,14 @@ public class MailUtilTest extends TestCa
                 System.out.println("Reason: "+e.getMessage());
                 return;
             }
+            if( e.getCause() instanceof SSLHandshakeException )
+            {
+                // This can occur if you do not have the required cert in the JVM's keystore.
 We just log this
+                // and don't fail.
+                System.out.println("I could not test whether mail sending works, since I
don't have the required cert in my keystore.");
+                System.out.println("Reason: "+e.getMessage());
+                return;
+            }
             e.printStackTrace();
             fail( "Unknown problem (check the console for error report)" );
         }

Modified: incubator/jspwiki/trunk/tests/org/apache/wiki/util/UtilJ2eeCompatTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/org/apache/wiki/util/UtilJ2eeCompatTest.java?rev=1410091&r1=1410090&r2=1410091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/org/apache/wiki/util/UtilJ2eeCompatTest.java (original)
+++ incubator/jspwiki/trunk/tests/org/apache/wiki/util/UtilJ2eeCompatTest.java Thu Nov 15
23:02:27 2012
@@ -26,20 +26,30 @@ import org.apache.wiki.util.UtilJ2eeComp
 public class UtilJ2eeCompatTest extends TestCase
 {
 
+    public void setUp() 
+    {
+        UtilJ2eeCompat.useOutputStreamValue = null;
+    }
+    
     public void testOracle()
     {
         assertTrue( UtilJ2eeCompat.useOutputStream( "Oracle Containers for J2EE 10g(10.1.3.1.0
)", true ) );
         // Do not reinitialize
         assertTrue( UtilJ2eeCompat.useOutputStream( "Apache Tomcat/5.5.20" ) );
+        // Do not reinitialize
+        assertTrue( UtilJ2eeCompat.useOutputStream( "Sun Java System Application Server 9.1_02"
) );
     }
 
     public void testGlassfish()
     {
-        assertTrue( UtilJ2eeCompat.useOutputStream( "Sun Java System Application Server 9.1_02"
) );
+        assertFalse( UtilJ2eeCompat.useOutputStream( "Sun Java System Application Server
9.1_02", true ) );
+        // Do not reinitialize
+        assertFalse( UtilJ2eeCompat.useOutputStream( "Sun Java System Application Server
9.1_02" ) );
     }
 
     public void testTomcat()
     {
+        assertFalse( UtilJ2eeCompat.useOutputStream( "Apache Tomcat/5.5.20", true ) );
         // Reinitialize
         assertFalse( UtilJ2eeCompat.useOutputStream( "Apache Tomcat/5.5.20", true ) );
     }



Mime
View raw message