Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
3e88c366
Commit
3e88c366
authored
Jan 19, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Avoid property name collisions when serializing AuditEvent to JSON"
See gh-7990
parent
fcf36ed0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
AuditEvent.java
...va/org/springframework/boot/actuate/audit/AuditEvent.java
+1
-1
AuditEventTests.java
...g/springframework/boot/actuate/audit/AuditEventTests.java
+8
-5
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java
View file @
3e88c366
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/audit/AuditEventTests.java
View file @
3e88c366
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -79,12 +79,15 @@ public class AuditEventTests {
...
@@ -79,12 +79,15 @@ public class AuditEventTests {
@Test
@Test
public
void
jsonFormat
()
throws
Exception
{
public
void
jsonFormat
()
throws
Exception
{
AuditEvent
event
=
new
AuditEvent
(
"johannes"
,
"UNKNOWN"
,
Collections
.
singletonMap
(
"type"
,
(
Object
)
"BadCredentials"
));
AuditEvent
event
=
new
AuditEvent
(
"johannes"
,
"UNKNOWN"
,
Collections
.
singletonMap
(
"type"
,
(
Object
)
"BadCredentials"
));
String
json
=
Jackson2ObjectMapperBuilder
.
json
().
build
().
writeValueAsString
(
event
);
String
json
=
Jackson2ObjectMapperBuilder
.
json
().
build
()
.
writeValueAsString
(
event
);
System
.
out
.
println
(
json
);
JSONObject
jsonObject
=
new
JSONObject
(
json
);
JSONObject
jsonObject
=
new
JSONObject
(
json
);
assertThat
(
jsonObject
.
getString
(
"type"
)).
isEqualTo
(
"UNKNOWN"
);
assertThat
(
jsonObject
.
getString
(
"type"
)).
isEqualTo
(
"UNKNOWN"
);
assertThat
(
jsonObject
.
getJSONObject
(
"data"
).
getString
(
"type"
))
.
isEqualTo
(
"BadCredentials"
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment