@@ -0,0 +1,2272 @@
+package nl.esciencecenter.octopus.webservice.job;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.net.URI;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport nl.esciencecenter.octopus.webservice.api.JobSubmitRequest;%0Aimport nl.esciencecenter.octopus.webservice.api.SandboxedJob;%0A%0Aimport org.apache.http.client.HttpClient;%0Aimport org.apache.http.impl.client.DefaultHttpClient;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.TemporaryFolder;%0A%0Aimport com.google.common.collect.ImmutableMap;%0A%0Apublic class PendingCancelITCase %7B%0A    @Rule%0A    public TemporaryFolder testFolder = new TemporaryFolder();%0A%0A    private OctopusManager manager;%0A%0A    private HttpClient httpClient = new DefaultHttpClient();%0A%0A    @Test%0A    public void test() throws Exception %7B%0A        URI scheduler = new URI(%22local:///%22);%0A        PollConfiguration pollConfiguration = new PollConfiguration();%0A        ImmutableMap%3CString, Object%3E preferences =%0A                ImmutableMap.of(%22octopus.adaptors.local.queue.multi.maxConcurrentJobs%22, (Object) 1);%0A        URI sandboxRoot = testFolder.newFolder(%22sandboxes%22).toURI();%0A        String queue = %22multi%22;%0A        OctopusConfiguration configuration =%0A                new OctopusConfiguration(scheduler, queue, sandboxRoot, preferences, pollConfiguration);%0A%0A        manager = new OctopusManager(configuration);%0A%0A        String jobdir = testFolder.newFolder(%22job1%22).getPath();%0A        List%3CString%3E arguments = new ArrayList%3CString%3E();%0A        arguments.add(%226000%22);%0A        JobSubmitRequest submit =%0A                new JobSubmitRequest(jobdir, %22/bin/sleep%22, arguments, new ArrayList%3CString%3E(), new ArrayList%3CString%3E(),%0A                        %22stderr.txt%22, %22stdout.txt%22, null);%0A%0A        // when 1 job is submmited -%3E test passes,%0A        // when 2 jobs are submitted and second cancelled -%3E test fails.%0A        manager.submitJob(submit, httpClient);%0A        SandboxedJob job = manager.submitJob(submit, httpClient);%0A%0A        manager.start();%0A        Thread.sleep(5000); // allow poller to update status%0A%0A        manager.cancelJob(job.getIdentifier());%0A%0A        SandboxedJob job_out = manager.getJob(job.getIdentifier());%0A%0A        assertEquals(job_out.getStatus().getState(), %22KILLED%22);%0A%0A        manager.stop();%0A    %7D%0A%7D%0A

Add test to reproduce the bug that a pending job can not be cancelled.