CR-IC-2008 (mock JRE update)

This commit is contained in:
Roman Shevchenko
2013-08-22 11:40:57 +04:00
parent 36e54e9219
commit 1b24edcc68
4 changed files with 365 additions and 17 deletions

View File

@@ -15,20 +15,154 @@ public class SCR20557 {
private final MyResultSet myResultSet = new MyResultSet(); private final MyResultSet myResultSet = new MyResultSet();
protected abstract Object getObject(int columnIndex, Map<String, Class<?>> map)
throws SQLException;
protected abstract Object getObject(String columnLabel, Map<String, Class<?>> map)
throws SQLException;
protected abstract RowId getRowId(int columnIndex) throws SQLException;
protected abstract RowId getRowId(String columnLabel) throws SQLException;
protected abstract void updateRowId(int columnIndex, RowId x) throws SQLException;
protected abstract void updateRowId(String columnLabel, RowId x) throws SQLException;
protected abstract int getHoldability() throws SQLException;
protected abstract boolean isClosed() throws SQLException;
protected abstract void updateNString(int columnIndex, String nString) throws SQLException;
protected abstract void updateNString(String columnLabel, String nString) throws SQLException;
protected abstract void updateNClob(int columnIndex, NClob nClob) throws SQLException;
protected abstract void updateNClob(String columnLabel, NClob nClob) throws SQLException;
protected abstract NClob getNClob(int columnIndex) throws SQLException;
protected abstract NClob getNClob(String columnLabel) throws SQLException;
protected abstract SQLXML getSQLXML(int columnIndex) throws SQLException;
protected abstract SQLXML getSQLXML(String columnLabel) throws SQLException;
protected abstract void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException;
protected abstract void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException;
protected abstract String getNString(int columnIndex) throws SQLException;
protected abstract String getNString(String columnLabel) throws SQLException;
protected abstract Reader getNCharacterStream(int columnIndex) throws SQLException;
protected abstract Reader getNCharacterStream(String columnLabel) throws SQLException;
protected abstract void updateNCharacterStream(int columnIndex,
Reader x,
long length) throws SQLException;
protected abstract void updateNCharacterStream(String columnLabel,
Reader reader,
long length) throws SQLException;
protected abstract void updateAsciiStream(int columnIndex,
InputStream x,
long length) throws SQLException;
protected abstract void updateBinaryStream(int columnIndex,
InputStream x,
long length) throws SQLException;
protected abstract void updateCharacterStream(int columnIndex,
Reader x,
long length) throws SQLException;
protected abstract void updateAsciiStream(String columnLabel,
InputStream x,
long length) throws SQLException;
protected abstract void updateBinaryStream(String columnLabel,
InputStream x,
long length) throws SQLException;
protected abstract void updateCharacterStream(String columnLabel,
Reader reader,
long length) throws SQLException;
protected abstract void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException;
protected abstract void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException;
protected abstract void updateClob(int columnIndex, Reader reader, long length) throws SQLException;
protected abstract void updateClob(String columnLabel, Reader reader, long length) throws SQLException;
protected abstract void updateNClob(int columnIndex, Reader reader, long length) throws SQLException;
protected abstract void updateNClob(String columnLabel, Reader reader, long length) throws SQLException;
protected abstract void updateNCharacterStream(int columnIndex,
Reader x) throws SQLException;
protected abstract void updateNCharacterStream(String columnLabel,
Reader reader) throws SQLException;
protected abstract void updateAsciiStream(int columnIndex,
InputStream x) throws SQLException;
protected abstract void updateBinaryStream(int columnIndex,
InputStream x) throws SQLException;
protected abstract void updateCharacterStream(int columnIndex,
Reader x) throws SQLException;
protected abstract void updateAsciiStream(String columnLabel,
InputStream x) throws SQLException;
protected abstract void updateBinaryStream(String columnLabel,
InputStream x) throws SQLException;
protected abstract void updateCharacterStream(String columnLabel,
Reader reader) throws SQLException;
protected abstract void updateBlob(int columnIndex, InputStream inputStream) throws SQLException;
protected abstract void updateBlob(String columnLabel, InputStream inputStream) throws SQLException;
protected abstract void updateClob(int columnIndex, Reader reader) throws SQLException;
protected abstract void updateClob(String columnLabel, Reader reader) throws SQLException;
protected abstract void updateNClob(int columnIndex, Reader reader) throws SQLException;
protected abstract void updateNClob(String columnLabel, Reader reader) throws SQLException;
protected abstract <T> T getObject(int columnIndex, Class<T> type) throws SQLException;
protected abstract <T> T getObject(String columnLabel, Class<T> type) throws SQLException;
protected abstract <T> T unwrap(Class<T> iface) throws SQLException;
protected abstract boolean isWrapperFor(Class<?> iface) throws SQLException;
public Date getDate(int columnIndex) throws SQLException { public Date getDate(int columnIndex) throws SQLException {
return myResultSet.getDate(columnIndex); return myResultSet.getDate(columnIndex);
} }
public Date getDate(String columnName) throws SQLException { public Date getDate(String columnLabel) throws SQLException {
return myResultSet.getDate(columnName); return myResultSet.getDate(columnLabel);
} }
public Date getDate(int columnIndex, Calendar cal) throws SQLException { public Date getDate(int columnIndex, Calendar cal) throws SQLException {
return myResultSet.getDate(columnIndex, cal); return myResultSet.getDate(columnIndex, cal);
} }
public Date getDate(String columnName, Calendar cal) throws SQLException { public Date getDate(String columnLabel, Calendar cal) throws SQLException {
return myResultSet.getDate(columnName, cal); return myResultSet.getDate(columnLabel, cal);
} }
private class MyResultSet implements ResultSet { private class MyResultSet implements ResultSet {
@@ -528,5 +662,221 @@ public class SCR20557 {
public boolean relative(int rows) throws SQLException { public boolean relative(int rows) throws SQLException {
return false; return false;
} }
public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
return SCR20557.this.getObject(columnIndex, map);
}
public Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException {
return SCR20557.this.getObject(columnLabel, map);
}
public RowId getRowId(int columnIndex) throws SQLException {
return SCR20557.this.getRowId(columnIndex);
}
public RowId getRowId(String columnLabel) throws SQLException {
return SCR20557.this.getRowId(columnLabel);
}
public void updateRowId(int columnIndex, RowId x) throws SQLException {
SCR20557.this.updateRowId(columnIndex, x);
}
public void updateRowId(String columnLabel, RowId x) throws SQLException {
SCR20557.this.updateRowId(columnLabel, x);
}
public int getHoldability() throws SQLException {
return SCR20557.this.getHoldability();
}
public boolean isClosed() throws SQLException {
return SCR20557.this.isClosed();
}
public void updateNString(int columnIndex, String nString) throws SQLException {
SCR20557.this.updateNString(columnIndex, nString);
}
public void updateNString(String columnLabel, String nString) throws SQLException {
SCR20557.this.updateNString(columnLabel, nString);
}
public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
SCR20557.this.updateNClob(columnIndex, nClob);
}
public void updateNClob(String columnLabel, NClob nClob) throws SQLException {
SCR20557.this.updateNClob(columnLabel, nClob);
}
public NClob getNClob(int columnIndex) throws SQLException {
return SCR20557.this.getNClob(columnIndex);
}
public NClob getNClob(String columnLabel) throws SQLException {
return SCR20557.this.getNClob(columnLabel);
}
public SQLXML getSQLXML(int columnIndex) throws SQLException {
return SCR20557.this.getSQLXML(columnIndex);
}
public SQLXML getSQLXML(String columnLabel) throws SQLException {
return SCR20557.this.getSQLXML(columnLabel);
}
public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
SCR20557.this.updateSQLXML(columnIndex, xmlObject);
}
public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
SCR20557.this.updateSQLXML(columnLabel, xmlObject);
}
public String getNString(int columnIndex) throws SQLException {
return SCR20557.this.getNString(columnIndex);
}
public String getNString(String columnLabel) throws SQLException {
return SCR20557.this.getNString(columnLabel);
}
public Reader getNCharacterStream(int columnIndex) throws SQLException {
return SCR20557.this.getNCharacterStream(columnIndex);
}
public Reader getNCharacterStream(String columnLabel) throws SQLException {
return SCR20557.this.getNCharacterStream(columnLabel);
}
public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
SCR20557.this.updateNCharacterStream(columnIndex, x, length);
}
public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
SCR20557.this.updateNCharacterStream(columnLabel, reader, length);
}
public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
SCR20557.this.updateAsciiStream(columnIndex, x, length);
}
public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
SCR20557.this.updateBinaryStream(columnIndex, x, length);
}
public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
SCR20557.this.updateCharacterStream(columnIndex, x, length);
}
public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
SCR20557.this.updateAsciiStream(columnLabel, x, length);
}
public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
SCR20557.this.updateBinaryStream(columnLabel, x, length);
}
public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
SCR20557.this.updateCharacterStream(columnLabel, reader, length);
}
public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
SCR20557.this.updateBlob(columnIndex, inputStream, length);
}
public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
SCR20557.this.updateBlob(columnLabel, inputStream, length);
}
public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
SCR20557.this.updateClob(columnIndex, reader, length);
}
public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
SCR20557.this.updateClob(columnLabel, reader, length);
}
public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
SCR20557.this.updateNClob(columnIndex, reader, length);
}
public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
SCR20557.this.updateNClob(columnLabel, reader, length);
}
public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
SCR20557.this.updateNCharacterStream(columnIndex, x);
}
public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
SCR20557.this.updateNCharacterStream(columnLabel, reader);
}
public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
SCR20557.this.updateAsciiStream(columnIndex, x);
}
public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
SCR20557.this.updateBinaryStream(columnIndex, x);
}
public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
SCR20557.this.updateCharacterStream(columnIndex, x);
}
public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
SCR20557.this.updateAsciiStream(columnLabel, x);
}
public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
SCR20557.this.updateBinaryStream(columnLabel, x);
}
public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
SCR20557.this.updateCharacterStream(columnLabel, reader);
}
public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
SCR20557.this.updateBlob(columnIndex, inputStream);
}
public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
SCR20557.this.updateBlob(columnLabel, inputStream);
}
public void updateClob(int columnIndex, Reader reader) throws SQLException {
SCR20557.this.updateClob(columnIndex, reader);
}
public void updateClob(String columnLabel, Reader reader) throws SQLException {
SCR20557.this.updateClob(columnLabel, reader);
}
public void updateNClob(int columnIndex, Reader reader) throws SQLException {
SCR20557.this.updateNClob(columnIndex, reader);
}
public void updateNClob(String columnLabel, Reader reader) throws SQLException {
SCR20557.this.updateNClob(columnLabel, reader);
}
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
return SCR20557.this.getObject(columnIndex, type);
}
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
return SCR20557.this.getObject(columnLabel, type);
}
public <T> T unwrap(Class<T> iface) throws SQLException {
return SCR20557.this.unwrap(iface);
}
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return SCR20557.this.isWrapperFor(iface);
}
} }
} }

