Skip to content

Commit 177e053

Browse files
committed
Add tests to ensure fetchSize is applied to Statement
Signed-off-by: Yanming Zhou <[email protected]>
1 parent 5f8927d commit 177e053

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

Diff for: src/test/java/org/apache/ibatis/executor/statement/BaseStatementHandlerTest.java

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2023 the original author or authors.
2+
* Copyright 2009-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -155,4 +155,33 @@ void specifyQueryTimeoutAndTransactionTimeoutWithSameValue() throws SQLException
155155
verify(statement).setQueryTimeout(10);
156156
}
157157

158+
@Test
159+
void specifyDefaultFetchSizeOnly() throws SQLException {
160+
doReturn(50).when(configuration).getDefaultFetchSize();
161+
BaseStatementHandler handler = new SimpleStatementHandler(null, mappedStatementBuilder.build(), null, null, null,
162+
null);
163+
handler.setFetchSize(statement);
164+
165+
verify(statement).setFetchSize(50);
166+
}
167+
168+
@Test
169+
void specifyMappedStatementFetchSizeOnly() throws SQLException {
170+
BaseStatementHandler handler = new SimpleStatementHandler(null, mappedStatementBuilder.fetchSize(10).build(), null,
171+
null, null, null);
172+
handler.setFetchSize(statement);
173+
174+
verify(statement).setFetchSize(10);
175+
}
176+
177+
@Test
178+
void specifyDefaultAndMappedStatementFetchSize() throws SQLException {
179+
doReturn(50).when(configuration).getDefaultFetchSize();
180+
BaseStatementHandler handler = new SimpleStatementHandler(null, mappedStatementBuilder.fetchSize(10).build(), null,
181+
null, null, null);
182+
handler.setFetchSize(statement);
183+
184+
verify(statement).setFetchSize(10);
185+
}
186+
158187
}

0 commit comments

Comments
 (0)