### Question:
LocalTransactionConnection implements Connection { @SuppressWarnings("unchecked") @Override public <T> T unwrap(Class<T> iface) throws SQLException { if (iface == null) { throw new SQLException("iface must not be null"); } if (iface.isAssignableFrom(getClass())) { return (T) this; } return connection.unwrap(iface); } LocalTransactionConnection(
      Connection connection, int preservedTransactionIsolation, boolean preservedAutoCommitState); Connection getWrappedConnection(); @Override void clearWarnings(); @Override void close(); @Override void commit(); @Override Array createArrayOf(String typeName, Object[] elements); @Override Blob createBlob(); @Override Clob createClob(); @Override NClob createNClob(); @Override SQLXML createSQLXML(); @Override Statement createStatement(); @Override Statement createStatement(
      int resultSetType, int resultSetConcurrency, int resultSetHoldability); @Override Statement createStatement(int resultSetType, int resultSetConcurrency); @Override Struct createStruct(String typeName, Object[] attributes); @Override boolean getAutoCommit(); @Override String getCatalog(); @Override Properties getClientInfo(); @Override String getClientInfo(String name); @Override int getHoldability(); @Override DatabaseMetaData getMetaData(); @Override int getTransactionIsolation(); @Override Map<String, Class<?>> getTypeMap(); @Override SQLWarning getWarnings(); @Override boolean isClosed(); @Override boolean isReadOnly(); @Override boolean isValid(int timeout); @Override boolean isWrapperFor(Class<?> iface); @Override String nativeSQL(String sql); @Override CallableStatement prepareCall(
      String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability); @Override CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency); @Override CallableStatement prepareCall(String sql); @Override PreparedStatement prepareStatement(
      String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability); @Override PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency); @Override PreparedStatement prepareStatement(String sql, int autoGeneratedKeys); @Override PreparedStatement prepareStatement(String sql, int[] columnIndexes); @Override PreparedStatement prepareStatement(String sql, String[] columnNames); @Override PreparedStatement prepareStatement(String sql); @Override void releaseSavepoint(Savepoint savepoint); @Override void rollback(); @Override void rollback(Savepoint savepoint); @Override void setAutoCommit(boolean autoCommit); @Override void setCatalog(String catalog); @Override void setClientInfo(Properties properties); @Override void setClientInfo(String name, String value); @Override void setHoldability(int holdability); @Override void setReadOnly(boolean readOnly); @Override Savepoint setSavepoint(); @Override Savepoint setSavepoint(String name); @Override void setTransactionIsolation(int level); @Override void setTypeMap(Map<String, Class<?>> map); @SuppressWarnings("unchecked") @Override T unwrap(Class<T> iface); @Override void setSchema(String schema); @Override String getSchema(); @Override void abort(Executor executor); @Override void setNetworkTimeout(Executor executor, int milliseconds); @Override int getNetworkTimeout();  }### Answer:
@Test public void testUnwrap() throws Exception { try (Connection connection = new LocalTransactionConnection( new MockConnection(), Connection.TRANSACTION_READ_COMMITTED, true)) { assertNotNull(connection.unwrap(LocalTransactionConnection.class)); assertNotNull(connection.unwrap(LocalTransactionConnection.class)); try { connection.unwrap(Runnable.class); fail(); } catch (SQLException ignored) { } } }