Add mock ScheduledExecutorService
This commit is contained in:
parent
34589e34d7
commit
02dc9842f8
6
pom.xml
6
pom.xml
|
@ -143,6 +143,12 @@
|
||||||
<artifactId>jersey-test-framework-provider-jetty</artifactId>
|
<artifactId>jersey-test-framework-provider-jetty</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-core</artifactId>
|
||||||
|
<version>2.2.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -10,25 +10,31 @@ import org.junit.AfterClass;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
public class DatastoreServiceIntegrationTest {
|
public class DatastoreServiceIntegrationTest {
|
||||||
|
|
||||||
private static ServiceLocator locator;
|
private static ServiceLocator locator;
|
||||||
private static DatastoreService datastoreService;
|
private static DatastoreService datastoreService;
|
||||||
|
|
||||||
|
private static ScheduledExecutorService mockScheduledExecutorService;
|
||||||
|
|
||||||
// BeforeClass because there's no reason to start/stop Elasticsearch for every test when
|
// BeforeClass because there's no reason to start/stop Elasticsearch for every test when
|
||||||
// all our operations are read-only
|
// all our operations are read-only
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
|
mockScheduledExecutorService = Mockito.mock(ScheduledExecutorService.class);
|
||||||
locator = ServiceLocatorUtilities.bind(
|
locator = ServiceLocatorUtilities.bind(
|
||||||
new io.jenkins.plugins.datastore.Binder(),
|
new io.jenkins.plugins.datastore.Binder(),
|
||||||
new AbstractBinder() {
|
new AbstractBinder() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
bind(mockScheduledExecutorService.getClass()).to(ScheduledExecutorService.class).in(Singleton.class);
|
||||||
bind(MockConfigurationService.class).to(ConfigurationService.class).in(Singleton.class);
|
bind(MockConfigurationService.class).to(ConfigurationService.class).in(Singleton.class);
|
||||||
bind(ElasticsearchDatastoreService.class).to(DatastoreService.class).in(Singleton.class);
|
bind(ElasticsearchDatastoreService.class).to(DatastoreService.class).in(Singleton.class);
|
||||||
bind(HttpClientWikiService.class).to(WikiService.class).in(Singleton.class);
|
bind(HttpClientWikiService.class).to(WikiService.class).in(Singleton.class);
|
||||||
|
|
|
@ -8,6 +8,9 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Mocked ConfigurationService</p>
|
||||||
|
*/
|
||||||
public class MockConfigurationService implements ConfigurationService {
|
public class MockConfigurationService implements ConfigurationService {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(MockConfigurationService.class);
|
private final Logger logger = LoggerFactory.getLogger(MockConfigurationService.class);
|
||||||
|
|
Loading…
Reference in New Issue