[java] Fixing a test since the returned code changed
package com.thoughtworks.selenium;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
@@ -54,7 +54,7 @@ public void testCanStopTheSeleneseSessionWhenASessionIsInProgress() {
@Override
public String doCommand(String commandName, String[] args) {
assertEquals("testComplete", commandName);
- assertNull(args);
+ assertArrayEquals(args, new String[0]);
return null;
}
};
@@ -113,6 +113,23 @@ public void testResourcesClosedWhenNoIoes() {
}
}
+ @Test
+ public void testGetBooleanArray() {
+ HttpCommandProcessor processor =
+ new HttpCommandProcessor("localhost", 4444, "*chrome", "http://www.openqa.org");
+ processor = spy(processor);
+
+ String[] cmdArgs = new String[] {"1", "2"};
+ String[] cmdResults = new String[] {"true", "false"};
+ boolean[] boolCmdResults = new boolean[] {true, false};
+
+ doReturn(cmdResults).when(processor).getStringArray("command", cmdArgs);
+
+ boolean[] methodResults = processor.getBooleanArray("command", cmdArgs);
+ assertEquals(boolCmdResults[0], methodResults[0]);
+ assertEquals(boolCmdResults[1], methodResults[1]);
+ }
+
/**
* Inner class to help mock out the network and pipe connections to verify that they are closed
* regardless of where IOExceptions occur.
@@ -121,14 +138,13 @@ public void testResourcesClosedWhenNoIoes() {
*/
private class IOEThrowingHttpCommandProcessor extends HttpCommandProcessor {
- private HttpURLConnection closedConn;
- private Writer closedWriter;
- private Reader closedReader;
-
protected String responseString = "normal response";
protected boolean throwIoeOnGetConnection = false;
protected boolean throwIoeOnGetInputStream = false;
protected boolean throwIoeOnGetOutputStream = false;
+ private HttpURLConnection closedConn;
+ private Writer closedWriter;
+ private Reader closedReader;
public IOEThrowingHttpCommandProcessor(String serverHost,
int serverPort, String browserStartCommand, String browserURL) {
@@ -184,21 +200,4 @@ protected boolean verifyClosedResources(boolean connNotNull,
}
- @Test
- public void testGetBooleanArray() {
- HttpCommandProcessor processor =
- new HttpCommandProcessor("localhost", 4444, "*chrome", "http://www.openqa.org");
- processor = spy(processor);
-
- String[] cmdArgs = new String[] {"1", "2"};
- String[] cmdResults = new String[] {"true", "false"};
- boolean[] boolCmdResults = new boolean[] {true, false};
-
- doReturn(cmdResults).when(processor).getStringArray("command", cmdArgs);
-
- boolean[] methodResults = processor.getBooleanArray("command", cmdArgs);
- assertEquals(boolCmdResults[0], methodResults[0]);
- assertEquals(boolCmdResults[1], methodResults[1]);
- }
-
}
