JSMPPServer.java

1
package fr.sii.ogham.testing.sms.simulator.jsmpp;
2
3
import java.util.List;
4
5
import ogham.testing.org.jsmpp.bean.SubmitSm;
6
import org.slf4j.Logger;
7
import org.slf4j.LoggerFactory;
8
9
import fr.sii.ogham.testing.sms.simulator.SmppServerException;
10
import fr.sii.ogham.testing.sms.simulator.SmppServerSimulator;
11
import fr.sii.ogham.testing.sms.simulator.config.SimulatorConfiguration;
12
13
/**
14
 * The server simulator based on <a href="http://jsmpp.org/">jsmpp</a> samples.
15
 */
16
public class JSMPPServer implements SmppServerSimulator<SubmitSm> {
17
	private static final Logger LOG = LoggerFactory.getLogger(JSMPPServer.class);
18
19
	private Thread thread;
20
	private final JSMPPServerSimulator simulator;
21
22
	/**
23
	 * Initializes with provided configuration.
24
	 * 
25
	 * @param config
26
	 *            the server configuration
27
	 */
28
	public JSMPPServer(SimulatorConfiguration config) {
29
		super();
30 1 1. <init> : negated conditional → RUN_ERROR
		if (config.getPortProvider() == null) {
31
			throw new IllegalArgumentException("Port configuration is mandatory");
32
		}
33
		simulator = new JSMPPServerSimulator(config.getPortProvider().getPort(), config);
34
	}
35
36
	@Override
37
	public synchronized void start() throws SmppServerException {
38
		try {
39
			LOG.debug("starting simulator thread...");
40 1 1. start : removed call to fr/sii/ogham/testing/sms/simulator/jsmpp/JSMPPServerSimulator::reset → RUN_ERROR
			simulator.reset();
41
			thread = new Thread(simulator);
42 1 1. start : removed call to java/lang/Thread::start → RUN_ERROR
			thread.start();
43 1 1. start : removed call to fr/sii/ogham/testing/sms/simulator/jsmpp/JSMPPServerSimulator::waitTillRunning → RUN_ERROR
			simulator.waitTillRunning(5000L);
44
			LOG.debug("simulator started");
45
		} catch (ServerStartupException e) {
46
			throw new SmppServerException("Failed to start JSMPP server ("+e.getMessage()+")", e);
47
		}
48
	}
49
50
	@Override
51
	public synchronized void stop() throws SmppServerException {
52
		try {
53
			LOG.debug("stopping simulator thread...");
54 1 1. stop : removed call to fr/sii/ogham/testing/sms/simulator/jsmpp/JSMPPServerSimulator::stop → RUN_ERROR
			simulator.stop();
55 1 1. stop : removed call to java/lang/Thread::interrupt → RUN_ERROR
			thread.interrupt();
56 1 1. stop : removed call to java/lang/Thread::join → RUN_ERROR
			thread.join();
57
			LOG.debug("simulator stopped");
58
		} catch (InterruptedException e) {
59 1 1. stop : removed call to java/lang/Thread::interrupt → NO_COVERAGE
			Thread.currentThread().interrupt();
60
			throw new SmppServerException("Failed to stop JSMPP server", e);
61
		}
62
	}
63
64
	@Override
65
	public int getPort() {
66 1 1. getPort : replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/jsmpp/JSMPPServer::getPort → RUN_ERROR
		return simulator.getPort();
67
	}
68
69
	@Override
70
	public List<SubmitSm> getReceivedMessages() {
71 1 1. getReceivedMessages : replaced return value with Collections.emptyList for fr/sii/ogham/testing/sms/simulator/jsmpp/JSMPPServer::getReceivedMessages → NO_COVERAGE
		return simulator.getReceivedMessages();
72
	}
73
74
}

Mutations

30

1.1
Location : <init>
Killed by :
negated conditional → RUN_ERROR

40

1.1
Location : start
Killed by :
removed call to fr/sii/ogham/testing/sms/simulator/jsmpp/JSMPPServerSimulator::reset → RUN_ERROR

42

1.1
Location : start
Killed by :
removed call to java/lang/Thread::start → RUN_ERROR

43

1.1
Location : start
Killed by :
removed call to fr/sii/ogham/testing/sms/simulator/jsmpp/JSMPPServerSimulator::waitTillRunning → RUN_ERROR

54

1.1
Location : stop
Killed by :
removed call to fr/sii/ogham/testing/sms/simulator/jsmpp/JSMPPServerSimulator::stop → RUN_ERROR

55

1.1
Location : stop
Killed by :
removed call to java/lang/Thread::interrupt → RUN_ERROR

56

1.1
Location : stop
Killed by :
removed call to java/lang/Thread::join → RUN_ERROR

59

1.1
Location : stop
Killed by :
removed call to java/lang/Thread::interrupt → NO_COVERAGE

66

1.1
Location : getPort
Killed by :
replaced int return with 0 for fr/sii/ogham/testing/sms/simulator/jsmpp/JSMPPServer::getPort → RUN_ERROR

71

1.1
Location : getReceivedMessages
Killed by :
replaced return value with Collections.emptyList for fr/sii/ogham/testing/sms/simulator/jsmpp/JSMPPServer::getReceivedMessages → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.13.1