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 testCustomExpirationTimeWithValues() {
        final long twentyMinutesInMillis = 20 * 60 * 1000;
        final TileSourcePolicy tileSourcePolicy = new TileSourcePolicy() {
            @Override
            public long computeExpirationTime(String pHttpExpiresHeader, String pHttpCacheControlHeader, long pNow) {
                return pNow + twentyMinutesInMillis;
            }
        };
        final long now = System.currentTimeMillis();
        final long expected = now + twentyMinutesInMillis;
        for (final String cacheControlString : mCacheControlStringOK) {
            for (final String expiresString : mExpiresStringOK) {
                Assert.assertEquals(
                        expected,
                        tileSourcePolicy.computeExpirationTime(expiresString, cacheControlString, now));
            }
            for (final String expiresString : mExpiresStringKO) {
                Assert.assertEquals(
                        expected,
                        tileSourcePolicy.computeExpirationTime(expiresString, cacheControlString, now));
            }
        }
        for (final String cacheControlString : mCacheControlStringKO) {
            for (final String expiresString : mExpiresStringOK) {
                Assert.assertEquals(
                        expected,
                        tileSourcePolicy.computeExpirationTime(expiresString, cacheControlString, now));
            }
            for (final String expiresString : mExpiresStringKO) {
                Assert.assertEquals(
                        expected,
                        tileSourcePolicy.computeExpirationTime(expiresString, cacheControlString, now));
            }
        }
    }