blob: 609e83683b1f4f02676922232e1377f3f2e356f0 (
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
|
// Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.documentapi.messagebus.protocol;
import com.yahoo.documentapi.metrics.DocumentProtocolMetricSet;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class RoutingPolicyRepositoryTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Test
public void policy_creation_does_not_swallow_exception() {
final DocumentProtocolMetricSet metrics = new DocumentProtocolMetricSet();
final RoutingPolicyRepository repo = new RoutingPolicyRepository(metrics);
final RoutingPolicyFactory factory = mock(RoutingPolicyFactory.class);
when(factory.createPolicy(anyString())).thenThrow(new IllegalArgumentException("oh no!"));
repo.putFactory("foo", factory);
expectedException.expectMessage("oh no!");
expectedException.expect(IllegalArgumentException.class);
repo.createPolicy("foo", "bar");
}
}
|