1   /*
2    * This file is part of AceLogger.
3    * 
4    * AceLogger is free software: you can redistribute it and/or modify it under the terms of the GNU
5    * Lesser General Public License as published by the Free Software Foundation, either version 3 of
6    * the License, or (at your option) any later version.
7    * 
8    * AceLogger is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
9    * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10   * Lesser General Public License for more details.
11   * 
12   * You should have received a copy of the GNU Lesser General Public License along with AceLogger.
13   * If not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
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   * TODO: Create Doc.
30   * 
31   * @author Zardi (https://sourceforge.net/users/daniel_zardi)
32   * @version 1.0.0
33   * @since 1.0.0
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  }