Java Code Examples for junit.framework.Assert#assertSame()

The following examples show how to use junit.framework.Assert#assertSame() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: blueflood   File: EmitterTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void offOnlyClearsForGivenEvent() {

    // given
    emitter.on(testEventName, listener);
    emitter.on(testEventName2, listener);

    // precondition
    Assert.assertEquals(0, store.size());

    // when
    emitter.off(testEventName);
    emitter.emit(testEventName, event1);
    emitter.emit(testEventName2, event2);

    // then
    Assert.assertEquals(1, store.size());
    Assert.assertSame(event2, store.get(0));
}
 
Example 2
public void testDatedTransactionalSerialization() throws ParseException
{
    Timestamp businessDate = new Timestamp(timestampFormat.parse("2002-11-29 00:00:00").getTime());
    int balanceId = 1;
    TinyBalance tb = findTinyBalanceForBusinessDate(balanceId, businessDate);
    TinyBalance tb2 = (TinyBalance) serializeAndDeserialize(tb);
    Assert.assertSame(tb, tb2);

    tb = new TinyBalance(businessDate, InfinityTimestamp.getParaInfinity());
    tb.setAcmapCode("A");
    tb.setBalanceId(2000);
    tb.setQuantity(12.5);

    tb2 = (TinyBalance) serializeAndDeserialize(tb);
    Assert.assertNotSame(tb, tb2);
    Assert.assertEquals(tb.getBalanceId(), tb2.getBalanceId());
    Assert.assertEquals(tb.getAcmapCode(), tb2.getAcmapCode());
    Assert.assertEquals(tb.getQuantity(), tb2.getQuantity(), 0);
    Assert.assertEquals(tb.getBusinessDate(), tb2.getBusinessDate());
    Assert.assertEquals(tb.getProcessingDate(), tb2.getProcessingDate());
}
 
Example 3
@Test
public void testPopulatedAdsInsertion() throws InternalProviderData.ParseException {
    InternalProviderData internalProviderData = new InternalProviderData();
    ArrayList<Advertisement> advertisementArrayList = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
        // Insert 5 advertisements
        advertisementArrayList.add(
                new Advertisement.Builder()
                        .setRequestUrl("http://example.com/commercial.mp4")
                        .setStartTimeUtcMillis(i * 5000)
                        .setStopTimeUtcMillis((i + 1) * 5000)
                        .setType(Advertisement.TYPE_VAST)
                        .build());
    }
    internalProviderData.setAds(advertisementArrayList);
    Assert.assertSame("Ad list should have 5 items", 5, internalProviderData.getAds().size());
    Assert.assertTrue(
            "Ad start time should be 5000ms",
            (5000L - internalProviderData.getAds().get(1).getStartTimeUtcMillis()) <= 0);
    Assert.assertSame(
            "Ad type should be VAST",
            Advertisement.TYPE_VAST,
            internalProviderData.getAds().get(2).getType());
}
 
Example 4
Source Project: blueflood   File: EmitterTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void emitOnlyTriggersForGivenEvent2() {

    // given
    emitter.on(testEventName, listener);
    emitter.on(testEventName2, listener);

    // precondition
    Assert.assertEquals(0, store.size());

    // when
    emitter.emit(testEventName2, event2);

    // then
    Assert.assertEquals(1, store.size());
    Assert.assertSame(event2, store.get(0));
}
 
Example 5
@Test
public void testMoveToFolder() throws Exception {
	User user = userDao.findByUsername("admin");
	Document doc = docDao.findById(1);
	Assert.assertNotNull(doc);
	Folder folder = doc.getFolder();
	Assert.assertEquals(6, folder.getId());

	DocumentHistory transaction = new DocumentHistory();
	transaction.setFolderId(6L);
	transaction.setUser(user);
	transaction.setDocId(doc.getId());
	transaction.setUserId(1L);
	transaction.setNotified(0);
	transaction.setComment("pippo_reason");

	Folder newFolder = folderDao.findById(6);
	docDao.initialize(doc);
	documentManager.moveToFolder(doc, newFolder, transaction);
	Assert.assertSame(1L, doc.getId());
	Assert.assertEquals(newFolder, doc.getFolder());
}
 
Example 6
@Test
public void emitTriggersListenerInSameOrder1() {

    // given
    emitter.on(testEventName, listener);
    emitter.on(testEventName2, listener);

    // precondition
    Assert.assertEquals(0, store.size());

    // when
    emitter.emit(testEventName, event1);
    emitter.emit(testEventName2, event2);

    // then
    Assert.assertEquals(2, store.size());
    Assert.assertSame(event1, store.get(0));
    Assert.assertSame(event2, store.get(1));
}
 
Example 7
Source Project: consulo   File: HugeArrayTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testToArray() {
  myArray.put(1, "a");
  myArray.put(15, "b");
  Object[] array = myArray.toArray();
  Assert.assertEquals(16, array.length);
  String[] expectedArray = new String[16];
  Assert.assertSame(expectedArray, myArray.toArray(expectedArray));
}
 
