Skip to content
Permalink
Browse files
Regression test and changelog for [JENKINS-16573]
Originally-Committed-As: bdd8580882295177900855572e41ce891ab9cfaf
  • Loading branch information
kutzi committed Jan 31, 2013
1 parent 94fb9bb commit b4767299887a9369de59a2393555c886e59bb041
@@ -45,6 +45,8 @@
import java.lang.reflect.Proxy;
import java.lang.reflect.Method;

import javax.annotation.CheckForNull;

import hudson.util.InvocationInterceptor;
import hudson.util.ReflectionUtils;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
@@ -145,13 +147,14 @@ public String getGoal() {
*
* @return
* The configuration value either specified in POM, or inherited from
* parent POM, or default value if one is specified in mojo.
* parent POM, or default value if one is specified in mojo,
* or null if no such configuration value exists.
*
* @throws ComponentConfigurationException
* Not sure when exactly this is thrown, but it's probably when
* the configuration in POM is syntactically incorrect.
*/
public <T> T getConfigurationValue(String configName, Class<T> type) throws ComponentConfigurationException {
@CheckForNull public <T> T getConfigurationValue(String configName, Class<T> type) throws ComponentConfigurationException {
PlexusConfiguration child = configuration.getChild(configName,false);
if(child==null) return null; // no such config

@@ -8,6 +8,8 @@
import java.util.Collections;
import java.util.Iterator;

import javax.annotation.CheckForNull;

import org.apache.maven.project.MavenProject;
import org.apache.tools.ant.types.FileSet;
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
@@ -60,7 +62,10 @@ protected boolean is(String artifactId, String groupId, String goal) {
File reportsDir = mojo.getConfigurationValue("jasmineTargetDir", File.class);
String junitFileName = mojo.getConfigurationValue("junitXmlReportFileName", String.class);

return Collections.singleton(new File(reportsDir,junitFileName));
if (reportsDir != null && junitFileName != null) {
return Collections.singleton(new File(reportsDir,junitFileName));
}
return null;
}
},
TOOLKIT_RESOLVER_PLUGIN("org.terracotta.maven.plugins", "toolkit-resolver-plugin", "toolkit-resolve-test","reportsDirectory");
@@ -98,7 +103,7 @@ public boolean canRunTests(MojoInfo mojo) {
return mojo.pluginName.version.compareTo(this.minimalRequiredVersion) >= 0;
}

public Iterable<File> getReportFiles(MavenProject pom, MojoInfo mojo) throws ComponentConfigurationException {
@CheckForNull public Iterable<File> getReportFiles(MavenProject pom, MojoInfo mojo) throws ComponentConfigurationException {
if (this.reportDirectoryConfigKey != null) {
File reportsDir = mojo.getConfigurationValue(this.reportDirectoryConfigKey, File.class);
if (reportsDir != null && reportsDir.exists()) {
@@ -0,0 +1,36 @@
package hudson.maven.reporters;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import hudson.maven.MojoInfo;
import hudson.maven.MojoInfoBuilder;

import java.io.File;

import org.apache.maven.model.Build;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
import org.junit.Test;
import org.jvnet.hudson.test.Bug;

public class TestMojoTest {

@Test
@Bug(16573)
public void testGetReportFilesThrowsNoException() throws ComponentConfigurationException {
// no 'reportsDirectory' or so config value set:
MojoInfo mojoInfo = MojoInfoBuilder.mojoBuilder("com.some", "testMojo", "test").build();

MavenProject pom = mock(MavenProject.class);
when(pom.getBasedir()).thenReturn(new File("foo"));

Build build = mock(Build.class);
when(build.getDirectory()).thenReturn("bar");
when(pom.getBuild()).thenReturn(build);

for (TestMojo testMojo : TestMojo.values()) {
testMojo.getReportFiles(pom, mojoInfo);
}
}

}

0 comments on commit b476729

Please sign in to comment.