@Test public void testProducerSingletonism() throws Exception { // given Endpoint endpoint = context.getEndpoint("smslib://asdf"); endpoint.createProducer(); // when then try { endpoint.createProducer(); fail(); } catch (Exception e) { // expected } }
private void prepareFtpServer() throws Exception { // prepares the FTP Server by creating a file on the server Endpoint endpoint = context.getEndpoint(getFtpUrl()); Exchange exchange = endpoint.createExchange(); exchange.getIn().setBody("Hello World"); exchange.getIn().setHeader(Exchange.FILE_NAME, "hello.txt"); Producer producer = endpoint.createProducer(); producer.start(); producer.process(exchange); producer.stop(); }
public boolean canSendToEndpoint(String endpointUri) { try { Endpoint endpoint = context.getEndpoint(endpointUri); if (endpoint != null) { Producer producer = endpoint.createProducer(); return producer != null; } } catch (Exception e) { // ignore } return false; }
@Override protected void doStart() throws Exception { ObjectHelper.notNull(camelContext, "camelContext", this); if (endpoint == null && endpointUri == null) { throw new IllegalArgumentException("Either endpoint or endpointUri must be configured"); } if (endpoint == null) { endpoint = camelContext.getEndpoint(endpointUri); } producer = endpoint.createProducer(); ServiceHelper.startService(producer); }
private void prepareFtpServer() throws Exception { // prepares the FTP Server by creating a file on the server that we want to unit // test that we can pool and store as a local file Endpoint endpoint = context.getEndpoint(getFtpUrl()); Exchange exchange = endpoint.createExchange(); exchange.getIn().setBody("Hello World this file will be moved"); exchange.getIn().setHeader(Exchange.FILE_NAME, "hello.txt"); Producer producer = endpoint.createProducer(); producer.start(); producer.process(exchange); producer.stop(); // assert file is created File file = new File(FTP_ROOT_DIR + "movefile/hello.txt"); file = file.getAbsoluteFile(); assertTrue("The file should exists", file.exists()); }
private Exchange sendExchange(boolean setException) throws Exception { Endpoint endpoint = context.getEndpoint( "mina:tcp://localhost:{{port}}?sync=true&encoding=UTF-8&transferExchange=true"); Exchange exchange = endpoint.createExchange(); Message message = exchange.getIn(); message.setBody("Hello!"); message.setHeader("cheese", "feta"); exchange.setProperty("ham", "old"); exchange.setProperty("setException", setException); Producer producer = endpoint.createProducer(); producer.start(); producer.process(exchange); return exchange; }
public ObserverSender(Endpoint endpoint) throws Exception { this.producer = endpoint.createProducer(); ServiceHelper.startService(producer); }