@Test
  public void testIsJDBC3() {
    Overrider overrider = new Overrider();

    Assert.assertEquals(false, TypeHandlerUtils.isJDBC3(overrider));

    overrider.override(MjdbcConstants.OVERRIDE_INT_JDBC3, true);
    Assert.assertEquals(true, TypeHandlerUtils.isJDBC3(overrider));

    overrider.override(MjdbcConstants.OVERRIDE_INT_JDBC3, false);
    Assert.assertEquals(false, TypeHandlerUtils.isJDBC3(overrider));
  }
  private void testReadClob(boolean close) throws Exception {
    byte[] result = null;
    String data = "ZIP";

    when(clob.getAsciiStream()).thenReturn(new ByteArrayInputStream(data.getBytes()));

    if (close == true) {
      result = TypeHandlerUtils.readClob(clob);
    } else {
      result = TypeHandlerUtils.readClob(clob, false);
    }

    Assert.assertEquals(data, new String(result));
  }
  private void testReadSqlXml(boolean close) throws Exception {
    byte[] result = null;
    String data = "tar.gz";

    // when(sqlXml.getBinaryStream()).thenReturn(new ByteArrayInputStream(data.getBytes()));
    when(MappingUtils.invokeFunction(sqlXml, "getBinaryStream", new Class[] {}, new Object[] {}))
        .thenReturn(new ByteArrayInputStream(data.getBytes()));

    if (close == true) {
      result = TypeHandlerUtils.readSqlXml(sqlXml);
    } else {
      result = TypeHandlerUtils.readSqlXml(sqlXml, false);
    }

    Assert.assertEquals(data, new String(result));
  }
  @Test
  public void testConvertClobByte() throws Exception {
    testConvertClobPrepare();

    TypeHandlerUtils.convertClob(clob, "JPEG".getBytes());

    testConvertClobCheck();
  }
  @Test
  public void testConvertSqlXmlString() throws Exception {
    testConvertSqlXmlPrepare();

    TypeHandlerUtils.convertSqlXml(sqlXml, "TIFF");

    testConvertSqlXmlCheck();
  }
  @Test
  public void testConvertSqlXmlInputStream() throws Exception {
    testConvertSqlXmlPrepare();

    TypeHandlerUtils.convertSqlXml(sqlXml, new ByteArrayInputStream("PNG".getBytes()));

    testConvertSqlXmlCheck();
  }
  @Test
  public void testConvertSqlXmlByte() throws Exception {
    testConvertSqlXmlPrepare();

    TypeHandlerUtils.convertSqlXml(sqlXml, "JPEG".getBytes());

    testConvertSqlXmlCheck();
  }
  @Test
  public void testConvertClobString() throws Exception {
    testConvertClobPrepare();

    TypeHandlerUtils.convertClob(clob, "TIFF");

    testConvertClobCheck();
  }
  @Test
  public void testConvertClobInputStream() throws Exception {
    testConvertClobPrepare();

    TypeHandlerUtils.convertClob(clob, new ByteArrayInputStream("PNG".getBytes()));

    testConvertClobCheck();
  }
  @Test
  public void testToString() throws Exception {
    String data = "tar.gz";
    String result = "";

    result = TypeHandlerUtils.toString(new StringReader(data));

    Assert.assertEquals(data, result);
  }
  @Test
  public void testToByteArray() throws Exception {
    String data = "ace";
    byte[] result = null;

    result = TypeHandlerUtils.toByteArray(new ByteArrayInputStream(data.getBytes()));

    Assert.assertEquals(data, new String(result));
  }
  @Test
  public void testCloseQuietlyOutput() throws Exception {
    Mockito.doThrow(new IOException()).when(output).close();

    try {
      TypeHandlerUtils.closeQuietly(output);
    } catch (Exception ex) {
      fail();
    }
  }
  @Test
  public void testCopy() throws Exception {
    String data = "rar";
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    InputStream inputStream = new ByteArrayInputStream(data.getBytes());

    TypeHandlerUtils.copy(inputStream, outputStream);

    Assert.assertEquals(data, new String(outputStream.toByteArray()));
  }
  @Test
  public void testConvertSqlXmlConnString() throws Exception {
    testConvertSqlXmlPrepare();

    TypeHandlerUtils.convertSqlXml(conn, "PCX");

    // verify(conn, times(1)).createSQLXML();
    MappingUtils.invokeFunction(
        verify(conn, times(1)), "createSQLXML", new Class[] {}, new Object[] {});
    testConvertSqlXmlCheck();
  }
  @Test
  public void testConvertBlobConnInputStream() throws Exception {
    testConvertBlobPrepare();

    TypeHandlerUtils.convertBlob(conn, new ByteArrayInputStream("BMP".getBytes()));

    // verify(conn, times(1)).createBlob();
    MappingUtils.invokeFunction(
        verify(conn, times(1)), "createBlob", new Class[] {}, new Object[] {});
    testConvertBlobCheck();
  }
  @Test
  public void testConvertClobConnByte() throws Exception {
    testConvertClobPrepare();

    TypeHandlerUtils.convertClob(conn, "GIF".getBytes());

    // verify(conn, times(1)).createClob();
    MappingUtils.invokeFunction(
        verify(conn, times(1)), "createClob", new Class[] {}, new Object[] {});
    testConvertClobCheck();
  }
  @Test
  public void testConvertArrayCollection() throws Exception {
    Object[] array = new String[] {"Venus"};

    TypeHandlerUtils.convertArray(conn, Arrays.asList(array));

    // verify(conn, times(1)).createArrayOf("VARCHAR", array);
    MappingUtils.invokeFunction(
        verify(conn, times(1)),
        "createArrayOf",
        new Class[] {String.class, Object[].class},
        new Object[] {"VARCHAR", array});
  }
 @Test
 public void testConvertJavaClassToSqlType() throws Exception {
   Assert.assertEquals("VARCHAR", TypeHandlerUtils.convertJavaClassToSqlType("String"));
 }