Maven Test Harness issue

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Maven Test Harness issue

kamesh.sampath
Hi,

I am developing a Mojo and trying to test it  using the maven-plugin-testing-harness and i use Maven 3.0.x as my maven platform,

The following is the pom.xml snippet of my plugin where maven.version = 2.0.10

....



                <dependency>
                        <groupId>org.apache.maven</groupId>
                        <artifactId>maven-artifact</artifactId>
                        <version>${maven.version}</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.maven</groupId>
                        <artifactId>maven-model</artifactId>
                        <version>${maven.version}</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.maven</groupId>
                        <artifactId>maven-plugin-api</artifactId>
                        <version>${maven.version}</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.maven</groupId>
                        <artifactId>maven-project</artifactId>
                        <version>${maven.version}</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.maven.shared</groupId>
                        <artifactId>maven-invoker</artifactId>
                        <version>${maven.version}</version>
                </dependency>

.....

                <dependency>
                        <groupId>org.codehaus.plexus</groupId>
                        <artifactId>plexus-container-default</artifactId>
                        <version>1.5.5</version>
                        <scope>test</scope>
                </dependency>
                <dependency>
                        <groupId>org.apache.maven.plugin-testing</groupId>
                        <artifactId>maven-plugin-testing-harness</artifactId>
                        <version>2.0-alpha-1</version>
                        <scope>test</scope>
                </dependency>

When i execute the  test case i get the error as

java.lang.NoSuchMethodError: org.codehaus.plexus.configuration.PlexusConfiguration.setName(Ljava/lang/String;)V
        at org.codehaus.plexus.configuration.DefaultPlexusConfiguration.addChild(DefaultPlexusConfiguration.java:222)
        at org.codehaus.plexus.configuration.DefaultPlexusConfiguration.getChild(DefaultPlexusConfiguration.java:165)
        at org.codehaus.plexus.configuration.DefaultPlexusConfiguration.getChild(DefaultPlexusConfiguration.java:149)
        at org.codehaus.plexus.container.initialization.InitializeComponentRegistryPhase.getComponentRepository(InitializeComponentRegistryPhase.java:66)
        at org.codehaus.plexus.container.initialization.InitializeComponentRegistryPhase.execute(InitializeComponentRegistryPhase.java:41)
        at org.codehaus.plexus.DefaultPlexusContainer.initializePhases(DefaultPlexusContainer.java:644)
        at org.codehaus.plexus.DefaultPlexusContainer.initialize(DefaultPlexusContainer.java:556)
        at org.codehaus.plexus.DefaultPlexusContainer.construct(DefaultPlexusContainer.java:281)
        at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:172)
        at org.apache.maven.plugin.testing.AbstractMojoTestCase.setupContainer(AbstractMojoTestCase.java:128)
        at org.apache.maven.plugin.testing.AbstractMojoTestCase.getContainer(AbstractMojoTestCase.java:141)
        at org.apache.maven.plugin.testing.AbstractMojoTestCase.setUp(AbstractMojoTestCase.java:87)
.....

Not sure what is the cause of the issue , can someone help to fix this pointing out what is wrong and how to fix this and test mojo with maven 3.0.3 and also ensure backward compatibility to a extent possible

~Kamesh
Reply | Threaded
Open this post in threaded view
|

Re: Maven Test Harness issue

Igor Fedorenko-3
You have to use maven-plugin-testing-harness 1.x for maven 2.x and
maven-plugin-testing-harness 2.x for maven 3.0.x. I think both 1.x and
2.x testing harness provide the same client API, so you maybe able to
run the same tests against different versions of maven, but I am not
certain about that.

--
Regards,
Igor

On 12-02-18 12:10 PM, kamesh.sampath wrote:

