test: enhance ExternalResourcesTest coverage with additional cases#3647
Open
lmj798 wants to merge 2 commits intomybatis:masterfrom
Open
test: enhance ExternalResourcesTest coverage with additional cases#3647lmj798 wants to merge 2 commits intomybatis:masterfrom
lmj798 wants to merge 2 commits intomybatis:masterfrom
Conversation
- Add shouldCopyFileContentCorrectly() - verify file content copying - Add shouldOverwriteExistingDestination() - verify destination overwrite - Add shouldCopyEmptyFile() - verify empty file copying - Add shouldCopyFileWithBinaryContent() - verify binary content copying - Add shouldThrowExceptionWhenSourceIsNull() - verify null source exception - Add shouldCopyFileWithSizeExactly4096Bytes() - verify 4096-byte boundary - Add shouldThrowExceptionWhenDestPathContainsNonExistentDirectory() - verify path validation
…ose and ThreadLocal cleanupadd new tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add 7 new test cases for ExternalResources.copyExternalResource() to enhance test coverage.
Add tests for file content correctness, destination overwrite, empty file copying, binary content, null source validation, 4096-byte boundary size, and non-existent directory path validation.
Update copyright year to 2026 in test file.
Why
Existing tests cover basic copy operations, file not found scenarios, and empty string paths, but lack explicit coverage for edge cases like empty files, binary content, and boundary conditions (e.g., 4096 bytes).
These boundary cases are prone to regression (for example, through buffer handling or I/O stream changes), so explicit tests improve behavioral stability and ensure robustness across different file types and sizes.
Verification
Ran mvn -Dtest=ExternalResourcesTest test
Result: all 11 tests passed