JsmppServerInitializer.java

1
package fr.sii.ogham.testing.extension.spring;
2
3
import fr.sii.ogham.testing.extension.junit.sms.JsmppServerExtension;
4
import fr.sii.ogham.testing.util.RandomPortUtils;
5
import org.slf4j.Logger;
6
import org.slf4j.LoggerFactory;
7
import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition;
8
import org.springframework.beans.factory.config.BeanDefinition;
9
import org.springframework.context.ApplicationContext;
10
import org.springframework.context.ApplicationContextInitializer;
11
import org.springframework.context.ConfigurableApplicationContext;
12
import org.springframework.context.support.GenericApplicationContext;
13
import org.springframework.core.env.Environment;
14
import org.springframework.test.context.support.TestPropertySourceUtils;
15
16
/**
17
 * Initializer for Spring Boot tests that registers:
18
 * <ul>
19
 * <li>{@code "jsmpp.server.port"} property in Spring {@link Environment}</li>
20
 * <li>{@link JsmppServerExtension} bean in Spring {@link ApplicationContext} through
21
 * {@link JsmppServerTestConfiguration} in order to use the port defined by
22
 * {@code "jsmpp.server.port"} property</li>
23
 * </ul>
24
 * 
25
 * @author Aurélien Baudet
26
 *
27
 */
28
public class JsmppServerInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
29
	private static final Logger LOG = LoggerFactory.getLogger(JsmppServerInitializer.class);
30
31
	@Override
32
	public void initialize(ConfigurableApplicationContext applicationContext) {
33 1 1. initialize : negated conditional → NO_COVERAGE
		if (applicationContext instanceof GenericApplicationContext) {
34
			BeanDefinition configBean = new AnnotatedGenericBeanDefinition(JsmppServerTestConfiguration.class);
35 1 1. initialize : removed call to org/springframework/context/support/GenericApplicationContext::registerBeanDefinition → NO_COVERAGE
			((GenericApplicationContext) applicationContext).registerBeanDefinition("jsmppServerTestConfiguration", configBean);
36
		}
37
		int port = RandomPortUtils.findAvailableTcpPort();
38
		LOG.debug("Registering {} port for JSMPP server", port);
39 1 1. initialize : removed call to org/springframework/test/context/support/TestPropertySourceUtils::addInlinedPropertiesToEnvironment → NO_COVERAGE
		TestPropertySourceUtils.addInlinedPropertiesToEnvironment(applicationContext, "jsmpp.server.port=" + port);
40
	}
41
}

Mutations

33

1.1
Location : initialize
Killed by :
negated conditional → NO_COVERAGE

35

1.1
Location : initialize
Killed by :
removed call to org/springframework/context/support/GenericApplicationContext::registerBeanDefinition → NO_COVERAGE

39

1.1
Location : initialize
Killed by :
removed call to org/springframework/test/context/support/TestPropertySourceUtils::addInlinedPropertiesToEnvironment → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.13.1