Skip to content

Commit

Permalink
[JENKINS-28881] - Direct unit test for the issue discovered with fold…
Browse files Browse the repository at this point in the history
…ers (JENKINS-32359)
  • Loading branch information
oleg-nenashev committed Jan 8, 2016
1 parent 3589ce8 commit b42f293
Showing 1 changed file with 32 additions and 1 deletion.
Expand Up @@ -43,6 +43,7 @@

import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;

/**
Expand Down Expand Up @@ -83,10 +84,38 @@ public void ownershipInfoShouldSurviveRoundtrip() throws Exception {
equalTo(original));

// Reload folder from disk and check the state
j.jenkins.reload();
folder.doReload();
assertThat("Folder ownership helper should return the configured value after the reload",
ownershipHelper.getOwnershipDescription(j.jenkins.getItemByFullName("myFolder", Folder.class)),
equalTo(original));
}

@Test
@Issue("JENKINS-32359")
public void ownershipFromLoadedFolderShouldSurviveRoundtrip() throws Exception {
Folder folder = j.jenkins.createProject(Folder.class, "myFolder");

// Drop the Ownership property injected by ItemListener.
// We emulate the folder loaded from the instance with folders.
// After that we save and reload the config in order to drop PersistedListOwner according to JENKINS-32359
folder.getProperties().remove(FolderOwnershipProperty.class);
folder.save();
folder.doReload();

// Set ownership via API
// It should invoke save via the persisted list if JENKINS-32359 does not block it
OwnershipDescription original = new OwnershipDescription(true, "ownerId",
Arrays.asList("coowner1, coowner2"));
FolderOwnershipHelper.setOwnership(folder, original);
assertThat("Folder ownership helper should return the configured value",
ownershipHelper.getOwnershipDescription(folder),
equalTo(original));

// Reload folder from disk and check the state
folder.doReload();
assertThat("Folder ownership helper should return the configured value after the reload",
ownershipHelper.getOwnershipDescription(j.jenkins.getItemByFullName("myFolder", Folder.class)),
equalTo(original));
}

@Test
Expand Down Expand Up @@ -210,4 +239,6 @@ public void ownershipShouldNotBeInheritedFromTopLevelFolderIfDisabled() throws E
assertThat("Project should not inherit the ownerhip info when inheritance is disabled",
projectOwnershipInfo.getDescription(), equalTo(OwnershipDescription.DISABLED_DESCR));
}


}

0 comments on commit b42f293

Please sign in to comment.