List of usage examples for org.apache.commons.codec.digest DigestUtils shaHex
@Deprecated public static String shaHex(String data)
From source file:org.eclipse.gyrex.cloud.tests.internal.zookeeper.preferences.ZooKeeperPreferencesEnsambleTests.java
private String randomPath() { IPath path = Path.EMPTY;//www . j a va 2s . c om final int segments = RandomUtils.nextInt(16); for (int i = 0; i < segments; i++) { path = path.append(StringUtils.substring(DigestUtils.shaHex(UUID.randomUUID().toString()), 0, 6)); } return path.toString(); }
From source file:org.eclipse.gyrex.jobs.internal.schedules.ScheduleManagerImpl.java
/** * Creates a new instance./*from ww w.j ava2s . com*/ */ @Inject public ScheduleManagerImpl(final IRuntimeContext context) { this.context = context; try { internalIdPrefix = DigestUtils.shaHex(context.getContextPath().toString().getBytes(CharEncoding.UTF_8)) + SEPARATOR; } catch (final UnsupportedEncodingException e) { throw new IllegalStateException("Please use a JVM that supports UTF-8."); } }
From source file:org.eclipse.gyrex.jobs.internal.util.ContextHashUtil.java
private static String getInternalIdPrefix(final IPath contextPath) { try {/*from w w w . j ava2s .c om*/ return DigestUtils.shaHex(contextPath.toString().getBytes(CharEncoding.UTF_8)) + SEPARATOR; } catch (final UnsupportedEncodingException e) { throw new IllegalStateException("Please use a JVM that supports UTF-8."); } }
From source file:org.eclipse.skalli.commons.StatisticsTest.java
@Test public void testStatisticsInfo() throws Exception { long now = System.currentTimeMillis(); StatisticsInfo info = new StatisticsInfo("homer", 4711L); assertEquals(DigestUtils.shaHex("homer"), info.getUserHash()); assertEquals(4711L, info.getSequenceNumber()); assertTrue(info.getTimestamp() >= now); }
From source file:org.eclipse.skalli.commons.StatisticsTest.java
@Test public void testTrackUsage() throws Exception { long now = System.currentTimeMillis(); Statistics stats = new Statistics(now, 0, 0, 0); stats.trackUsage("homer", "/projects", "x"); stats.trackUsage("marge", "/projects/a", "y"); stats.trackUsage("marge", "/projects/b", "z"); stats.trackUsage("homer", "/projects", "y"); stats.trackUsage("bart", "/projects/a", "y"); SortedSet<UsageInfo> info = stats.getUsageInfo(); assertInfoSet(stats, info);//w ww .j av a2s . c om assertEquals(DigestUtils.shaHex("bart"), info.last().getUserHash()); assertEquals("/projects/a", info.last().getPath()); assertEquals("y", info.last().getReferer()); }
From source file:org.eclipse.skalli.commons.StatisticsTest.java
@Test public void testTrackUser() throws Exception { long now = System.currentTimeMillis(); Statistics stats = new Statistics(now, 0, 0, 0); stats.trackUser("homer", "A", "X"); stats.trackUser("marge", "B", "Y"); stats.trackUser("homer", "A", "X"); stats.trackUser("bart", "C", "Z"); SortedSet<UserInfo> info = stats.getUserInfo(); assertInfoSet(stats, info);/*w w w. j a v a2 s.c om*/ assertEquals(DigestUtils.shaHex("bart"), info.last().getUserHash()); assertEquals("C", info.last().getDepartment()); assertEquals("Z", info.last().getLocation()); }
From source file:org.eclipse.skalli.commons.StatisticsTest.java
@Test public void testTrackBrowser() throws Exception { long now = System.currentTimeMillis(); Statistics stats = new Statistics(now, 0, 0, 0); stats.trackBrowser("homer", "UserAgent1"); stats.trackBrowser("marge", "UserAgent2"); stats.trackBrowser("bart", "UserAgent1"); SortedSet<BrowserInfo> info = stats.getBrowserInfo(); assertInfoSet(stats, info);/*from ww w . ja v a 2s .c om*/ assertEquals(DigestUtils.shaHex("bart"), info.last().getUserHash()); assertEquals("UserAgent1", info.last().getUserAgent()); }
From source file:org.eclipse.skalli.commons.StatisticsTest.java
@Test public void testTrackSearch() throws Exception { long now = System.currentTimeMillis(); Statistics stats = new Statistics(now, 0, 0, 0); stats.trackSearch("homer", "queryA", 25, 1234L); stats.trackSearch("marge", "queryB", 2, 344L); stats.trackSearch("bart", "queryC", 0, 723L); stats.trackSearch("marge", "queryC", 0, 567L); SortedSet<SearchInfo> info = stats.getSearchInfo(); assertInfoSet(stats, info);/* w w w. ja va 2 s. c om*/ assertEquals(DigestUtils.shaHex("marge"), info.last().getUserHash()); assertEquals("queryC", info.last().getQueryString()); assertEquals(0, info.last().getResultCount()); assertEquals(567L, info.last().getDuration()); }
From source file:org.eclipse.skalli.commons.StatisticsTest.java
@Test public void testTrackReferer() throws Exception { long now = System.currentTimeMillis(); Statistics stats = new Statistics(now, 0, 0, 0); stats.trackReferer("homer", "ref35"); stats.trackReferer("marge", null); stats.trackReferer("bart", "ref12"); SortedSet<RefererInfo> info = stats.getRefererInfo(); assertInfoSet(stats, info);/* w ww . ja v a 2s . c o m*/ assertEquals(DigestUtils.shaHex("bart"), info.last().getUserHash()); assertEquals("ref12", info.last().getReferer()); }
From source file:org.eclipse.skalli.commons.StatisticsTest.java
@Test public void testResponseTime() throws Exception { long now = System.currentTimeMillis(); Statistics stats = new Statistics(now, 0, 0, 0); stats.trackResponseTime("homer", "/projects", 12L); stats.trackResponseTime("marge", "/favorites", 2837L); stats.trackResponseTime("bart", "/projects/a", 54L); SortedSet<ResponseTimeInfo> info = stats.getResponseTimeInfo(); assertInfoSet(stats, info);/*from w w w. j a va2s .c o m*/ assertEquals(DigestUtils.shaHex("bart"), info.last().getUserHash()); assertEquals("/projects/a", info.last().getPath()); assertEquals(54L, info.last().getResponseTime()); }