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


Java JSONCompare.compareJSON方法代码示例

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


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

示例1: logInconsistencyUsingJSONCompare

import org.skyscreamer.jsonassert.JSONCompare; //导入方法依赖的package包/类
private void logInconsistencyUsingJSONCompare(final String parentThreadName, final String legacyJson, final String lightblueJson, final MethodCallStringifier callToLogInCaseOfInconsistency) {
    try {
        Timer t = new Timer("ConsistencyCheck (JSONCompare)");

        JSONCompareResult result = JSONCompare.compareJSON(legacyJson, lightblueJson, JSONCompareMode.NON_EXTENSIBLE);

        long jiffConsistencyCheckTook = t.complete();

        if (inconsistencyLog.isDebugEnabled()) {
            inconsistencyLog.debug(String.format("[%s] JSONCompare consistency check took: %dms", parentThreadName, jiffConsistencyCheckTook));
            inconsistencyLog.debug(String.format("[%s] JSONCompare consistency check passed: true", parentThreadName));
        }

        if (result.passed()) {
            inconsistencyLog.error(String.format("[%s] Jiff consistency check found an inconsistency but JSONCompare didn't! Happened in %s", parentThreadName, callToLogInCaseOfInconsistency.toString()));
            return;
        }

        // log nice diff
        logInconsistency(parentThreadName, callToLogInCaseOfInconsistency.toString(), legacyJson, lightblueJson, result.getMessage().replaceAll("\n", ","));
    } catch (Exception e) {
        inconsistencyLog.error("JSONCompare consistency check failed for " + callToLogInCaseOfInconsistency, e);
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-migrator,代码行数:25,代码来源:ConsistencyChecker.java

示例2: isDifferenceInDefinition

import org.skyscreamer.jsonassert.JSONCompare; //导入方法依赖的package包/类
private boolean isDifferenceInDefinition(String currentIndex, String definition){
		
	try {
		JSONCompareResult result = JSONCompare.compareJSON(definition, currentIndex, JSONCompareMode.STRICT);
		return result.passed();
		
	} catch (JSONException ex){
		logger.error("Failed while checking indexes", ex);
	}
	
	return false;
}
 
开发者ID:wesley-ramos,项目名称:spring-multitenancy,代码行数:13,代码来源:MongoPersistentEntityIndexCreator.java

示例3: compare

import org.skyscreamer.jsonassert.JSONCompare; //导入方法依赖的package包/类
private JSONCompareResult compare(CharSequence expectedJson,
		JSONCompareMode compareMode) {
	if (this.actual == null) {
		return compareForNull(expectedJson);
	}
	return JSONCompare.compareJSON(
			(expectedJson == null ? null : expectedJson.toString()),
			this.actual.toString(), compareMode);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:JsonContentAssert.java

示例4: compareJSON

import org.skyscreamer.jsonassert.JSONCompare; //导入方法依赖的package包/类
public static JSONCompareResult compareJSON(String expectedStr, String actualStr, JSONComparator comparator){
    try {
        return JSONCompare.compareJSON(expectedStr, actualStr, comparator);
    } catch (JSONException ex) {
        throw new IllegalStateException(ex);
    }
}
 
开发者ID:uaihebert,项目名称:uaiMockServer,代码行数:8,代码来源:UaiJSONCompareWrapper.java

示例5: should

import org.skyscreamer.jsonassert.JSONCompare; //导入方法依赖的package包/类
@Then("^the json response's body should (contain|be):$")
public void then_response_json_body_should_satisfy(String comparator, String expectedText) throws JSONException {
    HttpResponse response = httpWorld.lastResponse();
    String actual = response.bodyAsText();

    JSONCompareMode mode = JSONCompareMode.LENIENT;
    if (comparator.equals("be"))
        mode = JSONCompareMode.NON_EXTENSIBLE;

    JSONCompare.compareJSON(expectedText, actual, mode);
}
 
开发者ID:Arnauld,项目名称:bidij,代码行数:12,代码来源:RawHttpStepdefs.java

示例6: test

import org.skyscreamer.jsonassert.JSONCompare; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    String s1 = "{ \"f1\":1, \"obj\":{ \"f2\":2}, \"arr\":[ {\"f4\":3 } ] }";
    String s2 = "{ \"f1\":2, \"obj\":{ \"f2\":3 }, \"arr\":[ {\"f4\":4 } ] }";
    JSONCompareResult result = JSONCompare.compareJSON(s1, s2,
            JSONCompareMode.STRICT);
    for (FieldComparisonFailure x : result.getFieldFailures()) {
        System.out.println(x.getField() + " " + x.getExpected() + " " + x.getActual());
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-migrator,代码行数:11,代码来源:JsTest.java

示例7: matchesSafely

import org.skyscreamer.jsonassert.JSONCompare; //导入方法依赖的package包/类
@Override
protected boolean matchesSafely(JSONIterator actual, Description mismatchDescription)
{
    int line = 1;

    Iterator<String> itLeft = expected;
    Iterator<String> itRight = actual;

    while (true) {
        boolean hasLeft = itLeft.hasNext();
        boolean hasRight = itRight.hasNext();

        if (hasLeft && hasRight) {
            String left = itLeft.next();
            String right = itRight.next();

            try {
                JSONCompareResult r = JSONCompare.compareJSON(left, right, JSONCompareMode.STRICT);
                if (r.failed()) {
                    mismatchDescription.appendText("at line " + line + ": ");
                    mismatchDescription.appendText(r.getMessage());
                    return false;
                }
            }
            catch (JSONException e) {
                mismatchDescription.appendText("at line " + line + ": ");
                mismatchDescription.appendText(e.toString());
                throw new AssertionError(e);
            }
        }
        else if (!hasLeft && !hasRight) {
            return true;
        }
        else {
            // left or right has extra line
            mismatchDescription.appendText("at line " + line + ": ");
            if (hasLeft) {
                mismatchDescription.appendText("expected has extra lines");
            }
            else {
                mismatchDescription.appendText("actual has extra lines");
            }
            return false;
        }

        line += 1;
    }
}
 
开发者ID:CyberAgent,项目名称:embulk-input-parquet_hadoop,代码行数:49,代码来源:JSONIteratorMatcher.java


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