1717
1818package com .thoughtworks .selenium ;
1919
20+ import static org .junit .Assert .assertArrayEquals ;
2021import static org .junit .Assert .assertEquals ;
21- import static org .junit .Assert .assertNull ;
2222import static org .junit .Assert .fail ;
2323import static org .mockito .Mockito .doReturn ;
2424import static org .mockito .Mockito .spy ;
@@ -54,7 +54,7 @@ public void testCanStopTheSeleneseSessionWhenASessionIsInProgress() {
5454 @ Override
5555 public String doCommand (String commandName , String [] args ) {
5656 assertEquals ("testComplete" , commandName );
57- assertNull (args );
57+ assertArrayEquals (args , new String [ 0 ] );
5858 return null ;
5959 }
6060 };
@@ -113,6 +113,23 @@ public void testResourcesClosedWhenNoIoes() {
113113 }
114114 }
115115
116+ @ Test
117+ public void testGetBooleanArray () {
118+ HttpCommandProcessor processor =
119+ new HttpCommandProcessor ("localhost" , 4444 , "*chrome" , "http://www.openqa.org" );
120+ processor = spy (processor );
121+
122+ String [] cmdArgs = new String [] {"1" , "2" };
123+ String [] cmdResults = new String [] {"true" , "false" };
124+ boolean [] boolCmdResults = new boolean [] {true , false };
125+
126+ doReturn (cmdResults ).when (processor ).getStringArray ("command" , cmdArgs );
127+
128+ boolean [] methodResults = processor .getBooleanArray ("command" , cmdArgs );
129+ assertEquals (boolCmdResults [0 ], methodResults [0 ]);
130+ assertEquals (boolCmdResults [1 ], methodResults [1 ]);
131+ }
132+
116133 /**
117134 * Inner class to help mock out the network and pipe connections to verify that they are closed
118135 * regardless of where IOExceptions occur.
@@ -121,14 +138,13 @@ public void testResourcesClosedWhenNoIoes() {
121138 */
122139 private class IOEThrowingHttpCommandProcessor extends HttpCommandProcessor {
123140
124- private HttpURLConnection closedConn ;
125- private Writer closedWriter ;
126- private Reader closedReader ;
127-
128141 protected String responseString = "normal response" ;
129142 protected boolean throwIoeOnGetConnection = false ;
130143 protected boolean throwIoeOnGetInputStream = false ;
131144 protected boolean throwIoeOnGetOutputStream = false ;
145+ private HttpURLConnection closedConn ;
146+ private Writer closedWriter ;
147+ private Reader closedReader ;
132148
133149 public IOEThrowingHttpCommandProcessor (String serverHost ,
134150 int serverPort , String browserStartCommand , String browserURL ) {
@@ -184,21 +200,4 @@ protected boolean verifyClosedResources(boolean connNotNull,
184200
185201 }
186202
187- @ Test
188- public void testGetBooleanArray () {
189- HttpCommandProcessor processor =
190- new HttpCommandProcessor ("localhost" , 4444 , "*chrome" , "http://www.openqa.org" );
191- processor = spy (processor );
192-
193- String [] cmdArgs = new String [] {"1" , "2" };
194- String [] cmdResults = new String [] {"true" , "false" };
195- boolean [] boolCmdResults = new boolean [] {true , false };
196-
197- doReturn (cmdResults ).when (processor ).getStringArray ("command" , cmdArgs );
198-
199- boolean [] methodResults = processor .getBooleanArray ("command" , cmdArgs );
200- assertEquals (boolCmdResults [0 ], methodResults [0 ]);
201- assertEquals (boolCmdResults [1 ], methodResults [1 ]);
202- }
203-
204203}
0 commit comments