本文整理了Java中junit.framework.Assert.assertFalse()
方法的一些代码示例,展示了Assert.assertFalse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.assertFalse()
方法的具体详情如下:
包路径:junit.framework.Assert
类名称:Assert
方法名:assertFalse
[英]Asserts that a condition is false. If it isn't it throws an AssertionFailedError with the given message.
[中]断言某个条件为假。如果不是,则会抛出带有给定消息的AssertionFailedError。
代码示例来源:origin: google/guava
@SuppressWarnings({"SelfComparison", "SelfEquals"})
public static <T extends Comparable<? super T>> void testCompareToAndEquals(
List<T> valuesInExpectedOrder) {
// This does an O(n^2) test of all pairs of values in both orders
for (int i = 0; i < valuesInExpectedOrder.size(); i++) {
T t = valuesInExpectedOrder.get(i);
for (int j = 0; j < i; j++) {
T lesser = valuesInExpectedOrder.get(j);
assertTrue(lesser + ".compareTo(" + t + ')', lesser.compareTo(t) < 0);
assertFalse(lesser.equals(t));
}
assertEquals(t + ".compareTo(" + t + ')', 0, t.compareTo(t));
assertTrue(t.equals(t));
for (int j = i + 1; j < valuesInExpectedOrder.size(); j++) {
T greater = valuesInExpectedOrder.get(j);
assertTrue(greater + ".compareTo(" + t + ')', greater.compareTo(t) > 0);
assertFalse(greater.equals(t));
}
}
}
代码示例来源:origin: google/guava
static void checkEmpty(Cache<?, ?> cache) {
assertEquals(0, cache.size());
assertFalse(cache.asMap().containsKey(null));
assertFalse(cache.asMap().containsKey(6));
assertFalse(cache.asMap().containsValue(null));
assertFalse(cache.asMap().containsValue(6));
checkEmpty(cache.asMap());
}
代码示例来源:origin: google/guava
public void testCompletedFuture(@Nullable Object expectedValue)
throws InterruptedException, ExecutionException {
assertTrue(future.isDone());
assertFalse(future.isCancelled());
assertTrue(latch.await(5, TimeUnit.SECONDS));
assertTrue(future.isDone());
assertFalse(future.isCancelled());
assertEquals(expectedValue, future.get());
}
代码示例来源:origin: apache/ignite
/**
* @param mtd Called stored method.
*/
private void checkSession(String mtd) {
assertNotNull(ignite);
assertFalse(expData.isEmpty());
ExpectedData exp = expData.remove(0);
assertEquals(exp.expMtd, mtd);
CacheStoreSession ses = session();
assertNotNull(ses);
assertSame(ses, sesInParent);
if (exp.tx)
assertNotNull(ses.transaction());
else
assertNull(ses.transaction());
Map<Object, Object> props = ses.properties();
assertNotNull(props);
assertEquals(exp.expProps, props);
props.put(props.size(), mtd);
assertEquals(exp.expCacheName, ses.cacheName());
}
}
代码示例来源:origin: facebook/facebook-android-sdk
@Test
public void testJsonObjectContainsValue() throws JSONException {
JSONObject jsonObject = new JSONObject();
jsonObject.put("hello", "world");
jsonObject.put("hocus", "pocus");
assertTrue(JsonUtil.jsonObjectContainsValue(jsonObject, "pocus"));
assertFalse(JsonUtil.jsonObjectContainsValue(jsonObject, "Fred"));
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldReturnFalseIfAnyDescendentIsInvalid(){
JobConfig jobConfig = mock(JobConfig.class);
when(jobConfig.validateTree(any(PipelineConfigSaveValidationContext.class))).thenReturn(false);
JobConfigs jobConfigs = new JobConfigs(jobConfig);
boolean isValid = jobConfigs.validateTree(PipelineConfigSaveValidationContext.forChain(true, "group", new PipelineConfig()));
assertFalse(isValid);
verify(jobConfig).validateTree(any(PipelineConfigSaveValidationContext.class));
}
代码示例来源:origin: oasisfeng/condom
@Test public void testNonApplicationRootContextAsBaseContext() throws Exception {
final Context context = InstrumentationRegistry.getTargetContext();
final ContextWrapper context_wo_app = new ContextWrapper(context) {
@Override public Context getApplicationContext() { return this; }
};
final CondomContext condom_context = CondomContext.wrap(context_wo_app, TAG);
final Context condom_app_context = condom_context.getApplicationContext();
assertFalse(condom_app_context instanceof Application);
assertEquals(condom_context, condom_app_context);
}
代码示例来源:origin: hidroh/materialistic
@Test
public void testCreateLand() {
assertNotNull(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_share));
assertFalse(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_share).isVisible());
assertNotNull(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_external));
assertFalse(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_external).isVisible());
assertFalse(((ShadowFloatingActionButton) Shadow.extract(activity.findViewById(R.id.reply_button))).isVisible());
}
代码示例来源:origin: apache/ignite
/**
* @param mtd Called stored method.
*/
protected void checkSession(String mtd) {
assertNotNull(ignite);
CacheStoreSession ses = session();
assertNotNull(ses);
log.info("Cache: " + ses.cacheName());
assertFalse(ses.isWithinTransaction());
assertNull(ses.transaction());
assertNotNull(expData);
assertEquals(mtd, expData.expMtd);
assertEquals(expData.expCacheName, ses.cacheName());
assertNotNull(ses.properties());
ses.properties().put(1, "test");
assertEquals("test", ses.properties().get(1));
latch.countDown();
}
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public boolean apply(ClusterNode clusterNode) {
Boolean attr = clusterNode.attribute(IgniteNodeAttributes.ATTR_CLIENT_MODE);
assertNotNull(attr);
assertFalse(attr);
return true;
}
}
代码示例来源:origin: commons-collections/commons-collections
public void testSerializationEnabled() throws Exception {
Assert.assertFalse("true".equalsIgnoreCase(System.getProperty(FunctorUtils.UNSAFE_SERIALIZABLE_PROPERTY)));
System.setProperty(FunctorUtils.UNSAFE_SERIALIZABLE_PROPERTY, "true");
try {
Object object = makeObject();
byte[] data = serialize(object);
Assert.assertNotNull(data);
try {
Object obj = deserialize(data);
Assert.assertTrue(getTestClass().isInstance(obj));
} catch (UnsupportedOperationException ex) {
fail("de-serialization of " + getTestClass().getName() + " should be enabled");
}
} finally {
System.setProperty(FunctorUtils.UNSAFE_SERIALIZABLE_PROPERTY, "false");
}
}
代码示例来源:origin: google/guava
public void testFailedFuture(@Nullable String message) throws InterruptedException {
assertTrue(future.isDone());
assertFalse(future.isCancelled());
assertTrue(latch.await(5, TimeUnit.SECONDS));
assertTrue(future.isDone());
assertFalse(future.isCancelled());
try {
future.get();
fail("Future should rethrow the exception.");
} catch (ExecutionException e) {
assertThat(e).hasCauseThat().hasMessageThat().isEqualTo(message);
}
}
}
代码示例来源:origin: oasisfeng/condom
runInSeparateProcess(new TestService.Procedure() { @Override public void run(final Context context) {
installCondomProcess(context, new CondomOptions()); // Must be installed before the first call to Context.getPackageManager().
final Intent service_intent = new Intent("android.view.InputMethod").addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES/* For consistency */);
final ResolveInfo service = context.getPackageManager().resolveService(service_intent, 0);
Assume.assumeNotNull(service);
final List<ResolveInfo> services = context.getPackageManager().queryIntentServices(service_intent, 0);
assertNotNull(services);
assertFalse(services.isEmpty());
final List<ResolveInfo> receivers = context.getPackageManager().queryBroadcastReceivers(new Intent(Intent.ACTION_BOOT_COMPLETED), 0);
assertNotNull(receivers);
assertFalse(receivers.isEmpty());
installCondomProcess(context, new CondomOptions().setOutboundJudge(sBlockAllJudge));
assertNull(context.getPackageManager().resolveService(service_intent, 0));
List<ResolveInfo> result = context.getPackageManager().queryIntentServices(service_intent, 0);
assertTrue(result.isEmpty());
service_intent.setPackage(service.serviceInfo.packageName);
assertNull(context.getPackageManager().resolveService(service_intent, 0));
result = context.getPackageManager().queryIntentServices(service_intent, 0);
assertTrue(result.isEmpty());
service_intent.setPackage(null);
}});
}
代码示例来源:origin: google/guava
assertFalse(resultsForStrategy.contains(null));
comparator = (Comparator) Comparator.naturalOrder();
assertTrue(Ordering.from(comparator).isOrdered(resultsForStrategy));
assertEquals(Ints.checkedCast(estimatedSize), resultsForStrategy.size());
代码示例来源:origin: iSoron/uhabits
@Test
public void testExecuteUndoRedo()
{
assertFalse(habit.isArchived());
command.execute();
assertTrue(habit.isArchived());
command.undo();
assertFalse(habit.isArchived());
command.execute();
assertTrue(habit.isArchived());
}
代码示例来源:origin: json-path/JsonPath
@Test
public void lt_filters_evaluates() throws Exception {
Map<String, Object> check = new HashMap<String, Object>();
check.put("foo", 10.5D);
check.put("foo_null", null);
//assertTrue(filter(where("foo").lt(12D)).apply(createPredicateContext(check)));
assertFalse(filter(where("foo").lt(null)).apply(createPredicateContext(check)));
//assertFalse(filter(where("foo").lt(5D)).apply(createPredicateContext(check)));
//assertFalse(filter(where("foo_null").lt(5D)).apply(createPredicateContext(check)));
}
代码示例来源:origin: hidroh/materialistic
@Test
public void testParcelReadWrite() {
Parcel parcel = Parcel.obtain();
item.populate(new TestItem() {
@Override
public String getTitle() {
return "title";
}
});
item.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
Item actual = HackerNewsItem.CREATOR.createFromParcel(parcel);
assertEquals("title", actual.getDisplayedTitle());
assertFalse(actual.isFavorite());
}
代码示例来源:origin: apache/ignite
/**
* Checks correctness of the state after unmarshalling.
*/
void checkAfterUnmarshalled() {
assertEquals(longVal, 0x33445566778899AAL);
assertEquals(shortVal.shortValue(), (short)0xAABB);
assertTrue(Arrays.equals(strArr, new String[] {"AA","BB"}));
assertEquals(intVal, 0);
assertTrue(flag1);
assertFalse(flag2);
assertNull(flag3);
assertTrue(flag4);
assertFalse(flag5);
}
}
代码示例来源:origin: google/guava
public void setUp() {
future.addListener(
new Runnable() {
@Override
public void run() {
latch.countDown();
}
},
exec);
assertEquals(1, latch.getCount());
assertFalse(future.isDone());
assertFalse(future.isCancelled());
}
代码示例来源:origin: apache/ignite
/**
*/
private void checkConnection() {
Connection conn = ses.attachment();
assertNotNull(conn);
try {
assertFalse(conn.isClosed());
assertFalse(conn.getAutoCommit());
}
catch (SQLException e) {
throw new RuntimeException(e);
}
verifySameInstance(conn);
}
内容来源于网络,如有侵权,请联系作者删除!