Example 8
@Test
public void testDefaultConfigServer() throws Exception {
  LogSearchConfigServer config = LogSearchConfigFactory.createLogSearchConfigServer( Collections.<String, String> emptyMap(),
      LogSearchConfigServerClass1.class);
  
  Assert.assertSame(config.getClass(), LogSearchConfigServerClass1.class);
}
 
Example 9
/**
 * 创建4个报文,第二个报文的type被截断,后面的报文type不被截断,测试是否能读到type
 * 
 * @throws IOException
 */
@Test
public void testTypeParser() throws IOException {
    List<Byte> typeList = Arrays.asList(MySQLPacket.AUTH_PACKET, MySQLPacket.COM_INIT_DB,
            MySQLPacket.COM_QUERY, MySQLPacket.COM_QUIT);
    ByteBufferArray bufArray = splitPackage(createMultiPackage(Arrays.asList(16, 30, 40, 20), typeList), 26);
    Assert.assertEquals(4, bufArray.getCurPacageIndex());
    for (int i = 0; i < 4; i++) {
        Assert.assertSame(typeList.get(i), bufArray.getPacageType(i));
    }
}
 
Example 10
Source Project: consulo   File: ProjectViewTestUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void checkGetParentConsistency(AbstractTreeStructure structure, Object from) {
  Object[] childElements = structure.getChildElements(from);
  for (Object childElement : childElements) {
    Assert.assertSame(from, structure.getParentElement(childElement));
    checkGetParentConsistency(structure, childElement);
  }
}
 
Example 11
@Test()
public void testInvokeNoExceptoin() {
    
    resetInvoker1ToNoException();
    
    FailfastClusterInvoker<FailfastClusterInvokerTest> invoker = new FailfastClusterInvoker<FailfastClusterInvokerTest>(dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 12
@Test()
public void testInvokeNoExceptoin() {
    
    resetInvoker1ToNoException();
    
    FailfastClusterInvoker<FailfastClusterInvokerTest> invoker = new FailfastClusterInvoker<FailfastClusterInvokerTest>(dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 13
@Test()
public void testInvokeNoExceptoin() {

    resetInvokerToNoException();

    FailbackClusterInvoker<FailbackClusterInvokerTest> invoker = new FailbackClusterInvoker<FailbackClusterInvokerTest>(
                                                                                                                        dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 14
public void testNullCombination() {
    registerHolidays("US", createUSHolidayCalendar());
    final DateCalculator<E> cal1 = newDateCalculator("US", HolidayHandlerType.FORWARD);
    final E localDate = newDate("2006-08-08");
    cal1.setStartDate(localDate);

    final DateCalculator<E> combo = cal1.combine(null);
    Assert.assertSame("same", combo, cal1);
    Assert.assertEquals("Combo name", "US", combo.getName());
    Assert.assertEquals("Combo type", HolidayHandlerType.FORWARD, combo.getHolidayHandlerType());
    Assert.assertEquals("start", localDate, combo.getStartDate());
    Assert.assertEquals("currentDate", localDate, combo.getCurrentBusinessDate());
    Assert.assertEquals("Holidays", 3, combo.getHolidayCalendar().getHolidays().size());
}
 
Example 15
Source Project: tinybus   File: Callbacks.java    License: Apache License 2.0 4 votes vote down vote up
public void assertNullEvent() {
	Assert.assertEquals(1, mEvents.size());
	Assert.assertSame(null, mEvents.get(0));
}
 
Example 16
Source Project: coming   File: Nopol2017_009_t.java    License: MIT License 4 votes vote down vote up
public static JSType assertResolvesToSame(JSType type) {
  Assert.assertSame(type, assertValidResolve(type));
  return type;
}
 
Example 17
Source Project: coming   File: Nopol2017_0053_t.java    License: MIT License 4 votes vote down vote up
public static JSType assertResolvesToSame(JSType type) {
  Assert.assertSame(type, assertValidResolve(type));
  return type;
}
 
Example 18
@Test
public void testEmptyAdsInsertion() throws InternalProviderData.ParseException {
    InternalProviderData internalProviderData = new InternalProviderData();
    internalProviderData.setAds(new ArrayList<Advertisement>());
    Assert.assertSame("Ad list should be empty", 0, internalProviderData.getAds().size());
}
 
Example 19
@Test
public void testGetPlaylistControl() {
    Assert.assertSame(session, session.getPlaylistControl());
}
 
Example 20
Source Project: JTAF-XCore   File: IgnoreErrorsAssert.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Asserts that two objects refer to the same object. If they are not, a
 * Throwable is stored in the accumulator with the given message.
 * 
 * @param message
 *            message to be thrown if not the same
 * @param expected
 *            expected object
 * @param actual
 *            actual object that is being checked
 */
@SuppressWarnings("deprecation")
public void assertSame(String message, Object expected, Object actual) {
    try {
        Assert.assertSame(message, expected, actual);
    } catch (Throwable e) {
        ea.addError(e);
    }
}