SimpleClasspathHelper.java

1
package fr.sii.ogham.core.util.classpath;
2
3
import org.slf4j.Logger;
4
import org.slf4j.LoggerFactory;
5
6
7
/**
8
 * Helper for classpath management.
9
 * 
10
 * @author Aurélien Baudet
11
 *
12
 */
13
public class SimpleClasspathHelper implements ClasspathHelper {
14
	private static final Logger LOG = LoggerFactory.getLogger(SimpleClasspathHelper.class);
15
	
16
	private ClassLoader classLoader;
17
	
18
	public SimpleClasspathHelper() {
19
		super();
20
		classLoader = null;
21
	}
22
23
	/**
24
	 * Test if the class name is defined in the classpath.
25
	 * 
26
	 * @param className
27
	 *            the class name
28
	 * @return true if the class exists in the classpath, false otherwise
29
	 */
30
	public boolean exists(String className) {
31 7 1. exists : negated conditional → NO_COVERAGE
2. exists : negated conditional → KILLED
3. exists : negated conditional → KILLED
4. exists : negated conditional → KILLED
5. exists : negated conditional → KILLED
6. exists : negated conditional → KILLED
7. exists : negated conditional → KILLED
		if(this.classLoader!=null) {
32 2 1. exists : negated conditional → NO_COVERAGE
2. exists : negated conditional → KILLED
			if(exists(className, this.classLoader)) {
33
				LOG.debug("class {} found using class specific class loader", className);
34 2 1. exists : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE
2. exists : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED
				return true;
35
			}
36 2 1. exists : replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE
2. exists : replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED
			return false;
37
		}
38 5 1. exists : negated conditional → NO_COVERAGE
2. exists : negated conditional → SURVIVED
3. exists : negated conditional → KILLED
4. exists : negated conditional → KILLED
5. exists : negated conditional → KILLED
		if(existsWithDefaultClassLoader(className)) {
39
			LOG.debug("class {} found using default class loader", className);
40 7 1. exists : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE
2. exists : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED
3. exists : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED
4. exists : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED
5. exists : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED
6. exists : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED
7. exists : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED
			return true;
41
		}
42 4 1. exists : negated conditional → NO_COVERAGE
2. exists : negated conditional → KILLED
3. exists : negated conditional → KILLED
4. exists : negated conditional → KILLED
		if(exists(className, Thread.currentThread().getContextClassLoader())) {
43
			LOG.debug("class {} found using class loader of current thread", className);
44 1 1. exists : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE
			return true;
45
		}
46 4 1. exists : negated conditional → NO_COVERAGE
2. exists : negated conditional → KILLED
3. exists : negated conditional → KILLED
4. exists : negated conditional → KILLED
		if(exists(className, getClass().getClassLoader())) {
47
			LOG.debug("class {} found using class loader of current class", className);
48 1 1. exists : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE
			return true;
49
		}
50 4 1. exists : replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE
2. exists : replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED
3. exists : replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED
4. exists : replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED
		return false;
51
	}
52
53
	private static boolean existsWithDefaultClassLoader(String className) {
54
		try {
55
			Class.forName(className);
56 2 1. existsWithDefaultClassLoader : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::existsWithDefaultClassLoader → SURVIVED
2. existsWithDefaultClassLoader : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::existsWithDefaultClassLoader → NO_COVERAGE
			return true;
57
		} catch (ClassNotFoundException e) {
58
			LOG.debug("Class {} not found", className);
59
			LOG.trace("Cause:", e);
60 4 1. existsWithDefaultClassLoader : replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::existsWithDefaultClassLoader → NO_COVERAGE
2. existsWithDefaultClassLoader : replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::existsWithDefaultClassLoader → KILLED
3. existsWithDefaultClassLoader : replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::existsWithDefaultClassLoader → KILLED
4. existsWithDefaultClassLoader : replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::existsWithDefaultClassLoader → KILLED
			return false;
61
		}
62
	}
63
64
	private static boolean exists(String className, ClassLoader classLoader) {
65
		try {
66
			Class.forName(className, false, classLoader);
67 2 1. exists : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE
2. exists : replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED
			return true;
68
		} catch (ClassNotFoundException e) {
69
			LOG.debug("Class {} not found", className);
70
			LOG.trace("Cause:", e);
71 4 1. exists : replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE
2. exists : replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → TIMED_OUT
3. exists : replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED
4. exists : replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED
			return false;
72
		}
73
	}
74
75
	public void setClassLoader(ClassLoader classLoader) {
76
		this.classLoader = classLoader;
77
	}
78
79
	public void resetClassLoader() {
80
		this.classLoader = null;
81
	}
82
}

