| 1 | package fr.sii.ogham.testing.sms.simulator.jsmpp; | |
| 2 | ||
| 3 | import java.io.IOException; | |
| 4 | import java.util.List; | |
| 5 | import java.util.Objects; | |
| 6 | import java.util.concurrent.TimeoutException; | |
| 7 | ||
| 8 | import org.jsmpp.PDUStringException; | |
| 9 | import org.jsmpp.SMPPConstant; | |
| 10 | import org.jsmpp.bean.InterfaceVersion; | |
| 11 | import org.jsmpp.session.BindRequest; | |
| 12 | import org.jsmpp.session.SMPPServerSession; | |
| 13 | import org.slf4j.Logger; | |
| 14 | import org.slf4j.LoggerFactory; | |
| 15 | ||
| 16 | import fr.sii.ogham.testing.sms.simulator.config.Credentials; | |
| 17 | ||
| 18 | class WaitBindTask implements Runnable { | |
| 19 | private static final int WAIT_DURATION = 1000; | |
| 20 | ||
| 21 | private static final Logger LOG = LoggerFactory.getLogger(WaitBindTask.class); | |
| 22 | ||
| 23 | private final SMPPServerSession serverSession; | |
| 24 | private final List<Credentials> serverCredentials; | |
| 25 | ||
| 26 | public WaitBindTask(SMPPServerSession serverSession, List<Credentials> serverCredentials) { | |
| 27 | this.serverSession = serverSession; | |
| 28 | this.serverCredentials = serverCredentials; | |
| 29 | } | |
| 30 | ||
| 31 | public void run() { | |
| 32 | try { | |
| 33 | BindRequest bindRequest = serverSession.waitForBind(WAIT_DURATION); | |
| 34 | LOG.info("Accepting bind for session {}, interface version {}", serverSession.getSessionId(), InterfaceVersion.IF_34); | |
| 35 |
3
1. run : removed call to fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::bind → NO_COVERAGE 2. run : removed call to fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::bind → TIMED_OUT 3. run : removed call to fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::bind → KILLED |
bind(bindRequest); |
| 36 | } catch (IllegalStateException e) { | |
| 37 | LOG.error("System error", e); | |
| 38 | } catch (TimeoutException e) { | |
| 39 | LOG.warn("Wait for bind has reach timeout", e); | |
| 40 | } catch (IOException e) { | |
| 41 | LOG.error("Failed accepting bind request for session {}", serverSession.getSessionId(), e); | |
| 42 | } | |
| 43 | } | |
| 44 | ||
| 45 | private void bind(BindRequest bindRequest) throws IOException { | |
| 46 | try { | |
| 47 |
5
1. bind : negated conditional → NO_COVERAGE 2. bind : negated conditional → TIMED_OUT 3. bind : negated conditional → KILLED 4. bind : negated conditional → KILLED 5. bind : negated conditional → KILLED |
if (checkPassword(bindRequest)) { |
| 48 |
2
1. bind : removed call to org/jsmpp/session/BindRequest::accept → NO_COVERAGE 2. bind : removed call to org/jsmpp/session/BindRequest::accept → TIMED_OUT |
bindRequest.accept(bindRequest.getSystemId(), InterfaceVersion.IF_34); |
| 49 | } else { | |
| 50 |
2
1. bind : removed call to org/jsmpp/session/BindRequest::reject → NO_COVERAGE 2. bind : removed call to org/jsmpp/session/BindRequest::reject → TIMED_OUT |
bindRequest.reject(SMPPConstant.STAT_ESME_RINVPASWD); |
| 51 | } | |
| 52 | } catch (PDUStringException e) { | |
| 53 | LOG.error("Invalid system id", e); | |
| 54 |
1
1. bind : removed call to org/jsmpp/session/BindRequest::reject → NO_COVERAGE |
bindRequest.reject(SMPPConstant.STAT_ESME_RSYSERR); |
| 55 | } | |
| 56 | } | |
| 57 | ||
| 58 | private boolean checkPassword(BindRequest bindRequest) { | |
| 59 | // no credentials registered => allow requests | |
| 60 |
10
1. checkPassword : negated conditional → NO_COVERAGE 2. checkPassword : negated conditional → SURVIVED 3. checkPassword : negated conditional → NO_COVERAGE 4. checkPassword : negated conditional → TIMED_OUT 5. checkPassword : negated conditional → TIMED_OUT 6. checkPassword : negated conditional → KILLED 7. checkPassword : negated conditional → KILLED 8. checkPassword : negated conditional → KILLED 9. checkPassword : negated conditional → KILLED 10. checkPassword : negated conditional → KILLED |
if (serverCredentials == null || serverCredentials.isEmpty()) { |
| 61 |
5
1. checkPassword : replaced boolean return with false for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → NO_COVERAGE 2. checkPassword : replaced boolean return with false for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → TIMED_OUT 3. checkPassword : replaced boolean return with false for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → KILLED 4. checkPassword : replaced boolean return with false for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → KILLED 5. checkPassword : replaced boolean return with false for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → KILLED |
return true; |
| 62 | } | |
| 63 | for (Credentials creds : serverCredentials) { | |
| 64 |
6
1. checkPassword : negated conditional → NO_COVERAGE 2. checkPassword : negated conditional → NO_COVERAGE 3. checkPassword : negated conditional → KILLED 4. checkPassword : negated conditional → KILLED 5. checkPassword : negated conditional → KILLED 6. checkPassword : negated conditional → KILLED |
if (Objects.equals(creds.getSystemId(), bindRequest.getSystemId()) && Objects.equals(creds.getPassword(), bindRequest.getPassword())) { |
| 65 |
2
1. checkPassword : replaced boolean return with false for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → NO_COVERAGE 2. checkPassword : replaced boolean return with false for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → KILLED |
return true; |
| 66 | } | |
| 67 | } | |
| 68 |
3
1. checkPassword : replaced boolean return with true for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → NO_COVERAGE 2. checkPassword : replaced boolean return with true for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → KILLED 3. checkPassword : replaced boolean return with true for fr/sii/ogham/testing/sms/simulator/jsmpp/WaitBindTask::checkPassword → KILLED |
return false; |
| 69 | } | |
| 70 | } | |
Mutations | ||
| 35 |
1.1 2.2 3.3 |
|
| 47 |
1.1 2.2 3.3 4.4 5.5 |
|
| 48 |
1.1 2.2 |
|
| 50 |
1.1 2.2 |
|
| 54 |
1.1 |
|
| 60 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 |
|
| 61 |
1.1 2.2 3.3 4.4 5.5 |
|
| 64 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
| 65 |
1.1 2.2 |
|
| 68 |
1.1 2.2 3.3 |