Author: shawkins
Date: 2012-05-17 23:28:02 -0400 (Thu, 17 May 2012)
New Revision: 4121
Modified:
trunk/client/src/main/java/org/teiid/client/ResultsMessage.java
trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
trunk/client/src/main/java/org/teiid/jdbc/WarningUtil.java
trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java
Log:
TEIID-2054 fixing initial warnings
Modified: trunk/client/src/main/java/org/teiid/client/ResultsMessage.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/ResultsMessage.java 2012-05-17 18:21:28
UTC (rev 4120)
+++ trunk/client/src/main/java/org/teiid/client/ResultsMessage.java 2012-05-18 03:28:02
UTC (rev 4121)
@@ -158,7 +158,7 @@
/**
* @return
*/
- public List getWarnings() {
+ public List<Throwable> getWarnings() {
return warnings;
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2012-05-17 18:21:28 UTC
(rev 4120)
+++ trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2012-05-18 03:28:02 UTC
(rev 4121)
@@ -119,7 +119,6 @@
this.requestID = statement.getCurrentRequestID();
this.cursorType = statement.getResultSetType();
this.batchResults = new BatchResults(this, getCurrentBatch(resultsMsg),
this.cursorType == ResultSet.TYPE_FORWARD_ONLY ? 1 : BatchResults.DEFAULT_SAVED_BATCHES);
- accumulateWarnings(resultsMsg);
this.serverTimeZone = statement.getServerTimeZone();
if (metadata == null) {
MetadataProvider provider = new DeferredMetadataProvider(resultsMsg.getColumnNames(),
Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2012-05-17 18:21:28 UTC
(rev 4120)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2012-05-18 03:28:02 UTC
(rev 4121)
@@ -134,7 +134,7 @@
// resultSet object produced by execute methods on the statement.
protected volatile ResultSetImpl resultSet;
- private List<Exception> serverWarnings;
+ private List<Throwable> serverWarnings;
// the per-execution security payload
private Serializable payload;
@@ -783,12 +783,12 @@
return this.updateCounts[0];
}
- protected void accumulateWarnings(List<Exception> serverWarnings) {
+ protected void accumulateWarnings(List<Throwable> serverWarnings) {
if (serverWarnings == null || serverWarnings.isEmpty()) {
return;
}
if (this.serverWarnings == null) {
- this.serverWarnings = new ArrayList<Exception>();
+ this.serverWarnings = new ArrayList<Throwable>();
}
this.serverWarnings.addAll(serverWarnings);
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/WarningUtil.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/WarningUtil.java 2012-05-17 18:21:28 UTC
(rev 4120)
+++ trunk/client/src/main/java/org/teiid/jdbc/WarningUtil.java 2012-05-18 03:28:02 UTC
(rev 4121)
@@ -70,13 +70,13 @@
* @param exceptions List of exceptions from server
* @return Chain of SQLWarning corresponding to list of exceptions
*/
- static SQLWarning convertWarnings(List<Exception> exceptions) {
+ static SQLWarning convertWarnings(List<Throwable> exceptions) {
if(exceptions == null || exceptions.size() == 0) {
return null;
}
SQLWarning warning = null;
- for (Exception ex : exceptions) {
+ for (Throwable ex : exceptions) {
SQLWarning newWarning = createWarning(ex);
if(warning == null) {
warning = newWarning;
Modified: trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java
===================================================================
--- trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java 2012-05-17 18:21:28 UTC
(rev 4120)
+++ trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java 2012-05-18 03:28:02 UTC
(rev 4121)
@@ -25,6 +25,7 @@
import static org.junit.Assert.*;
import java.sql.ResultSet;
+import java.sql.SQLWarning;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
@@ -59,6 +60,30 @@
assertTrue(Arrays.equals(new int[] {1, 2}, statement.executeBatch()));
}
+ @Test public void testWarnings() throws Exception {
+ ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
+ DQP dqp = Mockito.mock(DQP.class);
+ ResultsFuture<ResultsMessage> results = new
ResultsFuture<ResultsMessage>();
+ Mockito.stub(dqp.executeRequest(Mockito.anyLong(),
(RequestMessage)Mockito.anyObject())).toReturn(results);
+ ResultsMessage rm = new ResultsMessage();
+ rm.setResults(new List<?>[] {Arrays.asList(1)});
+ rm.setWarnings(Arrays.asList(new Throwable()));
+ rm.setColumnNames(new String[] {"expr1"});
+ rm.setDataTypes(new String[] {"string"});
+ results.getResultsReceiver().receiveResults(rm);
+ Mockito.stub(conn.getDQP()).toReturn(dqp);
+ StatementImpl statement = new StatementImpl(conn, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY) {
+ protected java.util.TimeZone getServerTimeZone() throws java.sql.SQLException {
+ return null;
+ }
+ };
+ statement.execute("select 'a'");
+ assertNotNull(statement.getResultSet());
+ SQLWarning warning = statement.getWarnings();
+ assertNotNull(warning);
+ assertNull(warning.getNextWarning());
+ }
+
@Test public void testSetStatement() throws Exception {
ConnectionImpl conn = Mockito.mock(ConnectionImpl.class);
Properties p = new Properties();