@Test public void testConvertToAvroStreamForShort() throws SQLException, IOException { final ResultSetMetaData metadata = mock(ResultSetMetaData.class); when(metadata.getColumnCount()).thenReturn(1); when(metadata.getColumnType(1)).thenReturn(Types.TINYINT); when(metadata.getColumnName(1)).thenReturn("t_int"); when(metadata.getTableName(1)).thenReturn("table"); final ResultSet rs = mock(ResultSet.class); when(rs.getMetaData()).thenReturn(metadata); final AtomicInteger counter = new AtomicInteger(1); Mockito.doAnswer(new Answer<Boolean>() { @Override public Boolean answer(InvocationOnMock invocation) throws Throwable { return counter.getAndDecrement() > 0; } }).when(rs).next(); final short s = 25; when(rs.getObject(Mockito.anyInt())).thenReturn(s); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); JdbcCommon.convertToAvroStream(rs, baos, false); final byte[] serializedBytes = baos.toByteArray(); final InputStream instream = new ByteArrayInputStream(serializedBytes); final DatumReader<GenericRecord> datumReader = new GenericDatumReader<>(); try (final DataFileStream<GenericRecord> dataFileReader = new DataFileStream<>(instream, datumReader)) { GenericRecord record = null; while (dataFileReader.hasNext()) { record = dataFileReader.next(record); assertEquals(Short.toString(s), record.get("t_int").toString()); } } }
public static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, boolean convertNames) throws SQLException, IOException { return convertToAvroStream(rs, outStream, null, null, convertNames); }
JdbcCommon { public static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, boolean convertNames) throws SQLException, IOException { return convertToAvroStream(rs, outStream, null, null, convertNames); } }
JdbcCommon { public static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, boolean convertNames) throws SQLException, IOException { return convertToAvroStream(rs, outStream, null, null, convertNames); }  }
JdbcCommon { public static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, boolean convertNames) throws SQLException, IOException { return convertToAvroStream(rs, outStream, null, null, convertNames); }  static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, boolean convertNames); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, String recordName, boolean convertNames); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, String recordName, ResultSetRowCallback callback, boolean convertNames); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, String recordName, ResultSetRowCallback callback, final int maxRows, boolean convertNames); static void createEmptyAvroStream(final OutputStream outStream); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, final AvroConversionOptions options, final ResultSetRowCallback callback); static Schema createSchema(final ResultSet rs); static Schema createSchema(final ResultSet rs, String recordName, boolean convertNames); static Schema createSchema(final ResultSet rs, AvroConversionOptions options); static String normalizeNameForAvro(String inputName); static void setParameters(final PreparedStatement stmt, final Map<String, String> attributes); static void setParameter(final PreparedStatement stmt, final String attrName, final int parameterIndex, final String parameterValue, final int jdbcType,
                              final String valueFormat); static DateTimeFormatter getDateTimeFormatter(String pattern); }
JdbcCommon { public static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, boolean convertNames) throws SQLException, IOException { return convertToAvroStream(rs, outStream, null, null, convertNames); }  static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, boolean convertNames); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, String recordName, boolean convertNames); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, String recordName, ResultSetRowCallback callback, boolean convertNames); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, String recordName, ResultSetRowCallback callback, final int maxRows, boolean convertNames); static void createEmptyAvroStream(final OutputStream outStream); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, final AvroConversionOptions options, final ResultSetRowCallback callback); static Schema createSchema(final ResultSet rs); static Schema createSchema(final ResultSet rs, String recordName, boolean convertNames); static Schema createSchema(final ResultSet rs, AvroConversionOptions options); static String normalizeNameForAvro(String inputName); static void setParameters(final PreparedStatement stmt, final Map<String, String> attributes); static void setParameter(final PreparedStatement stmt, final String attrName, final int parameterIndex, final String parameterValue, final int jdbcType,
                              final String valueFormat); static DateTimeFormatter getDateTimeFormatter(String pattern); static final Pattern LONG_PATTERN; static final Pattern SQL_TYPE_ATTRIBUTE_PATTERN; static final Pattern NUMBER_PATTERN; static final String MIME_TYPE_AVRO_BINARY; static final PropertyDescriptor NORMALIZE_NAMES_FOR_AVRO; static final PropertyDescriptor USE_AVRO_LOGICAL_TYPES; static final PropertyDescriptor DEFAULT_PRECISION; static final PropertyDescriptor DEFAULT_SCALE; }