Skip to content

Create TestFileUtils.getMD5Hash to compare binary files#2547

Merged
labkey-tchad merged 1 commit intorelease25.7-SNAPSHOTfrom
25.7_fb_binaryFileComparison
Jul 9, 2025
Merged

Create TestFileUtils.getMD5Hash to compare binary files#2547
labkey-tchad merged 1 commit intorelease25.7-SNAPSHOTfrom
25.7_fb_binaryFileComparison

Conversation

@labkey-tchad
Copy link
Member

Rationale

IntelliJ recommended using Files.readString instead of Files.readAllBytes. However, Files.readString is more strict about the file structure. FileAttachmentColumnTest is failing because it is using TestFileUtils.getFileContents for various non-text files (e.g. zip and pdf). This strictness is useful for most scenarios, so I've created a new method to compare whether two files are equal (TestFileUtils.getMD5Hash).

java.lang.RuntimeException: java.nio.charset.MalformedInputException: Input length = 1
  at org.labkey.test.TestFileUtils.getFileContents(TestFileUtils.java:116)
  at org.labkey.test.TestFileUtils.getFileContents(TestFileUtils.java:105)
  at org.labkey.test.tests.FileAttachmentColumnTest.lambda$7(FileAttachmentColumnTest.java:553)
  at org.labkey.test.util.DeferredErrorCollector.wrapAssertion(DeferredErrorCollector.java:187)
  at org.labkey.test.tests.FileAttachmentColumnTest.validateSampleData(FileAttachmentColumnTest.java:553)
  at org.labkey.test.tests.FileAttachmentColumnTest.testSampleFileFields(FileAttachmentColumnTest.java:217)

Related Pull Requests

Changes

  • TestFileUtils.getMD5Hash

Don't use `Files.readString` to read non-text files
@github-actions
Copy link

github-actions bot commented Jul 9, 2025

ERROR: A pull request from 25.7_fb_binaryFileComparison is expected to target release25.7-SNAPSHOT, not develop

@labkey-chrisj
Copy link
Contributor

ERROR: A pull request from 25.7_fb_binaryFileComparison is expected to target release25.7-SNAPSHOT, not develop

make sure to retarget before merging!

@labkey-tchad labkey-tchad changed the base branch from develop to release25.7-SNAPSHOT July 9, 2025 20:22
@labkey-tchad labkey-tchad merged commit 6e4d1ba into release25.7-SNAPSHOT Jul 9, 2025
7 of 8 checks passed
@labkey-tchad labkey-tchad deleted the 25.7_fb_binaryFileComparison branch July 9, 2025 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants