@Test
@PrepareForTest({Log.class})

public void testGetHttpURLConnection() throws Exception {
    RuleDatabaseItemUpdateRunnable itemUpdateRunnable = mock(RuleDatabaseItemUpdateRunnable.class);
    when(itemUpdateRunnable.getHttpURLConnection(any(File.class), any(SingleWriterMultipleReaderFile.class), any(URL.class))).thenCallRealMethod();
    when(itemUpdateRunnable.internalOpenHttpConnection(any(URL.class))).thenReturn(connection);
    when(singleWriterMultipleReaderFile.openRead()).thenReturn(mock(FileInputStream.class));
    assertSame(connection, itemUpdateRunnable.getHttpURLConnection(file, singleWriterMultipleReaderFile, url));
    // Setting modified.
    CountingAnswer setIfModifiedAnswer = new CountingAnswer(null);
    when(file.lastModified()).thenReturn(42L);
    when(connection, "setIfModifiedSince", eq(42L)).then(setIfModifiedAnswer);
    assertSame(connection, itemUpdateRunnable.getHttpURLConnection(file, singleWriterMultipleReaderFile, url));
    assertEquals(1, setIfModifiedAnswer.numCalls);
    // If we do not have a last modified value, do not set if-modified-since.
    setIfModifiedAnswer.numCalls = 0;
    when(file.lastModified()).thenReturn(0L);
    assertSame(connection, itemUpdateRunnable.getHttpURLConnection(file, singleWriterMultipleReaderFile, url));
    assertEquals(0, setIfModifiedAnswer.numCalls);
}