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:
Trustin Lee 2013-04-25 21:56:34 +09:00
parent 73c35aef4e
commit 3a2b099e4b
2 changed files with 46 additions and 11 deletions

View File

@ -105,8 +105,27 @@
</dependencies>
<build>
<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 -->
<plugin>

View File

@ -15,18 +15,25 @@
*/
package io.netty.verify.osgi;
import static org.junit.Assert.*;
import java.io.File;
import io.netty.util.internal.StringUtil;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import org.apache.commons.io.FileUtils;
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.
*/
public class DependencyIT {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(DependencyIT.class);
/**
* Default location of generated karaf features file.
* <p>
@ -35,19 +42,28 @@ public class DependencyIT {
* >karaf-maven-plugin</a>
*/
public static final String FEATURE = "./target/feature/feature.xml";
private static final Pattern WRAPPED_MODULE_PATTERN = Pattern.compile("wrap:mvn:io\\.netty/");
@Test
public void verifyKarafFeatureHasNoWrapProtocol() throws Exception {
String text = FileUtils.readFileToString(new File(FEATURE));
final File file = new File(FEATURE);
final String text = FileUtils.readFileToString(file);
// Ignore wrap:mvn:io.netty - it occurs when Maven didn't give the Netty modules to karaf-maven-plugin
// as class directories.
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:")) {
System.err.println(text);
fail("karaf feature.xml contains 'wrap:' protocol: some transitive dependencies are not osgi bundles");
fail(
"feature.xml generated by karaf-maven-plugin contains 'wrap:' protocol; " +
"some transitive dependencies are not OSGi bundles: " + StringUtil.NEWLINE +
text
);
} else {
System.out.println("all transitive dependencies are osgi bundles");
logger.info("All transitive dependencies are OSGi bundles.");
}
}
}