Skip to content

Commit

Permalink
Regression test and changelog for [JENKINS-16573]
Browse files Browse the repository at this point in the history
  • Loading branch information
kutzi committed Jan 31, 2013
1 parent 38d8cdd commit bdd8580
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -58,6 +58,9 @@
<li class='major bug'>
Reverted change in 1.500 causing serious regression in HTTPS reverse proxy setups.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16368">issue 16368</a>)
<li class='major bug'>
Getting test results from custom test mojos failed build.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16573">issue 16573</a>)
<li class=bug>
Bogus “Build Record Root Directory” inadequately diagnosed.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16457">issue 16457</a>)
Expand Down
7 changes: 5 additions & 2 deletions maven-plugin/src/main/java/hudson/maven/MojoInfo.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -60,7 +62,10 @@ public Collection<File> getReportFiles(MavenProject pom,MojoInfo mojo)
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");
Expand Down Expand Up @@ -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()) {
Expand Down
@@ -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 bdd8580

Please sign in to comment.