public static boolean equalPopulation(final Population s1,final Population s2){
  try {
    @SuppressWarnings("resource") InputStream inputStream1=null;
    @SuppressWarnings("resource") InputStream inputStream2=null;
    try {
      inputStream1=openPopulationInputStream(s1);
      inputStream2=openPopulationInputStream(s2);
      return IOUtils.isEqual(inputStream1,inputStream2);
    }
  finally {
      if (inputStream1 != null)       inputStream1.close();
      if (inputStream2 != null)       inputStream2.close();
    }
  }
 catch (  IOException e) {
    throw new UncheckedIOException(e);
  }
}

public static boolean equalPopulation ( final Population s1 , final Population s2 ) { try { @ SuppressWarnings ( "resource" ) InputStream inputStream1 = null ; @ SuppressWarnings ( "resource" ) InputStream inputStream2 = null ; try { inputStream1 = openPopulationInputStream ( s1 ) ; inputStream2 = openPopulationInputStream ( s2 ) ; return IOUtils . isEqual ( inputStream1 , inputStream2 ) ; } finally { if ( inputStream1 != null ) inputStream1 . close ( ) ; if ( inputStream2 != null ) inputStream2 . close ( ) ; } } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } }
compares two populations by serializing them to xml with the current writer and comparing their xml form byte by byte . a bit like comparing checksums of files , but regression tests won ' t fail just because the serialization changes . limitation : if one of the populationwriters throws an exception , this will go unnoticed ( this method will just return true or false , probably false , except if both writers have written the exact same text until the exception happens ) .
