use of org.apache.camel.spi.BrowsableEndpoint in project camel by apache.
the class FtpBrowsableEndpointTest method testBrowsableNoFiles.
@Test
public void testBrowsableNoFiles() throws Exception {
// make sure starting directory exists
createDirectory(FTP_ROOT_DIR + "/browse");
BrowsableEndpoint browse = context.getEndpoint(getFtpUrl(), BrowsableEndpoint.class);
assertNotNull(browse);
List<Exchange> list = browse.getExchanges();
assertNotNull(list);
assertEquals(0, list.size());
}
use of org.apache.camel.spi.BrowsableEndpoint in project camel by apache.
the class EndpointHelper method browseRangeMessagesAsXml.
/**
* Browses the {@link BrowsableEndpoint} within the given range, and returns the messages as a XML payload.
*
* @param endpoint the browsable endpoint
* @param fromIndex from range
* @param toIndex to range
* @param includeBody whether to include the message body in the XML payload
* @return XML payload with the messages
* @throws IllegalArgumentException if the from and to range is invalid
* @see MessageHelper#dumpAsXml(org.apache.camel.Message)
*/
public static String browseRangeMessagesAsXml(BrowsableEndpoint endpoint, Integer fromIndex, Integer toIndex, Boolean includeBody) {
if (fromIndex == null) {
fromIndex = 0;
}
if (toIndex == null) {
toIndex = Integer.MAX_VALUE;
}
if (fromIndex > toIndex) {
throw new IllegalArgumentException("From index cannot be larger than to index, was: " + fromIndex + " > " + toIndex);
}
List<Exchange> exchanges = endpoint.getExchanges();
if (exchanges.size() == 0) {
return null;
}
StringBuilder sb = new StringBuilder();
sb.append("<messages>");
for (int i = fromIndex; i < exchanges.size() && i <= toIndex; i++) {
Exchange exchange = exchanges.get(i);
Message msg = exchange.hasOut() ? exchange.getOut() : exchange.getIn();
String xml = MessageHelper.dumpAsXml(msg, includeBody);
sb.append("\n").append(xml);
}
sb.append("\n</messages>");
return sb.toString();
}
use of org.apache.camel.spi.BrowsableEndpoint in project camel by apache.
the class BrowseRouteTest method testBrowseRoute.
public void testBrowseRoute() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World", "Bye World");
template.sendBody("direct:start", "Hello World");
template.sendBody("direct:start", "Bye World");
assertMockEndpointsSatisfied();
BrowsableEndpoint list = context.getEndpoint("browse:foo", BrowsableEndpoint.class);
mock.getExchanges().get(0).equals(list.getExchanges().get(0));
mock.getExchanges().get(1).equals(list.getExchanges().get(1));
}
use of org.apache.camel.spi.BrowsableEndpoint in project camel by apache.
the class FileBrowsableEndpointTest method testBrowsableNoFiles.
public void testBrowsableNoFiles() throws Exception {
BrowsableEndpoint browse = context.getEndpoint("file:target/browse", BrowsableEndpoint.class);
assertNotNull(browse);
List<Exchange> list = browse.getExchanges();
assertNotNull(list);
assertEquals(0, list.size());
}
Aggregations