junit.framework.TestCase.assertEquals()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(282)

本文整理了Java中junit.framework.TestCase.assertEquals()方法的一些代码示例,展示了TestCase.assertEquals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestCase.assertEquals()方法的具体详情如下:
包路径:junit.framework.TestCase
类名称:TestCase
方法名:assertEquals

TestCase.assertEquals介绍

[英]Asserts that two bytes are equal.
[中]断言两个字节相等。

代码示例

代码示例来源:origin: google/guava

/**
 * Asserts that two iterators contain elements in tandem.
 *
 * <p>This test only works with iterators that iterate over a finite set.
 */
public static void assertIteratorsInOrder(
  Iterator<?> expectedIterator, Iterator<?> actualIterator) {
 int i = 0;
 while (expectedIterator.hasNext()) {
  Object expected = expectedIterator.next();
  assertTrue(
    "index " + i + " expected <" + expected + "., actual is exhausted",
    actualIterator.hasNext());
  Object actual = actualIterator.next();
  assertEquals("index " + i, expected, actual);
  i++;
 }
 if (actualIterator.hasNext()) {
  fail("index " + i + ", expected is exhausted, actual <" + actualIterator.next() + ">");
 }
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void pathWithDuplicateSlashes() {
  DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory();
  URI uri = factory.expand("/foo/////////bar");
  assertEquals("/foo/bar", uri.toString());
}

代码示例来源:origin: LitePalFramework/LitePal

@Test
public void testQueryBySQLWithPlaceHolder() {
  Cursor cursor = LitePal.findBySQL(
      "select * from " + bookTable + " where id=? and bookname=? and pages=?",
      String.valueOf(book.getId()), "数据库", "300");
  assertTrue(cursor.getCount() == 1);
  cursor.moveToFirst();
  String bookName = cursor.getString(cursor.getColumnIndexOrThrow("bookname"));
  int pages = cursor.getInt(cursor.getColumnIndexOrThrow("pages"));
  assertEquals(bookName, "数据库");
  assertEquals(pages, 300);
  cursor.close();
}

代码示例来源:origin: igniterealtime/Smack

@Test
  public void t11_key_fetchDateTest() throws IOException {

    Map<OpenPgpV4Fingerprint, Date> fetchDates1 = openPgpStoreInstance1.getPublicKeyFetchDates(alice);
    assertNotNull(fetchDates1);
    assertTrue(fetchDates1.isEmpty());

    Date date1 = new Date(85092830954L);
    fetchDates1.put(finger1, date1);
    openPgpStoreInstance1.setPublicKeyFetchDates(alice, fetchDates1);

    Map<OpenPgpV4Fingerprint, Date> fetchDates2 = openPgpStoreInstance1.getPublicKeyFetchDates(alice);
    assertNotNull(fetchDates2);
    assertFalse(fetchDates2.isEmpty());
    assertEquals(fetchDates1, fetchDates2);

    Map<OpenPgpV4Fingerprint, Date> fetchDates3 = openPgpStoreInstance2.getPublicKeyFetchDates(alice);
    assertNotNull(fetchDates3);
    assertEquals(fetchDates1, fetchDates3);

    openPgpStoreInstance1.setPublicKeyFetchDates(alice, null);
    openPgpStoreInstance2.setPublicKeyFetchDates(alice, null);

    assertNotNull(openPgpStoreInstance1.getPublicKeyFetchDates(alice));
    assertTrue(openPgpStoreInstance1.getPublicKeyFetchDates(alice).isEmpty());
  }
}

代码示例来源:origin: DSRCorporation/imf-conversion

@Test
public void testGenerateSampleChapters() throws Exception {
  File chaptersFile = new File(TemplateParameterContextCreator.getWorkingDir(), "sample_chapters.xml");
  ChaptersXmlProvider.generateSampleXml(chaptersFile);
  assertEquals(new File(TemplateParameterContextCreator.getWorkingDir(), "sample_chapters.xml"), chaptersFile);
  new ChaptersXmlProvider(chaptersFile);
}

代码示例来源:origin: igniterealtime/Smack

