本文整理汇总了Java中junit.framework.Assert.assertNotNull方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.assertNotNull方法的具体用法?Java Assert.assertNotNull怎么用?Java Assert.assertNotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类junit.framework.Assert
的用法示例。
在下文中一共展示了Assert.assertNotNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: suite
import junit.framework.Assert; //导入方法依赖的package包/类
/** Executes the execution compatibility kit tests on the provided instance
* of execution engine.
*/
public static Test suite(ExecutionEngine engine) {
System.setProperty("org.openide.util.Lookup", ExecutionCompatibilityTest.class.getName() + "$Lkp");
Object o = Lookup.getDefault();
if (!(o instanceof Lkp)) {
Assert.fail("Wrong lookup object: " + o);
}
Lkp l = (Lkp)o;
l.assignExecutionEngine(engine);
if (engine != null) {
Assert.assertEquals("Same engine found", engine, ExecutionEngine.getDefault());
} else {
o = ExecutionEngine.getDefault();
Assert.assertNotNull("Engine found", o);
Assert.assertEquals(ExecutionEngine.Trivial.class, o.getClass());
}
TestSuite ts = new TestSuite();
ts.addTestSuite(ExecutionEngineHid.class);
return ts;
}
示例2: initWrites
import junit.framework.Assert; //导入方法依赖的package包/类
static void initWrites() throws IOException {
Set<String> allowedFiles = new HashSet<String>();
InputStream is = PerfCountingSecurityManager.class.getResourceAsStream("allowed-file-writes.txt");
Assert.assertNotNull("file found", is);
BufferedReader r = new BufferedReader(new InputStreamReader(is));
for (;;) {
String line = r.readLine();
if (line == null) {
break;
}
if (line.startsWith("#")) {
continue;
}
allowedFiles.add(line);
}
PerfCountingSecurityManager.initialize(null, PerfCountingSecurityManager.Mode.CHECK_WRITE, allowedFiles);
}
示例3: testLog4jAppender
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testLog4jAppender() throws IOException {
configureSource();
PropertyConfigurator.configure(props);
Logger logger = LogManager.getLogger(TestLog4jAppender.class);
for (int count = 0; count <= 1000; count++) {
/*
* Log4j internally defines levels as multiples of 10000. So if we
* create levels directly using count, the level will be set as the
* default.
*/
int level = ((count % 5) + 1) * 10000;
String msg = "This is log message number" + String.valueOf(count);
logger.log(Level.toLevel(level), msg);
Transaction transaction = ch.getTransaction();
transaction.begin();
Event event = ch.take();
Assert.assertNotNull(event);
Assert.assertEquals(new String(event.getBody(), "UTF8"), msg);
Map<String, String> hdrs = event.getHeaders();
Assert.assertNotNull(hdrs.get(Log4jAvroHeaders.TIMESTAMP.toString()));
Assert.assertEquals(Level.toLevel(level),
Level.toLevel(Integer.valueOf(hdrs.get(Log4jAvroHeaders.LOG_LEVEL
.toString()))
));
Assert.assertEquals(logger.getName(),
hdrs.get(Log4jAvroHeaders.LOGGER_NAME.toString()));
Assert.assertEquals("UTF8",
hdrs.get(Log4jAvroHeaders.MESSAGE_ENCODING.toString()));
transaction.commit();
transaction.close();
}
}
示例4: testMultipleOptionalChannels
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testMultipleOptionalChannels() throws Exception {
Context context = new Context();
context.put(ReplicatingChannelSelector.CONFIG_OPTIONAL, "ch1 ch4");
Configurables.configure(selector, context);
List<Channel> channels = selector.getRequiredChannels(new MockEvent());
Assert.assertNotNull(channels);
Assert.assertEquals(2, channels.size());
Assert.assertEquals("ch2", channels.get(0).getName());
Assert.assertEquals("ch3", channels.get(1).getName());
List<Channel> optCh = selector.getOptionalChannels(new MockEvent());
Assert.assertEquals(2, optCh.size());
Assert.assertEquals("ch1", optCh.get(0).getName());
Assert.assertEquals("ch4", optCh.get(1).getName());
}
示例5: check
import junit.framework.Assert; //导入方法依赖的package包/类
private static void check(ConfPairs confPairs, String expEncoded,
Map<String, String> expNameValues) {
String isEncoded = confPairs.getEncoded();
Assert.assertEquals("encoded", expEncoded, isEncoded);
Set<String> isNames = confPairs.names();
Assert.assertEquals("names", expNameValues.size(), isNames.size());
for (String isName : isNames) {
String expValue = expNameValues.get(isName);
Assert.assertNotNull("name " + isName + " is not expected", expValue);
Assert.assertEquals("value of name " + isName, expValue, confPairs.value(isName));
}
}
示例6: testget
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testget() {
int id = 1;
App app = null;
while (true) {
app = appMapper.get(id);
id++;
if (app != null) {
break;
}
}
Assert.assertNotNull(app.getId());
}
示例7: testWithoutNamespacedListsFile
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
@UseDataProvider("data")
public void testWithoutNamespacedListsFile(IBackupManagerFactory.BackupEntity entity, String expectedFilename) throws Exception {
String result = testee.getFilename(entity);
Assert.assertNotNull(result);
Assert.assertEquals(basePath + File.separator + appName + File.separator + expectedFilename, result);
}
示例8: correctConstructionFromACheckPoint
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void correctConstructionFromACheckPoint() {
Track testTrack = new Track(buildCheckPoint(50, 50));
Assert.assertEquals(0, testTrack.getDistance(), 0);
Assert.assertEquals(1, testTrack.getTotalCheckPoints(), 0);
Assert.assertNotNull(testTrack.getCheckpoints());
Assert.assertEquals(50, testTrack.getLastPoint().getLatitude(), 0);
Assert.assertEquals(50, testTrack.getLastPoint().getLongitude(), 0);
}
示例9: testAddSessionAfterSessionExpiry
import junit.framework.Assert; //导入方法依赖的package包/类
/**
* Verify the create session call in the Leader.FinalRequestProcessor after
* the session expiration.
*/
@Test(timeout = 20000)
public void testAddSessionAfterSessionExpiry() throws Exception {
ZooKeeperServer zks = setupSessionTracker();
latch = new CountDownLatch(1);
zks.sessionTracker.addSession(sessionId, sessionTimeout);
SessionTrackerImpl sessionTrackerImpl = (SessionTrackerImpl) zks.sessionTracker;
SessionImpl sessionImpl = sessionTrackerImpl.sessionsById
.get(sessionId);
Assert.assertNotNull("Sessionid:" + sessionId
+ " doesn't exists in sessiontracker", sessionImpl);
// verify the session existence
Object sessionOwner = new Object();
sessionTrackerImpl.checkSession(sessionId, sessionOwner);
// waiting for the session expiry
latch.await(sessionTimeout * 2, TimeUnit.MILLISECONDS);
// Simulating FinalRequestProcessor logic: create session request has
// delayed and now reaches FinalRequestProcessor. Here the leader zk
// will do sessionTracker.addSession(id, timeout)
sessionTrackerImpl.addSession(sessionId, sessionTimeout);
try {
sessionTrackerImpl.checkSession(sessionId, sessionOwner);
Assert.fail("Should throw session expiry exception "
+ "as the session has expired and closed");
} catch (KeeperException.SessionExpiredException e) {
// expected behaviour
}
Assert.assertTrue("Session didn't expired", sessionImpl.isClosing());
Assert.assertFalse("Session didn't expired", sessionTrackerImpl
.touchSession(sessionId, sessionTimeout));
Assert.assertEquals(
"Duplicate session expiry request has been generated", 1,
firstProcessor.getCountOfCloseSessionReq());
}
示例10: testgetLatestDate
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testgetLatestDate() {
Boolean noAds = true;
Boolean official = false;
List<LatestDate> list = appMapper.getLatestDate(noAds, official);
Assert.assertNotNull(list);
Assert.assertFalse(list.isEmpty());
}
示例11: testBackgroundColour
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testBackgroundColour() {
alert.setAlertBackgroundColor(ContextCompat.getColor(activityRule.getActivity(), android.R.color.darker_gray));
Assert.assertNotNull(alert.getAlertBackground().getBackground());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
Assert.assertEquals(((ColorDrawable) alert.getAlertBackground().getBackground()).getColor(), ContextCompat.getColor(activityRule.getActivity(), android.R.color.darker_gray));
}
}
示例12: testPutSerializationNullHeader
import junit.framework.Assert; //导入方法依赖的package包/类
@Test
public void testPutSerializationNullHeader() throws IOException, CorruptEventException {
Put in = new Put(System.currentTimeMillis(),
WriteOrderOracle.next(),
new FlumeEvent(null, new byte[0]));
Put out = (Put)TransactionEventRecord.fromByteArray(toByteArray(in));
Assert.assertEquals(in.getClass(), out.getClass());
Assert.assertEquals(in.getRecordType(), out.getRecordType());
Assert.assertEquals(in.getTransactionID(), out.getTransactionID());
Assert.assertEquals(in.getLogWriteOrderID(), out.getLogWriteOrderID());
Assert.assertNull(in.getEvent().getHeaders());
Assert.assertNotNull(out.getEvent().getHeaders());
Assert.assertTrue(Arrays.equals(in.getEvent().getBody(), out.getEvent().getBody()));
}
示例13: testConvertAsLocalDate
import junit.framework.Assert; //导入方法依赖的package包/类
public void testConvertAsLocalDate() {
//Datum ohne Zeit
LocalDate nowAsLocalDate = DateConvertUtils.asLocalDate(DateHelper.stripTime(now));
Date convertedBack = DateConvertUtils.asUtilDate(nowAsLocalDate);
Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
cal1.setTime(now);
Assert.assertNotNull(convertedBack);
cal2.setTime(convertedBack);
boolean sameDay = cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR);
Assert.assertTrue(sameDay);
}
示例14: NodeNameAsserter
import junit.framework.Assert; //导入方法依赖的package包/类
public NodeNameAsserter(String... expectNames) {
Assert.assertNotNull(expectNames);
this.expectNames = expectNames;
}
示例15: init
import junit.framework.Assert; //导入方法依赖的package包/类
@Before
public void init() {
Assert.assertNotNull(appConfig);
logger.info("Test bootstrap OK!");
}