/** * Destroy the {@link IntegrationFlow} bean (as well as all its dependant beans) * and clean up all the local cache for it. */ @Override public void destroy() { this.integrationFlowContext.remove(this.id); }
@Test public void testWrongLifecycle() { try { this.integrationFlowContext.remove("foo"); fail("IllegalStateException expected"); } catch (Exception e) { assertThat(e, instanceOf(IllegalStateException.class)); assertThat(e.getMessage(), containsString("An IntegrationFlow with the id [" + "foo" + "] doesn't exist in the registry.")); } }
@Test public void testIncludesDynamic() { Graph graph = this.server.getGraph(); assertThat(graph.getNodes().size()).isEqualTo(32); IntegrationFlow flow = f -> f.handle(m -> { }); IntegrationFlowRegistration reg = this.flowContext.registration(flow).register(); graph = this.server.rebuild(); assertThat(graph.getNodes().size()).isEqualTo(34); this.flowContext.remove(reg.getId()); graph = this.server.rebuild(); assertThat(graph.getNodes().size()).isEqualTo(32); }
/** * Destroy the {@link IntegrationFlow} bean (as well as all its dependant beans) * and clean up all the local cache for it. */ public void destroy() { this.integrationFlowContext.remove(this.id); }
/** * Destroy the {@link IntegrationFlow} bean (as well as all its dependant beans) * and clean up all the local cache for it. */ @Override public void destroy() { this.integrationFlowContext.remove(this.id); }
/** * Destroy the {@link IntegrationFlow} bean (as well as all its dependant beans) * and clean up all the local cache for it. */ public void destroy() { this.integrationFlowContext.remove(this.id); }
@Test public void testDynamicSubFlow() { PollableChannel resultChannel = new QueueChannel(); this.integrationFlowContext.registration(flow -> flow.publishSubscribeChannel(p -> p .minSubscribers(1) .subscribe(f -> f.channel(resultChannel)) )) .id("dynamicFlow") .register(); this.integrationFlowContext.messagingTemplateFor("dynamicFlow").send(new GenericMessage<>("test")); Message<?> receive = resultChannel.receive(1000); assertNotNull(receive); assertEquals("test", receive.getPayload()); MessageHistory messageHistory = MessageHistory.read(receive); assertNotNull(messageHistory); String messageHistoryString = messageHistory.toString(); assertThat(messageHistoryString, Matchers.containsString("dynamicFlow.input")); assertThat(messageHistoryString, Matchers.containsString("dynamicFlow.subFlow#0.channel#1")); this.integrationFlowContext.remove("dynamicFlow"); }
@Test public void testWrongLifecycle() { class MyIntegrationFlow implements IntegrationFlow { @Override public void configure(IntegrationFlowDefinition<?> flow) { flow.bridge(null); } } IntegrationFlow testFlow = new MyIntegrationFlow(); // This is fine because we are not going to start it automatically. assertNotNull(this.integrationFlowContext.registration(testFlow) .autoStartup(false) .register()); try { this.integrationFlowContext.registration(testFlow).register(); fail("IllegalStateException expected"); } catch (Exception e) { assertThat(e, instanceOf(IllegalStateException.class)); assertThat(e.getMessage(), containsString("Consider to implement it for [" + testFlow + "].")); } try { this.integrationFlowContext.remove("foo"); fail("IllegalStateException expected"); } catch (Exception e) { assertThat(e, instanceOf(IllegalStateException.class)); assertThat(e.getMessage(), containsString("But [" + "foo" + "] ins't one of them.")); } }