-
Notifications
You must be signed in to change notification settings - Fork 677
Cleanup #1488
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
Merged
Merged
Cleanup #1488
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
038bc94
cleanup
aleksandy b94a7fc
simplify check
aleksandy 93c40d6
simplify some utility methods
aleksandy fafc2b1
remove unused patch
aleksandy 9ed8dcc
cleanup:use standard methods instead of alternatives from third party…
aleksandy 1ca899c
cleanup:use constant instead of read system property
aleksandy 2a7b390
cleanup:close InputStream after reading
aleksandy fcc253c
cleanup:use single try
aleksandy d2f4c45
cleanup:use direct access to fields instead of reflection
aleksandy b6a8894
cleanup code
aleksandy 03d6c43
migrate tests to junit 5
aleksandy cd94733
* use try-with-resource
aleksandy 176a9e6
fix copyDirectory and add test inspired #1075
aleksandy e591a68
use standard api available from java 17 instead of third party depend…
aleksandy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
cleanup
* use java.util.Base64 instead of third-party implementation; * extract copy-pasted code into common method
- Loading branch information
commit 038bc94eddd21184d12b2a71d81d46b41d66e6d1
There are no files selected for viewing
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 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package play.libs; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| public class CodecTest { | ||
|
|
||
| @Test | ||
| public void encodeBASE64() { | ||
| // input and expected data are taken from https://datatracker.ietf.org/doc/html/rfc4648#section-10 | ||
| assertThat(Codec.encodeBASE64("")).isEmpty(); | ||
| assertThat(Codec.encodeBASE64(new byte[0])).isEmpty(); | ||
|
|
||
| assertThat(Codec.encodeBASE64("f")).isEqualTo("Zg=="); | ||
| assertThat(Codec.encodeBASE64("fo")).isEqualTo("Zm8="); | ||
| assertThat(Codec.encodeBASE64("foo")).isEqualTo("Zm9v"); | ||
| assertThat(Codec.encodeBASE64("foob")).isEqualTo("Zm9vYg=="); | ||
| assertThat(Codec.encodeBASE64("fooba")).isEqualTo("Zm9vYmE="); | ||
| assertThat(Codec.encodeBASE64("foobar")).isEqualTo("Zm9vYmFy"); | ||
|
|
||
| assertThat(Codec.encodeBASE64(new byte[] { 'f' })).isEqualTo("Zg=="); | ||
| assertThat(Codec.encodeBASE64(new byte[] { 'f', 'o' })).isEqualTo("Zm8="); | ||
| assertThat(Codec.encodeBASE64(new byte[] { 'f', 'o', 'o' })).isEqualTo("Zm9v"); | ||
| assertThat(Codec.encodeBASE64(new byte[] { 'f', 'o', 'o', 'b' })).isEqualTo("Zm9vYg=="); | ||
| assertThat(Codec.encodeBASE64(new byte[] { 'f', 'o', 'o', 'b', 'a' })).isEqualTo("Zm9vYmE="); | ||
| assertThat(Codec.encodeBASE64(new byte[] { 'f', 'o', 'o', 'b', 'a', 'r' })).isEqualTo("Zm9vYmFy"); | ||
| } | ||
|
|
||
| @Test | ||
| public void decodeBASE64() { | ||
| // input and expected data are taken from https://datatracker.ietf.org/doc/html/rfc4648#section-10 | ||
| assertThat(Codec.decodeBASE64("")).isEmpty(); | ||
| assertThat(Codec.decodeBASE64("Zg==")).isEqualTo(new byte[] { 'f' }); | ||
| assertThat(Codec.decodeBASE64("Zm8=")).isEqualTo(new byte[] { 'f', 'o' }); | ||
| assertThat(Codec.decodeBASE64("Zm9v")).isEqualTo(new byte[] { 'f', 'o', 'o' }); | ||
| assertThat(Codec.decodeBASE64("Zm9vYg==")).isEqualTo(new byte[] { 'f', 'o', 'o', 'b' }); | ||
| assertThat(Codec.decodeBASE64("Zm9vYmE=")).isEqualTo(new byte[] { 'f', 'o', 'o', 'b', 'a' }); | ||
| assertThat(Codec.decodeBASE64("Zm9vYmFy")).isEqualTo(new byte[] { 'f', 'o', 'o', 'b', 'a', 'r' }); | ||
| } | ||
|
|
||
| @Test | ||
| public void hexMD5() { | ||
| // https://www.febooti.com/products/filetweak/members/hash-and-crc/test-vectors/ | ||
| assertThat(Codec.hexMD5("")).isEqualTo("d41d8cd98f00b204e9800998ecf8427e"); | ||
| assertThat(Codec.hexMD5("The quick brown fox jumps over the lazy dog")).isEqualTo("9e107d9d372bb6826bd81d3542a419d6"); | ||
| assertThat(Codec.hexMD5("Test vector from febooti.com")).isEqualTo("500ab6613c6db7fbd30c62f5ff573d0f"); | ||
| } | ||
|
|
||
| @Test | ||
| public void hexSHA1() { | ||
| // https://www.febooti.com/products/filetweak/members/hash-and-crc/test-vectors/ | ||
| assertThat(Codec.hexSHA1("")).isEqualTo("da39a3ee5e6b4b0d3255bfef95601890afd80709"); | ||
| assertThat(Codec.hexSHA1("The quick brown fox jumps over the lazy dog")).isEqualTo("2fd4e1c67a2d28fced849ee1bb76e7391b93eb12"); | ||
| assertThat(Codec.hexSHA1("Test vector from febooti.com")).isEqualTo("a7631795f6d59cd6d14ebd0058a6394a4b93d868"); | ||
| } | ||
|
|
||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.