SmppServerRule.java

1
package fr.sii.ogham.testing.extension.junit.sms;
2
3
import org.junit.Rule;
4
import org.junit.rules.TestRule;
5
import org.junit.runner.Description;
6
import org.junit.runners.model.Statement;
7
import org.slf4j.Logger;
8
import org.slf4j.LoggerFactory;
9
10
import fr.sii.ogham.testing.extension.junit.sms.config.ServerConfig;
11
import fr.sii.ogham.testing.extension.junit.sms.config.SmppServerConfig;
12
import fr.sii.ogham.testing.sms.simulator.config.SimulatorConfiguration;
13
14
/**
15
 * JUnit {@link Rule} for starting a local SMPP server for integration tests.
16
 * 
17
 * <p>
18
 * The rule starts the server before every test, execute the test and stops the
19
 * server.
20
 * </p>
21
 * <p>
22
 * The server stores the received messages (raw messages). These messages are
23
 * available in testing through {@link #getReceivedMessages()}.
24
 * </p>
25
 * 
26
 * @param <M>
27
 *            The type of the received messages
28
 * 
29
 * @author Aurélien Baudet
30
 *
31
 */
32
public abstract class SmppServerRule<M> extends AbstractJUnitSmppServerExt<M> implements TestRule {
33
	private static final Logger LOG = LoggerFactory.getLogger(SmppServerRule.class);
34
35
	/**
36
	 * Initializes with the default configuration to use for the SMPP server:
37
	 * <ul>
38
	 * <li>Starts on random port</li>
39
	 * <li>No delay</li>
40
	 * <li>No credentials</li>
41
	 * <li>Do not keep messages between tests</li>
42
	 * </ul>
43
	 */
44
	public SmppServerRule() {
45
		super();
46
	}
47
48
	/**
49
	 * Initializes with the configuration to use for the SMPP server
50
	 * 
51
	 * @param builder
52
	 *            the configuration for the server
53
	 */
54
	public SmppServerRule(ServerConfig builder) {
55
		super(builder);
56
	}
57
58
	@Override
59
	public Statement apply(final Statement base, final Description description) {
60
		SmppServerConfig config = description.getAnnotation(SmppServerConfig.class);
61
		SimulatorConfiguration serverConfig = builder.annotationConfig(config).build();
62
		server = initServer(serverConfig);
63 5 1. apply : replaced return value with null for fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::apply → NO_COVERAGE
2. apply : replaced return value with null for fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::apply → TIMED_OUT
3. apply : replaced return value with null for fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::apply → KILLED
4. apply : replaced return value with null for fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::apply → KILLED
5. apply : replaced return value with null for fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::apply → KILLED
		return new StartServerStatement(base);
64
	}
65
66
	private final class StartServerStatement extends Statement {
67
		private final Statement base;
68
69
		private StartServerStatement(Statement base) {
70
			this.base = base;
71
		}
72
73
		@Override
74
		public void evaluate() throws Throwable {
75
			LOG.info("starting SMPP server on port {}...", getPort());
76 3 1. evaluate : removed call to fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::before → NO_COVERAGE
2. evaluate : removed call to fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::before → SURVIVED
3. evaluate : removed call to fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::before → TIMED_OUT
			before();
77 5 1. evaluate : removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::start → NO_COVERAGE
2. evaluate : removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::start → TIMED_OUT
3. evaluate : removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::start → KILLED
4. evaluate : removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::start → KILLED
5. evaluate : removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::start → KILLED
			server.start();
78
			LOG.info("SMPP server started on port {}", getPort());
79
			try {
80 3 1. evaluate : removed call to org/junit/runners/model/Statement::evaluate → SURVIVED
2. evaluate : removed call to org/junit/runners/model/Statement::evaluate → NO_COVERAGE
3. evaluate : removed call to org/junit/runners/model/Statement::evaluate → TIMED_OUT
				base.evaluate();
81
			} finally {
82
				LOG.info("stopping SMPP server...");
83 3 1. evaluate : removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::stop → NO_COVERAGE
2. evaluate : removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::stop → SURVIVED
3. evaluate : removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::stop → TIMED_OUT
				server.stop();
84 3 1. evaluate : removed call to fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::after → NO_COVERAGE
2. evaluate : removed call to fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::after → SURVIVED
3. evaluate : removed call to fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::after → TIMED_OUT
				after();
85
				LOG.info("SMPP server stopped");
86
			}
87
		}
88
	}
89
90
	protected void before() {
91
		// extension point
92
	}
93
94
	protected void after() {
95
		// extension point
96
	}
97
98
}

