I am trying to assert for equality the following collections:
String[] arr1= new String[] { "1", "2", "3" };
Collection<String[]> coll1= Arrays.asList(arr1, arr1);
String[] arr2 = new String[] { "1", "2", "3" };
Collection<String[]> coll2 = Arrays.asList(arr2, arr2);
assertEquals(coll1, coll2);
however, I got a result opposite to the expected - an assertion error. The problem is that the arrays are checked for equality with Object.equals()
method which actually checks the reference of the arrays which are clearly different.
Is there any handy method I can use from JUnit or Guava to overcome this problem?
EDIT: Notice that I want to compare the Collection objects, not the arrays itself.