Binary file not shown.

Binary file not shown.

View File

@@ -38,25 +38,23 @@ public class JDBCResourceInspectionTest extends LightInspectionTestCase {
} }
public void testARM() { public void testARM() {
// doesn't work with mock jdk doTest("import java.sql.*;\n" +
/*doTest("import java.sql.*;" + "class X {\n" +
"class X {" + " void m(Driver driver) throws SQLException {\n" +
" void m(Driver driver) throws SQLException {" + " try (Connection connection = driver.connect(\"jdbc\", null);\n" +
" try (Connection connection = driver.connect(\"asdf\", null);" + " PreparedStatement statement = connection.prepareStatement(\"SELECT *\");\n" +
" PreparedStatement statement = connection.prepareStatement(\"SELECT *\");" + " ResultSet resultSet = statement.executeQuery()) {\n" +
" ResultSet resultSet = statement.executeQuery()) {" + " while (resultSet.next()) { resultSet.getMetaData(); }\n" +
" while (resultSet.next()) {" + " }\n" +
" }" + " }\n" +
" }" + "}");
" }" +
"}");*/
} }
public void testSimple() { public void testSimple() {
doTest("import java.sql.*;" + doTest("import java.sql.*;" +
"class X {" + "class X {" +
" void m(Driver driver) throws SQLException {" + " void m(Driver driver) throws SQLException {" +
" /*'Connection' should be opened in front of a 'try' block and closed in the corresponding 'finally' block*/driver.connect(\"asdf\", null)/**/;" + " /*'Connection' should be opened in front of a 'try' block and closed in the corresponding 'finally' block*/driver.connect(\"jdbc\", null)/**/;" +
" }" + " }" +
"}"); "}");
} }