Class NetUtilsTest
NetUtils.
Two groups. NetUtils.bytePerSecondToDisplaySize(double) is the rate-formatter used by download
progress reporting: the threshold boundaries (B vs KB vs MB vs GB) and the two-decimal
formatting contract are pinned below.
NetUtils.ftpDownloadFile(FTPClient, String, File, boolean) is exercised against a mocked FTPClient, so no server is
involved. The cases that matter are the wrong-length ones: a transfer can report success and
still leave a file that does not match the remote size — short, or LONGER than the remote when a
run of already-written bytes is replayed mid-stream. Nothing used to compare the two, so the bad
file was accepted, cached, and only failed later in whatever read it. A corrupt GEO
_RAW.tar surfaced as Invalid byte <n> at offset 0 ... len=8 from the tar reader,
which reads like a bad archive rather than a bad transfer.
- Author:
- claude
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidA wrong-length file must not survive to be mistaken for a complete download by the skip-if-already-correct check on the next run.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidThe skip path pre-staging relies on: a local file already matching the remote size is used as-is and no transfer happens.voidThe fault actually observed against NCBI: the transfer replays a run of bytes and the local file ends up bigger than the remote.voidvoid
-
Constructor Details
-
NetUtilsTest
public NetUtilsTest()
-
-
Method Details
-
zeroBytesPerSecond_rendersAsBytesPerSecond
@Test public void zeroBytesPerSecond_rendersAsBytesPerSecond() -
belowKilobyteThreshold_rendersAsBytes
@Test public void belowKilobyteThreshold_rendersAsBytes() -
atKilobyteThreshold_rendersAsKilobytes
@Test public void atKilobyteThreshold_rendersAsKilobytes() -
belowMegabyteThreshold_rendersAsKilobytes
@Test public void belowMegabyteThreshold_rendersAsKilobytes() -
atMegabyteThreshold_rendersAsMegabytes
@Test public void atMegabyteThreshold_rendersAsMegabytes() -
belowGigabyteThreshold_rendersAsMegabytes
@Test public void belowGigabyteThreshold_rendersAsMegabytes() -
atGigabyteThreshold_rendersAsGigabytes
@Test public void atGigabyteThreshold_rendersAsGigabytes() -
aboveGigabytePastThreshold_stillRendersAsGigabytes
@Test public void aboveGigabytePastThreshold_stillRendersAsGigabytes() -
fractionalBytes_preservesTwoDecimals
@Test public void fractionalBytes_preservesTwoDecimals() -
fractionalKilobytes_preservesTwoDecimals
@Test public void fractionalKilobytes_preservesTwoDecimals() -
downloadMatchingTheRemoteSize_succeedsAndKeepsTheFile
@Test public void downloadMatchingTheRemoteSize_succeedsAndKeepsTheFile(@TempDir Path tmp) throws IOException - Throws:
IOException
-
overlongDownload_isRejectedAndTheFileRemoved
@Test public void overlongDownload_isRejectedAndTheFileRemoved(@TempDir Path tmp) throws IOException The fault actually observed against NCBI: the transfer replays a run of bytes and the local file ends up bigger than the remote.- Throws:
IOException
-
shortDownload_isRejectedAndTheFileRemoved
- Throws:
IOException
-
aRejectedDownloadIsNotReusedByTheSkipCheck
A wrong-length file must not survive to be mistaken for a complete download by the skip-if-already-correct check on the next run.- Throws:
IOException
-
localFileAlreadyMatchingTheRemoteSize_skipsTheDownload
@Test public void localFileAlreadyMatchingTheRemoteSize_skipsTheDownload(@TempDir Path tmp) throws IOException The skip path pre-staging relies on: a local file already matching the remote size is used as-is and no transfer happens.- Throws:
IOException
-
forceOverridesTheSkip
- Throws:
IOException
-