本文整理了Java中junit.framework.Assert.assertNotNull()
方法的一些代码示例,展示了Assert.assertNotNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertNotNull()
方法的具体详情如下:
包路径:junit.framework.Assert
类名称:Assert
方法名:assertNotNull
[英]Asserts that an object isn't null.
[中]断言对象不是null。
代码示例来源: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
private <E extends Object> void assertFindByName(EntityManager em, String clazz, E e, String name, String fieldName)
{
String query = "Select p from " + clazz + " p where p." + fieldName + " = " + name;
// // find by name.
Query q = em.createQuery(query);
List<E> results = q.getResultList();
Assert.assertNotNull(results);
Assert.assertFalse(results.isEmpty());
Assert.assertEquals(3, results.size());
}
代码示例来源: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
private void findByNameAndAgeGTAndLT()
{
EntityManager em;
String query;
Query q;
List<StudentBooleanPrimitive> students;
em = emf.createEntityManager();
query = "Select s From StudentBooleanPrimitive s where s.name = Amresh and s.age > " + getMinValue(short.class)
+ " and s.age < " + getMaxValue(short.class);
q = em.createQuery(query);
students = q.getResultList();
Assert.assertNotNull(students);
Assert.assertTrue(students.isEmpty());
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
public void deleteCounter()
{
EntityManager em = emf.createEntityManager();
Counters counters = new Counters();
counters = em.find(Counters.class, id3);
Assert.assertNotNull(counters);
Assert.assertNotNull(counters.getCounter());
em.remove(counters);
EntityManager em1 = emf.createEntityManager();
counters = em1.find(Counters.class, id3);
Assert.assertNull(counters);
em.close();
}
代码示例来源:origin: Impetus/Kundera
private <E extends Object> void assertFindByName(EntityManager em, String clazz, E e, String name, String fieldName)
{
String query = "Select p from PesonMongo p where p." + fieldName + " = " + name;
// // find by name.
Query q = em.createQuery(query);
List<E> results = q.getResultList();
Assert.assertNotNull(results);
Assert.assertFalse(results.isEmpty());
Assert.assertEquals(3, results.size());
}
代码示例来源: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: 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: Impetus/Kundera
private void findByNameAndAgeGTAndLT()
{
EntityManager em;
String query;
Query q;
List<StudentCouchDBBooleanWrapper> students;
em = emf.createEntityManager();
query = "Select s From StudentOracleNoSQLBooleanWrapper s where s.name = Amresh and s.age > "
+ getMinValue(short.class) + " and s.age < " + getMaxValue(short.class);
q = em.createQuery(query);
students = q.getResultList();
Assert.assertNotNull(students);
Assert.assertTrue(students.isEmpty());
em.close();
}
代码示例来源: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 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: 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());
代码示例来源: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: Impetus/Kundera
private void findByNameAndAgeGTAndLT()
{
EntityManager em;
String query;
Query q;
List<StudentCouchDBBooleanPrimitive> students;
em = emf.createEntityManager();
query = "Select s From StudentOracleNoSQLBooleanPrimitive s where s.name = Amresh and s.age > "
+ getMinValue(short.class) + " and s.age < " + getMaxValue(short.class);
q = em.createQuery(query);
students = q.getResultList();
Assert.assertNotNull(students);
Assert.assertTrue(students.isEmpty());
em.close();
}
代码示例来源: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
private <E extends Object> void assertFindByName(EntityManager em, String clazz, E e, String name,
String fieldName)
{
String query = "Select p from PF p where p." + fieldName + " = " + name;
// // find by name.
Query q = em.createQuery(query);
List<E> results = q.getResultList();
Assert.assertNotNull(results);
Assert.assertFalse(results.isEmpty());
Assert.assertEquals(3, results.size());
}
内容来源于网络,如有侵权,请联系作者删除!