Skip to content

Commit

Permalink
As of 601f942 a RuntimeException is thrown when stuff can not be dele…
Browse files Browse the repository at this point in the history
…ted.

So fix hudson.plugins.jobConfigHistory.JobConfigHistoryJobListenerIT.testRenameErrors():void to catch the RTE when
things go wrong.
  • Loading branch information
mfriedenhagen committed Sep 4, 2013
1 parent fe35ece commit 2b92f83
Showing 1 changed file with 17 additions and 13 deletions.
Expand Up @@ -22,7 +22,7 @@

/**
* @author mirko
*
*
*/
public class JobConfigHistoryJobListenerIT extends AbstractHudsonTestCaseDeletingInstanceDir {

Expand Down Expand Up @@ -58,7 +58,7 @@ public void testRename() throws IOException, SAXException, InterruptedException
final List<File> historyFilesNew = Arrays.asList(new File(jobHistoryDir, jobName2).listFiles());
assertTrue("Expected " + historyFilesNew.toString() + " to have at least two entries", historyFilesNew.size() >= 1);
}

//TODO: ???
public void testNonAbstractProjects() {
final JobConfigHistoryJobListener listener = new JobConfigHistoryJobListener();
Expand Down Expand Up @@ -89,21 +89,25 @@ public void testRenameErrors() throws Exception {
} else {
historyDir = jch.getHistoryDir(project.getConfigFile());
historyDir.getParentFile().setWritable(false);
project.renameTo("newproject2");
assertTrue("Verify history dir not able to be renamed.", historyDir.exists());
historyDir.getParentFile().setWritable(true);
try {
project.renameTo("newproject2");
fail("Expected RTE on rename");

This comment has been minimized.

Copy link
@jglick

jglick Dec 15, 2014

Member

I hit this failure when running with baseline 1.594, so the test needs to be fixed somehow I guess. Cf. #41.

} catch (RuntimeException e) {
assertTrue("Verify history dir not able to be renamed.", historyDir.exists());
historyDir.getParentFile().setWritable(true);

// test delete rename failure
project = createFreeStyleProject("newproject_deleteme");
historyDir = jch.getHistoryDir(project.getConfigFile());
historyDir.getParentFile().setWritable(false);
// test delete rename failure
project = createFreeStyleProject("newproject_deleteme");
historyDir = jch.getHistoryDir(project.getConfigFile());
historyDir.getParentFile().setWritable(false);

project.delete();
assertTrue("Verify history dir not able to be renamed on delete.", historyDir.exists());
historyDir.getParentFile().setWritable(true);
project.delete();
assertTrue("Verify history dir not able to be renamed on delete.", historyDir.exists());
historyDir.getParentFile().setWritable(true);
}
}
}

@Bug(16499)
public void testCopyJob() throws Exception {
final String text = "This is a description.";
Expand Down

0 comments on commit 2b92f83

Please sign in to comment.