ConfigurableSMPPServerSessionListener.java

1
package fr.sii.ogham.testing.sms.simulator.jsmpp;
2
3
import java.io.IOException;
4
5
import org.jsmpp.DefaultPDUReader;
6
import org.jsmpp.DefaultPDUSender;
7
import org.jsmpp.PDUReader;
8
import org.jsmpp.PDUSender;
9
import org.jsmpp.SynchronizedPDUSender;
10
import org.jsmpp.session.SMPPServerSession;
11
import org.jsmpp.session.SMPPServerSessionListener;
12
import org.jsmpp.session.ServerResponseDeliveryListener;
13
import org.jsmpp.session.connection.Connection;
14
import org.jsmpp.session.connection.ServerConnection;
15
import org.jsmpp.session.connection.ServerConnectionFactory;
16
import org.jsmpp.session.connection.socket.ServerSocketConnectionFactory;
17
18
import fr.sii.ogham.testing.sms.simulator.config.ServerDelays;
19
20
/**
21
 * Override default {@link SMPPServerSessionListener}.
22
 * 
23
 * 
24
 * Need to copy code because of visibility of fields.
25
 * 
26
 * @author Aurélien Baudet
27
 *
28
 */
29
public class ConfigurableSMPPServerSessionListener extends SMPPServerSessionListener {
30
	protected final ServerDelays delays;
31
	protected ServerResponseDeliveryListener responseDeliveryListener;
32
	protected final ServerConnection serverConn;
33
34
	public ConfigurableSMPPServerSessionListener(int port, ServerDelays delays, int timeout, int backlog, ServerConnectionFactory serverConnFactory) throws IOException {
35
		super(port, timeout, backlog, new NullServerConnectionFactory());
36
		this.delays = delays;
37
		serverConn = serverConnFactory.listen(port, timeout, backlog);
38
	}
39
40
	public ConfigurableSMPPServerSessionListener(int port, ServerDelays delays, int timeout, ServerConnectionFactory serverConnFactory) throws IOException {
41
		super(port, timeout, new NullServerConnectionFactory());
42
		this.delays = delays;
43
		serverConn = serverConnFactory.listen(port, timeout);
44
	}
45
46
	public ConfigurableSMPPServerSessionListener(int port, ServerDelays delays, ServerConnectionFactory serverConnFactory) throws IOException {
47
		super(port, new NullServerConnectionFactory());
48
		this.delays = delays;
49
		serverConn = serverConnFactory.listen(port);
50
	}
51
52
	public ConfigurableSMPPServerSessionListener(int port, ServerDelays delays) throws IOException {
53
		this(port, delays, new ServerSocketConnectionFactory());
54
	}
55
56
	@Override
57
	public SMPPServerSession accept() throws IOException {
58 5 1. accept : negated conditional → NO_COVERAGE
2. accept : negated conditional → SURVIVED
3. accept : negated conditional → TIMED_OUT
4. accept : negated conditional → KILLED
5. accept : negated conditional → KILLED
		if (delays == null) {
59
			Connection conn = serverConn.accept();
60 3 1. accept : removed call to org/jsmpp/session/connection/Connection::setSoTimeout → NO_COVERAGE
2. accept : removed call to org/jsmpp/session/connection/Connection::setSoTimeout → SURVIVED
3. accept : removed call to org/jsmpp/session/connection/Connection::setSoTimeout → TIMED_OUT
			conn.setSoTimeout(getInitiationTimer());
61 2 1. accept : replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::accept → NO_COVERAGE
2. accept : replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::accept → TIMED_OUT
			return new SMPPServerSession(conn, getSessionStateListener(), getMessageReceiverListener(), responseDeliveryListener, getPduProcessorDegree());
62
		}
63
		Connection conn = serverConn.accept();
64 2 1. accept : removed call to org/jsmpp/session/connection/Connection::setSoTimeout → SURVIVED
2. accept : removed call to org/jsmpp/session/connection/Connection::setSoTimeout → NO_COVERAGE
		conn.setSoTimeout(getInitiationTimer());
65 2 1. accept : replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::accept → NO_COVERAGE
2. accept : replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::accept → TIMED_OUT
		return new SMPPServerSession(conn, getSessionStateListener(), getMessageReceiverListener(), responseDeliveryListener, getPduProcessorDegree(), createPduSender(), createPduReader());
66
	}
67
68
	@Override
69
	public void setResponseDeliveryListener(ServerResponseDeliveryListener responseDeliveryListener) {
70 1 1. setResponseDeliveryListener : removed call to org/jsmpp/session/SMPPServerSessionListener::setResponseDeliveryListener → NO_COVERAGE
		super.setResponseDeliveryListener(responseDeliveryListener);
71
		this.responseDeliveryListener = responseDeliveryListener;
72
	}
73
74
	protected PDUSender createPduSender() {
75 3 1. createPduSender : negated conditional → NO_COVERAGE
2. createPduSender : negated conditional → KILLED
3. createPduSender : negated conditional → KILLED
		if (delays == null) {
76 1 1. createPduSender : replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::createPduSender → NO_COVERAGE
			return new SynchronizedPDUSender(new DefaultPDUSender());
77
		}
78 2 1. createPduSender : replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::createPduSender → NO_COVERAGE
2. createPduSender : replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::createPduSender → TIMED_OUT
		return new SlowPduSender(new SynchronizedPDUSender(new DefaultPDUSender()), delays);
79
	}
80
81
	protected PDUReader createPduReader() {
82 2 1. createPduReader : replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::createPduReader → NO_COVERAGE
2. createPduReader : replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::createPduReader → TIMED_OUT
		return new DefaultPDUReader();
83
	}
84
85
	@Override
86
	public int getTimeout(int timeout) throws IOException {
87 1 1. getTimeout : replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::getTimeout → NO_COVERAGE
		return serverConn.getSoTimeout();
88
	}
89
90
	@Override
91
	public void setTimeout(int timeout) throws IOException {
92 1 1. setTimeout : removed call to org/jsmpp/session/connection/ServerConnection::setSoTimeout → NO_COVERAGE
		serverConn.setSoTimeout(timeout);
93
	}
94
95
	@Override
96
	public void close() throws IOException {
97 2 1. close : removed call to org/jsmpp/session/connection/ServerConnection::close → NO_COVERAGE
2. close : removed call to org/jsmpp/session/connection/ServerConnection::close → TIMED_OUT
		serverConn.close();
98
	}
99
100
	private static class NullServerConnectionFactory implements ServerConnectionFactory {
101
		@Override
102
		public ServerConnection listen(int port) throws IOException {
103
			return null;
104
		}
105
106
		@Override
107
		public ServerConnection listen(int port, int timeout) throws IOException {
108
			return null;
109
		}
110
111
		@Override
112
		public ServerConnection listen(int port, int timeout, int backlog) throws IOException {
113
			return null;
114
		}
115
	}
116
}

