Fix test failure in testsuite-osgi-deps
This commit fixes both failure of test itself and failure of compiling and running test. - When the test was run via 'mvn test', Maven gives karaf-maven-plugin a list of class directories instead of OSGi bundles, so that karaf-maven-plugin generates incorrect feature.xml. I added a workaround for this specific case to DependencyIT - When the packaging of project is 'feature', maven-compiler-plugin is not run at all. Added a <plugin/> section so that it's always compiled.
This commit is contained in:
parent
73c35aef4e
commit
3a2b099e4b
|
@ -105,8 +105,27 @@
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<!-- feature doesn't invoke maven-compile-plugin unless specified explicitly. -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>test-compile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>testCompile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<!-- produce karaf feature.xml -->
|
<!-- produce karaf feature.xml -->
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
|
@ -15,18 +15,25 @@
|
||||||
*/
|
*/
|
||||||
package io.netty.verify.osgi;
|
package io.netty.verify.osgi;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import io.netty.util.internal.StringUtil;
|
||||||
|
import io.netty.util.internal.logging.InternalLogger;
|
||||||
import java.io.File;
|
import io.netty.util.internal.logging.InternalLoggerFactory;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dependency Integration Tests.
|
* Dependency Integration Tests.
|
||||||
*/
|
*/
|
||||||
public class DependencyIT {
|
public class DependencyIT {
|
||||||
|
|
||||||
|
private static final InternalLogger logger = InternalLoggerFactory.getInstance(DependencyIT.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default location of generated karaf features file.
|
* Default location of generated karaf features file.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -35,19 +42,28 @@ public class DependencyIT {
|
||||||
* >karaf-maven-plugin</a>
|
* >karaf-maven-plugin</a>
|
||||||
*/
|
*/
|
||||||
public static final String FEATURE = "./target/feature/feature.xml";
|
public static final String FEATURE = "./target/feature/feature.xml";
|
||||||
|
private static final Pattern WRAPPED_MODULE_PATTERN = Pattern.compile("wrap:mvn:io\\.netty/");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void verifyKarafFeatureHasNoWrapProtocol() throws Exception {
|
public void verifyKarafFeatureHasNoWrapProtocol() throws Exception {
|
||||||
|
String text = FileUtils.readFileToString(new File(FEATURE));
|
||||||
|
|
||||||
final File file = new File(FEATURE);
|
// Ignore wrap:mvn:io.netty - it occurs when Maven didn't give the Netty modules to karaf-maven-plugin
|
||||||
|
// as class directories.
|
||||||
final String text = FileUtils.readFileToString(file);
|
Matcher matcher = WRAPPED_MODULE_PATTERN.matcher(text);
|
||||||
|
if (matcher.find()) {
|
||||||
|
text = matcher.replaceAll("mvn:io.netty/");
|
||||||
|
logger.info("Ignored wrap:mvn:io.netty");
|
||||||
|
}
|
||||||
|
|
||||||
if (text.contains("wrap:")) {
|
if (text.contains("wrap:")) {
|
||||||
System.err.println(text);
|
fail(
|
||||||
fail("karaf feature.xml contains 'wrap:' protocol: some transitive dependencies are not osgi bundles");
|
"feature.xml generated by karaf-maven-plugin contains 'wrap:' protocol; " +
|
||||||
|
"some transitive dependencies are not OSGi bundles: " + StringUtil.NEWLINE +
|
||||||
|
text
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
System.out.println("all transitive dependencies are osgi bundles");
|
logger.info("All transitive dependencies are OSGi bundles.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user