コード例 #1
0
  @Test
  public void canProcessMultipleLinksWhenCommandNotKnownOnLink2() throws Exception {
    final String receiver = "*****@*****.**";
    createMailUser(receiver, "loginIdReceiver", "secretOfReceiver");

    String validSender = "*****@*****.**";
    sendMailTo(receiver).from(validSender).withSubject(anySubject()).andText("usedScenario");

    Link link1 = Links.getLink(new URI(mockURI + "?num=1&foo=bar"));
    Link link2 = Links.getLink(new URI(mockURI + "?num=2&foo=bar"));

    final String to1 =
        makeURI(
            mockURI,
            newMapBuilder()
                .put("linkparams", encode("num=1&foo=bar"))
                .put("validfroms", validSender)
                .put("scenario.usedScenario", "D11=true;A12=11")
                .build());
    final String to2 =
        makeURI(
            mockURI,
            newMapBuilder()
                .put("linkparams", encode("num=2&foo=bar"))
                .put("validfroms", validSender)
                .build());

    try {
      CamelContext context = new DefaultCamelContext();
      context.addRoutes(
          new RouteBuilder() {
            @Override
            public void configure() {
              from(localImap(receiver))
                  .multicast()
                  .setAggregationStrategy(new UseOriginalAggregationStrategy())
                  .to(to1, to2);
            }
          });
      context.start();

      waitUntilMailWasFetched();
      context.stop();

      Link mock1 = getMock(link1);
      verify(mock1).switchDigitalPin(digitalPin(11), true);
      verify(mock1).switchAnalogPin(analogPin(12), 11);
      verify(mock1).close();
      verifyNoMoreInteractions(mock1);

      Link mock2 = getMock(link2);
      verify(mock2).close();
      verifyNoMoreInteractions(mock2);
    } finally {
      link1.close();
      link2.close();
    }
  }
コード例 #2
0
 @Before
 public void setup() throws URISyntaxException, Exception {
   link = Links.getLink(new URI(mockURI));
 }