1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package net.sourceforge.acelogger.factory.test;
16
17 import java.util.List;
18
19 import org.testng.annotations.DataProvider;
20 import org.testng.annotations.Test;
21
22 import net.sourceforge.acelogger.execution.manager.ExecutorManager;
23 import net.sourceforge.acelogger.factory.ExecutorManagerFactory;
24 import net.sourceforge.acelogger.test.DataProviderHelper;
25
26 import static org.testng.Assert.assertTrue;
27
28
29
30
31
32
33
34
35 @Test
36 public class ExecutorManagerFactoryTest {
37
38 @DataProvider(name = "getRegisteredExecutorsDataProvider")
39 public Object[][] getRegisteredExecutorsDataProvider() {
40 return DataProviderHelper.loadData();
41 }
42
43 @Test(dataProvider = "getRegisteredExecutorsDataProvider")
44 public void testGetRegisteredExecutors(List<ExecutorManager> executors) {
45 List<ExecutorManager> expected = ExecutorManagerFactory.getRegisteredExecutorManagers();
46 expected.addAll(executors);
47 for (ExecutorManager currentExecutor : executors) {
48 ExecutorManagerFactory.registerExecutorManager(currentExecutor);
49 }
50 List<ExecutorManager> registered = ExecutorManagerFactory.getRegisteredExecutorManagers();
51 assertTrue(registered.containsAll(expected) && registered.size() == expected.size());
52 }
53
54 @Test
55 public void testSetNullExecutorManager() {
56 List<ExecutorManager> previouslyRegistered = ExecutorManagerFactory
57 .getRegisteredExecutorManagers();
58 ExecutorManager register = ExecutorManagerFactory.registerExecutorManager(null);
59 List<ExecutorManager> currentlyRegistered = ExecutorManagerFactory
60 .getRegisteredExecutorManagers();
61 assertTrue(register.equals(ExecutorManagerFactory.getDefaultExecutorManager())
62 && currentlyRegistered.containsAll(previouslyRegistered)
63 && currentlyRegistered.size() == previouslyRegistered.size());
64 }
65
66 }