aboutsummaryrefslogtreecommitdiffstats
path: root/docproc/src/test/java/com/yahoo/docproc/NotAcceptingNewProcessingsTestCase.java
blob: 0fa15f1e6b82c4c90eeb31b58f879fe5f57cdd61 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.docproc;

import com.yahoo.docproc.impl.DocprocService;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

/**
 * @author Einar M R Rosenvinge
 */
public class NotAcceptingNewProcessingsTestCase {

    @Test
    public void testNotAccepting() {
        DocprocService service = new DocprocService("habla");
        service.setCallStack(new CallStack());
        service.setInService(true);

        service.process(new Processing());
        assertEquals(1, service.getQueueSize());

        service.setAcceptingNewProcessings(false);

        try {
            service.process(new Processing());
            fail("Should have gotten IllegalStateException here");
        } catch (IllegalStateException ise) {
            //ok!
        }
        assertEquals(1, service.getQueueSize());
    }

}