[jOOQ/jOOQ#9468] SQLDialect.ASE cannot be used with a MockConnection

This commit is contained in:
Lukas Eder 2019-10-30 14:56:37 +01:00
parent af901e4e28
commit b03bed965b
4 changed files with 46 additions and 18 deletions

View File

@ -353,6 +353,24 @@ public class MockConnection extends JDBC41Connection implements Connection {
return null;
}
// -------------------------------------------------------------------------
// XXX: Unwrapping
// -------------------------------------------------------------------------
@SuppressWarnings("unchecked")
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
if (isWrapperFor(iface))
return (T) this;
else
throw new SQLException("MockConnection does not implement " + iface);
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return iface.isInstance(this);
}
// -------------------------------------------------------------------------
// XXX: Unsupported operations
// -------------------------------------------------------------------------
@ -362,16 +380,6 @@ public class MockConnection extends JDBC41Connection implements Connection {
throw new SQLFeatureNotSupportedException("Unsupported Operation");
}
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
throw new SQLFeatureNotSupportedException("Unsupported Operation");
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
throw new SQLFeatureNotSupportedException("Unsupported Operation");
}
@Override
public String nativeSQL(String sql) throws SQLException {
throw new SQLFeatureNotSupportedException("Unsupported Operation");

View File

@ -98,17 +98,21 @@ public class MockResultSet extends JDBC41ResultSet implements ResultSet, Seriali
}
// -------------------------------------------------------------------------
// XXX: Unsupported implementations
// XXX: Unwrapping
// -------------------------------------------------------------------------
@SuppressWarnings("unchecked")
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
return null;
if (isWrapperFor(iface))
return (T) this;
else
throw new SQLException("MockResultSet does not implement " + iface);
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return false;
return iface.isInstance(this);
}
// -------------------------------------------------------------------------

View File

@ -74,14 +74,22 @@ public class MockResultSetMetaData implements ResultSetMetaData, Serializable {
this.rs = rs;
}
// -------------------------------------------------------------------------
// XXX: Unwrapping
// -------------------------------------------------------------------------
@SuppressWarnings("unchecked")
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
return null;
if (isWrapperFor(iface))
return (T) this;
else
throw new SQLException("MockResultSetMetaData does not implement " + iface);
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return false;
return iface.isInstance(this);
}
@Override

View File

@ -844,19 +844,27 @@ public class MockStatement extends JDBC41Statement implements CallableStatement
}
// -------------------------------------------------------------------------
// XXX: Unsupported operations
// XXX: Unwrapping
// -------------------------------------------------------------------------
@SuppressWarnings("unchecked")
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
throw new SQLFeatureNotSupportedException("Unsupported Operation");
if (isWrapperFor(iface))
return (T) this;
else
throw new SQLException("MockStatement does not implement " + iface);
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
throw new SQLFeatureNotSupportedException("Unsupported Operation");
return iface.isInstance(this);
}
// -------------------------------------------------------------------------
// XXX: Unsupported operations
// -------------------------------------------------------------------------
@Override
public ParameterMetaData getParameterMetaData() throws SQLException {
throw new SQLFeatureNotSupportedException("Unsupported Operation");