| 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 2.2 3.3 4.4 5.5 6.6 |
|
| 38 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 |