Mutations

63

1.1
Location : apply
Killed by : none
replaced return value with null for fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::apply → TIMED_OUT

2.2
Location : apply
Killed by : none
replaced return value with null for fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::apply → NO_COVERAGE

3.3
Location : apply
Killed by : oghamall.it.configuration.EmptyBuilderTest.noMimetypeConfigurationCantSendEmail(oghamall.it.configuration.EmptyBuilderTest)
replaced return value with null for fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::apply → KILLED

4.4
Location : apply
Killed by : oghamcloudhopper.it.PartialConfigurationTest.splitterEnabledButAutoGuessNotEnabledAndNoEncodingConfiguredAndLongMessageShouldFailIndicatingThatNoSplitterIsConfigured(oghamcloudhopper.it.PartialConfigurationTest)
replaced return value with null for fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::apply → KILLED

5.5
Location : apply
Killed by : oghamcore.ut.sms.sender.impl.PhoneNumberTranslatorSenderTest.simple(oghamcore.ut.sms.sender.impl.PhoneNumberTranslatorSenderTest)
replaced return value with null for fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::apply → KILLED

76

1.1
Location : evaluate
Killed by : none
removed call to fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::before → TIMED_OUT

2.2
Location : evaluate
Killed by : none
removed call to fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::before → NO_COVERAGE

3.3
Location : evaluate
Killed by : none
removed call to fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::before → SURVIVED

77

1.1
Location : evaluate
Killed by : oghamcore.ut.sms.sender.impl.PhoneNumberTranslatorSenderTest.simple(oghamcore.ut.sms.sender.impl.PhoneNumberTranslatorSenderTest)
removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::start → KILLED

2.2
Location : evaluate
Killed by : none
removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::start → NO_COVERAGE

3.3
Location : evaluate
Killed by : none
removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::start → TIMED_OUT

4.4
Location : evaluate
Killed by : oghamall.it.configuration.EmptyBuilderTest.noMimetypeConfigurationCantSendEmail(oghamall.it.configuration.EmptyBuilderTest)
removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::start → KILLED

5.5
Location : evaluate
Killed by : oghamcloudhopper.it.PartialConfigurationTest.splitterEnabledButAutoGuessNotEnabledAndNoEncodingConfiguredAndLongMessageShouldFailIndicatingThatNoSplitterIsConfigured(oghamcloudhopper.it.PartialConfigurationTest)
removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::start → KILLED

80

1.1
Location : evaluate
Killed by : none
removed call to org/junit/runners/model/Statement::evaluate → TIMED_OUT

2.2
Location : evaluate
Killed by : none
removed call to org/junit/runners/model/Statement::evaluate → SURVIVED

3.3
Location : evaluate
Killed by : none
removed call to org/junit/runners/model/Statement::evaluate → NO_COVERAGE

83

1.1
Location : evaluate
Killed by : none
removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::stop → NO_COVERAGE

2.2
Location : evaluate
Killed by : none
removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::stop → TIMED_OUT

3.3
Location : evaluate
Killed by : none
removed call to fr/sii/ogham/testing/sms/simulator/SmppServerSimulator::stop → SURVIVED

84

1.1
Location : evaluate
Killed by : none
removed call to fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::after → NO_COVERAGE

2.2
Location : evaluate
Killed by : none
removed call to fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::after → TIMED_OUT

3.3
Location : evaluate
Killed by : none
removed call to fr/sii/ogham/testing/extension/junit/sms/SmppServerRule::after → SURVIVED

Active mutators

Tests examined


Report generated by PIT OGHAM