Author: vhalbert(a)redhat.com
Date: 2010-09-28 17:37:16 -0400 (Tue, 28 Sep 2010)
New Revision: 2618
Modified:
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
Log:
TEIID-1168 changs to stream out the blob/clob to a string before comparing to expected
results, can no longer call object.toString()
Modified:
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java
===================================================================
---
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java 2010-09-28
14:30:31 UTC (rev 2617)
+++
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestClientTransaction.java 2010-09-28
21:37:16 UTC (rev 2618)
@@ -166,11 +166,21 @@
testStatus, beginTS, endTS, resultException, null);
- this.querySet.handleTestResult(rs, this.internalResultSet, this.updateCount,
resultFromQuery, sql);
-
+ System.out.println("ADD THE TEST RESULT");
+
this.testResultsSummary.addTestResult(query.geQuerySetID(), rs);
+
+ try {
+ System.out.println("HANDLE RESULT " + this.internalResultSet.isClosed());
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ this.querySet.handleTestResult(rs, this.internalResultSet, this.updateCount,
resultFromQuery, sql);
+
}
Modified:
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java
===================================================================
---
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java 2010-09-28
14:30:31 UTC (rev 2617)
+++
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/TestResultsSummary.java 2010-09-28
21:37:16 UTC (rev 2618)
@@ -80,6 +80,14 @@
}
public synchronized void addTestResult(String querySetID, TestResult result) {
+
+ if (result == null) {
+ System.err
+ .println("Error - trying to add a null result set for querysetID: " +
querySetID); //$NON-NLS-1$
+ throw new RuntimeException(
+ "Error - trying to add a null result set for querysetID: " + querySetID);
//$NON-NLS-1$
+
+ }
Collection<TestResult> results = null;
if (this.testResults.containsKey(querySetID)) {
results = this.testResults.get(querySetID);
@@ -92,7 +100,7 @@
}
public Collection<TestResult> getTestResults(String querySetID) {
- return this.testResults.get(querySetID);
+ return this.testResults.get(querySetID);
}
private static PrintStream getSummaryStream(String outputDir,
@@ -397,7 +405,10 @@
String outputDir = scenario.getResultsGenerator().getOutputDir();
// CombinedTestClient.log("Calculating and printing result statistics");
//$NON-NLS-1$
- if (testResults.size() > 0) {
+ if (testResults == null) {
+ // do nothing
+
+ } else if (testResults.size() > 0) {
// Create output file
String outputFileName = generateFileName(querySetID, System
.currentTimeMillis(), runNumber);
Modified:
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java
===================================================================
---
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java 2010-09-28
14:30:31 UTC (rev 2617)
+++
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/CTCQueryScenario.java 2010-09-28
21:37:16 UTC (rev 2618)
@@ -61,12 +61,6 @@
}
validateResultsMode(this.getProperties());
-
-// try {
-// setupVDBs(this.getProperties());
-// } catch (IOException e) {
-// throw new TransactionRuntimeException(e.getMessage());
-// }
}
@@ -85,45 +79,43 @@
public void handleTestResult(TestResult tr, ResultSet resultSet, int updatecnt,
boolean resultFromQuery, String sql) {
Throwable resultException = tr.getException();
- if (getResultsMode().equalsIgnoreCase(
- TestProperties.RESULT_MODES.COMPARE)) {
+ if (getResultsMode().equalsIgnoreCase(TestProperties.RESULT_MODES.COMPARE)) {
if (tr.getStatus() != TestResult.RESULT_STATE.TEST_EXCEPTION) {
- try {
- this.getExpectedResults(tr.getQuerySetID()).compareResults(tr.getQueryID(),
- sql,
- resultSet,
- resultException,
- tr.getStatus(), isOrdered(sql), -1, resultFromQuery);
-
- } catch (QueryTestFailedException qtf) {
- resultException = (resultException != null ? resultException
- : qtf);
- tr.setException(resultException);
- tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
-
- }
+ try {
+ this.getExpectedResults(tr.getQuerySetID()).compareResults(tr.getQueryID(),
+ sql,
+ resultSet,
+ resultException,
+ tr.getStatus(), isOrdered(sql), -1, resultFromQuery);
+
+ } catch (QueryTestFailedException qtf) {
+ resultException = (resultException != null ? resultException
+ : qtf);
+ tr.setException(resultException);
+ tr.setStatus(TestResult.RESULT_STATE.TEST_EXCEPTION);
+
+ }
}
if (tr.getStatus() == TestResult.RESULT_STATE.TEST_EXCEPTION) {
- try {
-
- this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(),
- tr.getQueryID(), sql, resultSet, resultException,
- this.getExpectedResults(tr.getQuerySetID()).getResultsFile(tr.getQueryID()) );
-
-
- } catch (QueryTestFailedException qtfe) {
- throw new TransactionRuntimeException(qtfe.getMessage());
- }
+ try {
+
+ this.getResultsGenerator().generateErrorFile(tr.getQuerySetID(),
+ tr.getQueryID(), sql, resultSet, resultException,
+ this.getExpectedResults(tr.getQuerySetID()).getResultsFile(tr.getQueryID()) );
+
+
+ } catch (QueryTestFailedException qtfe) {
+ throw new TransactionRuntimeException(qtfe.getMessage());
+ }
}
- } else if (getResultsMode().equalsIgnoreCase(
- TestProperties.RESULT_MODES.GENERATE)) { //$NON-NLS-1$
+ } else if (getResultsMode().equalsIgnoreCase(TestProperties.RESULT_MODES.GENERATE)) {
//$NON-NLS-1$
try {
- this.getResultsGenerator().generateQueryResultFile(tr.getQuerySetID(),
- tr.getQueryID(), sql, resultSet, resultException, tr.getStatus());
+ this.getResultsGenerator().generateQueryResultFile(tr.getQuerySetID(),
+ tr.getQueryID(), sql, resultSet, resultException, tr.getStatus());
} catch (QueryTestFailedException qtfe) {
throw new TransactionRuntimeException(qtfe.getMessage());
Modified:
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
===================================================================
---
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2010-09-28
14:30:31 UTC (rev 2617)
+++
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2010-09-28
21:37:16 UTC (rev 2618)
@@ -41,6 +41,7 @@
import java.util.Properties;
import org.jdom.JDOMException;
+import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.core.util.StringUtil;
import org.teiid.test.client.ClassFactory;
import org.teiid.test.client.ExpectedResults;
@@ -493,26 +494,63 @@
// Compare actual elements with expected elements column by column in this
row
for (int col = 0; col < actualColumnCount; col++) {
// Get actual value
- final Object actualValue = actualRecord.get(col);
+ Object actualValue = actualRecord.get(col);
// Get expected value
- final Object expectedValue = expectedRecord.get(col);
+ Object expectedValue = expectedRecord.get(col);
// DEBUG:
// debugOut.println(" Col: " +(col +1) + ":
expectedValue:[" + expectedValue + "] actualValue:[" + actualValue +
// "]");
// Compare these values
- if (expectedValue == null) {
+ if ( ( expectedValue == null && actualValue != null) ||
+ (actualValue == null && expectedValue != null) ){
// Compare nulls
- if (actualValue != null) {
throw new QueryTestFailedException(eMsg + "Value mismatch at
row " + (row + 1) //$NON-NLS-1$
+ " and column " +
(col + 1) //$NON-NLS-1$
+ ": expected = ["
//$NON-NLS-1$
- + expectedValue + "],
actual = [" //$NON-NLS-1$
- + actualValue +
"]"); //$NON-NLS-1$
+ +
(expectedValue!=null?expectedValue:"null") + "], actual = ["
//$NON-NLS-1$
+ +
(actualValue!=null?actualValue:"null") + "]"); //$NON-NLS-1$
- }
- } else {
+ }
+
+ if (actualValue instanceof Blob || actualValue instanceof Clob ||
actualValue instanceof SQLXML) {
+
+ if (actualValue instanceof Clob){
+ Clob c = (Clob)actualValue;
+ try {
+ actualValue = ObjectConverterUtil.convertToString(c.getAsciiStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new QueryTestFailedException(e);
+ }
+ } else if (actualValue instanceof Blob){
+ Blob b = (Blob)actualValue;
+ try {
+ actualValue = ObjectConverterUtil.convertToString(b.getBinaryStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new QueryTestFailedException(e);
+ }
+ } else if (actualValue instanceof SQLXML){
+ SQLXML s = (SQLXML)actualValue;
+ try {
+ actualValue = ObjectConverterUtil.convertToString(s.getBinaryStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new QueryTestFailedException(e);
+ }
+ }
+
+
+ if (!(expectedValue instanceof String)) {
+ expectedValue = expectedValue.toString();
+ }
+ }
+
// Compare values with equals
if (!expectedValue.equals(actualValue)) {
// DEBUG:
@@ -521,18 +559,21 @@
if (expectedValue instanceof String) {
final String expectedString = (String)expectedValue;
- if (actualValue instanceof Blob || actualValue instanceof
Clob || actualValue instanceof SQLXML) {
- // LOB types are special case - metadata says they're
Object types so
- // expected results are of type String. Actual object
type is MMBlob, MMClob.
- // Must compare w/ String verion of actual!
- if (!expectedValue.equals(actualValue.toString())) {
- throw new QueryTestFailedException(eMsg + "LOB
Value mismatch at row " + (row + 1) //$NON-NLS-1$
- + " and
column " + (col + 1) //$NON-NLS-1$
- + ": expected
= [" //$NON-NLS-1$
- + expectedValue +
"], actual = [" //$NON-NLS-1$
- + actualValue +
"]"); //$NON-NLS-1$
- }
- } else if (!(actualValue instanceof String)) {
+// if (actualValue instanceof Blob || actualValue instanceof
Clob || actualValue instanceof SQLXML) {
+//
+// Clob c = (Clob)actualValue;
+// // LOB types are special case - metadata says
they're Object types so
+// // expected results are of type String. Actual object
type is MMBlob, MMClob.
+// // Must compare w/ String verion of actual!
+// if (!expectedValue.equals(actualValue.toString())) {
+// throw new QueryTestFailedException(eMsg + "LOB
Value mismatch at row " + (row + 1) //$NON-NLS-1$
+// + " and
column " + (col + 1) //$NON-NLS-1$
+// + ":
expected = [" //$NON-NLS-1$
+// + expectedValue
+ "], actual = [" //$NON-NLS-1$
+// + actualValue +
"]"); //$NON-NLS-1$
+// }
+// } else
+ if (!(actualValue instanceof String)) {
throw new QueryTestFailedException(eMsg + "Value
mismatch at row " + (row + 1) //$NON-NLS-1$
+ " and column
" + (col + 1) //$NON-NLS-1$
+ ": expected =
[" //$NON-NLS-1$
@@ -552,7 +593,7 @@
}
}
- }
+
} // end loop through columns
} // end loop through rows
}
Modified:
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
===================================================================
---
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-09-28
14:30:31 UTC (rev 2617)
+++
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-09-28
21:37:16 UTC (rev 2618)
@@ -123,6 +123,12 @@
String query, ResultSet result, Throwable ex, int testStatus)
throws QueryTestFailedException {
+ try {
+ System.out.println("GENERATE QRF: " + result.isClosed());
+ } catch (SQLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
File resultsFile = createNewResultsFile(queryID, querySetID,
getGenerateDir());
OutputStream outputStream;
Modified:
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java
===================================================================
---
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java 2010-09-28
14:30:31 UTC (rev 2617)
+++
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java 2010-09-28
21:37:16 UTC (rev 2618)
@@ -26,9 +26,12 @@
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.sql.Blob;
+import java.sql.Clob;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
+import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
@@ -43,6 +46,7 @@
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.internal.core.xml.SAXBuilderHelper;
import org.teiid.query.sql.lang.Select;
import org.teiid.query.sql.symbol.ElementSymbol;
@@ -50,6 +54,7 @@
import org.teiid.test.client.QueryTest;
import org.teiid.test.client.ctc.QueryResults.ColumnInfo;
import org.teiid.test.framework.TestLogger;
+import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
import org.teiid.test.util.StringUtil;
@@ -944,6 +949,12 @@
private Element produceResults(ResultSet object, int beginRow, int endRow)
throws JDOMException, SQLException {
+ if (object.isClosed()) {
+ throw new SQLException(
+ "ResultSet is closed at this point, unable to product results");
//$NON-NLS-1$
+
+ }
+
if ( beginRow < START_ROW ) {
throw new IllegalArgumentException(
"The starting row cannot be less than 1."); //$NON-NLS-1$
@@ -1118,7 +1129,7 @@
* @return the root element of the XML segment that was produced.
* @exception JDOMException if there is an error producing XML.
*/
- public Element produceMsg(Object object, Element parent) throws JDOMException {
+ public Element produceMsg(Object object, Element parent) throws JDOMException,
SQLException {
if ( object == null ) {
throw new IllegalArgumentException("Null object reference.");
//$NON-NLS-1$
}
@@ -1229,16 +1240,52 @@
* @return the root element of the XML segment that was produced.
* @exception JDOMException if there is an error producing the message.
*/
- private Element produceObject(Object object, Element parent) throws JDOMException {
+ private Element produceObject(Object object, Element parent) throws JDOMException,
SQLException {
+ System.out.println("PRODUCT OBJECT");
// ----------------------
// Create the Object element ...
// ----------------------
Element objectElement = new Element(TagNames.Elements.OBJECT);
+ String result = null;
+ if (object instanceof Blob || object instanceof Clob || object instanceof SQLXML)
{
+
+ if (object instanceof Clob){
+ Clob c = (Clob)object;
+ try {
+ result = ObjectConverterUtil.convertToString(c.getAsciiStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new SQLException(e);
+ }
+ } else if (object instanceof Blob){
+ Blob b = (Blob)object;
+ try {
+ result = ObjectConverterUtil.convertToString(b.getBinaryStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new SQLException(e);
+ }
+ } else if (object instanceof SQLXML){
+ SQLXML s = (SQLXML)object;
+ try {
+ result = ObjectConverterUtil.convertToString(s.getBinaryStream());
+
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ throw new SQLException(e);
+ }
+ }
+ } else {
+ result = object.toString();
+ }
+
// System.out.println("ProductObject (before encoding): " +
object.toString() );
// try {
- objectElement.setText(object.toString());
+ objectElement.setText(result);
// URLEncoder.encode(object.toString(), "UTF-8"));
// } catch (UnsupportedEncodingException e) {
// UTF-8 is supported natively by all jvms
Modified:
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java
===================================================================
---
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java 2010-09-28
14:30:31 UTC (rev 2617)
+++
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/client/impl/QueryScenarioImpl.java 2010-09-28
21:37:16 UTC (rev 2618)
@@ -50,8 +50,7 @@
*/
@Override
public void handleTestResult(TestResult tr, ResultSet resultSet, int updateCnt,
boolean resultFromQuery, String sql) {
-
- Throwable resultException = tr.getException();
+ Throwable resultException = tr.getException();
if (getResultsMode().equalsIgnoreCase(
TestProperties.RESULT_MODES.COMPARE)) {
Modified:
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
===================================================================
---
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2010-09-28
14:30:31 UTC (rev 2617)
+++
branches/7.1.x/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2010-09-28
21:37:16 UTC (rev 2618)
@@ -172,7 +172,7 @@
modelToDatasourceMap.clear();
}
- dsfactory.cleanup();
+ if (dsfactory != null) dsfactory.cleanup();
DataSourceMgr.reset();