-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Migrate integration tests to NIO2 Path API #11364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
gnodet
wants to merge
8
commits into
apache:master
Choose a base branch
from
gnodet:feature/nio2-integration-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
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
This commit migrates the Maven integration test infrastructure from java.io.File to NIO2 Path API while maintaining full backward compatibility. Changes in Verifier class: - Added Path-based overloads for loadProperties(), loadFile(), filterFile() - Migrated file operations to use Files.* methods instead of FileUtils - Replaced FileUtils.deleteDirectory() with custom NIO2 implementation - Updated file verification methods to use Path and DirectoryStream - Removed dependency on org.codehaus.plexus.util.FileUtils Changes in AbstractMavenIntegrationTestCase class: - Added extractResourcesAsPath() method returning Path instead of File - Updated settings file handling to use Path operations Benefits: - Better performance with NIO2 operations - Improved error handling and cross-platform compatibility - Modern API usage while maintaining backward compatibility - Comprehensive test coverage for new functionality All existing integration tests continue to work without modification. New @SInCE 4.0.0 methods provide Path-based alternatives for modern usage.
This commit migrates all Maven integration tests from File-based operations to the new NIO2 Path-based methods introduced in the previous commit. Changes made: - Replaced extractResources() with extractResourcesAsPath() in 704 test files - Updated File variable declarations to Path where appropriate - Replaced new File(dir, subpath) with dir.resolve(subpath) patterns - Updated .getAbsolutePath() calls to .toString() for Path variables - Fixed extractResources().toPath() patterns to use extractResourcesAsPath() Migration statistics: - 704 integration test files successfully migrated - All tests compile successfully with new Path-based API - Maintains full backward compatibility for any remaining File usage The migration was performed using an automated script (migrate-its-to-nio2.py) that identified and transformed common File-to-Path patterns while preserving the original test logic and functionality. Benefits: - Modern NIO2 API usage throughout integration test suite - Better performance with Path operations - Improved cross-platform file handling - Consistent API usage across all integration tests
This test verifies that all the common patterns used in integration tests work correctly with the new NIO2 Path-based API: - extractResourcesAsPath() method functionality - Path.resolve() operations for subdirectories and files - Path.toString() for verifier creation - Backward compatibility with File-based extractResources() - Complex path operations and parent-child relationships All tests pass, confirming the NIO2 migration is working correctly.
The migrate-its-to-nio2.py script has served its purpose and is no longer needed. All integration tests have been successfully migrated to use the new NIO2 Path-based methods.
After successfully migrating all 704 integration tests to use the new Path-based extractResourcesAsPath() method, the old File-based method is no longer needed and has been removed. Changes: - Removed extractResources() method from AbstractMavenIntegrationTestCase - Updated tests to verify Path-to-File conversion instead of backward compatibility - All integration tests compile successfully without the deprecated method - All unit tests pass This completes the full migration to NIO2 Path API for integration tests. The codebase now exclusively uses modern Path-based operations, providing better performance, improved cross-platform compatibility, and cleaner code.
The loadFile(File, boolean) method is no longer needed as all callers have been migrated to use the Path-based loadFile(Path, boolean) method or the String-based convenience method. This further reduces the File API surface in the integration test infrastructure, completing the migration to NIO2 Path API.
The File import is no longer needed after removing the extractResources() method. The class now exclusively uses Path for file operations. All integration tests compile and run successfully.
This commit completes the NIO2 migration by: 1. Removing all File-based filterFile() methods from Verifier class 2. Making Path-based filterFile() methods return Path instead of File 3. Renaming extractResourcesAsPath() back to extractResources() in AbstractMavenIntegrationTestCase 4. Updating all 687 integration test files to use the renamed extractResources() method The integration test infrastructure now uses NIO2 Path API as the primary API: - extractResources() returns Path (was File) - filterFile() methods return Path (were File) - All File-based wrapper methods have been removed This provides a clean, modern API surface while maintaining the familiar method names. All integration tests compile and run successfully with the new Path-based API.
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
This PR completes the migration of Maven Integration Tests from
java.io.Fileto NIO2PathAPI, making Path-based methods the primary API while maintaining familiar method names.Changes Made
Infrastructure Migration
Migrated
Verifierclass to NIO2:loadProperties(),loadFile(),filterFile()FileUtilsoperations with native NIO2 methods (Files.walk(),Files.copy(), etc.)deleteDirectoryRecursively()usingFiles.walk()PathandDirectoryStreamorg.codehaus.plexus.util.FileUtilsMigrated
AbstractMavenIntegrationTestCaseclass:extractResources()to returnPathinstead ofFileFileimportMade Path-based methods primary API:
extractResources()now returnsPath(wasFile)filterFile()methods now returnPath(wereFile)Integration Tests Migration
extractResources()returningPathFiletoPathwhere appropriatenew File(dir, subpath)patterns todir.resolve(subpath).getAbsolutePath()calls to.toString()for Path variablesTesting
VerifierNIO2Test) for new NIO2 functionalityNIO2MigrationVerificationTestto verify common integration test patternsBenefits
Migration Statistics
API Changes
Before (File-based)
After (Path-based)
Backward Compatibility
While the return types have changed from
FiletoPath, the migration is straightforward:Pathcan be converted toFileusing.toFile()if needed for legacy APIsFilecan be converted toPathusing.toPath()Commits
Testing Instructions
To verify the changes:
All compilation and tests should pass successfully.
Pull Request opened by Augment Code with guidance from the PR author