Exemple #1
0
  /** Checks the persistence of queue. */
  public void testPersistence() throws Exception {
    Queue q = hudson.getQueue();

    // prevent execution to push stuff into the queue
    hudson.setNumExecutors(0);
    hudson.setNodes(hudson.getNodes());

    FreeStyleProject testProject = createFreeStyleProject("test");
    testProject.scheduleBuild(new UserCause());
    q.save();

    System.out.println(FileUtils.readFileToString(new File(hudson.getRootDir(), "queue.xml")));

    assertEquals(1, q.getItems().length);
    q.clear();
    assertEquals(0, q.getItems().length);

    // load the contents back
    q.load();
    assertEquals(1, q.getItems().length);

    // did it bind back to the same object?
    assertSame(q.getItems()[0].task, testProject);
  }
Exemple #2
0
  /** Can {@link Queue} successfully recover removal? */
  public void testPersistence2() throws Exception {
    Queue q = hudson.getQueue();

    // prevent execution to push stuff into the queue
    hudson.setNumExecutors(0);
    hudson.setNodes(hudson.getNodes());

    FreeStyleProject testProject = createFreeStyleProject("test");
    testProject.scheduleBuild(new UserCause());
    q.save();

    System.out.println(FileUtils.readFileToString(new File(hudson.getRootDir(), "queue.xml")));

    assertEquals(1, q.getItems().length);
    q.clear();
    assertEquals(0, q.getItems().length);

    // delete the project before loading the queue back
    testProject.delete();
    q.load();
    assertEquals(0, q.getItems().length);
  }