1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.type;
17
18 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
19 import static org.mockito.Mockito.never;
20 import static org.mockito.Mockito.verify;
21 import static org.mockito.Mockito.when;
22
23 import org.junit.jupiter.api.Test;
24
25 class ByteArrayTypeHandlerTest extends BaseTypeHandlerTest {
26
27 private static final TypeHandler<byte[]> TYPE_HANDLER = new ByteArrayTypeHandler();
28
29 @Override
30 @Test
31 public void shouldSetParameter() throws Exception {
32 TYPE_HANDLER.setParameter(ps, 1, new byte[] { 1, 2, 3 }, null);
33 verify(ps).setBytes(1, new byte[] { 1, 2, 3 });
34 }
35
36 @Override
37 @Test
38 public void shouldGetResultFromResultSetByName() throws Exception {
39 when(rs.getBytes("column")).thenReturn(new byte[] { 1, 2, 3 });
40 assertArrayEquals(new byte[] { 1, 2, 3 }, TYPE_HANDLER.getResult(rs, "column"));
41 verify(rs, never()).wasNull();
42 }
43
44 @Override
45 public void shouldGetResultNullFromResultSetByName() throws Exception {
46
47 }
48
49 @Override
50 @Test
51 public void shouldGetResultFromResultSetByPosition() throws Exception {
52 when(rs.getBytes(1)).thenReturn(new byte[] { 1, 2, 3 });
53 assertArrayEquals(new byte[] { 1, 2, 3 }, TYPE_HANDLER.getResult(rs, 1));
54 verify(rs, never()).wasNull();
55 }
56
57 @Override
58 public void shouldGetResultNullFromResultSetByPosition() throws Exception {
59
60 }
61
62 @Override
63 @Test
64 public void shouldGetResultFromCallableStatement() throws Exception {
65 when(cs.getBytes(1)).thenReturn(new byte[] { 1, 2, 3 });
66 assertArrayEquals(new byte[] { 1, 2, 3 }, TYPE_HANDLER.getResult(cs, 1));
67 verify(cs, never()).wasNull();
68 }
69
70 @Override
71 public void shouldGetResultNullFromCallableStatement() throws Exception {
72
73 }
74
75 }