/** * When copying a folder, its contents need to be recursively copied. */ @Test public void copy() throws Exception { Folder f = createFolder(); FreeStyleProject c1 = f.createProject(FreeStyleProject.class, "child1"); Folder c2 = f.createProject(Folder.class, "nested"); FreeStyleProject c21 = c2.createProject(FreeStyleProject.class,"child2"); Folder f2 = r.jenkins.copy(f, "fcopy"); assertTrue(f2.getItem("child1") instanceof FreeStyleProject); Folder n = (Folder)f2.getItem("nested"); assertTrue(n.getItem("child2") instanceof FreeStyleProject); }
if (folder.getItem(item.getName()) != null) { continue;
if (folder.getItem(item.getName()) != null) { continue;
if (folder.getItem(item.getName()) != null) { continue;
if (folder.getItem(item.getName()) != null) { continue;
/** * Tests the path resolution of "foo" (relative) vs "/foo" (absolute) */ @Test public void copyJob() throws Exception { /* - foo - folder - foo */ FreeStyleProject top = r.createFreeStyleProject("foo"); top.setDescription("top"); Folder f = createFolder(); FreeStyleProject child = f.createProject(FreeStyleProject.class, "foo"); child.setDescription("child"); JenkinsRule.WebClient wc = r.createWebClient(); // "foo" should copy "child" copyViaHttp(f, wc, "foo", "xyz"); assertEquals("child",((Job)f.getItem("xyz")).getDescription()); // "/foo" should copy "top" copyViaHttp(f, wc, "/foo", "uvw"); assertEquals("top",((Job)f.getItem("uvw")).getDescription()); }
@Test public void reloadJenkinsAndFindBuildInProgress() throws Exception { Folder f1 = r.jenkins.createProject(Folder.class, "f"); FreeStyleProject p1 = f1.createProject(FreeStyleProject.class, "test1"); FreeStyleBuild p1b1 = p1.scheduleBuild2(0).get(); // one completed build p1.getBuildersList().add(new SleepBuilder(99999999)); p1.save(); FreeStyleBuild p1b2 = p1.scheduleBuild2(0).waitForStart(); // another build in progress // trigger the full Jenkins reload r.jenkins.reload(); Folder f2 = (Folder) r.jenkins.getItem("f"); assertNotSame(f1,f2); FreeStyleProject p2 = (FreeStyleProject) f2.getItem("test1"); /* Fails now. Why was this here? assertNotSame(p1,p2); */ FreeStyleBuild p2b1 = p2.getBuildByNumber(1); FreeStyleBuild p2b2 = p2.getBuildByNumber(2); assertTrue(p2b2.isBuilding()); assertSame(p2b2,p1b2); assertNotSame(p1b1,p2b1); p1b2.getExecutor().interrupt(); // kill the executor }