private HttpResponse mockResponse( int statusCode, String entityText ) throws IOException { HttpResponse resp = mock( HttpResponse.class ); StatusLine status = mock( StatusLine.class ); when( status.getStatusCode() ).thenReturn( statusCode ); when( resp.getStatusLine() ).thenReturn( status ); HttpEntity entity = mock( HttpEntity.class ); when( entity.getContent() ).thenReturn( IOUtils.getInputStream( entityText ) ); when( resp.getEntity() ).thenReturn( entity ); return resp; }
/** * Returns the input stream. * * @return the input stream */ public InputStream getAsciiStream() throws SQLException { try { debugCodeCall("getAsciiStream"); checkClosed(); String s = value.getString(); return IOUtils.getInputStream(s); } catch (Throwable e) { throw logAndConvert(e); } }
/** * Returns the value of the specified column as input stream. * * @param columnName the name of the column label * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ public InputStream getAsciiStream(String columnName) throws SQLException { try { debugCodeCall("getAsciiStream", columnName); String s = get(columnName).getString(); // TODO ascii stream: convert the reader to a ascii stream return IOUtils.getInputStream(s); } catch (Throwable e) { throw logAndConvert(e); } }
/** * Returns the value of the specified column as input stream. * * @param columnIndex (1,2,...) * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ public InputStream getAsciiStream(int columnIndex) throws SQLException { try { debugCodeCall("getAsciiStream", columnIndex); String s = get(columnIndex).getString(); // TODO ascii stream: convert the reader to a ascii stream return s == null ? null : IOUtils.getInputStream(s); } catch (Throwable e) { throw logAndConvert(e); } }