blob: 43687254498e51621e8762c467fa32c03b9c2302 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.documentapi.messagebus.protocol;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class RoutingPolicyRepositoryTest {
@Test
public void policy_creation_does_not_swallow_exception() {
final RoutingPolicyRepository repo = new RoutingPolicyRepository();
final RoutingPolicyFactory factory = mock(RoutingPolicyFactory.class);
when(factory.createPolicy(anyString())).thenThrow(new IllegalArgumentException("oh no!"));
repo.putFactory("foo", factory);
try {
repo.createPolicy("foo", "bar");
fail();
} catch (IllegalArgumentException e) {
assertEquals("oh no!", e.getMessage());
}
}
}
|