@Test public void testPurgeChannelBuilderWithNames() { MockBuilder builder = new MockBuilder(applicationContextMock) { @Override public void configure() { purgeChannels() .channelResolver(channelResolver) .channelNames("ch1", "ch2", "ch3") .channel("ch4") .selector(messageSelector); } }; reset(applicationContextMock); expect(applicationContextMock.getBean(TestListeners.class)) .andReturn(new TestListeners()) .once(); expect(applicationContextMock.getBean(TestActionListeners.class)) .andReturn(new TestActionListeners()) .once(); expect(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)) .andReturn(new HashMap<String, SequenceBeforeTest>()) .once(); replay(applicationContextMock); builder.run(null, null); Assert.assertEquals(builder.testCase().getActions().size(), 1); Assert.assertEquals( builder.testCase().getActions().get(0).getClass(), PurgeMessageChannelAction.class); PurgeMessageChannelAction action = (PurgeMessageChannelAction) builder.testCase().getActions().get(0); Assert.assertEquals(action.getChannelNames().size(), 4); Assert.assertEquals(action.getChannelNames().toString(), "[ch1, ch2, ch3, ch4]"); Assert.assertEquals(action.getChannelResolver(), channelResolver); Assert.assertEquals(action.getMessageSelector(), messageSelector); verify(applicationContextMock); }
@Test public void testMissingChannelResolver() { MockBuilder builder = new MockBuilder(applicationContextMock) { @Override public void configure() { purgeChannels().channel("ch1"); } }; reset(applicationContextMock); expect(applicationContextMock.getBean(TestListeners.class)) .andReturn(new TestListeners()) .once(); expect(applicationContextMock.getBean(TestActionListeners.class)) .andReturn(new TestActionListeners()) .once(); expect(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)) .andReturn(new HashMap<String, SequenceBeforeTest>()) .once(); replay(applicationContextMock); builder.run(null, null); Assert.assertEquals(builder.testCase().getActions().size(), 1); Assert.assertEquals( builder.testCase().getActions().get(0).getClass(), PurgeMessageChannelAction.class); PurgeMessageChannelAction action = (PurgeMessageChannelAction) builder.testCase().getActions().get(0); Assert.assertEquals(action.getChannelNames().size(), 1); Assert.assertEquals(action.getChannelNames().toString(), "[ch1]"); Assert.assertNotNull(action.getChannelResolver()); Assert.assertTrue(action.getChannelResolver() instanceof BeanFactoryChannelResolver); verify(applicationContextMock); }