I have a module that contains package com.temp
which has interface and implementation of th service - ServiceInterface
and ServiceImpl
. And I have in my module-info:
module temp {
exports com.temp;
provides com.temp.ServiceInterface with com.temp.ServiceImpl;
}
This is piece of my pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skipTests>${skip.integration.tests}</skipTests>
</configuration>
</execution>
</executions>
</plugin>
And this is my TempIT
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
class TempIT {
@Test
void tempTest() {
System.out.println("JDKModulePath:" + System.getProperty("jdk.module.path")); //LINE Y
ServiceLoader<ServiceInterface> loader = ServiceLoader.load(ServiceInterface.class);
System.out.println(loader.findFirst().get().getString());//LINE X
}
}
LINE Y prints: JDKModulePath:null
. At LINE X I get java.util.NoSuchElementException: No value present
.
How to make integration test of JPMS service? Is it possible to do outside the module in order to check module as one whole
but without creating additional testing module?
EDIT 1: These are implementation and interface:
package com.temp;
public class ServiceImpl implements ServiceInterface {
@Override
public String getString() {
return "This is test string";
}
}
package com.temp;
public interface ServiceInterface {
public String getString();
}
It seems to be a bug, as failsafe doesn't put the module on module path. See the issue https://issues.apache.org/jira/browse/SUREFIRE-1570