use of org.apache.camel.Producer in project camel by apache.
the class CMISQueryProducerTest method getResultCountFromHeader.
@Test
public void getResultCountFromHeader() throws Exception {
Endpoint endpoint = context.getEndpoint("cmis://" + getUrl() + "?queryMode=true");
Producer producer = endpoint.createProducer();
Exchange exchange = createExchangeWithInBody("SELECT * FROM cmis:document WHERE CONTAINS('Camel test content.')");
producer.process(exchange);
@SuppressWarnings("unchecked") List<Map<String, Object>> documents = exchange.getOut().getBody(List.class);
assertEquals(2, documents.size());
assertEquals(2, exchange.getOut().getHeader("CamelCMISResultCount"));
}
use of org.apache.camel.Producer in project camel by apache.
the class CMISQueryProducerTest method limitNumberOfResultsWithReadSizeHeader.
@Test
public void limitNumberOfResultsWithReadSizeHeader() throws Exception {
Endpoint endpoint = context.getEndpoint("cmis://" + getUrl() + "?queryMode=true");
Producer producer = endpoint.createProducer();
Exchange exchange = createExchangeWithInBody("SELECT * FROM cmis:document WHERE CONTAINS('Camel test content.')");
exchange.getIn().getHeaders().put("CamelCMISReadSize", 1);
producer.process(exchange);
@SuppressWarnings("unchecked") List<Map<String, Object>> documents = exchange.getOut().getBody(List.class);
assertEquals(1, documents.size());
}
use of org.apache.camel.Producer in project camel by apache.
the class CMISQueryProducerTest method retrieveAlsoDocumentContent.
@Test
public void retrieveAlsoDocumentContent() throws Exception {
Endpoint endpoint = context.getEndpoint("cmis://" + getUrl() + "?queryMode=true");
Producer producer = endpoint.createProducer();
Exchange exchange = createExchangeWithInBody("SELECT * FROM cmis:document WHERE cmis:name='test1.txt'");
exchange.getIn().getHeaders().put("CamelCMISRetrieveContent", true);
producer.process(exchange);
@SuppressWarnings("unchecked") List<Map<String, Object>> documents = exchange.getOut().getBody(List.class);
InputStream content = (InputStream) documents.get(0).get("CamelCMISContent");
assertEquals("This is the first Camel test content.", readFromStream(content));
}
use of org.apache.camel.Producer in project camel by apache.
the class FopEndpointTest method encryptPdfWithUserPassword.
@Test
public void encryptPdfWithUserPassword() throws Exception {
Endpoint endpoint = context().getEndpoint("fop:pdf");
Producer producer = endpoint.createProducer();
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setHeader("CamelFop.Encrypt.userPassword", "secret");
exchange.getIn().setBody(FopHelper.decorateTextWithXSLFO("Test Content"));
producer.process(exchange);
PDDocument document = getDocumentFrom(exchange);
assertTrue(document.isEncrypted());
}
use of org.apache.camel.Producer in project camel by apache.
the class FopEndpointTest method overridePdfOutputFormatToPlainText.
@Test
public void overridePdfOutputFormatToPlainText() throws Exception {
String defaultOutputFormat = "pdf";
Endpoint endpoint = context().getEndpoint("fop:" + defaultOutputFormat);
Producer producer = endpoint.createProducer();
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setHeader(FopConstants.CAMEL_FOP_OUTPUT_FORMAT, "txt");
exchange.getIn().setBody(FopHelper.decorateTextWithXSLFO("Test Content"));
producer.process(exchange);
String plainText = exchange.getOut().getBody(String.class).trim();
assertEquals("Test Content", plainText);
}
Aggregations