コード例 #1
0
  /*
   * Sends two messages and asserts they arrive as expected on the other side using
   * the supplied decoder.
   */
  protected void doTest(AbstractByteArraySerializer decoder) throws Exception {
    server.setDecoder(decoder);
    Message<String> message = new GenericMessage<>("foo");
    assertTrue(channels.input().send(message));
    String received = server.queue.poll(10, TimeUnit.SECONDS);
    assertEquals("foo", received);

    assertTrue(channels.input().send(message));
    received = server.queue.poll(10, TimeUnit.SECONDS);
    assertEquals("foo", received);
  }
 @Test
 public void testSubscribersNotInterrupted() throws Exception {
   ConfigurableApplicationContext context =
       SpringApplication.run(TestTimeWindows.class, "--server.port=0");
   Sink sink = context.getBean(Sink.class);
   TestTimeWindows testTimeWindows = context.getBean(TestTimeWindows.class);
   sink.input().send(MessageBuilder.withPayload("hello1").build());
   sink.input().send(MessageBuilder.withPayload("hello2").build());
   sink.input().send(MessageBuilder.withPayload("hello3").build());
   assertThat(testTimeWindows.latch.await(5, TimeUnit.SECONDS)).isTrue();
   assertThat(testTimeWindows.interruptionState).isNotNull();
   assertThat(testTimeWindows.interruptionState).isFalse();
   context.close();
 }