Return-Path: X-Original-To: apmail-maven-commits-archive@www.apache.org Delivered-To: apmail-maven-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C360B1089D for ; Sat, 8 Feb 2014 05:54:42 +0000 (UTC) Received: (qmail 42304 invoked by uid 500); 8 Feb 2014 05:54:39 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 42115 invoked by uid 500); 8 Feb 2014 05:54:34 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 41831 invoked by uid 99); 8 Feb 2014 05:54:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Feb 2014 05:54:28 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Feb 2014 05:54:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id B1B122388C65 for ; Sat, 8 Feb 2014 05:53:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r896847 [10/14] - in /websites/production/maven/content/plugin-testing-archives/LATEST: ./ maven-plugin-testing-harness/ maven-plugin-testing-harness/apidocs/ maven-plugin-testing-harness/apidocs/org/apache/maven/plugin/testing/ maven-plugi... Date: Sat, 08 Feb 2014 05:53:20 -0000 To: commits@maven.apache.org From: ifedorenko@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140208055332.B1B122388C65@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: websites/production/maven/content/plugin-testing-archives/LATEST/maven-plugin-testing-harness/xref/org/apache/maven/plugin/testing/MojoRule.html ============================================================================== --- websites/production/maven/content/plugin-testing-archives/LATEST/maven-plugin-testing-harness/xref/org/apache/maven/plugin/testing/MojoRule.html (original) +++ websites/production/maven/content/plugin-testing-archives/LATEST/maven-plugin-testing-harness/xref/org/apache/maven/plugin/testing/MojoRule.html Sat Feb 8 05:53:15 2014 @@ -33,287 +33,339 @@ 23 import java.io.InputStream; 24 import java.util.Map; 25 -26 import org.apache.maven.execution.MavenSession; -27 import org.apache.maven.plugin.Mojo; -28 import org.apache.maven.plugin.MojoExecution; -29 import org.apache.maven.project.MavenProject; -30 import org.codehaus.plexus.ContainerConfiguration; -31 import org.codehaus.plexus.PlexusContainer; -32 import org.codehaus.plexus.component.configurator.ComponentConfigurationException; -33 import org.codehaus.plexus.configuration.PlexusConfiguration; -34 import org.codehaus.plexus.util.xml.Xpp3Dom; -35 import org.junit.rules.TestRule; -36 import org.junit.runner.Description; -37 import org.junit.runners.model.Statement; -38 -39 /** -40 * {@link TestRule} for usage with Junit-4.10ff. This is just a wrapper for an embedded -41 * {@link AbstractMojoTestCase}, so all <tt>protected</tt> methods of the TestCase are -42 * exhibited as <tt>public</tt> in the rule. You may annotate single tests methods with -43 * {@link WithoutMojo} to prevent the rule from firing. -44 * -45 * @author Mirko Friedenhagen -46 * @version $Id$ -47 * @since 2.2 -48 */ -49 public class MojoRule -50 implements TestRule -51 { -52 private final AbstractMojoTestCase testCase; -53 -54 public MojoRule() -55 { -56 this( new AbstractMojoTestCase() {} ); -57 } -58 -59 public MojoRule(AbstractMojoTestCase testCase) -60 { -61 this.testCase = testCase; -62 } -63 -64 /** -65 * May be overridden in the implementation to do stuff <em>after</em> the embedded test case -66 * is set up but <em>before</em> the current test is actually run. -67 * -68 * @throws Throwable -69 */ -70 protected void before() throws Throwable -71 { -72 -73 } -74 -75 /** -76 * May be overridden in the implementation to do stuff after the current test was run. -77 */ -78 protected void after() -79 { -80 -81 } -82 -83 public InputStream getPublicDescriptorStream() -84 throws Exception +26 import org.apache.maven.execution.DefaultMavenExecutionRequest; +27 import org.apache.maven.execution.MavenExecutionRequest; +28 import org.apache.maven.execution.MavenSession; +29 import org.apache.maven.plugin.Mojo; +30 import org.apache.maven.plugin.MojoExecution; +31 import org.apache.maven.project.MavenProject; +32 import org.apache.maven.project.ProjectBuilder; +33 import org.apache.maven.project.ProjectBuildingRequest; +34 import org.codehaus.plexus.ContainerConfiguration; +35 import org.codehaus.plexus.PlexusContainer; +36 import org.codehaus.plexus.component.configurator.ComponentConfigurationException; +37 import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +38 import org.codehaus.plexus.configuration.PlexusConfiguration; +39 import org.codehaus.plexus.util.xml.Xpp3Dom; +40 import org.junit.Assert; +41 import org.junit.rules.TestRule; +42 import org.junit.runner.Description; +43 import org.junit.runners.model.Statement; +44 +45 /** +46 * {@link TestRule} for usage with Junit-4.10ff. This is just a wrapper for an embedded +47 * {@link AbstractMojoTestCase}, so all <tt>protected</tt> methods of the TestCase are +48 * exhibited as <tt>public</tt> in the rule. You may annotate single tests methods with +49 * {@link WithoutMojo} to prevent the rule from firing. +50 * +51 * @author Mirko Friedenhagen +52 * @version $Id$ +53 * @since 2.2 +54 */ +55 public class MojoRule +56 implements TestRule +57 { +58 private final AbstractMojoTestCase testCase; +59 +60 public MojoRule() +61 { +62 this( new AbstractMojoTestCase() {} ); +63 } +64 +65 public MojoRule(AbstractMojoTestCase testCase) +66 { +67 this.testCase = testCase; +68 } +69 +70 /** +71 * May be overridden in the implementation to do stuff <em>after</em> the embedded test case +72 * is set up but <em>before</em> the current test is actually run. +73 * +74 * @throws Throwable +75 */ +76 protected void before() throws Throwable +77 { +78 +79 } +80 +81 /** +82 * May be overridden in the implementation to do stuff after the current test was run. +83 */ +84 protected void after() 85 { -86 return testCase.getPublicDescriptorStream(); +86 87 } 88 -89 public String getPluginDescriptorPath() -90 { -91 return testCase.getPluginDescriptorPath(); -92 } -93 -94 public String getPluginDescriptorLocation() -95 { -96 return testCase.getPluginDescriptorLocation(); -97 } -98 -99 public void setupContainer() -100 { -101 testCase.setupContainer(); -102 } -103 -104 public ContainerConfiguration setupContainerConfiguration() -105 { -106 return testCase.setupContainerConfiguration(); -107 } -108 -109 public PlexusContainer getContainer() -110 { -111 return testCase.getContainer(); -112 } -113 -114 /** -115 * Lookup the mojo leveraging the subproject pom -116 * -117 * @param goal -118 * @param pluginPom -119 * @return a Mojo instance -120 * @throws Exception -121 */ -122 public Mojo lookupMojo( String goal, String pluginPom ) -123 throws Exception -124 { -125 return testCase.lookupMojo( goal, pluginPom ); -126 } -127 -128 /** -129 * Lookup an empty mojo -130 * -131 * @param goal -132 * @param pluginPom -133 * @return a Mojo instance -134 * @throws Exception -135 */ -136 public Mojo lookupEmptyMojo( String goal, String pluginPom ) -137 throws Exception -138 { -139 return testCase.lookupEmptyMojo( goal, new File( pluginPom ) ); -140 } -141 -142 /** -143 * Lookup the mojo leveraging the actual subprojects pom -144 * -145 * @param goal -146 * @param pom -147 * @return a Mojo instance -148 * @throws Exception -149 */ -150 public Mojo lookupMojo( String goal, File pom ) -151 throws Exception -152 { -153 return testCase.lookupMojo( goal, pom ); -154 } -155 -156 /** -157 * Lookup the mojo leveraging the actual subprojects pom -158 * -159 * @param goal -160 * @param pom -161 * @return a Mojo instance -162 * @throws Exception -163 */ -164 public Mojo lookupEmptyMojo( String goal, File pom ) -165 throws Exception -166 { -167 return testCase.lookupEmptyMojo( goal, pom ); -168 } -169 -170 public Mojo lookupMojo( String groupId, String artifactId, String version, String goal, -171 PlexusConfiguration pluginConfiguration ) -172 throws Exception -173 { -174 return testCase.lookupMojo( groupId, artifactId, version, goal, pluginConfiguration ); -175 } -176 -177 public Mojo lookupConfiguredMojo( MavenProject project, String goal ) +89 public InputStream getPublicDescriptorStream() +90 throws Exception +91 { +92 return testCase.getPublicDescriptorStream(); +93 } +94 +95 public String getPluginDescriptorPath() +96 { +97 return testCase.getPluginDescriptorPath(); +98 } +99 +100 public String getPluginDescriptorLocation() +101 { +102 return testCase.getPluginDescriptorLocation(); +103 } +104 +105 public void setupContainer() +106 { +107 testCase.setupContainer(); +108 } +109 +110 public ContainerConfiguration setupContainerConfiguration() +111 { +112 return testCase.setupContainerConfiguration(); +113 } +114 +115 public PlexusContainer getContainer() +116 { +117 return testCase.getContainer(); +118 } +119 +120 /** +121 * Lookup the mojo leveraging the subproject pom +122 * +123 * @param goal +124 * @param pluginPom +125 * @return a Mojo instance +126 * @throws Exception +127 */ +128 public Mojo lookupMojo( String goal, String pluginPom ) +129 throws Exception +130 { +131 return testCase.lookupMojo( goal, pluginPom ); +132 } +133 +134 /** +135 * Lookup an empty mojo +136 * +137 * @param goal +138 * @param pluginPom +139 * @return a Mojo instance +140 * @throws Exception +141 */ +142 public Mojo lookupEmptyMojo( String goal, String pluginPom ) +143 throws Exception +144 { +145 return testCase.lookupEmptyMojo( goal, new File( pluginPom ) ); +146 } +147 +148 /** +149 * Lookup the mojo leveraging the actual subprojects pom +150 * +151 * @param goal +152 * @param pom +153 * @return a Mojo instance +154 * @throws Exception +155 */ +156 public Mojo lookupMojo( String goal, File pom ) +157 throws Exception +158 { +159 return testCase.lookupMojo( goal, pom ); +160 } +161 +162 /** +163 * Lookup the mojo leveraging the actual subprojects pom +164 * +165 * @param goal +166 * @param pom +167 * @return a Mojo instance +168 * @throws Exception +169 */ +170 public Mojo lookupEmptyMojo( String goal, File pom ) +171 throws Exception +172 { +173 return testCase.lookupEmptyMojo( goal, pom ); +174 } +175 +176 public Mojo lookupMojo( String groupId, String artifactId, String version, String goal, +177 PlexusConfiguration pluginConfiguration ) 178 throws Exception 179 { -180 return testCase.lookupConfiguredMojo( project, goal ); +180 return testCase.lookupMojo( groupId, artifactId, version, goal, pluginConfiguration ); 181 } 182 -183 public Mojo lookupConfiguredMojo( MavenSession session, MojoExecution execution ) -184 throws Exception, ComponentConfigurationException +183 public Mojo lookupConfiguredMojo( MavenProject project, String goal ) +184 throws Exception 185 { -186 return testCase.lookupConfiguredMojo( session, execution ); +186 return testCase.lookupConfiguredMojo( project, goal ); 187 } 188 -189 public MavenSession newMavenSession( MavenProject project ) -190 { -191 return testCase.newMavenSession( project ); -192 } -193 -194 public MojoExecution newMojoExecution( String goal ) -195 { -196 return testCase.newMojoExecution( goal ); -197 } -198 -199 public PlexusConfiguration extractPluginConfiguration( String artifactId, File pom ) -200 throws Exception +189 public Mojo lookupConfiguredMojo( MavenSession session, MojoExecution execution ) +190 throws Exception, ComponentConfigurationException +191 { +192 return testCase.lookupConfiguredMojo( session, execution ); +193 } +194 +195 public MavenSession newMavenSession( MavenProject project ) +196 { +197 return testCase.newMavenSession( project ); +198 } +199 +200 public MojoExecution newMojoExecution( String goal ) 201 { -202 return testCase.extractPluginConfiguration( artifactId, pom ); +202 return testCase.newMojoExecution( goal ); 203 } 204 -205 public PlexusConfiguration extractPluginConfiguration( String artifactId, Xpp3Dom pomDom ) +205 public PlexusConfiguration extractPluginConfiguration( String artifactId, File pom ) 206 throws Exception 207 { -208 return testCase.extractPluginConfiguration( artifactId, pomDom ); +208 return testCase.extractPluginConfiguration( artifactId, pom ); 209 } 210 -211 public Mojo configureMojo( Mojo mojo, String artifactId, File pom ) +211 public PlexusConfiguration extractPluginConfiguration( String artifactId, Xpp3Dom pomDom ) 212 throws Exception 213 { -214 return testCase.configureMojo( mojo, artifactId, pom ); +214 return testCase.extractPluginConfiguration( artifactId, pomDom ); 215 } 216 -217 public Mojo configureMojo( Mojo mojo, PlexusConfiguration pluginConfiguration ) +217 public Mojo configureMojo( Mojo mojo, String artifactId, File pom ) 218 throws Exception 219 { -220 return testCase.configureMojo( mojo, pluginConfiguration ); +220 return testCase.configureMojo( mojo, artifactId, pom ); 221 } 222 -223 /** -224 * Convenience method to obtain the value of a variable on a mojo that might not have a getter. -225 * -226 * NOTE: the caller is responsible for casting to to what the desired type is. -227 * -228 * @param object -229 * @param variable -230 * @return object value of variable -231 * @throws IllegalArgumentException -232 */ -233 public Object getVariableValueFromObject( Object object, String variable ) -234 throws IllegalAccessException -235 { -236 return testCase.getVariableValueFromObject( object, variable ); -237 } -238 -239 /** -240 * Convenience method to obtain all variables and values from the mojo (including its superclasses) -241 * -242 * Note: the values in the map are of type Object so the caller is responsible for casting to desired types. -243 * -244 * @param object -245 * @return map of variable names and values -246 */ -247 public Map<String, Object> getVariablesAndValuesFromObject( Object object ) -248 throws IllegalAccessException -249 { -250 return testCase.getVariablesAndValuesFromObject( object ); -251 } -252 -253 /** -254 * Convenience method to obtain all variables and values from the mojo (including its superclasses) -255 * -256 * Note: the values in the map are of type Object so the caller is responsible for casting to desired types. -257 * -258 * @param clazz -259 * @param object -260 * @return map of variable names and values -261 */ -262 public Map<String, Object> getVariablesAndValuesFromObject( Class<?> clazz, Object object ) -263 throws IllegalAccessException -264 { -265 return testCase.getVariablesAndValuesFromObject( clazz, object ); -266 } -267 -268 /** -269 * Convenience method to set values to variables in objects that don't have setters -270 * -271 * @param object -272 * @param variable -273 * @param value -274 * @throws IllegalAccessException -275 */ -276 public void setVariableValueToObject( Object object, String variable, Object value ) -277 throws IllegalAccessException -278 { -279 testCase.setVariableValueToObject( object, variable, value ); -280 } -281 -282 @Override -283 public Statement apply(final Statement base, Description description) { -284 if (description.getAnnotation(WithoutMojo.class) != null) // skip. -285 { -286 return base; -287 } -288 return new Statement() -289 { -290 @Override -291 public void evaluate() throws Throwable -292 { -293 testCase.setUp(); -294 before(); -295 try -296 { -297 base.evaluate(); -298 } -299 finally -300 { -301 after(); -302 } -303 } -304 }; -305 } -306 } +223 public Mojo configureMojo( Mojo mojo, PlexusConfiguration pluginConfiguration ) +224 throws Exception +225 { +226 return testCase.configureMojo( mojo, pluginConfiguration ); +227 } +228 +229 /** +230 * Convenience method to obtain the value of a variable on a mojo that might not have a getter. +231 * +232 * NOTE: the caller is responsible for casting to to what the desired type is. +233 * +234 * @param object +235 * @param variable +236 * @return object value of variable +237 * @throws IllegalArgumentException +238 */ +239 public Object getVariableValueFromObject( Object object, String variable ) +240 throws IllegalAccessException +241 { +242 return testCase.getVariableValueFromObject( object, variable ); +243 } +244 +245 /** +246 * Convenience method to obtain all variables and values from the mojo (including its superclasses) +247 * +248 * Note: the values in the map are of type Object so the caller is responsible for casting to desired types. +249 * +250 * @param object +251 * @return map of variable names and values +252 */ +253 public Map<String, Object> getVariablesAndValuesFromObject( Object object ) +254 throws IllegalAccessException +255 { +256 return testCase.getVariablesAndValuesFromObject( object ); +257 } +258 +259 /** +260 * Convenience method to obtain all variables and values from the mojo (including its superclasses) +261 * +262 * Note: the values in the map are of type Object so the caller is responsible for casting to desired types. +263 * +264 * @param clazz +265 * @param object +266 * @return map of variable names and values +267 */ +268 public Map<String, Object> getVariablesAndValuesFromObject( Class<?> clazz, Object object ) +269 throws IllegalAccessException +270 { +271 return testCase.getVariablesAndValuesFromObject( clazz, object ); +272 } +273 +274 /** +275 * Convenience method to set values to variables in objects that don't have setters +276 * +277 * @param object +278 * @param variable +279 * @param value +280 * @throws IllegalAccessException +281 */ +282 public void setVariableValueToObject( Object object, String variable, Object value ) +283 throws IllegalAccessException +284 { +285 testCase.setVariableValueToObject( object, variable, value ); +286 } +287 +288 @Override +289 public Statement apply(final Statement base, Description description) { +290 if (description.getAnnotation(WithoutMojo.class) != null) // skip. +291 { +292 return base; +293 } +294 return new Statement() +295 { +296 @Override +297 public void evaluate() throws Throwable +298 { +299 testCase.setUp(); +300 before(); +301 try +302 { +303 base.evaluate(); +304 } +305 finally +306 { +307 after(); +308 } +309 } +310 }; +311 } +312 +313 /** +314 * @since 3.1.0 +315 */ +316 public MavenProject readMavenProject( File basedir ) +317 throws Exception +318 { +319 File pom = new File( basedir, "pom.xml" ); +320 MavenExecutionRequest request = new DefaultMavenExecutionRequest(); +321 request.setBaseDirectory( basedir ); +322 ProjectBuildingRequest configuration = request.getProjectBuildingRequest(); +323 MavenProject project = lookup( ProjectBuilder.class ).build( pom, configuration ).getProject(); +324 Assert.assertNotNull( project ); +325 return project; +326 } +327 +328 /** +329 * @since 3.1.0 +330 */ +331 public void executeMojo( File basedir, String goal ) +332 throws Exception +333 { +334 lookupConfiguredMojo( basedir, goal ).execute(); +335 } +336 +337 /** +338 * @since 3.1.0 +339 */ +340 public Mojo lookupConfiguredMojo( File basedir, String goal ) +341 throws Exception, ComponentConfigurationException +342 { +343 MavenProject project = readMavenProject( basedir ); +344 MavenSession session = newMavenSession( project ); +345 MojoExecution execution = newMojoExecution( goal ); +346 return lookupConfiguredMojo( session, execution ); +347 } +348 +349 /** +350 * @since 3.1.0 +351 */ +352 public final <T> T lookup( final Class<T> role ) +353 throws ComponentLookupException +354 { +355 return getContainer().lookup( role ); +356 } +357 +358 }
Modified: websites/production/maven/content/plugin-testing-archives/LATEST/maven-plugin-testing-harness/xref/org/apache/maven/plugin/testing/package-frame.html ============================================================================== --- websites/production/maven/content/plugin-testing-archives/LATEST/maven-plugin-testing-harness/xref/org/apache/maven/plugin/testing/package-frame.html (original) +++ websites/production/maven/content/plugin-testing-archives/LATEST/maven-plugin-testing-harness/xref/org/apache/maven/plugin/testing/package-frame.html Sat Feb 8 05:53:15 2014 @@ -3,7 +3,7 @@ - Maven Plugin Testing Mechanism 3.0.0 Reference Package org.apache.maven.plugin.testing + Maven Plugin Testing Mechanism 3.1.0 Reference Package org.apache.maven.plugin.testing Modified: websites/production/maven/content/plugin-testing-archives/LATEST/maven-plugin-testing-harness/xref/org/apache/maven/plugin/testing/package-summary.html ============================================================================== --- websites/production/maven/content/plugin-testing-archives/LATEST/maven-plugin-testing-harness/xref/org/apache/maven/plugin/testing/package-summary.html (original) +++ websites/production/maven/content/plugin-testing-archives/LATEST/maven-plugin-testing-harness/xref/org/apache/maven/plugin/testing/package-summary.html Sat Feb 8 05:53:15 2014 @@ -3,7 +3,7 @@ - Maven Plugin Testing Mechanism 3.0.0 Reference Package org.apache.maven.plugin.testing + Maven Plugin Testing Mechanism 3.1.0 Reference Package org.apache.maven.plugin.testing @@ -92,6 +92,6 @@
- Copyright © 2008-2013 The Apache Software Foundation. All Rights Reserved. + Copyright © 2008-2014 The Apache Software Foundation. All Rights Reserved. \ No newline at end of file