本文整理汇总了Java中edu.emory.mathcs.backport.java.util.Collections.singleton方法的典型用法代码示例。如果您正苦于以下问题:Java Collections.singleton方法的具体用法?Java Collections.singleton怎么用?Java Collections.singleton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.emory.mathcs.backport.java.util.Collections
的用法示例。
在下文中一共展示了Collections.singleton方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMultipleCachingEval
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testMultipleCachingEval() throws Exception {
AnnotatedClass target = new AnnotatedClass();
Method method = ReflectionUtils.findMethod(AnnotatedClass.class, "multipleCaching", Object.class,
Object.class);
Object[] args = new Object[] { new Object(), new Object() };
Collection<Cache> map = Collections.singleton(new ConcurrentMapCache("test"));
EvaluationContext evalCtx = eval.createEvaluationContext(map, method, args, target, target.getClass());
Collection<CacheOperation> ops = getOps("multipleCaching");
Iterator<CacheOperation> it = ops.iterator();
Object keyA = eval.key(it.next().getKey(), method, evalCtx);
Object keyB = eval.key(it.next().getKey(), method, evalCtx);
assertEquals(args[0], keyA);
assertEquals(args[1], keyB);
}
示例2: testCompat
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testCompat() {
Uri uri = Uri.parse("doist.com");
String authority = "com.doist";
JobInfo.Builder builder =
JobCreator.create(context, 103)
.addTriggerContentUri(new JobInfo.TriggerContentUri(uri, 0))
.setTriggerContentUpdateDelay(TimeUnit.SECONDS.toMillis(5))
.setTriggerContentMaxDelay(TimeUnit.SECONDS.toMillis(30));
Bundle transientExtras = new Bundle();
transientExtras.putBoolean("test", true);
builder.setTransientExtras(transientExtras);
JobInfo job = builder.build();
JobStatus jobStatus = JobStatus.createFromJobInfo(job, "noop");
jobStatus.changedUris = Collections.singleton(uri);
jobStatus.changedAuthorities = Collections.singleton(authority);
jobStore.add(jobStatus);
waitForJobStoreWrite();
JobStore.JobSet jobStatusSet = new JobStore.JobSet();
jobStore.readJobMapFromDisk(jobStatusSet);
assertEquals("Incorrect # of persisted tasks.", 1, jobStatusSet.size());
JobStatus loaded = jobStatusSet.getJobs().iterator().next();
assertEquals(jobStatus.changedUris, loaded.changedUris);
assertEquals(jobStatus.changedAuthorities, loaded.changedAuthorities);
assertJobInfoEquals(job, loaded.getJob());
}
示例3: testJobRescheduledPassesUriAuthorityForward
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
@Test
public void testJobRescheduledPassesUriAuthorityForward() {
Uri changedUri = job.getTriggerContentUris()[0].getUri();
String changedAuthority = changedUri.getAuthority();
JobStatus failedJobStatus = new JobStatus(job, AlarmScheduler.TAG, 0, 0);
failedJobStatus.changedUris = Collections.singleton(changedUri);
failedJobStatus.changedAuthorities = Collections.singleton(changedAuthority);
JobStatus newJobStatus = new JobStatus(job, AlarmScheduler.TAG, 0, 0);
scheduler.onJobRescheduled(newJobStatus, failedJobStatus);
assertThat(newJobStatus.changedUris, hasItem(changedUri));
assertThat(newJobStatus.changedAuthorities, hasItem(changedAuthority));
}
示例4: testEquals_differentSignatures
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
@Test
public void testEquals_differentSignatures() {
BrowserDescriptor a = Browsers.Chrome.standaloneBrowser("45");
BrowserDescriptor b = new BrowserDescriptor(
a.packageName,
Collections.<String>singleton("DIFFERENT_SIGNATURE"),
a.version,
a.useCustomTab);
assertThat(a).isNotEqualTo(b);
}
示例5: createEvaluationContext
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
private EvaluationContext createEvaluationContext(Object result) {
AnnotatedClass target = new AnnotatedClass();
Method method = ReflectionUtils.findMethod(AnnotatedClass.class, "multipleCaching", Object.class,
Object.class);
Object[] args = new Object[] { new Object(), new Object() };
@SuppressWarnings("unchecked")
Collection<Cache> map = Collections.singleton(new ConcurrentMapCache("test"));
EvaluationContext context = eval.createEvaluationContext(map, method, args, target, target.getClass(), result);
return context;
}
示例6: createGetDeleteCalendarItemBadTimeZone
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
@Test
public void createGetDeleteCalendarItemBadTimeZone() throws DatatypeConfigurationException{
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:test-contexts/exchangeContext.xml");
RequestServerTimeZoneInterceptor timeZoneInterceptor = context.getBean(RequestServerTimeZoneInterceptor.class);
ExchangeWebServices ews = context.getBean(ExchangeWebServices.class);
BaseExchangeCalendarDataDao exchangeCalendarDao = context.getBean(BaseExchangeCalendarDataDao.class);
exchangeCalendarDao.setWebServices(ews);
//XMLGregorianCalendar is sortof backed by a gregorian calendar, date/times should reflect default jvm timezone
XMLGregorianCalendar xmlStart = DateHelp.getXMLGregorianCalendarNow(java.util.TimeZone.getTimeZone("Pacific/Palau"));
CalendarItemType calendarItem = new CalendarItemType();
calendarItem.setStart(xmlStart);
ItemIdType itemId = exchangeCalendarDao.createCalendarItem(upn, calendarItem);
assertNotNull(itemId);
Set<ItemIdType> itemIds = Collections.singleton(itemId);
Set<CalendarItemType> calendarItems = exchangeCalendarDao.getCalendarItems(upn, itemIds);
assertNotNull(calendarItems);
CalendarItemType createdCalendarItem = DataAccessUtils.singleResult(calendarItems);
assertNotNull(createdCalendarItem);
XMLGregorianCalendar createdCalendarItemStart = createdCalendarItem.getStart();
assertNotNull(createdCalendarItemStart);
//because the XMLGregorian calnedar was created with a time zone other than system default
assertFalse(xmlStart.getTimezone() == createdCalendarItemStart.getTimezone());
assertTrue(DateHelp.withinOneSecond(xmlStart, createdCalendarItemStart));
assertTrue(exchangeCalendarDao.deleteCalendarItems(upn, itemIds));
}
示例7: createGetDeleteCalendarItem
import edu.emory.mathcs.backport.java.util.Collections; //导入方法依赖的package包/类
@Test
public void createGetDeleteCalendarItem() throws DatatypeConfigurationException{
TimeZone utcTimeZone = TimeZone.getTimeZone(RequestServerTimeZoneInterceptor.FALLBACK_TIMEZONE_ID);
TimeZone.setDefault(utcTimeZone);
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:test-contexts/exchangeContext.xml");
RequestServerTimeZoneInterceptor timeZoneInterceptor = context.getBean(RequestServerTimeZoneInterceptor.class);
ExchangeWebServices ews = context.getBean(ExchangeWebServices.class);
BaseExchangeCalendarDataDao exchangeCalendarDao = context.getBean(BaseExchangeCalendarDataDao.class);
exchangeCalendarDao.setWebServices(ews);
assertEquals(TimeZone.getDefault(), utcTimeZone);
//XMLGregorianCalendar is sortof backed by a gregorian calendar, date/times should reflect default jvm timezone
XMLGregorianCalendar xmlStart = DateHelp.getXMLGregorianCalendarNow();
CalendarItemType calendarItem = new CalendarItemType();
calendarItem.setStart(xmlStart);
ItemIdType itemId = exchangeCalendarDao.createCalendarItem(upn, calendarItem);
assertNotNull(itemId);
Set<ItemIdType> itemIds = Collections.singleton(itemId);
Set<CalendarItemType> calendarItems = exchangeCalendarDao.getCalendarItems(upn, itemIds);
assertNotNull(calendarItems);
CalendarItemType createdCalendarItem = DataAccessUtils.singleResult(calendarItems);
assertNotNull(createdCalendarItem);
XMLGregorianCalendar createdCalendarItemStart = createdCalendarItem.getStart();
assertNotNull(createdCalendarItemStart);
assertEquals(xmlStart.getTimezone(), createdCalendarItemStart.getTimezone());
//nope! tzDisplayName = createdCalendarItem.getTimeZone()
//assertEquals(RequestServerTimeZoneInterceptor.FALLBACK_TIMEZONE_ID, createdCalendarItem.getTimeZone());
assertEquals(xmlStart.getEon(), createdCalendarItemStart.getEon());
assertEquals(xmlStart.getEonAndYear(), createdCalendarItemStart.getEonAndYear());
assertEquals(xmlStart.getYear(), createdCalendarItemStart.getYear());
assertEquals(xmlStart.getMonth(), createdCalendarItemStart.getMonth());
assertEquals(xmlStart.getDay(), createdCalendarItemStart.getDay());
assertEquals(xmlStart.getHour(), createdCalendarItemStart.getHour());
assertEquals(xmlStart.getMinute(), createdCalendarItemStart.getMinute());
assertEquals(xmlStart.getSecond(), createdCalendarItemStart.getSecond());
//nope! always seems to be a slight variation
//assertEquals(xmlStart.toGregorianCalendar().getTimeInMillis(), createdCalendarItemStart.toGregorianCalendar().getTimeInMillis());
//assertEquals(xmlStart.getMillisecond(), createdCalendarItemStart.getMillisecond());
//assertEquals(xmlStart.getFractionalSecond(), createdCalendarItemStart.getFractionalSecond());
assertTrue(DateHelp.withinOneSecond(xmlStart, createdCalendarItemStart));
assertTrue(exchangeCalendarDao.deleteCalendarItems(upn, itemIds));
}