<commit_before>package arez.apitest;

import gir.io.Exec;
import gir.sys.SystemProperty;
import java.io.File;
import java.nio.file.Files;
import javax.annotation.Nonnull;
import org.testng.annotations.Test;
import static org.testng.Assert.*;

public class ApiDiffTest
{
  @Test
  public void compareApi()
    throws Exception
  {

    final boolean storeApiDiff = SystemProperty.get( "arez.api_test.store_api_diff" ).equals( "true" );
    final File reportFile = storeApiDiff ? getFixtureReport() : File.createTempFile( "apidiff", ".json" );
    try
    {
      generateReport( reportFile );
      final File fixture = getFixtureReport();
      if ( !fixture.exists() )
      {
        fail( "Unable to locate test fixture at " + fixture.getAbsolutePath() );
      }
      else
      {
        final byte[] reportData = Files.readAllBytes( reportFile.toPath() );
        final byte[] expectedData = Files.readAllBytes( fixture.toPath() );
        assertEquals( reportData, expectedData );
      }
    }
    finally
    {
      if ( !storeApiDiff )
      {
        assertTrue( !reportFile.exists() || reportFile.delete() );
      }
    }
  }

  private void generateReport( @Nonnull final File reportFile )
  {
    final String oldApiLabel = "org.realityforge.arez:arez-core:jar:" + SystemProperty.get( "arez.prev.version" );
    final String oldApi = oldApiLabel + "::" + SystemProperty.get( "arez.prev.jar" );
    final String newApiLabel = "org.realityforge.arez:arez-core:jar:" + SystemProperty.get( "arez.next.version" );
    final String newApi = newApiLabel + "::" + SystemProperty.get( "arez.next.jar" );
    Exec.system( "java",
                 "-jar",
                 SystemProperty.get( "arez.revapi.jar" ),
                 "--old-api",
                 oldApi,
                 "--new-api",
                 newApi,
                 "--output-file",
                 reportFile.toString() );
  }

  @Nonnull
  private File getFixtureReport()
  {
    return new File( SystemProperty.get( "arez.api_test.fixture_dir" ),
                     SystemProperty.get( "arez.prev.version" ) + "-" +
                     SystemProperty.get( "arez.next.version" ) + ".json" );
  }
}
<commit_msg>Compare the file contents as strings<commit_after>package arez.apitest;

import gir.io.Exec;
import gir.sys.SystemProperty;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Files;
import javax.annotation.Nonnull;
import org.testng.annotations.Test;
import static org.testng.Assert.*;

public class ApiDiffTest
{
  @Test
  public void compareApi()
    throws Exception
  {

    final boolean storeApiDiff = SystemProperty.get( "arez.api_test.store_api_diff" ).equals( "true" );
    final File reportFile = storeApiDiff ? getFixtureReport() : File.createTempFile( "apidiff", ".json" );
    try
    {
      generateReport( reportFile );
      final File fixture = getFixtureReport();
      if ( !fixture.exists() )
      {
        fail( "Unable to locate test fixture at " + fixture.getAbsolutePath() );
      }
      else
      {
        final byte[] reportData = Files.readAllBytes( reportFile.toPath() );
        final byte[] expectedData = Files.readAllBytes( fixture.toPath() );
        assertEquals( new String( reportData, Charset.forName( "UTF-8" ) ),
                      new String( expectedData, Charset.forName( "UTF-8" ) ) );
      }
    }
    finally
    {
      if ( !storeApiDiff )
      {
        assertTrue( !reportFile.exists() || reportFile.delete() );
      }
    }
  }

  private void generateReport( @Nonnull final File reportFile )
  {
    final String oldApiLabel = "org.realityforge.arez:arez-core:jar:" + SystemProperty.get( "arez.prev.version" );
    final String oldApi = oldApiLabel + "::" + SystemProperty.get( "arez.prev.jar" );
    final String newApiLabel = "org.realityforge.arez:arez-core:jar:" + SystemProperty.get( "arez.next.version" );
    final String newApi = newApiLabel + "::" + SystemProperty.get( "arez.next.jar" );
    Exec.system( "java",
                 "-jar",
                 SystemProperty.get( "arez.revapi.jar" ),
                 "--old-api",
                 oldApi,
                 "--new-api",
                 newApi,
                 "--output-file",
                 reportFile.toString() );
  }

  @Nonnull
  private File getFixtureReport()
  {
    return new File( SystemProperty.get( "arez.api_test.fixture_dir" ),
                     SystemProperty.get( "arez.prev.version" ) + "-" +
                     SystemProperty.get( "arez.next.version" ) + ".json" );
  }
}

{'fraction_non_alphanumeric': 0.13169446883230904, 'fraction_numerical': 0.0004389815627743635, 'mean_word_length': 2.388104089219331, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1456273', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1355, 'n_words': 283}