-1

I'm writing a unit test case, in which I'm not able to compare two strings only because of </> tag inside the object.

My output is

{"description":"<p>License forms information can be download as attachments<\/p>"}

My expected output is:

"{\"description\":\"<p>License forms information can be download as attachments</p>\"}";

The only place where I'm facing problem is at </p> tag. When I change to <\/p> it throws me syntax error. Any suggestions would be greatly appreciated.

My code

WebResource webResource = client.resource("http://myip:8080/Kalgudi/restService");
    ClientResponse response = webResource.type("application/xml").get(ClientResponse.class);        
    String output = response.getEntity(String.class);

    JSONObject json = new JSONObject(output);

    System.out.println("Json object is:"+json.getJSONObject("6824"));


    String expected = "{\"description\":\"<p>License forms information can be download as attachments</p>\"}";




    assertEquals(expected, json.getJSONObject("6824"));
ashrafi.iqbal
  • 51
  • 1
  • 6

1 Answers1

0

I am going to guess because there isn't really enough information to say anything else that you are not escaping your strings correctly which looks to be succinctly answered in What are all the escape characters in Java?. Doesn't really seem to be a problem with assertions, equality or unit tests.

Community
  • 1
  • 1
cyborg
  • 5,638
  • 1
  • 19
  • 25