本文整理了Java中org.mule.runtime.core.api.util.UUID.getUUID()
方法的一些代码示例,展示了UUID.getUUID()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UUID.getUUID()
方法的具体详情如下:
包路径:org.mule.runtime.core.api.util.UUID
类名称:UUID
方法名:getUUID
暂无
代码示例来源:origin: mulesoft/mule
@Override
public String getUniqueIdString() {
return getUUID();
}
代码示例来源:origin: mulesoft/mule
/**
* Generates a unique id for an artifact (domain or application).
*
* @return {@link String} a uniqueId
*/
public String getUniqueIdString(String type) {
return TOOLING_PREFIX + "-" + type + "-" + UUID.getUUID();
}
代码示例来源:origin: mulesoft/mule
protected String generateTaskToken() {
return currentThread().getName() + " - " + getUUID();
}
代码示例来源:origin: mulesoft/mule
public MuleContextProcessBuilder(File testDirectory) {
this.testDirectory = testDirectory;
systemProperties.put(MULE_CONTEXT_CONFIGURATION_ID_KEY, UUID.getUUID());
systemProperties.put(TIMEOUT_IN_SECONDS, "120");
systemProperties.put(FakeMuleServer.FAKE_SERVER_DISABLE_LOG_REPOSITORY_SELECTOR, "true");
}
代码示例来源:origin: mulesoft/mule
@Benchmark
public String UUID() throws MuleException {
return getUUID();
}
代码示例来源:origin: mulesoft/mule
@Override
protected String getArtifactId(ArtifactDescriptor artifactDescriptor) {
return TOOLING_EXTENSION_MODEL + getUUID() + "/" + artifactDescriptor.getName();
}
代码示例来源:origin: mulesoft/mule
public static MuleContextWithRegistry mockMuleContext() {
final MuleContextWithRegistry muleContext =
mock(DefaultMuleContext.class,
withSettings().defaultAnswer(RETURNS_DEEP_STUBS).extraInterfaces(PrivilegedMuleContext.class).lenient());
when(muleContext.getUniqueIdString()).thenReturn(UUID.getUUID());
when(muleContext.getDefaultErrorHandler(empty())).thenReturn(new OnErrorPropagateHandler());
StreamingManager streamingManager = mock(StreamingManager.class, RETURNS_DEEP_STUBS);
try {
MuleRegistry registry = mock(MuleRegistry.class, withSettings().lenient());
when(muleContext.getRegistry()).thenReturn(registry);
ComponentInitialStateManager componentInitialStateManager =
mock(ComponentInitialStateManager.class, withSettings().lenient());
when(componentInitialStateManager.mustStartMessageSource(any())).thenReturn(true);
when(registry.lookupObject(ComponentInitialStateManager.SERVICE_ID)).thenReturn(componentInitialStateManager);
doReturn(streamingManager).when(registry).lookupObject(StreamingManager.class);
doReturn(mock(NotificationDispatcher.class)).when(registry).lookupObject(NotificationDispatcher.class);
doReturn(mock(ObjectStoreManager.class, RETURNS_DEEP_STUBS)).when(registry).lookupObject(OBJECT_STORE_MANAGER);
} catch (RegistrationException e) {
throw new RuntimeException(e);
}
return muleContext;
}
代码示例来源:origin: mulesoft/mule
@Test
public void testGenerateUniqueAndIncrementalIds() throws Exception {
final Set<String> ids = new HashSet<String>();
final List<Object[]> idsWithIndexes = new ArrayList<Object[]>(1000);
final int numberOfIdsToGenerate = 10000;
for (int index = 0; index < numberOfIdsToGenerate; index++) {
String generatedId = UUID.getUUID();
idsWithIndexes.add(new Object[] {generatedId, Integer.valueOf(index)});
if (ids.contains(generatedId)) {
fail("REPEATED ID :" + index + ": " + generatedId);
} else {
ids.add(generatedId);
}
}
final Comparator<Object[]> comparatorById = new Comparator<Object[]>() {
public int compare(Object[] o1, Object[] o2) {
return ((String) o1[0]).compareTo((String) o2[0]);
}
};
Collections.sort(idsWithIndexes, comparatorById);
for (int index = 0; index < numberOfIdsToGenerate; index++) {
assertEquals(Integer.valueOf(index), idsWithIndexes.get(index)[1]);
}
}
代码示例来源:origin: mulesoft/mule
private MuleContext buildStartedMuleContext() throws Exception {
ctx.initialise();
// DefaultMuleContext refuses to start without these objects in place
SecurityManager securityManager = mock(SecurityManager.class);
((MuleContextWithRegistry) ctx).getRegistry().registerObject(UUID.getUUID(), securityManager);
QueueManager queueManager = mock(QueueManager.class);
((MuleContextWithRegistry) ctx).getRegistry().registerObject(UUID.getUUID(), queueManager);
ctx.start();
return ctx;
}
代码示例来源:origin: mulesoft/mule
@Test
public void isDisposedEventGroupPartition() throws Exception {
EventGroup eventGroup = new EventGroup(UUID.getUUID(), muleContext);
PartitionableObjectStore objectStore = mock(PartitionableObjectStore.class);
eventGroup.initEventsStore(objectStore);
eventGroup.clear();
verify(objectStore).disposePartition(anyString());
}
代码示例来源:origin: mulesoft/mule
/**
* {@inheritDoc}
*/
@Override
public ConnectivityTestingService build() {
checkState(artifactDeclaration != null, "artifact configuration cannot be null");
return new TemporaryArtifactConnectivityTestingService(() -> {
String applicationName = UUID.getUUID() + "-connectivity-testing-temp-app";
File applicationFolder = new File(getExecutionFolder(), applicationName);
ApplicationDescriptor applicationDescriptor = new ApplicationDescriptor(applicationName);
applicationDescriptor.setArtifactDeclaration(artifactDeclaration);
applicationDescriptor.setConfigResources(emptySet());
applicationDescriptor.setArtifactLocation(applicationFolder);
createDeployablePomFile(applicationFolder, model);
updateArtifactPom(applicationFolder, model);
MavenClientProvider mavenClientProvider =
MavenClientProvider.discoverProvider(DefaultConnectivityTestingServiceBuilder.class.getClassLoader());
applicationDescriptor
.setClassLoaderModel(new DeployableMavenClassLoaderModelLoader(mavenClientProvider
.createMavenClient(GlobalConfigLoader.getMavenConfig()))
.load(applicationFolder, emptyMap(), ArtifactType.APP));
return defaultApplicationFactory.createArtifact(applicationDescriptor);
});
}
代码示例来源:origin: mulesoft/mule
.then(invocation -> Optional.of(new MetadataCacheId(UUID.getUUID(), null)));
when(cacheIdGenerator.getIdForGlobalMetadata(any()))
.then(invocation -> Optional.of(new MetadataCacheId(UUID.getUUID(), null)));
when(cacheIdGenerator.getIdForMetadataKeys(any()))
.then(invocation -> Optional.of(new MetadataCacheId(UUID.getUUID(), null)));
代码示例来源:origin: mulesoft/mule
when(cacheIdGeneratorFactory.create(any(), any())).thenReturn(cacheIdGenerator);
when(cacheIdGenerator.getIdForComponentMetadata(any()))
.then(invocation -> Optional.of(new MetadataCacheId(UUID.getUUID(), null)));
when(cacheIdGenerator.getIdForGlobalMetadata(any()))
.then(invocation -> Optional.of(new MetadataCacheId(UUID.getUUID(), null)));
when(cacheIdGenerator.getIdForMetadataKeys(any()))
.then(invocation -> Optional.of(new MetadataCacheId(UUID.getUUID(), null)));
代码示例来源:origin: mulesoft/mule
@Test
public void arrivalOrderEvents() throws Exception {
EventGroup eventGroup = new EventGroup(UUID.getUUID(), muleContext);
eventGroup.initEventsStore(objectStore);
for (int i = 0; i < 3; i++) {
eventGroup.addEvent(eventBuilder(muleContext).message(Message.of("foo" + i)).build());
}
CoreEvent result = eventGroup.getMessageCollectionEvent();
Message message = result.getMessage();
List<Message> messages = (List<Message>) message.getPayload().getValue();
assertThat(messages.size(), is(3));
assertThat(messages.get(0).getPayload().getValue(), is("foo0"));
assertThat(messages.get(1).getPayload().getValue(), is("foo1"));
assertThat(messages.get(2).getPayload().getValue(), is("foo2"));
}
代码示例来源:origin: mulesoft/mule
@Test
public void eventGroupHashCode() throws ObjectStoreException {
String uuid = UUID.getUUID();
EventGroup g1 = new EventGroup(uuid, muleContext);
g1.initEventsStore(objectStore);
EventGroup g2 = new EventGroup(uuid, muleContext);
g2.initEventsStore(objectStore);
EventGroup g3 = new EventGroup(UUID.getUUID(), muleContext);
g3.initEventsStore(objectStore);
代码示例来源:origin: mulesoft/mule
@Test
public void eventGroupConversionToString() throws Exception {
EventGroup eg = new EventGroup(UUID.getUUID(), muleContext);
eg.initEventsStore(objectStore);
String es = eg.toString();
assertTrue(es.endsWith("events=0}"));
CoreEvent firstEvent = eventBuilder(muleContext).message(Message.of("foo")).build();
String firstId = firstEvent.getCorrelationId();
eg.addEvent(firstEvent);
es = eg.toString();
assertTrue(es.contains("events=1"));
assertTrue(es.endsWith("[" + firstId + "]}"));
CoreEvent secondEvent = eventBuilder(muleContext)
.message(Message.of("foo2"))
.build();
String secondId = secondEvent.getCorrelationId();
eg.addEvent(secondEvent);
es = eg.toString();
assertTrue(es.contains("events=2"));
assertTrue(es.contains(firstId));
assertTrue(es.contains(secondId));
}
代码示例来源:origin: mulesoft/mule
@Test
public void eventGroupComparison() throws InterruptedException, ObjectStoreException {
String uuid = UUID.getUUID();
EventGroup g1 = new EventGroup(uuid, muleContext);
g1.initEventsStore(objectStore);
EventGroup g2 = new EventGroup(uuid, muleContext);
g2.initEventsStore(objectStore);
EventGroup g3 = new EventGroup(UUID.getUUID(), muleContext);
g3.initEventsStore(objectStore);
代码示例来源:origin: mulesoft/mule
@Test
public void eventGroupConversionToArray() throws Exception {
EventGroup eg = new EventGroup(UUID.getUUID(), muleContext);
eg.initEventsStore(objectStore);
eg.addEvent(eventBuilder(muleContext).message(Message.of("foo1")).build());
eg.addEvent(eventBuilder(muleContext).message(Message.of("foo2")).build());
Object[] array1 = IteratorUtils.toArray(eg.iterator(false));
CoreEvent[] array2 = eg.toArray(false);
assertTrue(Arrays.equals(array1, array2));
}
代码示例来源:origin: mulesoft/mule
@Test
public void concurrentIteration() throws Exception {
EventGroup eg = new EventGroup(UUID.getUUID(), muleContext);
eg.initEventsStore(objectStore);
assertFalse(eg.iterator().hasNext());
eg.addEvent(eventBuilder(muleContext).message(Message.of("foo1")).build());
eg.addEvent(eventBuilder(muleContext).message(Message.of("foo2")).build());
assertTrue(eg.iterator().hasNext());
// now add events while we iterate over the group
Iterator<CoreEvent> i = eg.iterator();
assertNotNull(i.next());
eg.addEvent(eventBuilder(muleContext).message(Message.of("foo3")).build());
assertNotNull(i.next());
eg.addEvent(eventBuilder(muleContext).message(Message.of("foo4")).build());
assertFalse(i.hasNext());
// the added events should be in there though
assertEquals(4, eg.size());
}
代码示例来源:origin: mulesoft/mule
@Test
public void mergedSessions() throws Exception {
EventGroup eg = new EventGroup(UUID.getUUID(), muleContext);
eg.initEventsStore(objectStore);
assertFalse(eg.iterator().hasNext());
PrivilegedEvent event1 = (PrivilegedEvent) eventBuilder(muleContext).message(Message.of("foo1")).build();
PrivilegedEvent event2 = (PrivilegedEvent) eventBuilder(muleContext).message(Message.of("foo2")).build();
PrivilegedEvent event3 = (PrivilegedEvent) eventBuilder(muleContext).message(Message.of("foo3")).build();
event1.getSession().setProperty("key1", "value1");
event1.getSession().setProperty("key2", "value2");
event2.getSession().setProperty("KEY2", "value2NEW");
event2.getSession().setProperty("key3", "value3");
event3.getSession().setProperty("key4", "value4");
eg.addEvent(event1);
System.out.println(event1.getSession());
eg.addEvent(event2);
System.out.println(event2.getSession());
eg.addEvent(event3);
System.out.println(event3.getSession());
PrivilegedEvent result = (PrivilegedEvent) eg.getMessageCollectionEvent();
assertEquals("value1", result.getSession().getProperty("key1"));
// Cannot assert this because the ordering of events aren't ordered. See MULE-5998
// assertEquals("value2NEW", result.getSession().getProperty("key2"));
assertEquals("value3", result.getSession().getProperty("key3"));
assertEquals("value4", result.getSession().getProperty("key4"));
}
内容来源于网络,如有侵权,请联系作者删除!