ReleaseKeyGenerator extends UniqueKeyGenerator { public static String generateReleaseKey(Namespace namespace) { return generate(namespace.getAppId(), namespace.getClusterName(), namespace.getNamespaceName()); }  static String generateReleaseKey(Namespace namespace);  }
@Test public void testGenerateReleaseKey() throws Exception { String someAppId = "someAppId"; String someCluster = "someCluster"; String someNamespace = "someNamespace"; String anotherAppId = "anotherAppId"; Namespace namespace = MockBeanFactory.mockNamespace(someAppId, someCluster, someNamespace); Namespace anotherNamespace = MockBeanFactory.mockNamespace(anotherAppId, someCluster, someNamespace); int generateTimes = 50000; Set<String> releaseKeys = Sets.newConcurrentHashSet(); ExecutorService executorService = Executors.newFixedThreadPool(2); CountDownLatch latch = new CountDownLatch(1); executorService.submit(generateReleaseKeysTask(namespace, releaseKeys, generateTimes, latch)); executorService.submit(generateReleaseKeysTask(anotherNamespace, releaseKeys, generateTimes, latch)); latch.countDown(); executorService.shutdown(); executorService.awaitTermination(10, TimeUnit.SECONDS); assertEquals(generateTimes * 2, releaseKeys.size()); }