Source:
<code>public void testInitialClone_WithAuthentication() throws Exception { Repository dst = createBareRepository(); assertFalse(dst.hasObject(A_txt)); try (Transport t = Transport.open(dst, authURI)) { t.setCredentialsProvider(testCredentials); t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); } assertTrue(dst.hasObject(A_txt)); assertEquals(B, dst.exactRef(master).getObjectId()); fsck(dst, B); List<AccessEvent> requests = getRequests(); assertEquals(3, requests.size()); AccessEvent info = requests.get(0); assertEquals("GET", info.getMethod()); assertEquals(401, info.getStatus()); <START> assertNotNull(info.getResponseHeader(HDR_WWW_AUTHENTICATE)); <END> assertTrue(info.getResponseHeader(HDR_WWW_AUTHENTICATE).toLowerCase().startsWith("basic realm=")); info = requests.get(1); assertEquals("GET", info.getMethod()); assertEquals(join(authURI, "info/refs"), info.getPath()); assertEquals(1, info.getParameters().size()); assertEquals("git-upload-pack", info.getParameter("service")); assertEquals(200, info.getStatus()); assertEquals("application/x-git-upload-pack-advertisement", info.getResponseHeader(HDR_CONTENT_TYPE)); assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING)); AccessEvent service = requests.get(2); assertEquals("POST", service.getMethod()); assertEquals(join(authURI, "git-upload-pack"), service.getPath()); assertEquals(0, service.getParameters().size()); assertNotNull("has content-length", service.getRequestHeader(HDR_CONTENT_LENGTH)); assertNull("not chunked", service.getRequestHeader(HDR_TRANSFER_ENCODING)); assertEquals(200, service.getStatus()); assertEquals("application/x-git-upload-pack-result", service.getResponseHeader(HDR_CONTENT_TYPE)); }</code><technical_language>optional: 2 assertions repeated in places. Factor out a utility method</technical_language>

Target:
public void testInitialClone_WithAuthentication() throws Exception { Repository dst = createBareRepository(); assertFalse(dst.hasObject(A_txt)); try (Transport t = Transport.open(dst, authURI)) { t.setCredentialsProvider(testCredentials); t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); } assertTrue(dst.hasObject(A_txt)); assertEquals(B, dst.exactRef(master).getObjectId()); fsck(dst, B); List<AccessEvent> requests = getRequests(); assertEquals(3, requests.size()); AccessEvent info = requests.get(0); assertEquals("GET", info.getMethod()); assertEquals(401, info.getStatus()); assertStartsWithIgnoreCase(info.getResponseHeader(HDR_WWW_AUTHENTICATE), "basic realm="); info = requests.get(1); assertEquals("GET", info.getMethod()); assertEquals(join(authURI, "info/refs"), info.getPath()); assertEquals(1, info.getParameters().size()); assertEquals("git-upload-pack", info.getParameter("service")); assertEquals(200, info.getStatus()); assertEquals("application/x-git-upload-pack-advertisement", info.getResponseHeader(HDR_CONTENT_TYPE)); assertEquals("gzip", info.getResponseHeader(HDR_CONTENT_ENCODING)); AccessEvent service = requests.get(2); assertEquals("POST", service.getMethod()); assertEquals(join(authURI, "git-upload-pack"), service.getPath()); assertEquals(0, service.getParameters().size()); assertNotNull("has content-length", service.getRequestHeader(HDR_CONTENT_LENGTH)); assertNull("not chunked", service.getRequestHeader(HDR_TRANSFER_ENCODING)); assertEquals(200, service.getStatus()); assertEquals("application/x-git-upload-pack-result", service.getResponseHeader(HDR_CONTENT_TYPE)); }