2

I wish to unit test a camel route that looks as follows:

from("file://config")
    .process(configProcessor)

I've replaced the from with a direct endpoint using adviceWith and have a producer template to send a test exchange, however the body of the In exchange in the configProcessor is of the type File and questions like Mocking Files in Java - Mock Contents - Mockito recommend against trying to mock File objects.

Is it possible to pass another object that extends File but doesn't write to disk, or should I create a temporary file, or even refactor the configProcessor to split out the I/O from the processing?

Community
  • 1
  • 1
George
  • 903
  • 4
  • 19
  • Is your issue that when you test your code , the configProcess accepts only type "file" and your test code does not send message to "file" ? – Naveen Raj Mar 31 '15 at 19:58
  • Not quite, so the configProcessor currently only accepts type "File" and my test code currently sends a File object referencing a file on disk. I'd like to not send a reference to a file on disk. Whether that means being able to send a File object referencing a memory location or something else. – George Apr 01 '15 at 08:11
  • Can you post your code ? – Naveen Raj Apr 01 '15 at 08:33
  • Did you get to the bottom of this? – AncientSwordRage Apr 22 '15 at 09:00

1 Answers1

1

In the end I chose to split out the processing by making it a separate function from process(). It's not quite what I'd hoped for, but it works.

George
  • 903
  • 4
  • 19