File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\test\src\test\java\hudson\model\RunTest.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Jorg Heymans
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package hudson.model;
25
26 import org.jvnet.hudson.test.HudsonTestCase;
27
28 import java.util.List;
29
30 /**
31 * @author Kohsuke Kawaguchi
32 */
33 public class RunTest extends HudsonTestCase {
34 private List<? extends Run<?,?>.Artifact> createArtifactList(String... paths) throws Exception {
35 FreeStyleProject prj = createFreeStyleProject();
36 FreeStyleBuild r = prj.scheduleBuild2(0).get();
37 Run<FreeStyleProject,FreeStyleBuild>.ArtifactList list = r.new ArtifactList();
38 for (String p : paths) {
39 list.add(r.new Artifact(p,p,p,String.valueOf(p.length()),"n"+list.size())); // Assuming all test inputs don't need urlencoding
40 }
41 list.computeDisplayName();
42 return list;
43 }
44
45 public void testArtifactListDisambiguation1() throws Exception {
46 List<? extends Run<?, ?>.Artifact> a = createArtifactList("a/b/c.xml", "d/f/g.xml", "h/i/j.xml");
47 assertEquals(a.get(0).getDisplayPath(),"c.xml");
48 assertEquals(a.get(1).getDisplayPath(),"g.xml");
49 assertEquals(a.get(2).getDisplayPath(),"j.xml");
50 }
51
52 public void testArtifactListDisambiguation2() throws Exception {
53 List<? extends Run<?, ?>.Artifact> a = createArtifactList("a/b/c.xml", "d/f/g.xml", "h/i/g.xml");
54 assertEquals(a.get(0).getDisplayPath(),"c.xml");
55 assertEquals(a.get(1).getDisplayPath(),"f/g.xml");
56 assertEquals(a.get(2).getDisplayPath(),"i/g.xml");
57 }
58
59 public void testArtifactListDisambiguation3() throws Exception {
60 List<? extends Run<?, ?>.Artifact> a = createArtifactList("a.xml","a/a.xml");
61 assertEquals(a.get(0).getDisplayPath(),"a.xml");
62 assertEquals(a.get(1).getDisplayPath(),"a/a.xml");
63 }
64 }
65