RandomServerPortProvider.java

1
package fr.sii.ogham.testing.sms.simulator.config;
2
3
import fr.sii.ogham.testing.util.RandomPortUtils;
4
5
/**
6
 * Provider that provides a random port.
7
 * 
8
 * This provider can be reseted in order to provide a different random port each
9
 * time.
10
 * 
11
 * @author Aurélien Baudet
12
 *
13
 */
14
public class RandomServerPortProvider implements ServerPortProvider {
15
	private final int minPort;
16
	private final int maxPort;
17
	private int currentPort;
18
19
	/**
20
	 * Initialize with the port range.
21
	 * 
22
	 * @param minPort
23
	 *            the minimum port value
24
	 * @param maxPort
25
	 *            the maximum port value
26
	 */
27
	public RandomServerPortProvider(int minPort, int maxPort) {
28
		super();
29
		this.minPort = minPort;
30
		this.maxPort = maxPort;
31
	}
32
33
	@Override
34
	public int getPort() {
35 6 1. getPort : negated conditional → SURVIVED
2. getPort : negated conditional → NO_COVERAGE
3. getPort : negated conditional → TIMED_OUT
4. getPort : negated conditional → KILLED
5. getPort : negated conditional → KILLED
6. getPort : negated conditional → KILLED
		if (currentPort == 0) {
36
			currentPort = RandomPortUtils.findAvailableTcpPort(minPort, maxPort);
37
		}
38 7 1. getPort : replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/config/RandomServerPortProvider::getPort → NO_COVERAGE
2. getPort : replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/config/RandomServerPortProvider::getPort → SURVIVED
3. getPort : replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/config/RandomServerPortProvider::getPort → TIMED_OUT
4. getPort : replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/config/RandomServerPortProvider::getPort → KILLED
5. getPort : replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/config/RandomServerPortProvider::getPort → KILLED
6. getPort : replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/config/RandomServerPortProvider::getPort → KILLED
7. getPort : replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/config/RandomServerPortProvider::getPort → KILLED
		return currentPort;
39
	}
40
41
	@Override
42
	public void reset() {
43
		currentPort = 0;
44
	}
45
46
}

Mutations

35

1.1
Location : getPort
Killed by : none
negated conditional → SURVIVED

2.2
Location : getPort
Killed by : oghamall.it.freemarker.StaticMethodAccessDisabledTest.smsUsingFreemarkerTemplateAndStaticMethodAccessDisabledShouldFail(oghamall.it.freemarker.StaticMethodAccessDisabledTest)
negated conditional → KILLED

3.3
Location : getPort
Killed by : oghamtesting.it.sms.simulator.JsmppSimulatorSpec
negated conditional → KILLED

4.4
Location : getPort
Killed by : oghamcloudhopper.it.PartialConfigurationTest.splitterEnabledButAutoGuessNotEnabledAndNoEncodingConfiguredAndLongMessageShouldFailIndicatingThatNoSplitterIsConfigured(oghamcloudhopper.it.PartialConfigurationTest)
negated conditional → KILLED

5.5
Location : getPort
Killed by : none
negated conditional → NO_COVERAGE

6.6
Location : getPort
Killed by : none
negated conditional → TIMED_OUT

38

1.1
Location : getPort
Killed by : none
replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/config/RandomServerPortProvider::getPort → NO_COVERAGE

2.2
Location : getPort
Killed by : oghamcloudhopper.it.PartialConfigurationTest.splitterEnabledButAutoGuessNotEnabledAndNoEncodingConfiguredAndLongMessageShouldFailIndicatingThatNoSplitterIsConfigured(oghamcloudhopper.it.PartialConfigurationTest)
replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/config/RandomServerPortProvider::getPort → KILLED

3.3
Location : getPort
Killed by : oghamspringbootv2autoconfigure.it.StaticMethodAccessTest.smsUsingFreemarkerTemplateAndStaticMethodAccessDisabledShouldFail(oghamspringbootv2autoconfigure.it.StaticMethodAccessTest)
replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/config/RandomServerPortProvider::getPort → KILLED

4.4
Location : getPort
Killed by : none
replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/config/RandomServerPortProvider::getPort → TIMED_OUT

5.5
Location : getPort
Killed by : oghamall.it.freemarker.StaticMethodAccessDisabledTest.smsUsingFreemarkerTemplateAndStaticMethodAccessDisabledShouldFail(oghamall.it.freemarker.StaticMethodAccessDisabledTest)
replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/config/RandomServerPortProvider::getPort → KILLED

6.6
Location : getPort
Killed by : none
replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/config/RandomServerPortProvider::getPort → SURVIVED

7.7
Location : getPort
Killed by : oghamtesting.it.sms.simulator.JsmppSimulatorSpec
replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/config/RandomServerPortProvider::getPort → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM