当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.difference方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.StringUtils.difference方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.difference方法的具体用法?Java StringUtils.difference怎么用?Java StringUtils.difference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.StringUtils的用法示例。


在下文中一共展示了StringUtils.difference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBinaryCompatibility

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public void testBinaryCompatibility()
{
  
  try
  {
    String golden = System.getProperty("trinidad.clirr.golden");
    String clirrRunResult = System.getProperty("trinidad.clirr.compare");

    String goldenFileContent = FileUtils.readFileToString(new File(golden));
    String clirrRunFileContent = FileUtils.readFileToString(new File(clirrRunResult));
    
    String binaryIssue = StringUtils.difference(goldenFileContent, clirrRunFileContent);
    
    if (binaryIssue.length() > 0)
    {
      fail("Check your binary compatibility! - See output in file: "  + clirrRunResult);
    }
  }
  catch (IOException e)
  {
    e.printStackTrace();
    fail(e.getMessage());
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:25,代码来源:ClirrRunnerTest.java

示例2: _throwAssertionFailure

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private void _throwAssertionFailure(String golden, String results, boolean forceGolden)
{
  if (golden == null)
  {
    // Don't report "no golden file" as an error when
    // forceGolden is on; but do report diffs as errors
    if (!forceGolden)
    {
      throw new AssertionFailedError("No golden file for test " +
                                     _scriptName);
    }
  } else
  {
    int index = StringUtils.indexOfDifference(golden, results);
    String difference = StringUtils.difference(golden, results);
    int diffLength = difference.length();
    if (diffLength > 50)
      difference = StringUtils.abbreviate(difference, 50);
    /*
    int resultsLength = results.length();
    int goldenLength = golden.length();
    
    if (resultsLength != goldenLength)
    {
      if (resultsLength < goldenLength)
      {
        throw new AssertionFailedError("golden file longer by:" + (goldenLength - resultsLength) + " char='" + ((int)golden.charAt(index)) + "'");
      }
      else
      {
        throw new AssertionFailedError("results file longer by:" + (resultsLength - goldenLength));            
      }
    }
    
    if (index >= resultsLength)
      throw new AssertionFailedError("golden file longer by:" + (goldenLength - resultsLength));
      
    if (results.length() < 50)
    {
      throw new AssertionFailedError(
           "Golden file for test "+ _scriptName + " did not match; " +
           "first difference at " + index + ", difference of length " +
           diffLength + ", \"" + difference + "\"" + "\ngolden:\n" + golden + "\nnew:\n" + results + "\ndiffChars g='" + golden.charAt(index) + "' r='" + results.charAt(index) + "'");
      
    }
    */
    throw new AssertionFailedError(
        "Golden file for test " + _scriptName + " did not match; " +
        "first difference at " + index + ", difference of length " +
        diffLength + ", \"" + difference + "\"");
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:53,代码来源:RenderKitTestCase.java


注:本文中的org.apache.commons.lang3.StringUtils.difference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。