@Test
public void generateOmemoPreKeysIdsMatchAndNoNullValues() {
  TreeMap<Integer, T_PreKey> pks =
      keyUtil.generateOmemoPreKeys(1, 20);
  for (int i = 1; i <= 20; i++) {
    assertEquals("PreKeyIds must correspond the requested ids.", Integer.valueOf(i), pks.firstKey());
    assertNotNull("All PreKeys must not be null.", pks.get(pks.firstKey()));
    pks.remove(pks.firstKey());
  }
}

代码示例来源:origin: approvals/ApprovalTests.Java

@Override
public void report(String received, String approved) throws Exception
{
 String aText = new File(approved).exists() ? FileUtils.readFile(approved) : "";
 String rText = FileUtils.readFile(received);
 String approveCommand = "To approve run : " + ClipboardReporter.getAcceptApprovalText(received, approved);
 System.out.println(approveCommand);
 TestCase.assertEquals(aText, rText);
}
@Override

代码示例来源:origin: org.geoserver/gs-wcs2_0

@Test
public void testGetCoverageNativeFormat() throws Exception {
  MockHttpServletResponse response =
      getAsServletResponse(
          "wcs?request=GetCoverage&service=WCS&version=2.0.1"
              + "&coverageId=sf__rain");
  // we got back an ArcGrid response
  assertEquals("text/plain", response.getContentType());
}

代码示例来源:origin: org.geoserver/gs-wcs2_0

private void assertOriginPixelColor(MockHttpServletResponse response, int[] expected)
      throws DataSourceException, IOException {
    assertEquals("image/tiff", response.getContentType());
    byte[] bytes = response.getContentAsByteArray();

    GeoTiffReader reader = new GeoTiffReader(new ByteArrayInputStream(bytes));
    GridCoverage2D coverage = reader.read(null);
    Raster raster = coverage.getRenderedImage().getData();
    int[] pixel = new int[3];
    raster.getPixel(0, 0, pixel);
    assertThat(pixel, equalTo(expected));
  }
}

代码示例来源:origin: igniterealtime/Smack

@Test
public void t10_meta_emptyStoreTest() throws IOException {
  assertNotNull(openPgpStoreInstance1.getAnnouncedFingerprintsOf(alice));
  assertTrue(openPgpStoreInstance1.getAnnouncedFingerprintsOf(alice).isEmpty());
  Map<OpenPgpV4Fingerprint, Date> map = new HashMap<>();
  Date date1 = new Date(12354563423L);
  Date date2 = new Date(8274729879812L);
  map.put(finger1, date1);
  map.put(finger2, date2);
  openPgpStoreInstance1.setAnnouncedFingerprintsOf(alice, map);
  assertFalse(openPgpStoreInstance1.getAnnouncedFingerprintsOf(alice).isEmpty());
  assertEquals(map, openPgpStoreInstance1.getAnnouncedFingerprintsOf(alice));
  assertTrue(openPgpStoreInstance1.getAnnouncedFingerprintsOf(bob).isEmpty());
  assertFalse(openPgpStoreInstance2.getAnnouncedFingerprintsOf(alice).isEmpty());
  assertEquals(map, openPgpStoreInstance2.getAnnouncedFingerprintsOf(alice));
  openPgpStoreInstance1.setAnnouncedFingerprintsOf(alice, Collections.<OpenPgpV4Fingerprint, Date>emptyMap());
  openPgpStoreInstance2.setAnnouncedFingerprintsOf(alice, Collections.<OpenPgpV4Fingerprint, Date>emptyMap());
}

代码示例来源:origin: DSRCorporation/imf-conversion