Mutations

58

1.1
Location : accept
Killed by : oghamcloudhopper.it.ReuseSessionStrategyTest.reuseSessionButEnquireLinkTimeout(oghamcloudhopper.it.ReuseSessionStrategyTest)
negated conditional → KILLED

2.2
Location : accept
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : accept
Killed by : none
negated conditional → TIMED_OUT

4.4
Location : accept
Killed by : none
negated conditional → SURVIVED

5.5
Location : accept
Killed by : oghamtesting.it.sms.simulator.JsmppSimulatorSpec
negated conditional → KILLED

60

1.1
Location : accept
Killed by : none
removed call to org/jsmpp/session/connection/Connection::setSoTimeout → TIMED_OUT

2.2
Location : accept
Killed by : none
removed call to org/jsmpp/session/connection/Connection::setSoTimeout → NO_COVERAGE

3.3
Location : accept
Killed by : none
removed call to org/jsmpp/session/connection/Connection::setSoTimeout → SURVIVED

61

1.1
Location : accept
Killed by : none
replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::accept → NO_COVERAGE

2.2
Location : accept
Killed by : none
replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::accept → TIMED_OUT

64

1.1
Location : accept
Killed by : none
removed call to org/jsmpp/session/connection/Connection::setSoTimeout → SURVIVED

2.2
Location : accept
Killed by : none
removed call to org/jsmpp/session/connection/Connection::setSoTimeout → NO_COVERAGE

65

1.1
Location : accept
Killed by : none
replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::accept → TIMED_OUT

2.2
Location : accept
Killed by : none
replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::accept → NO_COVERAGE

70

1.1
Location : setResponseDeliveryListener
Killed by : none
removed call to org/jsmpp/session/SMPPServerSessionListener::setResponseDeliveryListener → NO_COVERAGE

75

1.1
Location : createPduSender
Killed by : oghamcloudhopper.it.ReuseSessionStrategyTest.reuseSessionButEnquireLinkTimeout(oghamcloudhopper.it.ReuseSessionStrategyTest)
negated conditional → KILLED

2.2
Location : createPduSender
Killed by : oghamtesting.it.sms.simulator.JsmppSimulatorSpec
negated conditional → KILLED

3.3
Location : createPduSender
Killed by : none
negated conditional → NO_COVERAGE

76

1.1
Location : createPduSender
Killed by : none
replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::createPduSender → NO_COVERAGE

78

1.1
Location : createPduSender
Killed by : none
replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::createPduSender → NO_COVERAGE

2.2
Location : createPduSender
Killed by : none
replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::createPduSender → TIMED_OUT

82

1.1
Location : createPduReader
Killed by : none
replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::createPduReader → TIMED_OUT

2.2
Location : createPduReader
Killed by : none
replaced return value with null for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::createPduReader → NO_COVERAGE

87

1.1
Location : getTimeout
Killed by : none
replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/jsmpp/ConfigurableSMPPServerSessionListener::getTimeout → NO_COVERAGE

92

1.1
Location : setTimeout
Killed by : none
removed call to org/jsmpp/session/connection/ServerConnection::setSoTimeout → NO_COVERAGE

97

1.1
Location : close
Killed by : none
removed call to org/jsmpp/session/connection/ServerConnection::close → NO_COVERAGE

2.2
Location : close
Killed by : none
removed call to org/jsmpp/session/connection/ServerConnection::close → TIMED_OUT

Active mutators

Tests examined


Report generated by PIT OGHAM