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 f128a56  Re-enable another Aggregate Feature Test
f128a56 is described below

commit f128a560f0c481ce28cd3b7e11cf0f1a28db1604
Author: David Bosschaert <[email protected]>
AuthorDate: Sat Sep 29 10:23:09 2018 +0100

    Re-enable another Aggregate Feature Test
---
 .../feature/maven/mojos/AggregateFeaturesTest.java     | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

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 b7a909c..0b10d2e 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
@@ -504,26 +504,42 @@ public class AggregateFeaturesTest {
         assertEquals("Expected only one bundle", 1, numFound);
     }
 
-    //@Test
+    @Test
     public void testPluginHandling() throws Exception {
         File featuresDir = new File(
                 getClass().getResource("/aggregate-features/dir3").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.getAbsolutePath(), feat);
+        }
 
         FeatureConfig fc = new FeatureConfig();
+        fc.setIncludes("*.json");
 
         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);
+        Mockito.when(mockProj.getContextValue(Feature.class.getName() + 
"/assembledmain.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.features = featuresDir;
 
         assertEquals("Precondition", 0, pluginCallbacks.size());
         af.execute();

Reply via email to