Last active
December 13, 2015 21:08
-
-
Save peysal/4975387 to your computer and use it in GitHub Desktop.
Simple unit test using CamelTestSupport. I having problem running unit test with camel. So I going to do step by step as what mentioned in camel in action.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import org.apache.camel.Exchange; | |
import org.apache.camel.builder.RouteBuilder; | |
import org.apache.camel.test.junit4.CamelTestSupport; | |
import org.junit.Test; | |
public class FirstTest extends CamelTestSupport { | |
@Override | |
protected RouteBuilder createRouteBuilder() throws Exception { | |
return new RouteBuilder() { | |
@Override | |
public void configure() throws Exception { | |
from("file://target/inbox").to("file://target/outbox"); | |
} | |
}; | |
} | |
@Test | |
public void testMoveFile() throws Exception { | |
template.sendBodyAndHeader("file://target/inbox", "Hello World", | |
Exchange.FILE_NAME, "hello.txt"); | |
Thread.sleep(10000); | |
File target = new File("target/outbox/hello.txt"); | |
assertTrue("File not moved", target.exists()); | |
String content = context.getTypeConverter().convertTo(String.class, target); | |
assertEquals("Hello World", content); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment