Author: vsiveton Date: Wed Aug 27 16:39:18 2008 New Revision: 689670 URL: http://svn.apache.org/viewvc?rev=689670&view=rev Log: o added some tests
Added: maven/plugins/trunk/maven-help-plugin/src/test/ maven/plugins/trunk/maven-help-plugin/src/test/java/ maven/plugins/trunk/maven-help-plugin/src/test/java/org/ maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/ maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/ maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/ maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/ maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java (with props) maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/ExpressionsMojoTest.java (with props) maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/HelpUtilTest.java (with props) maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/stubs/ maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/stubs/DefaultMavenProjectStub.java (with props) maven/plugins/trunk/maven-help-plugin/src/test/resources/ maven/plugins/trunk/maven-help-plugin/src/test/resources/unit/ maven/plugins/trunk/maven-help-plugin/src/test/resources/unit/default-configuration/ maven/plugins/trunk/maven-help-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml (with props) Modified: maven/plugins/trunk/maven-help-plugin/pom.xml maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java Modified: maven/plugins/trunk/maven-help-plugin/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/pom.xml?rev=689670&r1=689669&r2=689670&view=diff ============================================================================== --- maven/plugins/trunk/maven-help-plugin/pom.xml (original) +++ maven/plugins/trunk/maven-help-plugin/pom.xml Wed Aug 27 16:39:18 2008 @@ -125,6 +125,20 @@ <artifactId>commons-lang</artifactId> <version>2.4</version> </dependency> + + <!-- test --> + <dependency> + <groupId>org.apache.maven.plugin-testing</groupId> + <artifactId>maven-plugin-testing-harness</artifactId> + <version>1.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit-addons</groupId> + <artifactId>junit-addons</artifactId> + <version>1.4</version> + <scope>test</scope> + </dependency> </dependencies> <reporting> <plugins> Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java?rev=689670&r1=689669&r2=689670&view=diff ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java (original) +++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java Wed Aug 27 16:39:18 2008 @@ -136,7 +136,7 @@ * @required * @readonly */ - private ArtifactRepository localRepository; + protected ArtifactRepository localRepository; /** * The current Maven project or the super pom. @@ -145,7 +145,7 @@ * @readonly * @required */ - private MavenProject project; + protected MavenProject project; /** * Remote repositories used for the project. @@ -163,7 +163,7 @@ * @readonly * @required */ - private Settings settings; + protected Settings settings; /** * The current Maven session. Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java?rev=689670&r1=689669&r2=689670&view=diff ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java (original) +++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java Wed Aug 27 16:39:18 2008 @@ -119,7 +119,7 @@ * @throws MojoFailureException if any reflection exceptions occur * @throws MojoFailureException if no value exists for <code>ExpressionDocumenter#EXPRESSION_ROOTS</code> */ - private List getExpressionsRoot() + private static List getExpressionsRoot() throws MojoFailureException, MojoExecutionException { try Added: maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java?rev=689670&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java (added) +++ maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java Wed Aug 27 16:39:18 2008 @@ -0,0 +1,53 @@ +package org.apache.maven.plugins.help; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.Assert; +import junit.framework.TestCase; +import junitx.util.PrivateAccessor; + +/** + * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Siveton</a> + * @version $Id$ + */ +public class DescribeMojoTest + extends TestCase +{ + /** + * Test method for [EMAIL PROTECTED] org.apache.maven.plugins.help.DescribeMojo#toLines(java.lang.String, int, int, int)}. + * + * @throws Exception if any + */ + public void testGetExpressionsRoot() + throws Exception + { + try + { + PrivateAccessor.invoke( DescribeMojo.class, "toLines", new Class[] { String.class, Integer.TYPE, + Integer.TYPE, Integer.TYPE }, new Object[] { "", new Integer( 2 ), new Integer( 2 ), + new Integer( 80 ) } ); + assertTrue( true ); + } + catch ( Throwable e ) + { + Assert.fail( "The API changes" ); + } + } +} Propchange: maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/ExpressionsMojoTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/ExpressionsMojoTest.java?rev=689670&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/ExpressionsMojoTest.java (added) +++ maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/ExpressionsMojoTest.java Wed Aug 27 16:39:18 2008 @@ -0,0 +1,52 @@ +package org.apache.maven.plugins.help; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.Assert; +import junit.framework.TestCase; +import junitx.util.PrivateAccessor; + +/** + * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Siveton</a> + * @version $Id$ + */ +public class ExpressionsMojoTest + extends TestCase +{ + /** + * Test method for [EMAIL PROTECTED] org.apache.maven.plugins.help.ExpressionsMojo#getExpressionsRoot()}. + * + * @throws Exception if any + */ + public void testGetExpressionsRoot() + throws Exception + { + try + { + PrivateAccessor.invoke( ExpressionsMojo.class, "getExpressionsRoot", + new Class[] {}, new Object[] {} ); + assertTrue( true ); + } + catch ( Throwable e ) + { + Assert.fail( "The API changes" ); + } + } +} Propchange: maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/ExpressionsMojoTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/ExpressionsMojoTest.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/HelpUtilTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/HelpUtilTest.java?rev=689670&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/HelpUtilTest.java (added) +++ maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/HelpUtilTest.java Wed Aug 27 16:39:18 2008 @@ -0,0 +1,80 @@ +package org.apache.maven.plugins.help; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Properties; + +import junit.framework.Assert; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; + +/** + * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Siveton</a> + * @version $Id$ + * + */ +public class HelpUtilTest + extends AbstractMojoTestCase +{ + /** + * Test method for [EMAIL PROTECTED] org.apache.maven.plugins.help.HelpUtil#getMojoDescriptor(java.lang.String, org.apache.maven.execution.MavenSession, org.apache.maven.project.MavenProject, + * java.lang.String, boolean, boolean)}. + * + * @throws Exception if any + */ + public void testGetMojoDescriptor() + throws Exception + { + File testPom = + new File( getBasedir(), + "src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" ); + EvaluateMojo describe = (EvaluateMojo) lookupMojo( "evaluate", testPom ); + + MavenSession session = + new MavenSession( + container, + describe.settings, // Settings settings, + describe.localRepository, // ArtifactRepository localRepository, + null, // EventDispatcher eventDispatcher, + null, // ReactorManager reactorManager, + Arrays.asList( new String[] { "evaluate" } ), + describe.project.getBasedir().toString(), new Properties(), + Calendar.getInstance().getTime() ); + try + { + HelpUtil.getMojoDescriptor( "help:evaluate", session, describe.project, "help:evaluate", true, false ); + assertTrue( true ); + } + catch ( MojoFailureException e ) + { + Assert.fail( "The API changes" ); + } + catch ( MojoExecutionException e ) + { + Assert.fail( "The API changes" ); + } + } +} Propchange: maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/HelpUtilTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/HelpUtilTest.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/stubs/DefaultMavenProjectStub.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/stubs/DefaultMavenProjectStub.java?rev=689670&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/stubs/DefaultMavenProjectStub.java (added) +++ maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/stubs/DefaultMavenProjectStub.java Wed Aug 27 16:39:18 2008 @@ -0,0 +1,63 @@ +package org.apache.maven.plugins.help.stubs; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.FileReader; + +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.plugin.testing.stubs.MavenProjectStub; + +/** + * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Siveton</a> + * @version $Id$ + */ +public class DefaultMavenProjectStub + extends MavenProjectStub +{ + /** + * Default constructor. + */ + public DefaultMavenProjectStub() + { + MavenXpp3Reader pomReader = new MavenXpp3Reader(); + Model model = null; + + try + { + model = + pomReader.read( new FileReader( new File( getBasedir() + + "/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" ) ) ); + setModel( model ); + } + catch ( Exception e ) + { + throw new RuntimeException( e ); + } + + setGroupId( model.getGroupId() ); + setArtifactId( model.getArtifactId() ); + setVersion( model.getVersion() ); + setName( model.getName() ); + setUrl( model.getUrl() ); + setPackaging( model.getPackaging() ); + } +} Propchange: maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/stubs/DefaultMavenProjectStub.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/stubs/DefaultMavenProjectStub.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-help-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml?rev=689670&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml (added) +++ maven/plugins/trunk/maven-help-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml Wed Aug 27 16:39:18 2008 @@ -0,0 +1,41 @@ +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>def.configuration</groupId> + <artifactId>default-configuration</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <inceptionYear>2008</inceptionYear> + <name>Maven Help Plugin Default Configuration Test</name> + <url>http://maven.apache.org</url> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-help-plugin</artifactId> + <configuration> + <project implementation="org.apache.maven.plugins.help.stubs.DefaultMavenProjectStub"/> + <localRepository>${localRepository}</localRepository> + </configuration> + </plugin> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-help-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision