Skip to content

Remove System.exit from main and error paths, add tests - #19

Merged
eskopp merged 2 commits into
mainfrom
more-tests-no-exit
Oct 6, 2026
Merged

eskopp merged 2 commits into
mainfrom
more-tests-no-exit

Conversation

@eskopp

@eskopp eskopp commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Changes

  • MyCryptMain: logic moved to execute(args), main only calls it. A missing or unknown command now exits with code 1 instead of 0.
  • RunEncrypt.getCipher: throws IllegalStateException instead of calling System.exit(8).
  • RunGenKeys: a key file that cannot be written is reported as IOException instead of System.exit(2).
  • New tests for MyCryptMain (usage, full cycle, copy) and for error paths (missing files, wrong key, unwritable path).

Coverage

JaCoCo: 62% -> 88% instructions, 71% branches, 86% lines. 19 tests, all green locally on JDK 27.

Not changed

The System.exit(2) for a missing RSA algorithm in RunGenKeys stays, it is unreachable in practice.

@eskopp
eskopp merged commit 36118de into main Oct 6, 2026
13 checks passed
@eskopp
eskopp deleted the more-tests-no-exit branch October 6, 2026 19:35
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.

1 participant