本文整理了Java中junit.framework.Assert.assertEquals()
方法的一些代码示例,展示了Assert.assertEquals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertEquals()
方法的具体详情如下:
包路径:junit.framework.Assert
类名称:Assert
方法名:assertEquals
[英]Asserts that two bytes are equal.
[中]断言两个字节相等。
代码示例来源:origin: google/guava
/**
* Asserts that a Unicode escaper escapes the given code point into the expected string.
*
* @param escaper the non-null escaper to test
* @param expected the expected output string
* @param cp the Unicode code point to escape
*/
public static void assertEscaping(UnicodeEscaper escaper, String expected, int cp) {
String escaped = computeReplacement(escaper, cp);
Assert.assertNotNull(escaped);
Assert.assertEquals(expected, escaped);
}
代码示例来源:origin: apache/ignite
@Override public void verify(BaselineTopologyHistory bltHist) {
assertNotNull(bltHist);
assertEquals(1, bltHist.history().size());
BaselineTopologyHistoryItem histItem = bltHist.history().get(0);
assertEquals(1, histItem.branchingHistory().size());
long actualBranchingHash = histItem.branchingHistory().get(0);
assertEquals(expectedBranchingHash, actualBranchingHash);
}
};
代码示例来源:origin: Impetus/Kundera
/**
* Test max aggregation with nested and or clause.
*/
public void testMaxAggregationWithNestedAndOrClause()
{
String nestedQuery = "Select max(p.age) from PersonES p where p.age > 0 AND (p.salary > 250 and (p.personName = 'karthik' OR p.personName = 'pragalbh'))";
Query query = em.createQuery(nestedQuery);
List resultList = query.getResultList();
Assert.assertNotNull(resultList);
Assert.assertEquals(1, resultList.size());
Assert.assertEquals(40.0, resultList.get(0));
}
代码示例来源:origin: Impetus/Kundera
private void findByNameAndAgeWithOrClause()
{
EntityManager em;
String query;
Query q;
List<StudentCouchDBDate> students;
int count;
em = emf.createEntityManager();
query = "Select s From StudentOracleNoSQLDate s where s.name = Kuldeep and s.age > " + getMinValue(short.class);
q = em.createQuery(query);
students = q.getResultList();
Assert.assertNotNull(students);
Assert.assertEquals(1, students.size());
count = 0;
for (StudentCouchDBDate student : students)
{
Assert.assertEquals(getMaxValue(Date.class), student.getId());
Assert.assertEquals(getMaxValue(short.class), student.getAge());
Assert.assertEquals("Kuldeep", student.getName());
count++;
}
Assert.assertEquals(1, count);
em.close();
}
代码示例来源:origin: Impetus/Kundera
public void testFindById(boolean useSameEm)
{
EntityManager em = emf.createEntityManager();
StudentMongoCalendar studentMax = em.find(StudentMongoCalendar.class, getMaxValue(Calendar.class));
Assert.assertNotNull(studentMax);
Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
Assert.assertEquals(getMaxValue(String.class), studentMax.getName());
em.close();
}
代码示例来源:origin: Impetus/Kundera
/**
* Test min with in.
*/
public void testMinWithIn()
{
String queryString = "Select sum(p.age) from PersonES p where p.personId IN ( '1', '2') or p.age = 40";
Query query = em.createQuery(queryString);
List resultList = query.getResultList();
Assert.assertNotNull(resultList);
Assert.assertEquals(1, resultList.size());
Assert.assertEquals(70.0, resultList.get(0));
}
代码示例来源:origin: Impetus/Kundera
private void findByNameAndAgeWithOrClause()
{
EntityManager em;
String query;
Query q;
List<StudentHBaseByteWrapper> students;
int count;
em = emf.createEntityManager();
query = "Select s From StudentHBaseByteWrapper s where s.name = Kuldeep and s.age > " + getPartialValue(short.class);
q = em.createQuery(query);
students = q.getResultList();
Assert.assertNotNull(students);
Assert.assertEquals(1, students.size());
count = 0;
for (StudentHBaseByteWrapper student : students)
{
Assert.assertEquals(getMaxValue(Byte.class), student.getId());
Assert.assertEquals(getMaxValue(short.class), student.getAge());
Assert.assertEquals("Kuldeep", student.getName());
count++;
}
Assert.assertEquals(1, count);
em.close();
}
代码示例来源:origin: apache/ignite
@Override public void verify(BaselineTopologyHistory bltHist) {
assertNotNull(bltHist);
assertEquals(2, bltHist.history().size());
BaselineTopologyHistoryItem histItem = bltHist.history().get(0);
assertEquals(1, histItem.branchingHistory().size());
long actualBranchingHash0 = histItem.branchingHistory().get(0);
assertEquals(expectedBranchingHash0, actualBranchingHash0);
histItem = bltHist.history().get(1);
assertEquals(1, histItem.branchingHistory().size());
long actualBranchingHash1 = histItem.branchingHistory().get(0);
assertEquals(expectedBranchingHash1, actualBranchingHash1);
}
};
代码示例来源:origin: google/guava
/**
* Asserts that an escaper escapes the given character into the expected string.
*
* @param escaper the non-null escaper to test
* @param expected the expected output string
* @param c the character to escape
*/
public static void assertEscaping(CharEscaper escaper, String expected, char c) {
String escaped = computeReplacement(escaper, c);
Assert.assertNotNull(escaped);
Assert.assertEquals(expected, escaped);
}
代码示例来源:origin: Impetus/Kundera
public void testFindById(boolean useSameEm)
{
EntityManager em = emf.createEntityManager();
StudentHBaseCalendar studentMax = em.find(StudentHBaseCalendar.class, getMaxValue(Calendar.class));
Assert.assertNotNull(studentMax);
Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
Assert.assertEquals(getMaxValue(String.class), studentMax.getName());
em.close();
}
代码示例来源:origin: Impetus/Kundera
/**
* Test field with in clause.
*/
public void testFieldWithInClause()
{
String queryString = "Select p.personName from PersonES p where p.personId IN ( '1', '2') and p.age = 10";
Query query = em.createQuery(queryString);
List resultList = query.getResultList();
Assert.assertNotNull(resultList);
Assert.assertEquals(1, resultList.size());
Assert.assertEquals("karthik", resultList.get(0));
}
代码示例来源:origin: Impetus/Kundera
private void findByNameAndAgeWithOrClause()
{
EntityManager em;
String query;
Query q;
List<StudentHBaseInt> students;
int count;
em = emf.createEntityManager();
query = "Select s From StudentHBaseInt s where s.name = Kuldeep and s.age > " + getPartialValue(short.class);
q = em.createQuery(query);
students = q.getResultList();
Assert.assertNotNull(students);
Assert.assertEquals(1, students.size());
count = 0;
for (StudentHBaseInt student : students)
{
Assert.assertEquals(getMaxValue(int.class), student.getId());
Assert.assertEquals(getMaxValue(short.class), student.getAge());
Assert.assertEquals("Kuldeep", student.getName());
count++;
}
Assert.assertEquals(1, count);
em.close();
}
代码示例来源:origin: facebook/facebook-android-sdk
assertEquals(true, json.getBoolean("boolValue"));
assertEquals(7, json.getInt("intValue"));
assertEquals(5000000000l, json.getLong("longValue"));
assertEquals(3.14, json.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA);
assertEquals("hello world", json.getString("stringValue"));
assertEquals(2, jsonArray.length());
assertEquals("first", jsonArray.getString(0));
assertEquals("second", jsonArray.getString(1));
assertEquals(3, jsonArray.length());
assertEquals("1st", jsonArray.getString(0));
assertEquals("2nd", jsonArray.getString(1));
assertEquals("third", jsonArray.getString(2));
assertEquals(1, innerJson.getInt("inner"));
innerJson = innerJson.getJSONObject("nested bundle");
assertEquals("2", innerJson.getString("inner"));
assertEquals(2, jsonArray.length());
assertEquals("7", jsonArray.getString(0));
assertEquals("8", jsonArray.getString(1));
assertEquals(true, finalBundle.getBoolean("boolValue"));
assertEquals(7, finalBundle.getInt("intValue"));
assertEquals(5000000000l, finalBundle.getLong("longValue"));
assertEquals(3.14, finalBundle.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA);
assertEquals("hello world", finalBundle.getString("stringValue"));
代码示例来源:origin: google/guava
/**
* Asserts that a Unicode escaper escapes the given hi/lo surrogate pair into the expected string.
*
* @param escaper the non-null escaper to test
* @param expected the expected output string
* @param hi the high surrogate pair character
* @param lo the low surrogate pair character
*/
public static void assertUnicodeEscaping(
UnicodeEscaper escaper, String expected, char hi, char lo) {
int cp = Character.toCodePoint(hi, lo);
String escaped = computeReplacement(escaper, cp);
Assert.assertNotNull(escaped);
Assert.assertEquals(expected, escaped);
}
}
代码示例来源:origin: Impetus/Kundera
/**
* Test find by id.
*
* @param useSameEm
* the use same em
*/
public void testFindById(boolean useSameEm)
{
EntityManager em = emf.createEntityManager();
StudentHBaseCalendar studentMax = em.find(StudentHBaseCalendar.class, getMaxValue(Calendar.class));
Assert.assertNotNull(studentMax);
Assert.assertEquals(getMaxValue(short.class), studentMax.getAge());
Assert.assertEquals(getMaxValue(String.class), studentMax.getName());
em.close();
}
代码示例来源:origin: Impetus/Kundera
/**
* Test count with where null and.
*/
public void testCountWithWhereNullAnd()
{
String queryString = "Select count(p.age) from PersonES p where p.age < 25 and p.personName = 'amit'";
Query query = em.createQuery(queryString);
List resultList = query.getResultList();
Assert.assertNotNull(resultList);
Assert.assertEquals(1, resultList.size());
Assert.assertEquals(0, ((Long) resultList.get(0)).intValue());
}
代码示例来源:origin: Impetus/Kundera
private void findByNameAndAgeWithOrClause()
{
EntityManager em;
String query;
Query q;
List<StudentMongoInt> students;
int count;
em = emf.createEntityManager();
query = "Select s From StudentMongoInt s where s.name = Kuldeep and s.age > " + getMinValue(short.class);
q = em.createQuery(query);
students = q.getResultList();
Assert.assertNotNull(students);
Assert.assertEquals(1, students.size());
count = 0;
for (StudentMongoInt student : students)
{
Assert.assertEquals(getMaxValue(int.class), student.getId());
Assert.assertEquals(getMaxValue(short.class), student.getAge());
Assert.assertEquals("Kuldeep", student.getName());
count++;
}
Assert.assertEquals(1, count);
em.close();
}
代码示例来源:origin: apache/ignite
assertNotNull(caches);
assertNotNull(affMap);
assertNotNull(ownersMap);
assertEquals(cacheName, ccfg.getName());
assertEquals(Integer.MAX_VALUE, ccfg.getBackups());
else
assertEquals(backups, ccfg.getBackups());
assertEquals(parts, ccfg.getAffinity().partitions());
assertNotNull(cacheName, aff);
assertEquals(parts, aff.size());
assertNotNull(cacheName, owners);
assertEquals(parts, owners.size());
assertEquals(cacheName, expNodes, partAff.size());
assertEquals(cacheName, expNodes, partOwners.size());
代码示例来源:origin: apache/ignite
@Override public Boolean apply(Object o) {
assertNotNull(o);
Future<Integer> fut = (Future<Integer>)o;
try {
assertEquals(42, (int)fut.get());
}
catch (Exception ignored) {
fail("Failed submit task.");
}
return true;
}
}
代码示例来源:origin: Impetus/Kundera
/**
* Test count.
*/
public void testCount()
{
String queryString = "Select count(p) from PersonES p";
Query query = em.createQuery(queryString);
List resultList = query.getResultList();
Assert.assertNotNull(resultList);
Assert.assertEquals(1, resultList.size());
Assert.assertEquals(4, ((Long) resultList.get(0)).intValue());
}
内容来源于网络,如有侵权,请联系作者删除!