public void testWrappers() throws Exception {
    if (log.isDebugEnabled()) {
      log.debug("*** Starting testWrappers");
    }
    try {
      Connection.class.getMethod("isWrapperFor");
    } catch (NoSuchMethodException e) {
      // if there is no such method this means the JVM is running with pre-JDBC4 classes
      // so this test becomes pointless and must be skipped
      return;
    }

    // XADataSource
    assertTrue(pds.isWrapperFor(XADataSource.class));
    assertFalse(pds.isWrapperFor(DataSource.class));
    XADataSource unwrappedXads = (XADataSource) pds.unwrap(XADataSource.class);
    assertEquals(MockitoXADataSource.class.getName(), unwrappedXads.getClass().getName());

    // Connection
    Connection c = pds.getConnection();
    assertTrue(isWrapperFor(c, Connection.class));
    Connection unwrappedConnection = (Connection) unwrap(c, Connection.class);
    assertTrue(
        unwrappedConnection.getClass().getName().contains("java.sql.Connection")
            && unwrappedConnection.getClass().getName().contains("EnhancerByMockito"));

    // Statement
    Statement stmt = c.createStatement();
    assertTrue(isWrapperFor(stmt, Statement.class));
    Statement unwrappedStmt = (Statement) unwrap(stmt, Statement.class);
    assertTrue(
        unwrappedStmt.getClass().getName().contains("java.sql.Statement")
            && unwrappedStmt.getClass().getName().contains("EnhancerByMockito"));

    // PreparedStatement
    PreparedStatement pstmt = c.prepareStatement("mock sql");
    assertTrue(isWrapperFor(pstmt, PreparedStatement.class));
    Statement unwrappedPStmt = (Statement) unwrap(pstmt, PreparedStatement.class);
    assertTrue(
        unwrappedPStmt.getClass().getName().contains("java.sql.PreparedStatement")
            && unwrappedPStmt.getClass().getName().contains("EnhancerByMockito"));

    // CallableStatement
    CallableStatement cstmt = c.prepareCall("mock stored proc");
    assertTrue(isWrapperFor(cstmt, CallableStatement.class));
    Statement unwrappedCStmt = (Statement) unwrap(cstmt, CallableStatement.class);
    assertTrue(
        unwrappedCStmt.getClass().getName().contains("java.sql.CallableStatement")
            && unwrappedCStmt.getClass().getName().contains("EnhancerByMockito"));
  }