public long computeExpirationTime(final String pHttpExpiresHeader, final String pHttpCacheControlHeader, final long pNow) {
        final Long override = Configuration.getInstance().getExpirationOverrideDuration();
        if (override != null) {
            return pNow + override;
        }

        final long extension = Configuration.getInstance().getExpirationExtendedDuration();
        final Long cacheControlDuration = getHttpCacheControlDuration(pHttpCacheControlHeader);
        if (cacheControlDuration != null) {
            return pNow + cacheControlDuration * 1000 + extension;
        }

        final Long httpExpiresTime = getHttpExpiresTime(pHttpExpiresHeader);
        if (httpExpiresTime != null) {
            return httpExpiresTime + extension;
        }

        return pNow + OpenStreetMapTileProviderConstants.DEFAULT_MAXIMUM_CACHED_FILE_AGE + extension;
    }
@Test
    public void testCustomExpirationTimeWithHttpConnection() {
        final long twentyMinutesInMillis = 20 * 60 * 1000;
        final long thirtyMinutesInMillis = 30 * 60 * 1000;
        final HttpURLConnection dummyConnection = new HttpURLConnection(null) {
            @Override
            public void disconnect() {
            }

            @Override
            public boolean usingProxy() {
                return false;
            }

            @Override
            public void connect() {
            }

            @Override
            public String getHeaderField(String name) {
                return null;
            }
        };
        final TileSourcePolicy tileSourcePolicy = new TileSourcePolicy() {
            @Override
            public long computeExpirationTime(String pHttpExpiresHeader, String pHttpCacheControlHeader, long pNow) {
                return pNow + twentyMinutesInMillis;
            }

            @Override
            public long computeExpirationTime(HttpURLConnection pHttpURLConnection, long pNow) {
                return pNow + thirtyMinutesInMillis;
            }
        };
        final long now = System.currentTimeMillis();
        final long expected = now + thirtyMinutesInMillis;
        Assert.assertEquals(
                expected,
                tileSourcePolicy.computeExpirationTime(dummyConnection, now));
    }