Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions maven-plugin-testing-harness/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,10 @@ under the License.
<description>The Maven Plugin Testing Harness provides mechanisms to manage tests on Mojo.</description>

<properties>
<versions.junit5>5.13.0</versions.junit5>
<wagonVersion>3.5.3</wagonVersion>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.13.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- maven -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,51 @@
package org.apache.maven.plugin.testing;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

public class ParametersMojo extends AbstractMojo {
public String plain;

public String withProperty;
private String plain;

public String withDefault;
private String withProperty;

public String withPropertyAndDefault;
private String withDefault;

private String withPropertyAndDefault;

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
public void execute() {
getLog().info("Plain value = " + plain);
}

public String getPlain() {
return plain;
}

public void setPlain(String plain) {
this.plain = plain;
}

public String getWithProperty() {
return withProperty;
}

public void setWithProperty(String withProperty) {
this.withProperty = withProperty;
}

public String getWithDefault() {
return withDefault;
}

public void setWithDefault(String withDefault) {
this.withDefault = withDefault;
}

public String getWithPropertyAndDefault() {
return withPropertyAndDefault;
}

public void setWithPropertyAndDefault(String withPropertyAndDefault) {
this.withPropertyAndDefault = withPropertyAndDefault;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ public void testDefault() throws Exception {

ParametersMojo mojo = (ParametersMojo) lookupConfiguredMojo(project, "parameters");

assertNull(mojo.plain);
assertNull(mojo.withProperty);
assertEquals("default", mojo.withDefault);
assertEquals("default", mojo.withPropertyAndDefault);
assertNull(mojo.getPlain());
assertNull(mojo.getWithProperty());
assertEquals("default", mojo.getWithDefault());
assertEquals("default", mojo.getWithPropertyAndDefault());
}

public void testExplicit() throws Exception {
MavenProject project = readMavenProject(new File("src/test/projects/explicit"));

ParametersMojo mojo = (ParametersMojo) lookupConfiguredMojo(project, "parameters");

assertEquals("explicitValue", mojo.plain);
assertEquals("explicitWithPropertyValue", mojo.withProperty);
assertEquals("explicitWithDefaultValue", mojo.withDefault);
assertEquals("explicitWithPropertyAndDefaultValue", mojo.withPropertyAndDefault);
assertEquals("explicitValue", mojo.getPlain());
assertEquals("explicitWithPropertyValue", mojo.getWithProperty());
assertEquals("explicitWithDefaultValue", mojo.getWithDefault());
assertEquals("explicitWithPropertyAndDefaultValue", mojo.getWithPropertyAndDefault());
}

public void testDefaultWithProperty() throws Exception {
Expand All @@ -61,10 +61,10 @@ public void testDefaultWithProperty() throws Exception {
session.getUserProperties().put("property", "propertyValue");
ParametersMojo mojo = (ParametersMojo) lookupConfiguredMojo(session, execution);

assertNull(mojo.plain);
assertEquals("propertyValue", mojo.withProperty);
assertEquals("default", mojo.withDefault);
assertEquals("propertyValue", mojo.withPropertyAndDefault);
assertNull(mojo.getPlain());
assertEquals("propertyValue", mojo.getWithProperty());
assertEquals("default", mojo.getWithDefault());
assertEquals("propertyValue", mojo.getWithPropertyAndDefault());
}

public void testExplicitWithProperty() throws Exception {
Expand All @@ -75,10 +75,10 @@ public void testExplicitWithProperty() throws Exception {
session.getUserProperties().put("property", "propertyValue");
ParametersMojo mojo = (ParametersMojo) lookupConfiguredMojo(session, execution);

assertEquals("explicitValue", mojo.plain);
assertEquals("explicitWithPropertyValue", mojo.withProperty);
assertEquals("explicitWithDefaultValue", mojo.withDefault);
assertEquals("explicitWithPropertyAndDefaultValue", mojo.withPropertyAndDefault);
assertEquals("explicitValue", mojo.getPlain());
assertEquals("explicitWithPropertyValue", mojo.getWithProperty());
assertEquals("explicitWithDefaultValue", mojo.getWithDefault());
assertEquals("explicitWithPropertyAndDefaultValue", mojo.getWithPropertyAndDefault());
}

protected MavenProject readMavenProject(File basedir) throws ProjectBuildingException, Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ void simpleMojo(ParametersMojo mojo) {
@MojoParameter(name = "plain", value = "plainValue")
@MojoParameter(name = "withDefault", value = "withDefaultValue")
void simpleMojoWithParameters(ParametersMojo mojo) {
assertEquals("plainValue", mojo.plain);
assertEquals("withDefaultValue", mojo.withDefault);
assertEquals("plainValue", mojo.getPlain());
assertEquals("withDefaultValue", mojo.getWithDefault());
assertDoesNotThrow(mojo::execute);
}

@Test
@InjectMojo(goal = "test:test-plugin:0.0.1-SNAPSHOT:parameters", pom = POM)
@MojoParameter(name = "plain", value = "plainValue")
void simpleMojoWithParameter(ParametersMojo mojo) {
assertEquals("plainValue", mojo.plain);
assertEquals("plainValue", mojo.getPlain());
assertDoesNotThrow(mojo::execute);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import org.junit.Test;

public class TestResourcesTest {
public TestResources resources = new TestResources();

private final TestResources resources = new TestResources();

@Test(expected = IllegalStateException.class)
public void testNoRuleAnnotation() throws Exception {
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven-parent</artifactId>
<version>43</version>
<version>44</version>
<relativePath />
</parent>

Expand All @@ -49,8 +49,8 @@ under the License.
<url>https://github.com/apache/maven-plugin-testing/tree/${project.scm.tag}</url>
</scm>
<issueManagement>
<system>jira</system>
<url>https://issues.apache.org/jira/browse/MPLUGINTESTING</url>
<system>GitHub</system>
<url>https://github.com/apache/maven-plugin-testing/issues</url>
</issueManagement>
<ciManagement>
<system>Jenkins</system>
Expand Down
Loading