You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by da...@apache.org on 2019/01/23 15:21:21 UTC
[sling-org-apache-sling-feature-analyser] branch master updated:
SLING-8230 The bundle-packages analyzer should report on the feature
complete state
This is an automated email from the ASF dual-hosted git repository.
davidb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-analyser.git
The following commit(s) were added to refs/heads/master by this push:
new 8f67d37 SLING-8230 The bundle-packages analyzer should report on the feature complete state
8f67d37 is described below
commit 8f67d37e6ea014db67d68eadcd20133381be5822
Author: David Bosschaert <bo...@adobe.com>
AuthorDate: Wed Jan 23 15:20:48 2019 +0000
SLING-8230 The bundle-packages analyzer should report on the feature complete state
---
.../task/impl/CheckBundleExportsImports.java | 6 ++++
.../task/impl/CheckBundleExportsImportsTest.java | 34 ++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckBundleExportsImports.java b/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckBundleExportsImports.java
index 1ea47db..100e948 100644
--- a/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckBundleExportsImports.java
+++ b/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckBundleExportsImports.java
@@ -235,6 +235,7 @@ public class CheckBundleExportsImports implements AnalyserTask {
}
}
+ boolean errorReported = false;
for(final Map.Entry<BundleDescriptor, Report> entry : reports.entrySet()) {
final String key = "Bundle " + entry.getKey().getArtifact().getId().getArtifactId() + ":" + entry.getKey().getArtifact().getId().getVersion();
@@ -248,6 +249,7 @@ public class CheckBundleExportsImports implements AnalyserTask {
if ( !entry.getValue().missingExports.isEmpty() ) {
ctx.reportError(key + " is importing package(s) " + getPackageInfo(entry.getValue().missingExports, false) + " in start level " +
String.valueOf(entry.getKey().getBundleStartLevel()) + " but no bundle is exporting these for that start level.");
+ errorReported = true;
}
if ( !entry.getValue().missingExportsWithVersion.isEmpty() ) {
StringBuilder message = new StringBuilder(key + " is importing package(s) " + getPackageInfo(entry.getValue().missingExportsWithVersion, true) + " in start level " +
@@ -259,8 +261,12 @@ public class CheckBundleExportsImports implements AnalyserTask {
message.append("\n" + pkg.getName() + " is exported in regions " + regions.getKey() + " but it is imported in regions " + regions.getValue());
}
ctx.reportError(message.toString());
+ errorReported = true;
}
}
+ if (errorReported && ctx.getFeature().isComplete()) {
+ ctx.reportError(ctx.getFeature().getId().toMvnId() + " is marked as 'complete' but has missing imports.");
+ }
}
private Set<String> getBundleRegions(BundleDescriptor info, Map<String, Set<String>> bundleToOriginalFeatures,
diff --git a/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckBundleExportsImportsTest.java b/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckBundleExportsImportsTest.java
index 59f01b5..03b90c0 100644
--- a/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckBundleExportsImportsTest.java
+++ b/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckBundleExportsImportsTest.java
@@ -56,6 +56,37 @@ public class CheckBundleExportsImportsTest {
}
@Test
+ /*
+ * Bundle b3 imports org.foo.e, but no bundle exports it. The feature is marked
+ * as complete which it isn't
+ */
+ public void testImportExportNoRegionsMarkedAsComplete() throws Exception {
+ CheckBundleExportsImports t = new CheckBundleExportsImports();
+
+ Feature f = new Feature(ArtifactId.fromMvnId("f:f:1"));
+ f.setComplete(true);
+ FeatureDescriptor fd = new FeatureDescriptor() {
+ @Override
+ public Feature getFeature() {
+ return f;
+ }
+ };
+
+ fdAddBundle(fd, "g:b1:1", "test-bundle1.jar");
+ fdAddBundle(fd, "g:b3:1", "test-bundle3.jar");
+
+ AnalyserTaskContext ctx = Mockito.mock(AnalyserTaskContext.class);
+ Mockito.when(ctx.getFeature()).thenReturn(f);
+ Mockito.when(ctx.getFeatureDescriptor()).thenReturn(fd);
+ t.execute(ctx);
+
+ Mockito.verify(ctx, Mockito.times(2)).reportError(Mockito.anyString());
+ Mockito.verify(ctx).reportError(Mockito.contains("org.foo.e"));
+ Mockito.verify(ctx).reportError(Mockito.contains("marked as 'complete'"));
+ Mockito.verify(ctx, Mockito.never()).reportWarning(Mockito.anyString());
+ }
+
+ @Test
public void testImportExportNoRegionsAllOk() throws IOException {
CheckBundleExportsImports t = new CheckBundleExportsImports();
@@ -80,6 +111,9 @@ public class CheckBundleExportsImportsTest {
}
@Test
+ /*
+ * Bundle b3 imports org.foo.e, but no bundle exports it
+ */
public void testImportExportNoRegionsMissing() throws IOException {
CheckBundleExportsImports t = new CheckBundleExportsImports();