Hi,

currently i'm trying to understand how to create unit/integration tests for the ModelMerger / MavenModelMerger part..which does things like merging the configuration of plugins...

I have found a Test:

https://git-wip-us.apache.org/repos/asf?p=maven.git;a=blob_plain;f=maven-model-builder/src/test/java/org/apache/maven/model/merge/MavenModelMergerTest.java;hb=HEAD

which looks like what i need....Ok i enhanced it like the following:



    private Model readPomModel( String resource )
        throws IOException, XmlPullParserException
    {
InputStream resourceAsStream = this.getClass().getResourceAsStream( resource );

        MavenXpp3Reader reader = new MavenXpp3Reader();
        Model read = reader.read( resourceAsStream );
        return read;
    }

    @Test
    public void testMergeModel_XXX()
        throws IOException, XmlPullParserException
    {
Model sourceModel = readPomModel( "/poms/merge/plugin-pom-parent.xml" ); Model targetModel = readPomModel( "/poms/merge/plugin-pom-child.xml" );

        ConfigurationContainer target = new ConfigurationContainer();
target.setConfiguration( targetModel.getBuild().getPlugins().get( 0 ).getConfiguration() );

        ConfigurationContainer source = new ConfigurationContainer();
source.setConfiguration( sourceModel.getBuild().getPlugins().get( 0 ).getConfiguration() );

        modelMerger.merge( targetModel, sourceModel, true, null );

        System.out.println( "Configuration parent:"
+ sourceModel.getBuild().getPlugins().get( 0 ).getConfiguration().toString() );
        System.out.println( "Configuration child:"
+ targetModel.getBuild().getPlugins().get( 0 ).getConfiguration().toString() );

    }


But my problem at the moment is that the configuration aren't merged in any way as the default let me think... they should...

Can someone give me a tip where to go further into ? Or what i'm doing wrong ?

Kind regards
Karl Heinz Marbaise


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to