@Test
public void testSaveCorrectMetadata() throws Exception {
  FilmMetadataXmlProvider provider = new FilmMetadataXmlProvider(MetadataUtils.getCorrectFilmMetadataXml());
  File itmspDir = TestUtils.createDirectory(TemplateParameterContextCreator.getWorkingDir(), "correct.itmsp");
  File savedMetadata = provider.saveMetadata(itmspDir);
  assertEquals(new File(itmspDir, "metadata.xml"), savedMetadata);
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void defaultUriVarsSpr14147() {
  Map<String, String> defaultUriVars = new HashMap<>(2);
  defaultUriVars.put("host", "api.example.com");
  defaultUriVars.put("port", "443");
  DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory();
  factory.setDefaultUriVariables(defaultUriVars);
  URI uri = factory.expand("https://{host}:{port}/v42/customers/{id}", singletonMap("id", 123L));
  assertEquals("https://api.example.com:443/v42/customers/123", uri.toString());
}

代码示例来源:origin: spring-projects/spring-framework

@Test // SPR-17410
public void writePublisherError() {
  // Turn off writing so next item will be cached
  this.processor.setWritePossible(false);
  DataBuffer buffer = mock(DataBuffer.class);
  this.processor.onNext(buffer);
  // Send error while item cached
  this.processor.onError(new IllegalStateException());
  assertNotNull("Error should flow to result publisher", this.resultSubscriber.getError());
  assertEquals(1, this.processor.getDiscardedBuffers().size());
  assertSame(buffer, this.processor.getDiscardedBuffers().get(0));
}

代码示例来源:origin: io.snappydata/gemfire-hydra-tests

public void run2() throws CacheException {
  File d = new File("DynamicRegionData" + ProcessMgr.getProcessId());
  d.mkdirs();
  DynamicRegionFactory.get().open(new DynamicRegionFactory.Config(d, null));
  getSystem(p);
  assertEquals(true, DynamicRegionFactory.get().isOpen());
  createParentRegion("parent", persist);
 }
});

代码示例来源:origin: LitePalFramework/LitePal

@Test
public void testFindUniqueColumns() {
  List<String> uniqueColumns = DBUtility.findUniqueColumns(DBUtility.getTableNameByClassName(
          Cellphone.class.getName()), db);
  assertEquals(1, uniqueColumns.size());
  assertTrue(uniqueColumns.contains("serial"));
  uniqueColumns = DBUtility.findUniqueColumns(DBUtility.getTableNameByClassName(Book.class.getName()), db);
  assertEquals(0, uniqueColumns.size());
}

代码示例来源:origin: org.geoserver/gs-wcs2_0

@Test
public void testGetCoverageLocalWs() throws Exception {
  MockHttpServletResponse response =
      getAsServletResponse(
          "wcs/wcs?request=GetCoverage&service=WCS&version=2.0.1"
              + "&coverageId=BlueMarble&&Format=image/tiff");
  assertEquals("image/tiff", response.getContentType());
}

代码示例来源:origin: google/guava

@Override
protected void process(ByteBuffer bb) {
 processCalled++;
 assertEquals(ByteOrder.LITTLE_ENDIAN, bb.order());
 assertTrue(bb.remaining() >= chunkSize);
 for (int i = 0; i < chunkSize; i++) {
  out.write(bb.get());
 }
}

代码示例来源:origin: igniterealtime/Smack

@Test
public void instantiationTest() {
  SignalOmemoService.acknowledgeLicense();
  SignalOmemoService.setup();
  DummyConnection dummy = new DummyConnection();
  DummyConnection silly = new DummyConnection();
  OmemoManager a = OmemoManager.getInstanceFor(dummy, 123);
  OmemoManager b = OmemoManager.getInstanceFor(dummy, 234);
  OmemoManager c = OmemoManager.getInstanceFor(silly, 123);
  OmemoManager d = OmemoManager.getInstanceFor(dummy, 123);
  assertNotNull(a);
  assertNotNull(b);
  assertNotNull(c);
  assertNotNull(d);
  assertEquals(Integer.valueOf(123), a.getDeviceId());
  assertEquals(Integer.valueOf(234), b.getDeviceId());
  assertFalse(a == b);
  assertFalse(a == c);
  assertFalse(b == c);
  assertTrue(a == d);
}

代码示例来源:origin: DSRCorporation/imf-conversion

@Test
public void testSaveCorrectMetadata() throws Exception {
  TvMetadataXmlProvider provider = new TvMetadataXmlProvider(MetadataUtils.getCorrectTvMetadataXml());
  File itmspDir = TestUtils.createDirectory(TemplateParameterContextCreator.getWorkingDir(), "correct.itmsp");
  File savedMetadata = provider.saveMetadata(itmspDir);
  assertEquals(new File(itmspDir, "metadata.xml"), savedMetadata);
}

代码示例来源:origin: spring-projects/spring-framework

@Test // SPR-15201
public void pathWithTrailingSlash() {
  DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory();
  URI uri = factory.expand("http://localhost:8080/spring/");
  assertEquals("http://localhost:8080/spring/", uri.toString());
}

相关文章