URLConnection extends java.net.URLConnection { @Override public String getHeaderFieldKey(int index) { assert index >= 0 : AssertMessages.positiveOrZeroParameter(); switch (index) { case 0: return CONTENT_TYPE; case 1: return CONTENT_LENGTH; case 2: return LAST_MODIFIED; default: } return null; } protected  URLConnection(URL url); @Override String getHeaderField(int index); @Override String getHeaderField(String name); @Override String getHeaderFieldKey(int index); @Override Map<String, List<String>> getHeaderFields(); @Override void connect(); @Override OutputStream getOutputStream(); @Override InputStream getInputStream();  }
@Test public void getHeaderFieldKeyInt() { assertEquals("content-type", this.connection.getHeaderFieldKey(0)); assertEquals("content-length", this.connection.getHeaderFieldKey(1)); assertEquals("last-modified", this.connection.getHeaderFieldKey(2)); assertNull(this.connection.getHeaderFieldKey(3)); }