@@ -17,8 +17,13 @@ void userDto_getPasswordChars_returnsCharArray() {
1717 dto .setPassword ("TestP@ssw0rd" );
1818
1919 char [] passwordChars = dto .getPasswordChars ();
20- assertNotNull (passwordChars );
21- assertArrayEquals ("TestP@ssw0rd" .toCharArray (), passwordChars );
20+ char [] expected = "TestP@ssw0rd" .toCharArray ();
21+ try {
22+ assertNotNull (passwordChars );
23+ assertArrayEquals (expected , passwordChars );
24+ } finally {
25+ PasswordSecurityUtil .clearPassword (expected );
26+ }
2227 }
2328
2429 @ Test
@@ -73,8 +78,13 @@ void passwordDto_getOldPasswordChars_returnsCharArray() {
7378 dto .setOldPassword ("OldP@ssw0rd" );
7479
7580 char [] passwordChars = dto .getOldPasswordChars ();
76- assertNotNull (passwordChars );
77- assertArrayEquals ("OldP@ssw0rd" .toCharArray (), passwordChars );
81+ char [] expected = "OldP@ssw0rd" .toCharArray ();
82+ try {
83+ assertNotNull (passwordChars );
84+ assertArrayEquals (expected , passwordChars );
85+ } finally {
86+ PasswordSecurityUtil .clearPassword (expected );
87+ }
7888 }
7989
8090 @ Test
@@ -136,8 +146,13 @@ void savePasswordDto_getNewPasswordChars_returnsCharArray() {
136146 dto .setNewPassword ("NewP@ssw0rd" );
137147
138148 char [] passwordChars = dto .getNewPasswordChars ();
139- assertNotNull (passwordChars );
140- assertArrayEquals ("NewP@ssw0rd" .toCharArray (), passwordChars );
149+ char [] expected = "NewP@ssw0rd" .toCharArray ();
150+ try {
151+ assertNotNull (passwordChars );
152+ assertArrayEquals (expected , passwordChars );
153+ } finally {
154+ PasswordSecurityUtil .clearPassword (expected );
155+ }
141156 }
142157
143158 @ Test
0 commit comments