Fixed NPE in test

This commit is contained in:
str4d
2015-03-23 03:54:21 +00:00
parent 876b5714be
commit 399b068a4e

View File

@@ -9,6 +9,7 @@ import java.io.OutputStreamWriter;
import java.util.Map;
import java.util.List;
import net.i2p.I2PAppContext;
import junit.framework.TestCase;
public class I2PTunnelHTTPServerTest extends TestCase {
@@ -27,7 +28,7 @@ public class I2PTunnelHTTPServerTest extends TestCase {
headerString += "BLAH: something\r\n";
headerString += "\r\n";
InputStream in = fillInputStream(headerString);
Map<String, List<String>> headers = I2PTunnelHTTPServer.readHeaders(in, new StringBuilder(128), new String[0], null);
Map<String, List<String>> headers = I2PTunnelHTTPServer.readHeaders(in, new StringBuilder(128), new String[0], I2PAppContext.getGlobalContext());
assertEquals(headers.size(), 1); //One header
}
@@ -37,7 +38,7 @@ public class I2PTunnelHTTPServerTest extends TestCase {
headerString += "someHeader: oh my, duplication!\r\n";
headerString += "\r\n";
InputStream in = fillInputStream(headerString);
Map<String, List<String>> headers = I2PTunnelHTTPServer.readHeaders(in, new StringBuilder(128), new String[0], null);
Map<String, List<String>> headers = I2PTunnelHTTPServer.readHeaders(in, new StringBuilder(128), new String[0], I2PAppContext.getGlobalContext());
assertEquals(headers.size(), 1);
assertEquals(headers.get("someHeader").size(), 2);
}
@@ -50,7 +51,7 @@ public class I2PTunnelHTTPServerTest extends TestCase {
headerString += "\r\n";
InputStream in = fillInputStream(headerString);
StringBuilder builder = new StringBuilder(128);
Map<String, List<String>> headers = I2PTunnelHTTPServer.readHeaders(in, builder, new String[0], null);
Map<String, List<String>> headers = I2PTunnelHTTPServer.readHeaders(in, builder, new String[0], I2PAppContext.getGlobalContext());
String result = I2PTunnelHTTPServer.formatHeaders(headers, builder);
int first = result.indexOf("abc");
assertTrue(first >= 0);