/** * Tests sendInitialSQL method. * * @throws SecurityException * @throws NoSuchFieldException * @throws IllegalArgumentException * @throws IllegalAccessException * @throws SQLException */ @Test public void testSendInitialSQL() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, SQLException { BoneCPConfig mockConfig = createNiceMock(BoneCPConfig.class); expect(mockPool.getConfig()).andReturn(mockConfig).anyTimes(); expect(mockConfig.getInitSQL()).andReturn("test").anyTimes(); testClass.setInternalConnection(mockConnection); Statement mockStatement = createNiceMock(Statement.class); ResultSet mockResultSet = createNiceMock(ResultSet.class); expect(mockConnection.createStatement()).andReturn(mockStatement).once(); expect(mockStatement.executeQuery("test")).andReturn(mockResultSet).once(); mockResultSet.close(); expectLastCall().once(); replay(mockConfig, mockPool, mockConnection, mockStatement, mockResultSet); testClass.sendInitSQL(); verify(mockConfig, mockPool, mockConnection, mockStatement, mockResultSet); }