-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileProcessingRouteTest.groovy
More file actions
44 lines (38 loc) · 1.65 KB
/
FileProcessingRouteTest.groovy
File metadata and controls
44 lines (38 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@GrabConfig(systemClassLoader=true)
@Grapes([
@Grab(group='org.apache.camel', module='camel-core', version='4.8.1'),
@Grab(group='org.apache.camel', module='camel-test-junit5', version='4.8.1'),
@Grab(group='org.junit.jupiter', module='junit-jupiter-api', version='5.10.0'),
@Grab(group='org.junit.jupiter', module='junit-jupiter-engine', version='5.10.0'),
@Grab(group='org.apache.camel', module='camel-file', version='4.8.1'),
@Grab(group='ch.qos.logback', module='logback-classic', version='1.5.12')
])
import org.apache.camel.CamelContext
import org.apache.camel.builder.RouteBuilder
import org.apache.camel.test.junit5.CamelTestSupport
import org.junit.jupiter.api.Test
import org.apache.camel.component.mock.MockEndpoint
class FileProcessingRouteTest extends CamelTestSupport {
@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
void configure() throws Exception {
// Ruta para procesar archivos
from("file://input?noop=true") // Leer archivos del directorio 'input'
.transform().simple("\${bodyAs(String).toUpperCase()}") // Transformar el contenido a mayúsculas
.to("mock:output") // Enviar al endpoint simulado
}
}
}
@Test
void testFileProcessingRoute() throws Exception {
// Configurar el MockEndpoint
MockEndpoint mockEndpoint = getMockEndpoint("mock:output")
mockEndpoint.expectedBodiesReceived("HELLO CAMEL") // Mensaje esperado
// Enviar archivo simulado
template.sendBodyAndHeader("file://input", "hello camel", "CamelFileName", "test.txt")
// Validar el procesamiento
MockEndpoint.assertIsSatisfied(context)
}
}