Skip to content

Commit

Permalink
[JENKINS-17713] Preparing unit and functional test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed May 29, 2013
1 parent 93b82be commit a5ac54e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
19 changes: 18 additions & 1 deletion core/src/test/java/hudson/FunctionsTest.java
Expand Up @@ -171,7 +171,24 @@ public void testGetRelativeLinkTo_JobContainedInViewWithinItemGroup() throws Exc
String result = Functions.getRelativeLinkTo(i);
assertEquals("job/i/", result);
}


@Bug(17713)
@PrepareForTest({Stapler.class, Jenkins.class})
@Test public void getRelativeLinkTo_MavenModules() throws Exception {
Jenkins j = createMockJenkins();
StaplerRequest req = createMockRequest("/jenkins");
mockStatic(Stapler.class);
when(Stapler.getCurrentRequest()).thenReturn(req);
TopLevelItemAndItemGroup ms = mock(TopLevelItemAndItemGroup.class);
when(ms.getShortUrl()).thenReturn("job/ms/");
// XXX "." (in second ancestor) is what Stapler currently fails to do. Could edit test to use ".." but set a different request path?
createMockAncestors(req, createAncestor(j, "../.."), createAncestor(ms, "."));
Item m = mock(Item.class);
when(m.getParent()).thenReturn(ms);
when(m.getShortUrl()).thenReturn("grp$art/");
assertEquals("grp$art/", Functions.getRelativeLinkTo(m));
}

@Test
public void testGetRelativeDisplayName() {
Item i = mock(Item.class);
Expand Down
19 changes: 19 additions & 0 deletions test/src/test/java/hudson/maven/MavenMultiModuleTest.java
@@ -1,5 +1,6 @@
package hudson.maven;

import com.gargoylesoftware.htmlunit.html.HtmlPage;
import org.junit.Assert;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.ExtractResourceSCM;
Expand Down Expand Up @@ -411,6 +412,24 @@ else if (parentModuleName.equals("org.jvnet.hudson.main.test.multimod.incr:modul
assertEquals("not only one module", 1, m.getModules().size());
}

@Ignore("still failing")
@Bug(17713)
@Test public void modulesPageLinks() throws Exception {
j.configureMaven3();
MavenModuleSet ms = j.createMavenProject();
ms.setScm(new ExtractResourceSCM(getClass().getResource("maven-multimod.zip")));
j.buildAndAssertSuccess(ms);
MavenModule m = ms.getModule("org.jvnet.hudson.main.test.multimod:moduleA");
assertNotNull(m);
assertEquals(1, m.getLastBuild().getNumber());
JenkinsRule.WebClient wc = j.createWebClient();
HtmlPage modulesPage = wc.getPage(ms, "modules");
// for (HtmlAnchor a : modulesPage.getAnchors()) {
// System.out.println(a.getHrefAttribute() + " → " + a.asText());
// }
modulesPage.getAnchorByText(m.getDisplayName()).openLinkInNewWindow();
}

/*
@Test public void parallelMultiModMavenWsExists() throws Exception {
configureDefaultMaven();
Expand Down

0 comments on commit a5ac54e

Please sign in to comment.