> Hi,
>
> I am developing a Mojo and trying to test it  using the
> maven-plugin-testing-harness and i use Maven 3.0.x as my maven platform,
>
> The following is the pom.xml snippet of my plugin where maven.version =
> 2.0.10
>
> ....
>
>
>
> <dependency>
> <groupId>org.apache.maven</groupId>
> <artifactId>maven-artifact</artifactId>
> <version>${maven.version}</version>
> </dependency>
> <dependency>
> <groupId>org.apache.maven</groupId>
> <artifactId>maven-model</artifactId>
> <version>${maven.version}</version>
> </dependency>
> <dependency>
> <groupId>org.apache.maven</groupId>
> <artifactId>maven-plugin-api</artifactId>
> <version>${maven.version}</version>
> </dependency>
> <dependency>
> <groupId>org.apache.maven</groupId>
> <artifactId>maven-project</artifactId>
> <version>${maven.version}</version>
> </dependency>
> <dependency>
> <groupId>org.apache.maven.shared</groupId>
> <artifactId>maven-invoker</artifactId>
> <version>${maven.version}</version>
> </dependency>
>
> .....
>
> <dependency>
> <groupId>org.codehaus.plexus</groupId>
> <artifactId>plexus-container-default</artifactId>
> <version>1.5.5</version>
> <scope>test</scope>
> </dependency>
> <dependency>
> <groupId>org.apache.maven.plugin-testing</groupId>
> <artifactId>maven-plugin-testing-harness</artifactId>
> <version>2.0-alpha-1</version>
> <scope>test</scope>
> </dependency>
>
> When i execute the  test case i get the error as
>
> java.lang.NoSuchMethodError:
> org.codehaus.plexus.configuration.PlexusConfiguration.setName(Ljava/lang/String;)V
> at
> org.codehaus.plexus.configuration.DefaultPlexusConfiguration.addChild(DefaultPlexusConfiguration.java:222)
> at
> org.codehaus.plexus.configuration.DefaultPlexusConfiguration.getChild(DefaultPlexusConfiguration.java:165)
> at
> org.codehaus.plexus.configuration.DefaultPlexusConfiguration.getChild(DefaultPlexusConfiguration.java:149)
> at
> org.codehaus.plexus.container.initialization.InitializeComponentRegistryPhase.getComponentRepository(InitializeComponentRegistryPhase.java:66)
> at
> org.codehaus.plexus.container.initialization.InitializeComponentRegistryPhase.execute(InitializeComponentRegistryPhase.java:41)
> at
> org.codehaus.plexus.DefaultPlexusContainer.initializePhases(DefaultPlexusContainer.java:644)
> at
> org.codehaus.plexus.DefaultPlexusContainer.initialize(DefaultPlexusContainer.java:556)
> at
> org.codehaus.plexus.DefaultPlexusContainer.construct(DefaultPlexusContainer.java:281)
> at
> org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:172)
> at
> org.apache.maven.plugin.testing.AbstractMojoTestCase.setupContainer(AbstractMojoTestCase.java:128)
> at
> org.apache.maven.plugin.testing.AbstractMojoTestCase.getContainer(AbstractMojoTestCase.java:141)
> at
> org.apache.maven.plugin.testing.AbstractMojoTestCase.setUp(AbstractMojoTestCase.java:87)
> .....
>
> Not sure what is the cause of the issue , can someone help to fix this
> pointing out what is wrong and how to fix this and test mojo with maven
> 3.0.3 and also ensure backward compatibility to a extent possible
>
> ~Kamesh
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/Maven-Test-Harness-issue-tp5495578p5495578.html
> Sent from the Maven Developers mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Maven Test Harness issue

kamesh.sampath
This post was updated on .
Thanks for the response Igor, i made to work after adding right set of plugins.

But now facing a peculiar issue,

How to make MojoTest case apply default values for the parameters ? rather how do i check the Mojo parameters default values in MojoTest case ? I am always getting those default values null even though i had given the Mojo parameter java doc annotation.

I have added the Project stubs too and set the basic values in them.
Reply | Threaded
Open this post in threaded view
|

Re: Maven Test Harness issue

Igor Fedorenko-3
This is only doable with testing harness 2.0-SNAPSHOT, but I did not
have a chance to release this feature yet.

--
Regards,
Igor

On 12-02-21 1:14 AM, kamesh.sampath wrote:

> Thanks for the response Igor, i made to work after adding right set of
> plugins.
>
> But now facing a peculiar issue,
>
> How to make MojoTest case apply default values for the parameters ? rather
> how do i check the Mojo parameters default values in MojoTest case ? I am
> always getting those default values null even though i had given the Mojo
> parameter java doc annotation.
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/Maven-Test-Harness-issue-tp5495578p5501335.html
> Sent from the Maven Developers mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Maven Test Harness issue

kamesh.sampath
No problem ! Ok will test my future plugins with that
Reply | Threaded
Open this post in threaded view
|

Re: Maven Test Harness issue

menelaosbgr
In reply to this post by kamesh.sampath
I fixed this problem by adding a dependency before the testing-harness.
This seems to load the correct cofehaus defaultConfiguration class into the
classloader.

  <dependency>
            <groupId>org.eclipse.sisu</groupId>
            <artifactId>org.eclipse.sisu.plexus</artifactId>
            <version>0.3.3</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven.plugin-testing</groupId>
            <artifactId>maven-plugin-testing-harness</artifactId>
            <version>3.3.0</version>
            <scope>test</scope>
        </dependency>

Comments?




--
Sent from: http://maven.40175.n5.nabble.com/Maven-Developers-f142166.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]