Skip to content

Commit

Permalink
TEIID-4567 adding missing read method
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Feb 6, 2017
1 parent 206cd52 commit 3a79c4d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
25 changes: 25 additions & 0 deletions engine/src/main/java/org/teiid/query/function/FunctionMethods.java
Expand Up @@ -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 {
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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++) {
Expand Down

0 comments on commit 3a79c4d

Please sign in to comment.