From 3a79c4d1a6d0d2a247bf442d50c18e123123d082 Mon Sep 17 00:00:00 2001 From: shawkins Date: Mon, 6 Feb 2017 13:45:59 -0500 Subject: [PATCH] TEIID-4567 adding missing read method --- .../teiid/query/function/FunctionMethods.java | 25 +++++++++++++++++++ .../transport/TestJDBCSocketTransport.java | 13 ++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/engine/src/main/java/org/teiid/query/function/FunctionMethods.java b/engine/src/main/java/org/teiid/query/function/FunctionMethods.java index dbc31dfce2..bba10a34c1 100644 --- a/engine/src/main/java/org/teiid/query/function/FunctionMethods.java +++ b/engine/src/main/java/org/teiid/query/function/FunctionMethods.java @@ -109,6 +109,31 @@ private UpperLowerReader(Reader in, boolean upper) { super(in); this.upper = upper; } + + @Override + public int read(char[] cbuf, int off, int len) throws IOException { + if (len <= 0) { + if (len < 0) { + throw new IndexOutOfBoundsException(); + } else if ((off < 0) || (off > cbuf.length)) { + throw new IndexOutOfBoundsException(); + } + return 0; + } + int chars = 0; + while (chars <= len) { + int c = read(); + if (c == -1) { + if (chars == 0) { + return -1; + } + break; + } + cbuf[off++] = (char)c; + chars++; + } + return chars; + } @Override public int read() throws IOException { diff --git a/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java b/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java index 2acf1ac949..516ece8f45 100644 --- a/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java +++ b/test-integration/common/src/test/java/org/teiid/transport/TestJDBCSocketTransport.java @@ -22,11 +22,7 @@ package org.teiid.transport; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.Assert.*; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -364,6 +360,13 @@ public Object getConnectionFactory() s.execute(); } + @Test public void testLobCase() throws Exception { + Statement s = conn.createStatement(); + s.execute("select ucase(cast('abc' as clob))"); + s.getResultSet().next(); + assertEquals("ABC", s.getResultSet().getString(1)); + } + @Test public void testGeometryStreaming() throws Exception { StringBuilder geomString = new StringBuilder(); for (int i = 0; i < 600; i++) {