@@ -149,13 +149,36 @@ public void testSetSecureRandomWithNull() {
149149@ Test
150150public void testGetConnectionInfoThrowsWhenNotConnected () {
151151 try {
152- connection .getConnectionInfo ();
153- fail ("Should throw IllegalStateException when not connected" );
152+ connection .getConnectionInfo ();
153+ fail ("Should throw IllegalStateException when not connected" );
154154 } catch (IllegalStateException e ) {
155- assertTrue (e .getMessage ().contains ("establish a connection first" ), "Exception message should indicate connection required" );
155+ assertTrue (e .getMessage ().contains ("establish a connection first" ), "Exception message should indicate connection required" );
156156 } catch (Exception e ) {
157- fail ("Should throw IllegalStateException, got: " +
158- e .getClass ().getSimpleName ());
157+ fail ("Should throw IllegalStateException, got: " + e .getClass ().getSimpleName ());
158+ }
159+ }
160+
161+ @ Test
162+ public void testGetLocalSocketAddressThrowsWhenNotConnected () {
163+ try {
164+ connection .getLocalSocketAddress ();
165+ fail ("Should throw IllegalStateException when not connected" );
166+ } catch (IllegalStateException e ) {
167+ assertTrue (e .getMessage ().contains ("establish a connection first" ), "Exception message should indicate connection required" );
168+ } catch (Exception e ) {
169+ fail ("Should throw IllegalStateException, got: " + e .getClass ().getSimpleName ());
170+ }
171+ }
172+
173+ @ Test
174+ public void testGetRemoteSocketAddressThrowsWhenNotConnected () {
175+ try {
176+ connection .getRemoteSocketAddress ();
177+ fail ("Should throw IllegalStateException when not connected" );
178+ } catch (IllegalStateException e ) {
179+ assertTrue (e .getMessage ().contains ("establish a connection first" ), "Exception message should indicate connection required" );
180+ } catch (Exception e ) {
181+ fail ("Should throw IllegalStateException, got: " + e .getClass ().getSimpleName ());
159182 }
160183}
161184
0 commit comments