Signature { public static Map<String, String> buildHttpHeaders(String url, String appId, String secret) { long currentTimeMillis = System.currentTimeMillis(); String timestamp = String.valueOf(currentTimeMillis); String pathWithQuery = url2PathWithQuery(url); String signature = signature(timestamp, pathWithQuery, secret); Map<String, String> headers = Maps.newHashMap(); headers.put(HttpHeaders.AUTHORIZATION, String.format(AUTHORIZATION_FORMAT, appId, signature)); headers.put(HTTP_HEADER_TIMESTAMP, timestamp); return headers; }  static String signature(String timestamp, String pathWithQuery, String secret); static Map<String, String> buildHttpHeaders(String url, String appId, String secret); static final String HTTP_HEADER_TIMESTAMP; }
@Test public void testBuildHttpHeaders() { String url = "http: String appId = "100004458"; String secret = "df23df3f59884980844ff3dada30fa97"; Map<String, String> actualHttpHeaders = Signature.buildHttpHeaders(url, appId, secret); assertTrue(actualHttpHeaders.containsKey(HttpHeaders.AUTHORIZATION)); assertTrue(actualHttpHeaders.containsKey(Signature.HTTP_HEADER_TIMESTAMP)); }