当前位置: 首页>>代码示例>>Java>>正文


Java Collections.singleton方法代码示例

本文整理汇总了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);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:ExpressionEvaluatorTests.java

示例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());
}
 
开发者ID:Doist,项目名称:JobSchedulerCompat,代码行数:35,代码来源:JobStoreTest.java

示例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));
}
 
开发者ID:Doist,项目名称:JobSchedulerCompat,代码行数:15,代码来源:AlarmSchedulerTest.java

示例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);
}
 
开发者ID:openid,项目名称:AppAuth-Android,代码行数:11,代码来源:BrowserDescriptorTest.java

示例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;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:11,代码来源:ExpressionEvaluatorTests.java

示例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));
}
 
开发者ID:Bedework,项目名称:exchange-ws-client,代码行数:35,代码来源:TimeZoneIntegrationTest.java

示例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));
}
 
开发者ID:Bedework,项目名称:exchange-ws-client,代码行数:54,代码来源:TimeZoneIntegrationTest.java


注:本文中的edu.emory.mathcs.backport.java.util.Collections.singleton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。