1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.dbcp2.datasources;
19
20 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
21
22 import java.sql.SQLException;
23
24 import javax.sql.PooledConnection;
25
26 import org.junit.jupiter.api.Test;
27
28
29
30
31 class PooledConnectionManagerTest {
32
33 static class Fixture implements PooledConnectionManager {
34
35 private char[] password;
36
37 @Override
38 public void closePool(final String userName) throws SQLException {
39
40 }
41
42 char[] getPassword() {
43 return password;
44 }
45
46 @Override
47 public void invalidate(final PooledConnection pc) throws SQLException {
48
49 }
50
51 @Override
52 public void setPassword(final String password) {
53 this.password = password.toCharArray();
54 }
55 }
56
57 @Test
58 void testSetPasswordCharArray() {
59 final Fixture fixture = new Fixture();
60 fixture.setPassword("p".toCharArray());
61 assertArrayEquals("p".toCharArray(), fixture.getPassword());
62 }
63
64 @Test
65 void testSetPasswordString() {
66 final Fixture fixture = new Fixture();
67 fixture.setPassword("p");
68 assertArrayEquals("p".toCharArray(), fixture.getPassword());
69 }
70 }