List of usage examples for java.util UUID randomUUID
public static UUID randomUUID()
From source file:com.flicklib.service.cache.HttpEHCacheTest.java
@Test public void testHttpCache() throws IOException { String testValue = UUID.randomUUID().toString(); SourceLoader mockResolver = Mockito.mock(SourceLoader.class); Mockito.when(mockResolver.loadSource("test", true)).thenReturn(new Source("test", testValue, "test")); SourceLoader cache = new HttpEHCache(mockResolver); {/*from w ww .ja v a 2s . c o m*/ Source source = cache.loadSource("test"); assertEquals(testValue, source.getContent()); } { Source source = cache.loadSource("test"); assertEquals(testValue, source.getContent()); } // second call should not hit the resolver so we should have only one #get call Mockito.verify(mockResolver).loadSource("test", true); }
From source file:com.alibaba.akka.DataQueryService.java
public List<Item> query(QueryParam param) { List<Item> itemList = new ArrayList<Item>(); UUID uuid = UUID.randomUUID(); SpringExtension.SpringExtProvider.get(actorSystem).initialize(applicationContext); final ActorRef queryActor = actorSystem.actorOf( SpringExtension.SpringExtProvider.get(actorSystem).props("queryActor"), "queryActor" + uuid); QueryMsg queryMsg = new QueryMsg(); // /* w w w . j a v a 2 s.c o m*/ List<PageQueryMsg> pageQueryMsgList = new ArrayList<PageQueryMsg>(); PageQueryMsg pageQueryMsg1 = new PageQueryMsg(); PageQueryMsg pageQueryMsg2 = new PageQueryMsg(); PageQueryMsg pageQueryMsg3 = new PageQueryMsg(); pageQueryMsgList.add(pageQueryMsg1); pageQueryMsgList.add(pageQueryMsg2); pageQueryMsgList.add(pageQueryMsg3); queryMsg.setPageQueryMsgList(pageQueryMsgList); Timeout timeout = new Timeout(Duration.create(20, "seconds")); Future<Object> future = Patterns.ask(queryActor, queryMsg, timeout); try { ResultMsg resultMsg = (ResultMsg) Await.result(future, timeout.duration()); for (PageResultMsg page : resultMsg.getResultList()) { Item item = new Item(); item.setContent(page.getContent()); itemList.add(item); } } catch (Exception e) { e.printStackTrace(); } return itemList; }
From source file:com.netflix.genie.web.data.entities.TagEntityTest.java
/** * Make sure we can create a tag.//from w ww . j a va 2s. co m */ @Test public void canCreateTagEntity() { final TagEntity tagEntity = new TagEntity(); final String tag = UUID.randomUUID().toString(); tagEntity.setTag(tag); Assert.assertThat(tagEntity.getTag(), Matchers.is(tag)); }
From source file:org.lightcouch.CouchDbUtil.java
public static String generateUUID() { return UUID.randomUUID().toString().replace("-", ""); }
From source file:ddf.catalog.content.operation.impl.ReadStorageRequestImpl.java
public ReadStorageRequestImpl(URI resourceUri, String id, Map<String, Serializable> properties) { super(properties); if (StringUtils.isEmpty(id)) { this.id = UUID.randomUUID().toString(); } else {/* w ww . j a v a 2 s . c o m*/ this.id = id; } this.resourceUri = resourceUri; }
From source file:org.dawnsci.commandserver.core.consumer.RemoteSubmission.java
public RemoteSubmission(URI uri) { this.uri = uri; this.uniqueId = System.currentTimeMillis() + "_" + UUID.randomUUID(); }
From source file:com.intuit.tank.script.TestUploadBean.java
/** * Saves the script in the database.//ww w . j a va 2s .c om */ public String save() { UploadedFile item = getFile(); try { String fileName = item.getFileName(); fileName = FilenameUtils.getBaseName(fileName) + "-" + UUID.randomUUID().toString() + "." + FilenameUtils.getExtension(fileName); File parent = new File("uploads"); parent.mkdirs(); File f = new File(parent, fileName); LOG.info("Writing file to " + f.getAbsolutePath()); FileUtils.writeByteArrayToFile(f, item.getContents()); messages.info("Wrote file to " + f.getAbsolutePath()); } catch (Exception e) { messages.error(e.getMessage()); } return null; }
From source file:eu.trentorise.game.managers.QueueGameWorkflow.java
@Override public void apply(String gameId, String actionId, String userId, Map<String, Object> data, List<Object> factObjects) { try {// ww w . j a v a 2 s. co m String executionId = UUID.randomUUID().toString(); long executionMoment = System.currentTimeMillis(); executor.execute( new Execution(gameId, actionId, userId, executionId, executionMoment, data, factObjects)); } catch (Exception e) { LogHub.error(gameId, logger, "Exception in game queue execution", e); } }
From source file:com.auditbucket.registration.service.KeyGenService.java
private String getUUID() { return UUID.randomUUID().toString(); }
From source file:com.cloudant.sync.datastore.PreparedAttachment.java
/** * Prepare an attachment by copying it to a temp location and calculating its sha1. * * @param attachment The attachment to prepare * @param attachmentsDir The 'BLOB store' or location where attachments are stored for this database * @throws IOException/* w w w . j a va2 s . com*/ */ public PreparedAttachment(Attachment attachment, String attachmentsDir) throws IOException { this.attachment = attachment; this.tempFile = new File(attachmentsDir, "temp" + UUID.randomUUID()); FileUtils.copyInputStreamToFile(attachment.getInputStream(), tempFile); this.sha1 = Misc.getSha1(new FileInputStream(tempFile)); }