Пример #1
0
 public void testInOnlySync() throws Exception {
   // Create thread to answer
   new Thread(
           new Runnable() {
             public void run() {
               try {
                 // Provider side
                 InOnly mep = (InOnly) provider.getChannel().accept(10000L);
                 assertNotNull(mep);
                 assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
                 mep.setStatus(ExchangeStatus.DONE);
                 provider.getChannel().send(mep);
               } catch (Exception e) {
                 e.printStackTrace();
                 fail();
               }
             }
           })
       .start();
   // Send message exchange
   MessageExchangeFactory mef = consumer.getChannel().createExchangeFactory(endpoint);
   InOnly mec = mef.createInOnlyExchange();
   NormalizedMessage m = mec.createMessage();
   m.setContent(new StreamSource(new ByteArrayInputStream(PAYLOAD.getBytes())));
   mec.setInMessage(m);
   consumer.getChannel().sendSync(mec, 10000L);
   assertEquals(ExchangeStatus.DONE, mec.getStatus());
   // Nothing left
   assertNull(consumer.getChannel().accept(10L)); // receive in
   assertNull(provider.getChannel().accept(10L)); // receive in
 }
Пример #2
0
 public void testRobustInOnlyWithFault() throws Exception {
   // Send message exchange
   MessageExchangeFactory mef = consumer.getChannel().createExchangeFactory(endpoint);
   RobustInOnly mec = mef.createRobustInOnlyExchange();
   NormalizedMessage m = mec.createMessage();
   m.setContent(new StreamSource(new ByteArrayInputStream(PAYLOAD.getBytes())));
   mec.setInMessage(m);
   consumer.getChannel().send(mec);
   // Provider side
   RobustInOnly mep = (RobustInOnly) provider.getChannel().accept(10L);
   assertNotNull(mep);
   assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
   mep.setStatus(ExchangeStatus.ERROR);
   provider.getChannel().send(mep);
   // Consumer side
   assertSame(mec, consumer.getChannel().accept(10L));
   assertEquals(ExchangeStatus.ERROR, mec.getStatus());
   mec.setStatus(ExchangeStatus.DONE);
   provider.getChannel().send(mec);
   // Provider site
   assertSame(mep, provider.getChannel().accept(10L));
   assertEquals(ExchangeStatus.DONE, mep.getStatus());
   // Nothing left
   assertNull(consumer.getChannel().accept(10L)); // receive in
   assertNull(provider.getChannel().accept(10L)); // receive in
 }