forked from wildfly/galleon-plugins
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for WFGP-270, Add testing of FeaturePackBuildModelParser
- Loading branch information
Showing
2 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
122 changes: 122 additions & 0 deletions
122
...n-plugin/src/test/java/org/wildfly/galleon/maven/FeaturePackBuildModelParserTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.wildfly.galleon.maven; | ||
|
||
import java.io.InputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import org.jboss.galleon.config.ConfigId; | ||
import org.jboss.galleon.config.ConfigModel; | ||
import org.jboss.galleon.universe.FeaturePackLocation; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.wildfly.galleon.plugin.ArtifactCoords; | ||
|
||
/** | ||
* | ||
* @author jdenise | ||
*/ | ||
public class FeaturePackBuildModelParserTestCase { | ||
|
||
@Test | ||
public void testParseAll() throws Exception { | ||
FeaturePackBuildModelParser parser = new FeaturePackBuildModelParser(); | ||
WildFlyFeaturePackBuild build; | ||
try (InputStream stream = Files.newInputStream(Paths.get("src/test/resources/xml/test-feature-pack-build.xml"))) { | ||
build = parser.parse(stream); | ||
} | ||
Assert.assertEquals("level-1", build.getStabilityLevel()); | ||
Assert.assertEquals("level-2", build.getMinimumStabilityLevel()); | ||
Assert.assertEquals("level-3", build.getConfigStabilityLevel()); | ||
Assert.assertEquals("level-4", build.getPackageStabilityLevel()); | ||
|
||
Assert.assertEquals(3, build.getSystemPaths().size()); | ||
Assert.assertTrue(build.getSystemPaths().contains("system-path-1")); | ||
Assert.assertTrue(build.getSystemPaths().contains("system-path-2")); | ||
Assert.assertTrue(build.getSystemPaths().contains("system-path-3")); | ||
|
||
Assert.assertEquals(3, build.getStandaloneExtensions().size()); | ||
Assert.assertTrue(build.getStandaloneExtensions().contains("standalone-extension-1")); | ||
Assert.assertTrue(build.getStandaloneExtensions().contains("standalone-extension-1")); | ||
Assert.assertTrue(build.getStandaloneExtensions().contains("standalone-extension-1")); | ||
|
||
Assert.assertEquals(3, build.getDomainExtensions().size()); | ||
Assert.assertTrue(build.getDomainExtensions().contains("domain-extension-1")); | ||
Assert.assertTrue(build.getDomainExtensions().contains("domain-extension-1")); | ||
Assert.assertTrue(build.getDomainExtensions().contains("domain-extension-1")); | ||
|
||
Assert.assertEquals(3, build.getHostExtensions().size()); | ||
Assert.assertTrue(build.getHostExtensions().contains("host-extension-1")); | ||
Assert.assertTrue(build.getHostExtensions().contains("host-extension-1")); | ||
Assert.assertTrue(build.getHostExtensions().contains("host-extension-1")); | ||
|
||
Assert.assertEquals(3, build.getResourcesTasks().size()); | ||
|
||
Assert.assertEquals(4, build.getPlugins().size()); | ||
Assert.assertTrue(build.getPlugins().get("artifactId1").equals(ArtifactCoordsUtil.fromJBossModules("grpoupId1:artifactId1", "jar"))); | ||
Assert.assertTrue(build.getPlugins().get("plugin1").equals(ArtifactCoordsUtil.fromJBossModules("grpoupId2:artifactId2:2.0", "jar"))); | ||
Assert.assertTrue(build.getPlugins().get("plugin2").equals(ArtifactCoordsUtil.fromJBossModules("grpoupId3:artifactId3:3.0:classifier3", "jar"))); | ||
Assert.assertTrue(build.getPlugins().get("plugin3").equals(ArtifactCoordsUtil.fromJBossModules("grpoupId3:artifactId3:3.0:classifier3:zip", "jar"))); | ||
|
||
Assert.assertEquals(6, build.getDependencies().size()); | ||
|
||
FeaturePackDependencySpec spec1 = build.getDependencies().get(ArtifactCoords.newGav("groupId-1:artifactId-1")); | ||
Assert.assertEquals("dependency-1", spec1.getName()); | ||
Assert.assertEquals(Boolean.TRUE, spec1.getTarget().getInheritConfigs()); | ||
Assert.assertEquals(true, spec1.getTarget().isInheritModelOnlyConfigs()); | ||
Assert.assertTrue(spec1.getTarget().getIncludedConfigs().contains(new ConfigId("model-1", "default-config-1"))); | ||
Assert.assertEquals(1, spec1.getTarget().getDefinedConfigs().size()); | ||
Assert.assertTrue(spec1.getTarget().getDefinedConfigs().toArray(new ConfigModel[1])[0].isInheritFeatures()); | ||
|
||
Assert.assertEquals(3, spec1.getTarget().getPatches().size()); | ||
Assert.assertTrue(spec1.getTarget().getPatches().contains(FeaturePackLocation.fromString("org:patch1:1").getFPID())); | ||
Assert.assertTrue(spec1.getTarget().getPatches().contains(FeaturePackLocation.fromString("org:patch2:2").getFPID())); | ||
Assert.assertTrue(spec1.getTarget().getPatches().contains(FeaturePackLocation.fromString("org:patch3:3").getFPID())); | ||
|
||
Assert.assertEquals(3, spec1.getTarget().getIncludedPackages().size()); | ||
Assert.assertTrue(spec1.getTarget().getIncludedPackages().contains("package-1")); | ||
Assert.assertTrue(spec1.getTarget().getIncludedPackages().contains("package-2")); | ||
Assert.assertTrue(spec1.getTarget().getIncludedPackages().contains("package-3")); | ||
|
||
Assert.assertEquals(3, spec1.getTarget().getExcludedPackages().size()); | ||
Assert.assertTrue(spec1.getTarget().getExcludedPackages().contains("package-4")); | ||
Assert.assertTrue(spec1.getTarget().getExcludedPackages().contains("package-5")); | ||
Assert.assertTrue(spec1.getTarget().getExcludedPackages().contains("package-6")); | ||
|
||
FeaturePackDependencySpec spec2 = build.getDependencies().get(ArtifactCoords.newGav("groupId-2:artifactId-2")); | ||
Assert.assertNull(spec2.getName()); | ||
|
||
FeaturePackDependencySpec spec3 = build.getDependencies().get(ArtifactCoords.newGav("groupId-3:artifactId-3")); | ||
Assert.assertNull(spec3.getName()); | ||
|
||
FeaturePackDependencySpec spec4 = build.getDependencies().get(ArtifactCoords.newGav("tgroupId-1:tartifactId-1")); | ||
Assert.assertEquals("transitive-1", spec4.getName()); | ||
Assert.assertEquals(Boolean.TRUE, spec4.getTarget().getInheritConfigs()); | ||
Assert.assertEquals(true, spec4.getTarget().isInheritModelOnlyConfigs()); | ||
Assert.assertTrue(spec4.getTarget().getIncludedConfigs().contains(new ConfigId("model-1", "default-config-1"))); | ||
|
||
Assert.assertEquals(3, spec4.getTarget().getPatches().size()); | ||
Assert.assertTrue(spec4.getTarget().getPatches().contains(FeaturePackLocation.fromString("org:patch1:1").getFPID())); | ||
Assert.assertTrue(spec4.getTarget().getPatches().contains(FeaturePackLocation.fromString("org:patch2:2").getFPID())); | ||
Assert.assertTrue(spec4.getTarget().getPatches().contains(FeaturePackLocation.fromString("org:patch3:3").getFPID())); | ||
|
||
Assert.assertEquals(3, spec4.getTarget().getIncludedPackages().size()); | ||
Assert.assertTrue(spec4.getTarget().getIncludedPackages().contains("package-1")); | ||
Assert.assertTrue(spec4.getTarget().getIncludedPackages().contains("package-2")); | ||
Assert.assertTrue(spec4.getTarget().getIncludedPackages().contains("package-3")); | ||
|
||
Assert.assertEquals(3, spec4.getTarget().getExcludedPackages().size()); | ||
Assert.assertTrue(spec4.getTarget().getExcludedPackages().contains("package-4")); | ||
Assert.assertTrue(spec4.getTarget().getExcludedPackages().contains("package-5")); | ||
Assert.assertTrue(spec4.getTarget().getExcludedPackages().contains("package-6")); | ||
|
||
FeaturePackDependencySpec spec5 = build.getDependencies().get(ArtifactCoords.newGav("tgroupId-2:tartifactId-2")); | ||
Assert.assertNull(spec5.getName()); | ||
|
||
FeaturePackDependencySpec spec6 = build.getDependencies().get(ArtifactCoords.newGav("tgroupId-3:tartifactId-3")); | ||
Assert.assertNull(spec6.getName()); | ||
} | ||
|
||
} |
108 changes: 108 additions & 0 deletions
108
maven-plugin/src/test/resources/xml/test-feature-pack-build.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<!-- | ||
~ Copyright The WildFly Authors | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
<build xmlns="urn:wildfly:feature-pack-build:3.4" producer="foo@maven(org.jboss.universe:community-universe):latest"> | ||
<dependencies> | ||
<dependency group-id="groupId-1" artifact-id="artifactId-1" translate-to-fpl="true"> | ||
<name>dependency-1</name> | ||
<default-configs inherit="true" inherit-unnamed-models="true"> | ||
<include name="default-config-1" model="model-1"/> | ||
</default-configs> | ||
<config name="config-1" model="model-1" inherit-features="true"/> | ||
<patches> | ||
<patch id="org:patch1:1"/> | ||
<patch id="org:patch2:2"/> | ||
<patch id="org:patch3:3"/> | ||
</patches> | ||
<packages> | ||
<include name="package-1"/> | ||
<include name="package-2"/> | ||
<include name="package-3"/> | ||
<exclude name="package-4"/> | ||
<exclude name="package-5"/> | ||
<exclude name="package-6"/> | ||
</packages> | ||
</dependency> | ||
<dependency group-id="groupId-2" artifact-id="artifactId-2" translate-to-fpl="false"/> | ||
<dependency group-id="groupId-3" artifact-id="artifactId-3" translate-to-fpl="false"/> | ||
</dependencies> | ||
<default-packages> | ||
<package name="package-1"/> | ||
<package name="package-2"/> | ||
<package name="package-3"/> | ||
</default-packages> | ||
<package-schemas> | ||
<group name="package-schema-1"/> | ||
<group name="package-schema-2"/> | ||
<group name="package-schema-3"/> | ||
</package-schemas> | ||
<config name="config-1.xml" model="model-1" inherit-features="true"/> | ||
<config name="config-2.xml" model="model-2"/> | ||
<config name="config-3.xml" model="model-3"/> | ||
<transitive> | ||
<dependency group-id="tgroupId-1" artifact-id="tartifactId-1" translate-to-fpl="true"> | ||
<name>transitive-1</name> | ||
<default-configs inherit="true" inherit-unnamed-models="true"> | ||
<include name="default-config-1" model="model-1"/> | ||
</default-configs> | ||
<patches> | ||
<patch id="org:patch1:1"/> | ||
<patch id="org:patch2:2"/> | ||
<patch id="org:patch3:3"/> | ||
</patches> | ||
<packages> | ||
<include name="package-1"/> | ||
<include name="package-2"/> | ||
<include name="package-3"/> | ||
<exclude name="package-4"/> | ||
<exclude name="package-5"/> | ||
<exclude name="package-6"/> | ||
</packages> | ||
</dependency> | ||
<dependency group-id="tgroupId-2" artifact-id="tartifactId-2" translate-to-fpl="false"/> | ||
<dependency group-id="tgroupId-3" artifact-id="tartifactId-3" translate-to-fpl="false"/> | ||
</transitive> | ||
<plugins> | ||
<plugin artifact="grpoupId1:artifactId1"/> | ||
<plugin id="plugin1" artifact="grpoupId2:artifactId2:2.0"/> | ||
<plugin id="plugin2" artifact="grpoupId3:artifactId3:3.0:classifier3"/> | ||
<plugin id="plugin3" artifact="grpoupId3:artifactId3:3.0:classifier3:zip"/> | ||
</plugins> | ||
<resources> | ||
<copy to="to1" artifact="grpoupId2:artifactId2:2.0"/> | ||
<copy to="to2" artifact="grpoupId3:artifactId3:3.0:classifier3"/> | ||
<copy to="to3" artifact="grpoupId3:artifactId3:3.0:classifier3:zip"/> | ||
</resources> | ||
<generate-feature-specs> | ||
<extensions> | ||
<standalone> | ||
<extension>standalone-extension-1</extension> | ||
<extension>standalone-extension-2</extension> | ||
<extension>standalone-extension-3</extension> | ||
</standalone> | ||
<domain> | ||
<extension>domain-extension-1</extension> | ||
<extension>domain-extension-2</extension> | ||
<extension>domain-extension-3</extension> | ||
</domain> | ||
<host> | ||
<extension>host-extension-1</extension> | ||
<extension>host-extension-2</extension> | ||
<extension>host-extension-3</extension> | ||
</host> | ||
</extensions> | ||
</generate-feature-specs> | ||
<system-paths> | ||
<system-path path="system-path-1"/> | ||
<system-path path="system-path-2"/> | ||
<system-path path="system-path-3"/> | ||
</system-paths> | ||
<stability-levels> | ||
<stability-level>level-1</stability-level> | ||
<minimum-stability-level>level-2</minimum-stability-level> | ||
<config-stability-level>level-3</config-stability-level> | ||
<package-stability-level>level-4</package-stability-level> | ||
</stability-levels> | ||
</build> |