From 3a2b099e4b7b35beb4dd443ee366db980279545c Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 25 Apr 2013 21:56:34 +0900 Subject: [PATCH] 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 section so that it's always compiled. --- testsuite-osgi/testsuite-osgi-deps/pom.xml | 21 ++++++++++- .../io/netty/verify/osgi/DependencyIT.java | 36 +++++++++++++------ 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/testsuite-osgi/testsuite-osgi-deps/pom.xml b/testsuite-osgi/testsuite-osgi-deps/pom.xml index d9d9dcb533..ee1a53d5ca 100644 --- a/testsuite-osgi/testsuite-osgi-deps/pom.xml +++ b/testsuite-osgi/testsuite-osgi-deps/pom.xml @@ -105,8 +105,27 @@ - + + + maven-compiler-plugin + + + compile + compile + + compile + + + + test-compile + test-compile + + testCompile + + + + diff --git a/testsuite-osgi/testsuite-osgi-deps/src/test/java/io/netty/verify/osgi/DependencyIT.java b/testsuite-osgi/testsuite-osgi-deps/src/test/java/io/netty/verify/osgi/DependencyIT.java index 0aa59c4f9f..09e692df9d 100644 --- a/testsuite-osgi/testsuite-osgi-deps/src/test/java/io/netty/verify/osgi/DependencyIT.java +++ b/testsuite-osgi/testsuite-osgi-deps/src/test/java/io/netty/verify/osgi/DependencyIT.java @@ -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. *

@@ -35,19 +42,28 @@ public class DependencyIT { * >karaf-maven-plugin */ 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."); } } }