TestHttpHeaderspublic class TestHttpHeaders extends com.sun.midp.i3test.TestCase
Fields Summary |
---|
final String | URL | StubHttpProtocol | conn |
Methods Summary |
---|
public void | runTests()Runs all the tests.
declare("testParsing");
setUp();
testParsing();
tearDown();
declare("testSetGet");
setUp();
testSetGet();
tearDown();
declare("testOverwrite");
setUp();
testOverwrite();
tearDown();
declare("testOutput");
setUp();
testOutput();
tearDown();
| void | setUp()
conn = new StubHttpProtocol();
conn.openPrim(getSecurityToken(), URL);
| void | tearDown()
| void | testOutput()Tests that the output matches the case of what was passed by the
programmer.
conn.setRequestProperty("calvin", "hobbes");
conn.setRequestProperty("CaLvIN", "Wittgenstein");
conn.setInputBuffer("");
conn.startRequest();
String outbuf = conn.getOutputBuffer();
assertTrue("calvin", outbuf.indexOf("CaLvIN: Wittgenstein") >= 0);
| void | testOverwrite()Tests overwriting of a property in a case-insensitive fashion.
conn.setRequestProperty("hello", "tweedledee");
conn.setRequestProperty("HELLO", "tweedledum");
assertEquals("three", "tweedledum", conn.getRequestProperty("hElLo"));
assertEquals("count", 1, conn.reqProperties.size());
assertEquals("value", "HELLO",
conn.reqProperties.getKeyAt(0));
| void | testParsing()Tests parsing of different pieces of the URL.
assertEquals("URL", URL, conn.getURL());
assertEquals("protocol", "http", conn.getProtocol());
assertEquals("host", "nonexistent.example.com", conn.getHost());
assertEquals("file", "/foo/bar", conn.getFile());
assertEquals("query", "bazz", conn.getQuery());
assertEquals("ref", "mumble", conn.getRef());
assertEquals("port", 8080, conn.getPort());
| void | testSetGet()Tests that getting a property is case-insensitive relative to a
property that had been set previously.
conn.setRequestProperty("hElLo", "goodbye");
assertEquals("two", "goodbye", conn.getRequestProperty("hello"));
|
|