Mutations

31

1.1
Location : exists
Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest)
negated conditional → KILLED

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

3.3
Location : exists
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest)
negated conditional → KILLED

4.4
Location : exists
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests.oghamPropertiesWithSpringPropsShouldUseOghamPropertiesPrecedence(oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests)
negated conditional → KILLED

5.5
Location : exists
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
negated conditional → KILLED

6.6
Location : exists
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
negated conditional → KILLED

7.7
Location : exists
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
negated conditional → KILLED

32

1.1
Location : exists
Killed by : oghamall.it.optional.ImplementationSelectionTests.javaMailAvailable(oghamall.it.optional.ImplementationSelectionTests)
negated conditional → KILLED

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

34

1.1
Location : exists
Killed by : none
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE

2.2
Location : exists
Killed by : oghamall.it.resolver.FreemarkerRelativeResourcesTests.relativeToPrefixSuffixAndPath(oghamall.it.resolver.FreemarkerRelativeResourcesTests)
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED

36

1.1
Location : exists
Killed by : oghamall.it.optional.ImplementationSelectionTests.javaMailAvailable(oghamall.it.optional.ImplementationSelectionTests)
replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED

2.2
Location : exists
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE

38

1.1
Location : exists
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : exists
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2FreeMarkerAutoConfigurationTests.oghamWithFreemarkerAutoConfigWithoutWebContextShouldUseSpringFreemarkerConfiguration(oghamspringbootv2autoconfigure.it.OghamSpringBoot2FreeMarkerAutoConfigurationTests)
negated conditional → KILLED

3.3
Location : exists
Killed by : none
negated conditional → SURVIVED

4.4
Location : exists
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
negated conditional → KILLED

5.5
Location : exists
Killed by : oghamall.it.configuration.SendGridConfigurationTest.asDeveloperIDefineApiKeyUsingProperties(oghamall.it.configuration.SendGridConfigurationTest)
negated conditional → KILLED

40

1.1
Location : exists
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED

2.2
Location : exists
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED

3.3
Location : exists
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest)
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED

4.4
Location : exists
Killed by : none
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE

5.5
Location : exists
Killed by : oghamcloudhopper.it.AutoRetryExtensionTest.smsNotRetriedDueToCloudhopperError(oghamcloudhopper.it.AutoRetryExtensionTest)
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED

6.6
Location : exists
Killed by : oghamjavamail.it.UnreadableAttachmentTest.attachmentUnreadable(oghamjavamail.it.UnreadableAttachmentTest)
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED

7.7
Location : exists
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests.oghamPropertiesWithSpringPropsShouldUseOghamPropertiesPrecedence(oghamspringbootv2autoconfigure.it.OghamSpringBoot2JavaMailAutoConfigurationTests)
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED

42

1.1
Location : exists
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
negated conditional → KILLED

2.2
Location : exists
Killed by : oghamall.it.configuration.SendGridConfigurationTest.asDeveloperIDefineApiKeyUsingProperties(oghamall.it.configuration.SendGridConfigurationTest)
negated conditional → KILLED

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

