本文整理汇总了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());
}
}
示例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 + "\"");
}
}