StatementHandle implements Statement { public int[] executeBatch() throws SQLException { int[] result = null; checkClosed(); try{ if (this.logStatementsEnabled && logger.isDebugEnabled()){ logger.debug(PoolUtil.fillLogParams(this.batchSQL.toString(), this.logParams)); } long queryStartTime = queryTimerStart(); String query = ""; if (this.connectionHook != null){ query = this.batchSQL.toString(); this.connectionHook.onBeforeStatementExecute(this.connectionHandle, this, query, this.logParams); } result = this.internalStatement.executeBatch(); if (this.connectionHook != null){ this.connectionHook.onAfterStatementExecute(this.connectionHandle, this, query, this.logParams); } queryTimerEnd(this.logStatementsEnabled ? this.batchSQL.toString() : "", queryStartTime); if (this.logStatementsEnabled){ this.logParams.clear(); this.batchSQL = new StringBuilder(); } } catch (SQLException e) { throw this.connectionHandle.markPossiblyBroken(e); } return result; } StatementHandle(Statement internalStatement, String sql, IStatementCache cache, 
						   ConnectionHandle connectionHandle, String cacheKey, 
						   boolean logStatementsEnabled);  StatementHandle(Statement internalStatement, ConnectionHandle connectionHandle, boolean logStatementsEnabled); void close(); void addBatch(String sql); void cancel(); void clearBatch(); void clearWarnings(); boolean execute(String sql); boolean execute(String sql, int autoGeneratedKeys); boolean execute(String sql, int[] columnIndexes); boolean execute(String sql, String[] columnNames); int[] executeBatch(); ResultSet executeQuery(String sql); int executeUpdate(String sql); int executeUpdate(String sql, int autoGeneratedKeys); int executeUpdate(String sql, int[] columnIndexes); int executeUpdate(String sql, String[] columnNames); Connection getConnection(); int getFetchDirection(); int getFetchSize(); ResultSet getGeneratedKeys(); int getMaxFieldSize(); int getMaxRows(); boolean getMoreResults(); boolean getMoreResults(int current); int getQueryTimeout(); ResultSet getResultSet(); int getResultSetConcurrency(); int getResultSetHoldability(); int getResultSetType(); int getUpdateCount(); SQLWarning getWarnings(); boolean isClosed(); void setPoolable(boolean poolable); boolean isWrapperFor(Class<?> iface); T unwrap(Class<T> iface); boolean isPoolable(); void closeOnCompletion(); boolean isCloseOnCompletion(); void setCursorName(String name); void setEscapeProcessing(boolean enable); void setFetchDirection(int direction); void setFetchSize(int rows); void setMaxFieldSize(int max); void setMaxRows(int max); void setQueryTimeout(int seconds); @Override String toString(); String getOpenStackTrace(); void setOpenStackTrace(String openStackTrace); Statement getInternalStatement(); void setInternalStatement(Statement internalStatement); void setDebugHandle(Object debugHandle); Object getDebugHandle(); volatile boolean inCache; public String openStackTrace; }
@Test public void testAssortedCoverage() throws SQLException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException{ Statement mockStatement = createNiceMock(Statement.class); testClass.logStatementsEnabled = false; Field field = testClass.getClass().getDeclaredField("internalStatement"); field.setAccessible(true); field.set(testClass, mockStatement); expect(mockStatement.executeBatch()).andReturn(null).once(); replay(mockStatement); testClass.executeBatch(); }