|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2019 the original author or authors. |
| 2 | + * Copyright 2002-2023 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
21 | 21 |
|
22 | 22 | import static org.assertj.core.api.Assertions.assertThat;
|
23 | 23 | import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
| 24 | +import static org.mockito.BDDMockito.given; |
| 25 | +import static org.mockito.Mockito.mock; |
24 | 26 |
|
25 | 27 | /**
|
26 | 28 | * Unit tests for the {@link JmsAccessor} class.
|
27 | 29 | *
|
28 | 30 | * @author Rick Evans
|
29 | 31 | * @author Chris Beams
|
| 32 | + * @author Vedran Pavic |
30 | 33 | */
|
31 |
| -public class JmsAccessorTests { |
| 34 | +class JmsAccessorTests { |
32 | 35 |
|
33 | 36 | @Test
|
34 |
| - public void testChokesIfConnectionFactoryIsNotSupplied() throws Exception { |
| 37 | + void testChokesIfConnectionFactoryIsNotSupplied() { |
35 | 38 | JmsAccessor accessor = new StubJmsAccessor();
|
36 | 39 | assertThatIllegalArgumentException().isThrownBy(
|
37 | 40 | accessor::afterPropertiesSet);
|
38 | 41 | }
|
39 | 42 |
|
40 | 43 | @Test
|
41 |
| - public void testSessionTransactedModeReallyDoesDefaultToFalse() throws Exception { |
| 44 | + void testSessionTransactedModeReallyDoesDefaultToFalse() { |
42 | 45 | JmsAccessor accessor = new StubJmsAccessor();
|
43 | 46 | assertThat(accessor.isSessionTransacted()).as("The [sessionTransacted] property of JmsAccessor must default to " +
|
44 | 47 | "false. Change this test (and the attendant Javadoc) if you have " +
|
45 | 48 | "changed the default.").isFalse();
|
46 | 49 | }
|
47 | 50 |
|
48 | 51 | @Test
|
49 |
| - public void testAcknowledgeModeReallyDoesDefaultToAutoAcknowledge() throws Exception { |
| 52 | + void testAcknowledgeModeReallyDoesDefaultToAutoAcknowledge() { |
50 | 53 | JmsAccessor accessor = new StubJmsAccessor();
|
51 | 54 | assertThat(accessor.getSessionAcknowledgeMode()).as("The [sessionAcknowledgeMode] property of JmsAccessor must default to " +
|
52 | 55 | "[Session.AUTO_ACKNOWLEDGE]. Change this test (and the attendant " +
|
53 | 56 | "Javadoc) if you have changed the default.").isEqualTo(Session.AUTO_ACKNOWLEDGE);
|
54 | 57 | }
|
55 | 58 |
|
56 | 59 | @Test
|
57 |
| - public void testSetAcknowledgeModeNameChokesIfBadAckModeIsSupplied() throws Exception { |
| 60 | + void testSetAcknowledgeModeNameChokesIfBadAckModeIsSupplied() { |
58 | 61 | assertThatIllegalArgumentException().isThrownBy(() ->
|
59 | 62 | new StubJmsAccessor().setSessionAcknowledgeModeName("Tally ho chaps!"));
|
60 | 63 | }
|
61 | 64 |
|
| 65 | + @Test |
| 66 | + void testCustomAcknowledgeModeIsConsideredClientAcknowledge() throws Exception { |
| 67 | + Session session = mock(Session.class); |
| 68 | + given(session.getAcknowledgeMode()).willReturn(100); |
| 69 | + JmsAccessor accessor = new StubJmsAccessor(); |
| 70 | + assertThat(accessor.isClientAcknowledge(session)).isTrue(); |
| 71 | + } |
62 | 72 |
|
63 | 73 | /**
|
64 | 74 | * Crummy, stub, do-nothing subclass of the JmsAccessor class for use in testing.
|
|
0 commit comments