List of usage examples for junit.framework Assert assertSame
static public void assertSame(Object expected, Object actual)
From source file:com.metamx.tranquility.kafka.writer.WriterControllerTest.java
@Test public void testGetWriter() { Assert.assertEquals(0, writerController.mockWriters.size()); TranquilityEventWriter writerTwitter = writerController.getWriter("twitter"); Assert.assertEquals(1, writerController.mockWriters.size()); Assert.assertSame(writerTwitter, writerController.mockWriters.get("twitter")); Assert.assertSame(writerTwitter, writerController.getWriter("twitter")); TranquilityEventWriter writerTest0 = writerController.getWriter("test0"); TranquilityEventWriter writerTest1 = writerController.getWriter("test1"); Assert.assertEquals(3, writerController.mockWriters.size()); Assert.assertSame(writerTest0, writerController.getWriter("test0")); Assert.assertSame(writerTest1, writerController.getWriter("test1")); }
From source file:com.connectsdk.service.FireTVServiceTest.java
@Test public void testGetMediaPlayer() { Assert.assertSame(service, service.getMediaPlayer()); }
From source file:org.apache.ambari.server.controller.metrics.timeline.cache.TimelineMetricCacheTest.java
@Test public void testTimelineMetricCacheProviderGets() throws Exception { Configuration configuration = createNiceMock(Configuration.class); expect(configuration.getMetricCacheTTLSeconds()).andReturn(3600); expect(configuration.getMetricCacheIdleSeconds()).andReturn(100); expect(configuration.getMetricsCacheManagerHeapPercent()).andReturn("10%").anyTimes(); replay(configuration);/* w w w. ja v a 2s . c o m*/ final long now = System.currentTimeMillis(); TimelineMetrics metrics = new TimelineMetrics(); TimelineMetric timelineMetric = new TimelineMetric(); timelineMetric.setMetricName("cpu_user"); timelineMetric.setAppId("app1"); TreeMap<Long, Double> metricValues = new TreeMap<Long, Double>(); metricValues.put(now + 100, 1.0); metricValues.put(now + 200, 2.0); metricValues.put(now + 300, 3.0); timelineMetric.setMetricValues(metricValues); metrics.getMetrics().add(timelineMetric); TimelineMetricCacheEntryFactory cacheEntryFactory = createMock(TimelineMetricCacheEntryFactory.class); TimelineAppMetricCacheKey queryKey = new TimelineAppMetricCacheKey(Collections.singleton("cpu_user"), "app1", new TemporalInfoImpl(now, now + 1000, 1)); TimelineMetricsCacheValue value = new TimelineMetricsCacheValue(now, now + 1000, metrics, null); TimelineAppMetricCacheKey testKey = new TimelineAppMetricCacheKey(Collections.singleton("cpu_user"), "app1", new TemporalInfoImpl(now, now + 2000, 1)); expect(cacheEntryFactory.createEntry(anyObject())).andReturn(value); cacheEntryFactory.updateEntryValue(testKey, value); expectLastCall().once(); replay(cacheEntryFactory); TimelineMetricCacheProvider cacheProvider = createMockBuilder(TimelineMetricCacheProvider.class) .addMockedMethod("createCacheConfiguration").withConstructor(configuration, cacheEntryFactory) .createNiceMock(); expect(cacheProvider.createCacheConfiguration()).andReturn(createTestCacheConfiguration(configuration)) .anyTimes(); replay(cacheProvider); TimelineMetricCache cache = cacheProvider.getTimelineMetricsCache(); // call to get metrics = cache.getAppTimelineMetricsFromCache(queryKey); List<TimelineMetric> metricsList = metrics.getMetrics(); Assert.assertEquals(1, metricsList.size()); TimelineMetric metric = metricsList.iterator().next(); Assert.assertEquals("cpu_user", metric.getMetricName()); Assert.assertEquals("app1", metric.getAppId()); Assert.assertSame(metricValues, metric.getMetricValues()); // call to update with new key metrics = cache.getAppTimelineMetricsFromCache(testKey); metricsList = metrics.getMetrics(); Assert.assertEquals(1, metricsList.size()); Assert.assertEquals("cpu_user", metric.getMetricName()); Assert.assertEquals("app1", metric.getAppId()); Assert.assertSame(metricValues, metric.getMetricValues()); verify(configuration, cacheEntryFactory); }
From source file:de.hybris.platform.catalog.jalo.synchronization.ItemCopyCreatorTest.java
@Test public void testUpdatingNullValues() throws JaloBusinessException { final UnitModel u = modelService.create(UnitModel.class); u.setCode("unit-" + System.nanoTime()); u.setUnitType("type"); u.setConversion(Double.valueOf(1.0)); modelService.save(u);// ww w . j a v a 2 s . co m final ProductModel p = modelService.create(ProductModel.class); p.setCatalogVersion((CatalogVersionModel) modelService.get(src)); p.setCode("foo-" + System.nanoTime()); p.setMinOrderQuantity(12); p.setUnit(u); p.setApprovalStatus(ArticleApprovalStatus.APPROVED); modelService.save(p); final Product pJalo = modelService.getSource(p); // 1. create copy -> values are non-null final Product pCopyJalo = (Product) new CatalogVersionSyncCopyContext(syncJob, syncCronJob, worker) { @Override protected Set<Language> getTargetLanguages() { return jaloSession.getC2LManager().getAllLanguages(); } @Override protected SyncSchedule getCurrentSchedule() { return new SyncSchedule(pJalo.getPK(), null, null, Collections.EMPTY_SET, Collections.EMPTY_MAP); } }.copy(pJalo); Assert.assertNotNull("Product not copied", pCopyJalo); final ProductModel pCopy = modelService.get(pCopyJalo); Assert.assertEquals(p.getCode(), pCopy.getCode()); Assert.assertEquals(p.getMinOrderQuantity(), pCopy.getMinOrderQuantity()); Assert.assertEquals(p.getApprovalStatus(), pCopy.getApprovalStatus()); Assert.assertEquals(p.getUnit(), pCopy.getUnit()); // 2. change original -> some values are null now p.setUnit(null); p.setMinOrderQuantity(null); modelService.save(p); Assert.assertNull(p.getMinOrderQuantity()); Assert.assertNull(p.getUnit()); // 3. copy again -> copy should have null values too final Product pCopyJalo2 = (Product) new CatalogVersionSyncCopyContext(syncJob, syncCronJob, worker) { @Override protected Set<Language> getTargetLanguages() { return jaloSession.getC2LManager().getAllLanguages(); } @Override protected SyncSchedule getCurrentSchedule() { return new SyncSchedule(pJalo.getPK(), pCopyJalo.getPK(), null, Collections.EMPTY_SET, Collections.EMPTY_MAP); } }.copy(pJalo); Assert.assertNotNull("Product not copied", pCopyJalo2); final ProductModel pCopy2 = modelService.get(pCopyJalo2); Assert.assertSame(pCopy, pCopy2); modelService.refresh(pCopy2); // unchanged ? Assert.assertEquals(p.getCode(), pCopy2.getCode()); Assert.assertEquals(p.getApprovalStatus(), pCopy2.getApprovalStatus()); // null'ed ? Assert.assertNull(pCopy2.getUnit()); Assert.assertNull(pCopy2.getMinOrderQuantity()); }
From source file:org.motechproject.mobile.core.dao.hibernate.GatewayRequestDAOImplTest.java
/** * Test of getById method, of class GatewayRequestDAOImpl. *///from ww w. j a va2 s. co m @Test public void testGetById() { System.out.println("testing FindById"); GatewayRequest result = (GatewayRequest) mDDAO.getById(md1.getId()); System.out.println("the date lastModified: " + result.getLastModified()); Assert.assertSame(md1, result); Assert.assertEquals(md1.getId(), result.getId()); Assert.assertEquals(md1.getMessage(), result.getMessage()); Assert.assertEquals(md1.getRecipientsNumber(), result.getRecipientsNumber()); Assert.assertEquals(md1.getDateFrom(), result.getDateFrom()); System.out.println(result.toString()); }
From source file:com.connectsdk.service.FireTVServiceTest.java
@Test public void testGetMediaControl() { Assert.assertSame(service, service.getMediaControl()); }
From source file:com.link_intersystems.lang.reflect.Class2Test.java
@Test public void getArrayType2Cached() { Class2<?> genericDefinition = Class2.get(GenericClassWithBeanType.class); Class2<?> asArrayType1 = genericDefinition.getArrayType2(); Class2<?> asArrayType2 = genericDefinition.getArrayType2(); Assert.assertSame(asArrayType1, asArrayType2); }
From source file:com.connectsdk.service.FireTVServiceTest.java
@Test public void testSubscribePlayStateShouldBeSingle() { MediaControl.PlayStateListener listener = Mockito.mock(MediaControl.PlayStateListener.class); ServiceSubscription<MediaControl.PlayStateListener> subscription = service.subscribePlayState(listener); ServiceSubscription<MediaControl.PlayStateListener> subscription2 = service.subscribePlayState(listener); Assert.assertSame(subscription, subscription2); }
From source file:com.connectsdk.service.FireTVServiceTest.java
private void verifyLauncherListener(MediaPlayer.LaunchListener launchListener) { ArgumentCaptor<MediaPlayer.MediaLaunchObject> argMediaObject = ArgumentCaptor .forClass(MediaPlayer.MediaLaunchObject.class); Mockito.verify(launchListener).onSuccess(argMediaObject.capture()); MediaPlayer.MediaLaunchObject mediaLaunchObject = argMediaObject.getValue(); Assert.assertSame(service, mediaLaunchObject.mediaControl); Assert.assertEquals(null, mediaLaunchObject.playlistControl); Assert.assertEquals(LaunchSession.LaunchSessionType.Media, mediaLaunchObject.launchSession.getSessionType()); Assert.assertSame(service, mediaLaunchObject.launchSession.getService()); }
From source file:com.amazonaws.services.kinesis.clientlibrary.lib.worker.ShardSyncerTest.java
/** * Test method for constructShardIdToShardMap. * * .//from w w w .ja v a 2 s . com */ @Test public final void testConstructShardIdToShardMap() { List<Shard> shards = new ArrayList<Shard>(2); shards.add(ShardObjectHelper.newShard("shardId-0", null, null, null)); shards.add(ShardObjectHelper.newShard("shardId-1", null, null, null)); Map<String, Shard> shardIdToShardMap = ShardSyncer.constructShardIdToShardMap(shards); Assert.assertEquals(shards.size(), shardIdToShardMap.size()); for (Shard shard : shards) { Assert.assertSame(shard, shardIdToShardMap.get(shard.getShardId())); } }