0

I am writing Junit test for apache camel route. I have a mock endpoint here.

So instead of writing to a file I will get the body content to the mock end point.

In the test method I am using assertEquals to validate the body that I receive in mock endpoint.

Below is the code

private static final String EXPECTED_RESULT = "COMPANY\n" +
        "\"CUSTOMER\",\"2018-12-11\"";

.....(Below is the test method)

@Test
public void testFileCreation() throws Exception{

   .....
   List<Exchange> exchanges = resultEndpoint.getExchanges();
   //Expects the same body content as EXPECTED_RESULT
   Assert.assertEquals(EXPECTED_RESULT, 
   exchanges.get(0).getIn().getBody().toString());

}

Note: In the above code resultEndPoint is the mock endpoint.

In the local when I do gradle build it's satisfying the assert statement and test is passing.

But when I commit to github then in drone the gradle build is failing at this assert statement.

I tried using the logs to display the value of exchanges.get(0).getIn().getBody().toString()) in drone build but the value is same as EXPECTED_RESULT.

Not sure why it is failing only in drone build. Any comments on this?

Thanks in advance..

  • If you are reading from files, then it can be newlines can be different on different platforms. – Claus Ibsen Feb 09 '19 at 07:21
  • Thanks for the comment @ClausIbsen Here it's not reading from files. In exchange I am getting the line as we have mock endpoint. Just comparing two strings. But this is working --> boolean equality = EXPECTED_RESULT.equals(exchanges.get(0).getIn().getBody().toString().trim()); Assert.assertTrue(equality); – Jaswanth Bellam Feb 11 '19 at 15:26

0 Answers0