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 2018/09/28 15:49:31 UTC
[sling-slingfeature-maven-plugin] branch master updated: Re-enable
another Aggregate Features Test
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-slingfeature-maven-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new e7a3f6b Re-enable another Aggregate Features Test
e7a3f6b is described below
commit e7a3f6bf5259392bd84f5fb6eeccecf3906964e6
Author: David Bosschaert <bo...@adobe.com>
AuthorDate: Fri Sep 28 16:48:44 2018 +0100
Re-enable another Aggregate Features Test
Also fix the includes and excludes handling condition
---
.../sling/feature/maven/mojos/AggregateFeatures.java | 4 ++--
.../sling/feature/maven/mojos/AggregateFeaturesTest.java | 16 ++++++++++++++--
.../dir/{test_z.feature => test_z.json} | 0
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeatures.java b/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeatures.java
index b66e759..10f753d 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeatures.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeatures.java
@@ -230,10 +230,10 @@ public class AggregateFeatures extends AbstractFeatureMojo {
Map<ArtifactId, Feature> featureMap,
Map<String, Feature> contextFeatures) throws IOException {
final FeatureScanner scanner = new FeatureScanner(contextFeatures);
- if ( fc.includes.isEmpty() ) {
+ if ( !fc.includes.isEmpty() ) {
scanner.setIncludes(fc.includes.toArray(new String[fc.includes.size()]));
}
- if ( fc.excludes.isEmpty() ) {
+ if ( !fc.excludes.isEmpty() ) {
scanner.setExcludes(fc.excludes.toArray(new String[fc.excludes.size()]));
}
scanner.scan();
diff --git a/src/test/java/org/apache/sling/feature/maven/mojos/AggregateFeaturesTest.java b/src/test/java/org/apache/sling/feature/maven/mojos/AggregateFeaturesTest.java
index f5b20f4..8e7503b 100644
--- a/src/test/java/org/apache/sling/feature/maven/mojos/AggregateFeaturesTest.java
+++ b/src/test/java/org/apache/sling/feature/maven/mojos/AggregateFeaturesTest.java
@@ -203,10 +203,16 @@ public class AggregateFeaturesTest {
}
}
- //@Test
+ @Test
public void testAggregateFeaturesFromDirectoryWithIncludesExcludes() throws Exception {
File featuresDir = new File(
getClass().getResource("/aggregate-features/dir").getFile());
+ // read features
+ Map<String, Feature> featureMap = new HashMap<>();
+ for (File f : featuresDir.listFiles((d,f) -> f.endsWith(".json"))) {
+ Feature feat = FeatureJSONReader.read(new FileReader(f), null);
+ featureMap.put(f.getName(), feat);
+ }
FeatureConfig fc = new FeatureConfig();
fc.setIncludes("*.json");
@@ -218,20 +224,26 @@ public class AggregateFeaturesTest {
Build mockBuild = Mockito.mock(Build.class);
Mockito.when(mockBuild.getDirectory()).thenReturn(tempDir.toString());
+ Artifact parentArtifact = createMockArtifact();
MavenProject mockProj = Mockito.mock(MavenProject.class);
Mockito.when(mockProj.getBuild()).thenReturn(mockBuild);
Mockito.when(mockProj.getGroupId()).thenReturn("org.foo");
Mockito.when(mockProj.getArtifactId()).thenReturn("org.foo.bar");
Mockito.when(mockProj.getVersion()).thenReturn("1.2.3-SNAPSHOT");
+ Mockito.when(mockProj.getArtifact()).thenReturn(parentArtifact);
+ Mockito.when(mockProj.getContextValue(Feature.class.getName() + "/rawmain.json-cache"))
+ .thenReturn(featureMap);
AggregateFeatures af = new AggregateFeatures();
af.aggregateClassifier = "aggregated";
af.aggregates = Collections.singletonList(fc);
af.project = mockProj;
+ af.projectHelper = new DefaultMavenProjectHelper();
+ setPrivateField(af.projectHelper, "artifactHandlerManager", Mockito.mock(ArtifactHandlerManager.class));
af.execute();
- File expectedFile = new File(tempDir.toFile(), FEATURE_PROCESSED_LOCATION + "/aggregated.json");
+ File expectedFile = new File(tempDir.toFile(), "/aggregated.json");
try (Reader fr = new FileReader(expectedFile)) {
Feature genFeat = FeatureJSONReader.read(fr, null);
ArtifactId id = genFeat.getId();
diff --git a/src/test/resources/aggregate-features/dir/test_z.feature b/src/test/resources/aggregate-features/dir/test_z.json
similarity index 100%
rename from src/test/resources/aggregate-features/dir/test_z.feature
rename to src/test/resources/aggregate-features/dir/test_z.json