use of java.io.Reader in project OpenGrok by OpenGrok.
the class JFlexXrefTest method bug18586.
@Test
public void bug18586() throws IOException {
String filename = repository.getSourceRoot() + "/sql/bug18586.sql";
Reader in = new InputStreamReader(new FileInputStream(filename), "UTF-8");
SQLXref xref = new SQLXref(in);
xref.setDefs(ctags.doCtags(filename + "\n"));
// The next call used to fail with an ArrayIndexOutOfBoundsException.
xref.write(new StringWriter());
}
use of java.io.Reader in project OpenGrok by OpenGrok.
the class ContextTest method testLongLineNearBufferBoundary.
/**
* Test that we don't get an {@code ArrayIndexOutOfBoundsException} when a
* long (>100 characters) line which contains a match is not terminated
* with a newline character before the buffer boundary. Bug #383.
*
* @throws org.apache.lucene.queryparser.classic.ParseException
*/
@Test
public void testLongLineNearBufferBoundary() throws ParseException {
char[] chars = new char[Context.MAXFILEREAD];
Arrays.fill(chars, 'a');
char[] substring = " this is a test ".toCharArray();
System.arraycopy(substring, 0, chars, Context.MAXFILEREAD - substring.length, substring.length);
Reader in = new CharArrayReader(chars);
QueryBuilder qb = new QueryBuilder().setFreetext("test");
Context c = new Context(qb.build(), qb.getQueries());
StringWriter out = new StringWriter();
boolean match = c.getContext(in, out, "", "", "", null, true, qb.isDefSearch(), null);
assertTrue("No match found", match);
String s = out.toString();
assertTrue("Match not written to Writer", s.contains(" this is a <b>test</b>"));
assertTrue("No match on line #1", s.contains("href=\"#1\""));
}
use of java.io.Reader in project druid by alibaba.
the class EncodingConvertFilter method clob_getCharacterStream.
@Override
public Reader clob_getCharacterStream(FilterChain chain, ClobProxy wrapper, long pos, long length) throws SQLException {
Reader reader = super.clob_getCharacterStream(chain, wrapper, pos, length);
String text = Utils.read(reader);
return new StringReader(decode(wrapper.getConnectionWrapper(), text));
}
use of java.io.Reader in project druid by alibaba.
the class EncodingConvertFilter method callableStatement_setCharacterStream.
@Override
public void callableStatement_setCharacterStream(FilterChain chain, CallableStatementProxy statement, String parameterName, java.io.Reader reader, int length) throws SQLException {
String text = Utils.read(reader, length);
String encodeText = encode(statement.getConnectionProxy(), text);
Reader encodeReader = new StringReader(encodeText);
super.callableStatement_setCharacterStream(chain, statement, parameterName, encodeReader, encodeText.length());
}
use of java.io.Reader in project druid by alibaba.
the class EncodingConvertFilter method callableStatement_setCharacterStream.
// ///////////// callableStatement_
@Override
public void callableStatement_setCharacterStream(FilterChain chain, CallableStatementProxy statement, String parameterName, java.io.Reader reader) throws SQLException {
String text = Utils.read(reader);
Reader encodeReader = new StringReader(encode(statement.getConnectionProxy(), text));
super.callableStatement_setCharacterStream(chain, statement, parameterName, encodeReader);
}
Aggregations