[teiid-commits] teiid SVN: r2673 - in branches/7.1.x: engine/src/test/java/org/teiid/query/processor and 1 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Thu Oct 21 17:05:21 EDT 2010
Author: shawkins
Date: 2010-10-21 17:05:20 -0400 (Thu, 21 Oct 2010)
New Revision: 2673
Added:
branches/7.1.x/engine/src/test/resources/encoding.xml
Modified:
branches/7.1.x/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
Log:
TEIID-1316 fix for picking up the encoding correctly from the document
Modified: branches/7.1.x/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java
===================================================================
--- branches/7.1.x/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java 2010-10-21 18:49:17 UTC (rev 2672)
+++ branches/7.1.x/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java 2010-10-21 21:05:20 UTC (rev 2673)
@@ -89,14 +89,17 @@
if (cs != null) {
return cs;
}
+ String enc = null;
try {
- String enc = XMLType.getEncoding(this.getBinaryStream());
- if (enc != null) {
- setEncoding(enc);
- }
+ enc = XMLType.getEncoding(this.getBinaryStream());
} catch (SQLException e) {
}
- return Streamable.CHARSET;
+ if (enc != null) {
+ setEncoding(enc);
+ } else {
+ super.setCharset(Streamable.CHARSET);
+ }
+ return super.getCharset();
}
@SuppressWarnings("unchecked")
Modified: branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2010-10-21 18:49:17 UTC (rev 2672)
+++ branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2010-10-21 21:05:20 UTC (rev 2673)
@@ -25,6 +25,8 @@
import static org.teiid.query.processor.TestProcessor.*;
import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.List;
@@ -349,6 +351,16 @@
processPreparedStatement(sql, expected, dataManager, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), Arrays.asList(blobFromFile("udf.xmi")));
}
+ @Test public void testXmlParseBlobWithEncoding() throws Exception {
+ String sql = "select xmlparse(document cast(? as blob)) x"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(ObjectConverterUtil.convertToString(new InputStreamReader(new FileInputStream(UnitTestUtil.getTestDataFile("encoding.xml")), Charset.forName("ISO-8859-1")))),
+ };
+
+ processPreparedStatement(sql, expected, dataManager, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), Arrays.asList(blobFromFile("encoding.xml")));
+ }
+
@Test public void testXmlTableTypes() throws Exception {
String sql = "select * from xmltable('/a' passing xmlparse(document '<a>2000-01-01T01:01:00.2-06:00</a>') columns x timestamp path 'xs:dateTime(./text())', y timestamp path '.') as x"; //$NON-NLS-1$
Timestamp ts = TimestampUtil.createTimestamp(100, 0, 1, 1, 1, 0, 200000000);
Added: branches/7.1.x/engine/src/test/resources/encoding.xml
===================================================================
--- branches/7.1.x/engine/src/test/resources/encoding.xml (rev 0)
+++ branches/7.1.x/engine/src/test/resources/encoding.xml 2010-10-21 21:05:20 UTC (rev 2673)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<name>æåø</name>
Property changes on: branches/7.1.x/engine/src/test/resources/encoding.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the teiid-commits
mailing list