4.4
Location : exists
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2FreeMarkerAutoConfigurationTests.oghamWithFreemarkerAutoConfigWithoutWebContextShouldUseSpringFreemarkerConfiguration(oghamspringbootv2autoconfigure.it.OghamSpringBoot2FreeMarkerAutoConfigurationTests)
negated conditional → KILLED

44

1.1
Location : exists
Killed by : none
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE

46

1.1
Location : exists
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : exists
Killed by : oghamall.it.configuration.SendGridConfigurationTest.asDeveloperIDefineApiKeyUsingProperties(oghamall.it.configuration.SendGridConfigurationTest)
negated conditional → KILLED

3.3
Location : exists
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2FreeMarkerAutoConfigurationTests.oghamWithFreemarkerAutoConfigWithoutWebContextShouldUseSpringFreemarkerConfiguration(oghamspringbootv2autoconfigure.it.OghamSpringBoot2FreeMarkerAutoConfigurationTests)
negated conditional → KILLED

4.4
Location : exists
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
negated conditional → KILLED

48

1.1
Location : exists
Killed by : none
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE

50

1.1
Location : exists
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE

2.2
Location : exists
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2FreeMarkerAutoConfigurationTests.oghamWithFreemarkerAutoConfigWithoutWebContextShouldUseSpringFreemarkerConfiguration(oghamspringbootv2autoconfigure.it.OghamSpringBoot2FreeMarkerAutoConfigurationTests)
replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED

3.3
Location : exists
Killed by : oghamall.it.configuration.SendGridConfigurationTest.asDeveloperIDefineApiKeyUsingProperties(oghamall.it.configuration.SendGridConfigurationTest)
replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED

4.4
Location : exists
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED

56

1.1
Location : existsWithDefaultClassLoader
Killed by : none
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::existsWithDefaultClassLoader → SURVIVED

2.2
Location : existsWithDefaultClassLoader
Killed by : none
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::existsWithDefaultClassLoader → NO_COVERAGE

60

1.1
Location : existsWithDefaultClassLoader
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::existsWithDefaultClassLoader → KILLED

2.2
Location : existsWithDefaultClassLoader
Killed by : oghamall.it.configuration.SendGridConfigurationTest.asDeveloperIDefineApiKeyUsingProperties(oghamall.it.configuration.SendGridConfigurationTest)
replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::existsWithDefaultClassLoader → KILLED

3.3
Location : existsWithDefaultClassLoader
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::existsWithDefaultClassLoader → NO_COVERAGE

4.4
Location : existsWithDefaultClassLoader
Killed by : oghamspringbootv2autoconfigure.it.OghamSpringBoot2FreeMarkerAutoConfigurationTests.oghamWithFreemarkerAutoConfigWithoutWebContextShouldUseSpringFreemarkerConfiguration(oghamspringbootv2autoconfigure.it.OghamSpringBoot2FreeMarkerAutoConfigurationTests)
replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::existsWithDefaultClassLoader → KILLED

67

1.1
Location : exists
Killed by : none
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE

2.2
Location : exists
Killed by : oghamall.it.resolver.FreemarkerRelativeResourcesTests.relativeToPrefixSuffixAndPath(oghamall.it.resolver.FreemarkerRelativeResourcesTests)
replaced boolean return with false for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED

71

1.1
Location : exists
Killed by : oghamall.it.optional.ImplementationSelectionTests.javaMailAvailable(oghamall.it.optional.ImplementationSelectionTests)
replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED

2.2
Location : exists
Killed by : oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests.oghamAloneShouldUseOghamProperties(oghamspringbootv1autoconfigure.it.OghamSpringBoot1JavaMailAutoConfigurationTests)
replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → KILLED

3.3
Location : exists
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → NO_COVERAGE

4.4
Location : exists
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/util/classpath/SimpleClasspathHelper::exists → TIMED_OUT

Active mutators

Tests examined


Report generated by PIT OGHAM