20
20
import io .r2dbc .postgresql .codec .MockCodecs ;
21
21
import io .r2dbc .postgresql .message .backend .DataRow ;
22
22
import io .r2dbc .postgresql .message .backend .RowDescription ;
23
+ import io .r2dbc .postgresql .util .ReferenceCountedCleaner ;
24
+ import org .junit .jupiter .api .AfterEach ;
23
25
import org .junit .jupiter .api .Test ;
24
26
25
27
import java .util .Arrays ;
41
43
*/
42
44
final class PostgresqlRowUnitTests {
43
45
46
+ private final ReferenceCountedCleaner cleaner = new ReferenceCountedCleaner ();
47
+
44
48
private final List <RowDescription .Field > columns = Arrays .asList (
45
49
new RowDescription .Field ((short ) 100 , 200 , 300 , (short ) 400 , FORMAT_BINARY , "test-name-1" , 500 ),
46
50
new RowDescription .Field ((short ) 300 , 400 , 300 , (short ) 400 , FORMAT_TEXT , "test-name-2" , 500 ),
@@ -49,6 +53,11 @@ final class PostgresqlRowUnitTests {
49
53
50
54
private final ByteBuf [] data = new ByteBuf []{TEST .buffer (4 ).writeInt (100 ), TEST .buffer (4 ).writeInt (300 ), null };
51
55
56
+ @ AfterEach
57
+ void tearDown () {
58
+ cleaner .clean ();
59
+ }
60
+
52
61
@ Test
53
62
void constructorNoContext () {
54
63
assertThatIllegalArgumentException ().isThrownBy (() -> new PostgresqlRow (null , null , Collections .emptyList (), null ))
@@ -156,7 +165,7 @@ void toRow() {
156
165
.build ();
157
166
158
167
RowDescription description = new RowDescription (Collections .singletonList (new RowDescription .Field ((short ) 200 , 300 , (short ) 400 , (short ) 500 , FORMAT_TEXT , "test-name-1" , 600 )));
159
- PostgresqlRow row = PostgresqlRow .toRow (MockContext .builder ().codecs (codecs ).build (), new DataRow (TEST .buffer (4 ).writeInt (100 )),
168
+ PostgresqlRow row = PostgresqlRow .toRow (MockContext .builder ().codecs (codecs ).build (), cleaner . capture ( new DataRow (TEST .buffer (4 ).writeInt (100 ) )),
160
169
codecs , description );
161
170
162
171
assertThat (row .get (0 , Object .class )).isSameAs (value );
@@ -170,7 +179,7 @@ void toRowNoDataRow() {
170
179
171
180
@ Test
172
181
void toRowNoRowDescription () {
173
- assertThatIllegalArgumentException ().isThrownBy (() -> PostgresqlRow .toRow (MockContext .empty (), new DataRow (TEST .buffer (4 ).writeInt (100 )), MockCodecs .empty (), null ))
182
+ assertThatIllegalArgumentException ().isThrownBy (() -> PostgresqlRow .toRow (MockContext .empty (), cleaner . capture ( new DataRow (TEST .buffer (4 ).writeInt (100 ) )), MockCodecs .empty (), null ))
174
183
.withMessage ("rowDescription must not be null" );
175
184
}
176
185
0 commit comments