Map<String, String> commonOAuthParameters(String consumerKey) { Map<String, String> oauthParameters = new HashMap<String, String>(); oauthParameters.put("oauth_consumer_key", consumerKey); oauthParameters.put("oauth_signature_method", HMAC_SHA1_SIGNATURE_NAME); long timestamp = timestampGenerator.generateTimestamp(); oauthParameters.put("oauth_timestamp", Long.toString(timestamp)); oauthParameters.put("oauth_nonce", Long.toString(timestampGenerator.generateNonce(timestamp))); oauthParameters.put("oauth_version", "1.0"); return oauthParameters; }
@Test public void testTimestamp() { TimestampGenerator generator = new TimestampGenerator(); long last = generator.getTimestamp(); long start = last; long startms = System.currentTimeMillis(); System.out.println(last); for (int i = 0; i < 100000; i++) { long timestamp = generator.getTimestamp(); assertTrue(timestamp > last); last = timestamp; } System.out.println(generator.getTimestamp() - start); System.out.println(System.currentTimeMillis() - startms); }