1 20 package org.apache.derbyTesting.functionTests.tests.derbynet; 21 22 import org.apache.derbyTesting.junit.BaseTestCase; 23 import org.apache.derby.client.am.SqlException; 24 import org.apache.derby.client.am.ClientMessageId; 25 import org.apache.derby.shared.common.reference.SQLState; 26 import java.sql.SQLException ; 27 import java.io.IOException ; 28 29 34 35 public class SqlExceptionTest extends BaseTestCase 36 { 37 public SqlExceptionTest(String name) 38 { 39 super(name); 40 } 41 42 45 public void testChainedException() { 46 IOException ioe = new IOException ("Test exception"); 47 SqlException sqle = new SqlException(null, 48 new ClientMessageId(SQLState.NOGETCONN_ON_CLOSED_POOLED_CONNECTION), 49 ioe); 50 SQLException javae = sqle.getSQLException(); 51 52 assertEquals(sqle, javae.getCause()); 55 assertEquals(ioe, javae.getCause().getCause()); 56 assertNull(sqle.getNextException()); 57 } 58 59 63 public void testNextException() { 64 SQLException nexte = new SQLException ("test"); 65 SqlException sqle = new SqlException(null, 66 new ClientMessageId(SQLState.NOGETCONN_ON_CLOSED_POOLED_CONNECTION), 67 nexte); 68 SQLException javae = sqle.getSQLException(); 69 70 assertEquals(sqle, javae.getCause()); 71 assertNull(javae.getCause().getCause()); 72 assertEquals(nexte, javae.getNextException()); 73 74 SqlException internalException = 77 new SqlException(null, 78 new ClientMessageId("08000")); 79 80 javae = new SqlException(null, 81 new ClientMessageId(SQLState.NOGETCONN_ON_CLOSED_POOLED_CONNECTION), 82 internalException).getSQLException(); 83 84 assertNotNull(javae.getNextException()); 85 assertEquals(javae.getNextException().getSQLState(), "08000"); 86 } 87 } 88 | Popular Tags |