@Test
public void testGetTargetContentEncoding() throws Exception {

    HttpContentCompressor compressor = new HttpContentCompressor();
    String[] tests = {
        // Accept-Encoding -> Content-Encoding
        "", null,
        "*", "gzip",
        "*;q=0.0", null,
        "gzip", "gzip",
        "compress, gzip;q=0.5", "gzip",
        "gzip; q=0.5, identity", "gzip",
        "gzip ; q=0.1", "gzip",
        "gzip; q=0, deflate", "deflate",
        " deflate ; q=0 , *;q=0.5", "gzip",
    };
    for (int i = 0; i < tests.length; i += 2) {
        String acceptEncoding = tests[i];
        String contentEncoding = tests[i + 1];
        ZlibWrapper targetWrapper = compressor.determineWrapper(acceptEncoding);
        String targetEncoding = null;
        if (targetWrapper != null) {
            switch (targetWrapper) {
            case GZIP:
                targetEncoding = "gzip";
                break;
            case ZLIB:
                targetEncoding = "deflate";
                break;
            default:
                fail();
            }
        }
        assertEquals(contentEncoding, targetEncoding);
    }
}