public Exchange createExchange() { // create the file String uri = "file://target/filelanguage?fileExist=Override"; template.sendBodyAndHeader(uri, "Hello World", Exchange.FILE_NAME, "test/hello.txt"); // get the file handle file = new File("target/filelanguage/test/hello.txt"); GenericFile<File> gf = FileConsumer.asGenericFile("target/filelanguage", file, null, false); FileEndpoint endpoint = getMandatoryEndpoint(uri, FileEndpoint.class); Exchange answer = endpoint.createExchange(gf); endpoint.configureMessage(gf, answer.getIn()); Calendar cal = Calendar.getInstance(); cal.set(1974, Calendar.APRIL, 20); answer.getIn().setHeader("birthday", cal.getTime()); cal.set(2008, Calendar.AUGUST, 8); answer.getOut().setHeader("special", cal.getTime()); return answer; }
public Exchange createExchange() { // create the file String uri = "file://target/filelanguage?fileExist=Override"; template.sendBodyAndHeader(uri, "Bye World", Exchange.FILE_NAME, "test/bye.def.txt"); // get the file handle file = new File("target/filelanguage/test/bye.def.txt"); GenericFile<File> gf = FileConsumer.asGenericFile("target/filelanguage", file, null, false); FileEndpoint endpoint = getMandatoryEndpoint(uri, FileEndpoint.class); Exchange answer = endpoint.createExchange(gf); endpoint.configureMessage(gf, answer.getIn()); Calendar cal = Calendar.getInstance(); cal.set(1974, Calendar.APRIL, 20); answer.getIn().setHeader("birthday", cal.getTime()); cal.set(2008, Calendar.AUGUST, 8); answer.getOut().setHeader("special", cal.getTime()); return answer; }
@Override public void configure() throws Exception { log.debug("Loading Bulk Ingest Process: @" + folder); fEPoint = endpoint( "file:" + folder + "?noop=false&sortBy=file:name&move=.done&delay=" + BULK_INGEST_POLL_INTERVAL, FileEndpoint.class); fEPoint.setFilter(new BulkIngestFileFilter()); RouteDefinition route = from(fEPoint); route.setId(folder); SplitDefinition split = route.split().tokenizeXML("ingestDocument"); split.streaming(); AggregateDefinition aggregator = split.aggregate(constant(true), new BodyAggregator()); aggregator.setParallelProcessing(BULK_PROCESSOR_MULTI_THREADED); aggregator.completionPredicate(new SplitPredicate(BULK_PROCESSOR_SPLIT_SIZE)); ThreadsDefinition threads = aggregator.threads(BULK_PROCESSOR_THREADS_MIN, BULK_PROCESSOR_THREADS_MAX); bulkIngestNIndexProcessor = new BulkIngestNIndexProcessor(user, action); threads.process(bulkIngestNIndexProcessor); threads.setThreadName("bulkIngest"); route.setErrorHandlerBuilder(DocStoreCamelContext.getInstance().getErrorHandler()); log.info("Loaded Bulk Ingest Process: @" + folder); }
public void testFileNameDoubleExtension() throws Exception { file = new File("target/filelanguage/test/bigfile.tar.gz"); String uri = "file://target/filelanguage?fileExist=Override"; GenericFile<File> gf = FileConsumer.asGenericFile("target/filelanguage", file, null, false); FileEndpoint endpoint = getMandatoryEndpoint(uri, FileEndpoint.class); Exchange answer = endpoint.createExchange(gf); endpoint.configureMessage(gf, answer.getIn()); assertEquals("bigfile.tar.gz", file.getName()); assertExpression(answer, "${file:onlyname}", "bigfile.tar.gz"); assertExpression(answer, "${file:ext}", "tar.gz"); }
@Test public void testMocksAreValid() throws Exception { // lets check that our injected endpoint is valid FileEndpoint fileEndpoint = assertIsInstanceOf(FileEndpoint.class, inputFile); assertEquals("File", new File("target/test-default-inbox"), fileEndpoint.getFile()); result.expectedBodiesReceived(expectedBody); result.setResultWaitTime(5000); template.sendBodyAndHeader(inputFile, expectedBody, Exchange.FILE_NAME, "hello.txt"); result.assertIsSatisfied(); }
public V1CamelFileConsumerBindingModelTest() { super(FileEndpoint.class, CAMEL_XML); }
public V1CamelFileBindingModelTest() { super(FileEndpoint.class, CAMEL_XML); }
public V1CamelFileProducerBindingModelTest() { super(FileEndpoint.class, CAMEL_XML); }
protected FileEndpoint getFileEndPoint() { return fEPoint; }