Skip to content

Commit

Permalink
Issue quartz-scheduler#491 : Added unit test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdennis committed Oct 23, 2019
1 parent ed7fdf6 commit 9dddfd6
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.quartz.impl.jdbcjobstore;

import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
Expand All @@ -27,7 +28,9 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import org.hamcrest.collection.IsIterableWithSize;
import org.quartz.JobPersistenceException;
import org.quartz.TriggerKey;
import org.quartz.spi.OperableTrigger;
Expand Down Expand Up @@ -135,6 +138,26 @@ public void testSelectSimpleTriggerWithDeleteBeforeSelectExtendedProps() throws
verify(persistenceDelegate).loadExtendedTriggerProperties(any(Connection.class), any(TriggerKey.class));
}

public void testSelectTriggerToAcquireHonorsMaxCount() throws SQLException {

StdJDBCDelegate jdbcDelegate = new StdJDBCDelegate();

Connection conn = mock(Connection.class);
PreparedStatement preparedStatement = mock(PreparedStatement.class);
ResultSet resultSet = mock(ResultSet.class);

when(conn.prepareStatement(anyString())).thenReturn(preparedStatement);

when(preparedStatement.executeQuery()).thenReturn(resultSet);

when(resultSet.next()).thenReturn(true);
when(resultSet.getString(anyString())).thenReturn("test");

List<TriggerKey> triggerKeys = jdbcDelegate.selectTriggerToAcquire(conn, Long.MAX_VALUE, Long.MIN_VALUE, 10);

assertThat(triggerKeys, IsIterableWithSize.<TriggerKey>iterableWithSize(10));
}

static class TestStdJDBCDelegate extends StdJDBCDelegate {

private final TriggerPersistenceDelegate testDelegate;
Expand Down

0 comments on commit 9dddfd6

Please sign in to comment.