[JENKINS-18058] Throw IOException if negative int from port-based CLI connection stream

[JENKINS-18058](https://issues.jenkins-ci.org/browse/JENKINS-18058)

-Instead of failing at initializing array with negative size.
Introducing PowerMock test for the zero-size array case.
Negative-size case not tested thx to unhelping PowerMock behavior.
Using ConnectionMockTest instead of ConnectionTest; needed by PowerMock.