本文整理汇总了Java中org.skyscreamer.jsonassert.JSONAssert.assertEquals方法的典型用法代码示例。如果您正苦于以下问题:Java JSONAssert.assertEquals方法的具体用法?Java JSONAssert.assertEquals怎么用?Java JSONAssert.assertEquals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.skyscreamer.jsonassert.JSONAssert
的用法示例。
在下文中一共展示了JSONAssert.assertEquals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldFetchAccessToken
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test
public void shouldFetchAccessToken() throws Exception {
final TokenInfo tokenInfo = new TokenInfo("31239032-xycs.xddasdasdasda", 7200, "foo-type", "refresh-xysaddasdjlascdas");
when(request.authConfigs()).thenReturn(Collections.singletonList(authConfig));
when(request.requestParameters()).thenReturn(Collections.singletonMap("code", "code-received-in-previous-step"));
when(googleApiClient.fetchAccessToken(request.requestParameters())).thenReturn(tokenInfo);
final GoPluginApiResponse response = executor.execute();
final String expectedJSON = "{\n" +
" \"access_token\": \"31239032-xycs.xddasdasdasda\",\n" +
" \"expires_in\": 7200,\n" +
" \"token_type\": \"foo-type\",\n" +
" \"refresh_token\": \"refresh-xysaddasdjlascdas\"\n" +
"}";
assertThat(response.responseCode(), is(200));
JSONAssert.assertEquals(expectedJSON, response.responseBody(), true);
}
开发者ID:gocd-contrib,项目名称:google-oauth-authorization-plugin,代码行数:22,代码来源:FetchAccessTokenRequestExecutorTest.java
示例2: shouldValidateABadConfiguration
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test
public void shouldValidateABadConfiguration() throws Exception {
ValidatePluginSettings settings = new ValidatePluginSettings();
GoPluginApiResponse response = new ValidateConfigurationExecutor(settings, pluginRequest).execute();
assertThat(response.responseCode(), is(200));
JSONAssert.assertEquals("[\n" +
" {\n" +
" \"message\": \"Agent auto-register Timeout (in minutes) must be a positive integer.\",\n" +
" \"key\": \"auto_register_timeout\"\n" +
" },\n" +
" {\n" +
" \"message\": \"Maximum Pending Kuberneted Pods Count must be a positive integer.\",\n" +
" \"key\": \"pending_pods_count\"\n" +
" },\n" +
" {\n" +
" \"message\": \"Kubernetes Cluster URL must not be blank.\",\n" +
" \"key\": \"kubernetes_cluster_url\"\n" +
" }\n" +
"]", response.responseBody(), true);
}
示例3: serialize_GivesEmptyResult_WhenQueryIsEmpty
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test
public void serialize_GivesEmptyResult_WhenQueryIsEmpty() throws IOException, JSONException {
// Arrange
JsonFactory factory = new JsonFactory();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
JsonGenerator jsonGenerator = factory.createGenerator(outputStream);
when(tupleQueryResult.hasNext()).thenReturn(false);
// Act
jsonSerializer.serialize(tupleQueryResult, jsonGenerator, null);
// Assert
jsonGenerator.close();
String result = outputStream.toString();
JSONAssert.assertEquals("[]", result, true);
}
示例4: shouldValidateGoServerUrlFormat
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test
public void shouldValidateGoServerUrlFormat() throws Exception {
ValidatePluginSettings settings = new ValidatePluginSettings();
settings.put("go_server_url", "https://foo.com");
settings.put("kubernetes_cluster_url", "https://cluster.example.com");
settings.put("auto_register_timeout", "10");
settings.put("pending_pods_count", "10");
GoPluginApiResponse response = new ValidateConfigurationExecutor(settings, pluginRequest).execute();
assertThat(response.responseCode(), is(200));
JSONAssert.assertEquals("[" +
" {\n" +
" \"message\": \"Go Server URL must be in format https://<GO_SERVER_URL>:<GO_SERVER_PORT>/go.\",\n" +
" \"key\": \"go_server_url\"\n" +
" }\n" +
"]", response.responseBody(), true);
}
示例5: testGetFlowVersions
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test
public void testGetFlowVersions() throws Exception {
// Given: a bucket "1" with flow "1" with existing snapshots has been populated in the DB (see FlowsIT.sql)
final String prePopulatedBucketId = "1";
final String prePopulatedFlowId = "1";
// For this test case, the order of the expected list matters as we are asserting a strict equality check
final String expected = "[" +
"{\"bucketIdentifier\":\"1\"," +
"\"flowIdentifier\":\"1\"," +
"\"version\":2," +
"\"timestamp\":1505091480000," +
"\"author\" : \"user2\"," +
"\"comments\":\"This is flow 1 snapshot 2\"," +
"\"link\":{\"params\":{\"rel\":\"content\"},\"href\":\"buckets/1/flows/1/versions/2\"}}," +
"{\"bucketIdentifier\":\"1\"," +
"\"flowIdentifier\":\"1\"," +
"\"version\":1," +
"\"timestamp\":1505091420000," +
"\"author\" : \"user1\"," +
"\"comments\":\"This is flow 1 snapshot 1\"," +
"\"link\":{\"params\":{\"rel\":\"content\"},\"href\":\"buckets/1/flows/1/versions/1\"}}" +
"]";
// When: the /buckets/{id}/flows/{id}/versions endpoint is queried
final String flowSnapshotsJson = client
.target(createURL("buckets/{bucketId}/flows/{flowId}/versions"))
.resolveTemplate("bucketId", prePopulatedBucketId)
.resolveTemplate("flowId", prePopulatedFlowId)
.request()
.get(String.class);
// Then: the pre-populated list of flow versions is returned, in descending order
JSONAssert.assertEquals(expected, flowSnapshotsJson, true);
}
示例6: testUserGroups
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test
public void testUserGroups() throws Exception {
// Given: the client and server have been configured correctly for LDAP authentication
String expectedJson = "[" +
"{" +
"\"identity\":\"chemists\"," +
"\"users\":[{\"identity\":\"pasteur\"},{\"identity\":\"boyle\"},{\"identity\":\"curie\"},{\"identity\":\"nobel\"}]," +
"\"accessPolicies\":[]," +
"\"configurable\":false" +
"}," +
"{" +
"\"identity\":\"mathematicians\"," +
"\"users\":[{\"identity\":\"gauss\"},{\"identity\":\"euclid\"},{\"identity\":\"riemann\"},{\"identity\":\"euler\"}]," +
"\"accessPolicies\":[]," +
"\"configurable\":false" +
"}," +
"{" +
"\"identity\":\"scientists\"," +
"\"users\":[{\"identity\":\"einstein\"},{\"identity\":\"tesla\"},{\"identity\":\"newton\"},{\"identity\":\"galileo\"}]," +
"\"accessPolicies\":[]," +
"\"configurable\":false" +
"}," +
"{" +
"\"identity\":\"italians\"," +
"\"users\":[{\"identity\":\"galileo\"}]," +
"\"accessPolicies\":[]," +
"\"configurable\":false" +
"}]";
// When: the /tenants/users endpoint is queried
final String groupsJson = client
.target(createURL("tenants/user-groups"))
.request()
.header("Authorization", "Bearer " + adminAuthToken)
.get(String.class);
// Then: the server returns a list of all users (see test-ldap-data.ldif)
JSONAssert.assertEquals(expectedJson, groupsJson, false);
}
示例7: shouldSerializeToJSON
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test
public void shouldSerializeToJSON() throws Exception {
final User user = new User("foo", "bar", "baz");
final String expectedJSON = "{\"username\":\"foo\",\"display_name\":\"bar\",\"email\":\"baz\"}";
JSONAssert.assertEquals(expectedJSON, GSON.toJson(user), true);
}
示例8: shouldAuthorizeUser
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test
public void shouldAuthorizeUser() throws Exception {
final TokenInfo tokenInfo = new TokenInfo("access-token", "token-type", "user:email,org:read");
final LoggedInUserInfo loggedInUserInfo = mock(LoggedInUserInfo.class);
final User user = new User("bford", "Bob", "[email protected]");
final Role role = mock(Role.class);
when(loggedInUserInfo.getUser()).thenReturn(user);
when(request.authConfigs()).thenReturn(Collections.singletonList(authConfig));
when(request.roles()).thenReturn(Collections.singletonList(role));
when(request.tokenInfo()).thenReturn(tokenInfo);
when(authenticator.authenticate(tokenInfo, authConfig)).thenReturn(loggedInUserInfo);
when(authorizer.authorize(loggedInUserInfo, authConfig, request.roles())).thenReturn(Collections.singletonList("admin"));
final GoPluginApiResponse response = executor.execute();
String expectedJSON = "{\n" +
" \"roles\": [\"admin\"],\n" +
" \"user\": {\n" +
" \"username\": \"bford\",\n" +
" \"display_name\": \"Bob\",\n" +
" \"email\": \"[email protected]\"\n" +
" }\n" +
"}";
assertThat(response.responseCode(), is(200));
JSONAssert.assertEquals(expectedJSON, response.responseBody(), true);
}
开发者ID:gocd-contrib,项目名称:github-oauth-authorization-plugin,代码行数:29,代码来源:UserAuthenticationRequestExecutorTest.java
示例9: canStoreAndLoadEntitiesWithIdGeneratorAndAssociation
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test
public void canStoreAndLoadEntitiesWithIdGeneratorAndAssociation() throws JSONException {
OgmSession session = openSession();
session.getTransaction().begin();
// given
Plant ficus = new Plant( 181 );
session.persist( ficus );
Family family = new Family( "family-1", "Moraceae", ficus );
session.persist( family );
session.getTransaction().commit();
// when
String familyRepresentation = getConnection().get( "Family:family-1" );
String plantRepresentation = getConnection().get( "Plant:1" );
// then
JSONAssert.assertEquals(
"{\"members\":[1],\"name\":\"Moraceae\"}",
familyRepresentation,
JSONCompareMode.STRICT
);
JSONAssert.assertEquals(
"{\"height\":181}",
plantRepresentation,
JSONCompareMode.STRICT
);
session.close();
}
示例10: retrieveTodo
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test
public void retrieveTodo() throws Exception {
String expected = "{id:1,user:Jack,desc:\"Learn Spring MVC\",done:false}";
ResponseEntity<String> response = template.getForEntity(createUrl("/users/Jack/todos/1"), String.class);
JSONAssert.assertEquals(expected, response.getBody(), false);
}
示例11: shouldListUniqueUsersMatchingTheSearchTermAcrossMultiplePasswordFiles
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test
public void shouldListUniqueUsersMatchingTheSearchTermAcrossMultiplePasswordFiles() throws Exception {
final GoPluginApiRequest request = mock(GoPluginApiRequest.class);
mockPasswordFileWith("/var/etc/password_1.properties", "myname");
mockPasswordFileWith("/var/etc/password_2.properties", "yournamed", "bar", "myname");
mockPasswordFileWith("/var/etc/password_3.properties", "nameless", "foo");
when(request.requestBody()).thenReturn(requestJsonWithMultipleAuthConfig("name"));
final GoPluginApiResponse response = new SearchUserExecutor(request, fileReader).execute();
assertThat(response.responseCode(), is(200));
final String expectedResponseBody = "[\n" +
" {\n" +
" \"username\": \"myname\"\n" +
" },\n" +
" {\n" +
" \"username\": \"yournamed\"\n" +
" },\n" +
" {\n" +
" \"username\": \"nameless\"\n" +
" }\n" +
"]";
JSONAssert.assertEquals(expectedResponseBody, response.responseBody(), true);
}
示例12: shouldSupportWebAuthenticationCapabilities
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test
public void shouldSupportWebAuthenticationCapabilities() throws Exception {
GoPluginApiResponse response = new GetCapabilitiesRequestExecutor().execute();
String expectedJSON = "{\n" +
" \"supported_auth_type\":\"web\",\n" +
" \"can_authorize\":true,\n" +
" \"can_search\":false\n" +
"}";
JSONAssert.assertEquals(expectedJSON, response.responseBody(), true);
}
开发者ID:gocd-contrib,项目名称:github-oauth-authorization-plugin,代码行数:13,代码来源:GetCapabilitiesRequestExecutorTest.java
示例13: shouldWriteConfigAndEnvInfo
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test public void shouldWriteConfigAndEnvInfo() throws IOException, JSONException {
writer.begin();
writer.end();
String writtenJson = trimAppMemDetails(extractWrittenString(outputStream));
JSONAssert.assertEquals(emptyJson.content, writtenJson, true);
}
示例14: assertJsonStructure
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test
public void assertJsonStructure() throws Exception {
GoPluginApiResponse response = new GetPluginConfigurationExecutor().execute();
assertThat(response.responseCode(), is(200));
String expectedJSON = "{\n" +
" \"go_server_url\": {\n" +
" \"display-name\": \"Go Server URL\",\n" +
" \"required\": false,\n" +
" \"secure\": false,\n" +
" \"display-order\": \"0\"\n" +
" },\n" +
" \"auto_register_timeout\": {\n" +
" \"display-name\": \"Agent auto-register Timeout (in minutes)\",\n" +
" \"default-value\": \"10\",\n" +
" \"required\": true,\n" +
" \"secure\": false,\n" +
" \"display-order\": \"1\"\n" +
" },\n" +
" \"pending_pods_count\": {\n" +
" \"display-name\": \"Maximum Pending Kuberneted Pods Count\",\n" +
" \"default-value\": \"10\",\n" +
" \"required\": true,\n" +
" \"secure\": false,\n" +
" \"display-order\": \"2\"\n" +
" },\n" +
" \"kubernetes_cluster_url\": {\n" +
" \"display-name\": \"Kubernetes Cluster URL\",\n" +
" \"required\": true,\n" +
" \"secure\": false,\n" +
" \"display-order\": \"3\"\n" +
" },\n" +
" \"kubernetes_cluster_username\": {\n" +
" \"display-name\": \"Kubernetes Cluster Username\",\n" +
" \"required\": false,\n" +
" \"secure\": false,\n" +
" \"display-order\": \"4\"\n" +
" },\n" +
" \"kubernetes_cluster_password\": {\n" +
" \"display-name\": \"Kubernetes Cluster Password\",\n" +
" \"required\": false,\n" +
" \"secure\": true,\n" +
" \"display-order\": \"5\"\n" +
" },\n" +
" \"kubernetes_cluster_ca_cert\": {\n" +
" \"display-name\": \"Kubernetes Cluster CA Certificate\",\n" +
" \"required\": false,\n" +
" \"secure\": true,\n" +
" \"display-order\": \"6\"\n" +
" }\n" +
"}";
JSONAssert.assertEquals(expectedJSON, response.responseBody(), true);
}
示例15: test_model2jsonErr
import org.skyscreamer.jsonassert.JSONAssert; //导入方法依赖的package包/类
@Test
public void test_model2jsonErr() throws Exception {
Message.Err errMsg = new Message.Err(Message.Err.Type.CONNECTION_TERMINATED, "Something went wrong");
JSONAssert.assertEquals(errMsg.toJson().toString(), "{\"err\": {\"evt-id\": \""+errMsg.getEventId()+"\", \"err-type\": \"connection-terminated\", " +
"\"err-msg\":\"Something went wrong\"}}", false);
}