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 }
public void testInOnly() throws Exception { // 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().send(mec); // Provider side InOnly mep = (InOnly) provider.getChannel().accept(10L); assertNotNull(mep); assertEquals(ExchangeStatus.ACTIVE, mep.getStatus()); mep.setStatus(ExchangeStatus.DONE); provider.getChannel().send(mep); // Consumer side assertSame(mec, consumer.getChannel().accept(10L)); assertEquals(ExchangeStatus.DONE, mec.getStatus()); // Nothing left assertNull(consumer.getChannel().accept(10L)); // receive in assertNull(provider.getChannel().accept(10L)); // receive in }