commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject svn commit: r307280 - /jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/NotImplementedExceptionTest.java
Date Sat, 08 Oct 2005 09:56:02 GMT
Author: scolebourne
Date: Sat Oct  8 02:56:00 2005
New Revision: 307280

URL: http://svn.apache.org/viewcvs?rev=307280&view=rev
Log:
Handle differences between JDK1.3 and JDK1.4

Modified:
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/NotImplementedExceptionTest.java

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/NotImplementedExceptionTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/NotImplementedExceptionTest.java?rev=307280&r1=307279&r2=307280&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/NotImplementedExceptionTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/NotImplementedExceptionTest.java
Sat Oct  8 02:56:00 2005
@@ -16,18 +16,18 @@
 package org.apache.commons.lang;
 
 import java.io.ByteArrayOutputStream;
-import java.io.OutputStreamWriter;
 import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
-
-import org.apache.commons.lang.exception.NestableException;
+import java.lang.reflect.Constructor;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
 
+import org.apache.commons.lang.exception.NestableException;
+
 /**
  * JUnit tests.
  * 
@@ -111,20 +111,24 @@
         assertEquals("Code is not implemented in class java.lang.String", ex.getMessage());
     }
 
-// Does not compile on Java 1.3.1:    
-//    public void testGetMessage_Indexed() {
-//        NotImplementedException ex = new NotImplementedException(new Exception("nested
1", new Exception("nested 2")));
-//        assertEquals("Code is not implemented", ex.getMessage());
-//        assertEquals("Code is not implemented", ex.getMessage(0));
-//        assertEquals("nested 1", ex.getMessage(1));
-//        assertEquals("nested 2", ex.getMessage(2));
-//        
-//        String[] messages = ex.getMessages();
-//        assertEquals(3, messages.length);
-//        assertEquals("Code is not implemented", messages[0]);
-//        assertEquals("nested 1", messages[1]);
-//        assertEquals("nested 2", messages[2]);
-//    }
+    public void testGetMessage_Indexed() throws Exception {
+        if (SystemUtils.isJavaVersionAtLeast(1.4f)) {
+            Exception ex1 = new Exception("nested 2");
+            Constructor con = Exception.class.getConstructor(new Class[] {String.class, Throwable.class});
+            Exception ex2 = (Exception) con.newInstance(new Object[] {"nested 1", ex1});
+            NotImplementedException ex = new NotImplementedException(ex2);
+            assertEquals("Code is not implemented", ex.getMessage());
+            assertEquals("Code is not implemented", ex.getMessage(0));
+            assertEquals("nested 1", ex.getMessage(1));
+            assertEquals("nested 2", ex.getMessage(2));
+            
+            String[] messages = ex.getMessages();
+            assertEquals(3, messages.length);
+            assertEquals("Code is not implemented", messages[0]);
+            assertEquals("nested 1", messages[1]);
+            assertEquals("nested 2", messages[2]);
+        }
+    }
     
     public void testGetThrowable() {
         NotImplementedException ex = new NotImplementedException(new NestableException("nested
1", new NestableException("nested 2")));



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message