From 177e0538fc24ca7fc0abd0fbe7e8a65c4ed3b6b4 Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Thu, 17 Apr 2025 09:49:36 +0800 Subject: [PATCH] Add tests to ensure fetchSize is applied to Statement Signed-off-by: Yanming Zhou --- .../statement/BaseStatementHandlerTest.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/apache/ibatis/executor/statement/BaseStatementHandlerTest.java b/src/test/java/org/apache/ibatis/executor/statement/BaseStatementHandlerTest.java index 1a9b12c17d3..8f410229bca 100644 --- a/src/test/java/org/apache/ibatis/executor/statement/BaseStatementHandlerTest.java +++ b/src/test/java/org/apache/ibatis/executor/statement/BaseStatementHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2023 the original author or authors. + * Copyright 2009-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -155,4 +155,33 @@ void specifyQueryTimeoutAndTransactionTimeoutWithSameValue() throws SQLException verify(statement).setQueryTimeout(10); } + @Test + void specifyDefaultFetchSizeOnly() throws SQLException { + doReturn(50).when(configuration).getDefaultFetchSize(); + BaseStatementHandler handler = new SimpleStatementHandler(null, mappedStatementBuilder.build(), null, null, null, + null); + handler.setFetchSize(statement); + + verify(statement).setFetchSize(50); + } + + @Test + void specifyMappedStatementFetchSizeOnly() throws SQLException { + BaseStatementHandler handler = new SimpleStatementHandler(null, mappedStatementBuilder.fetchSize(10).build(), null, + null, null, null); + handler.setFetchSize(statement); + + verify(statement).setFetchSize(10); + } + + @Test + void specifyDefaultAndMappedStatementFetchSize() throws SQLException { + doReturn(50).when(configuration).getDefaultFetchSize(); + BaseStatementHandler handler = new SimpleStatementHandler(null, mappedStatementBuilder.fetchSize(10).build(), null, + null, null, null); + handler.setFetchSize(statement); + + verify(statement).setFetchSize(10); + } + }