本文整理了Java中com.google.common.truth.Subject.isInstanceOf()
方法的一些代码示例,展示了Subject.isInstanceOf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Subject.isInstanceOf()
方法的具体详情如下:
包路径:com.google.common.truth.Subject
类名称:Subject
方法名:isInstanceOf
[英]Fails if the subject is not an instance of the given class.
[中]如果主题不是给定类的实例,则失败。
代码示例来源:origin: google/guava
@Override
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
assertThat(command).isInstanceOf(WrappedRunnable.class);
lastMethodCalled = "scheduleRunnable";
lastDelay = delay;
lastUnit = unit;
return null;
}
代码示例来源:origin: google/guava
@Override
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
assertThat(callable).isInstanceOf(WrappedCallable.class);
lastMethodCalled = "scheduleCallable";
lastDelay = delay;
lastUnit = unit;
return null;
}
代码示例来源:origin: google/guava
@Override
public void execute(Runnable runnable) {
assertThat(runnable).isInstanceOf(TrustedListenableFutureTask.class);
runnable.run();
}
代码示例来源:origin: google/guava
@Override
public <T> Future<T> submit(Runnable task, T result) {
lastMethodCalled = "submit";
assertThat(task).isInstanceOf(WrappedRunnable.class);
return inline.submit(task, result);
}
代码示例来源:origin: google/guava
@Override
public <T> Future<T> submit(Callable<T> task) {
lastMethodCalled = "submit";
assertThat(task).isInstanceOf(WrappedCallable.class);
return inline.submit(task);
}
代码示例来源:origin: google/guava
@Override
public Future<?> submit(Runnable task) {
lastMethodCalled = "submit";
assertThat(task).isInstanceOf(WrappedRunnable.class);
return inline.submit(task);
}
代码示例来源:origin: google/guava
@Override
public void execute(Runnable command) {
lastMethodCalled = "execute";
assertThat(command).isInstanceOf(WrappedRunnable.class);
inline.execute(command);
}
代码示例来源:origin: google/guava
public void testMultiDimensionalGenericArrayType() {
TypeToken<List<Long>[][][]> token = new TypeToken<List<Long>[][][]>() {};
assertEquals(List[][][].class, token.getRawType());
assertThat(token.getType()).isInstanceOf(GenericArrayType.class);
}
代码示例来源:origin: google/guava
public void testGenericArrayType() {
TypeToken<List<String>[]> token = new TypeToken<List<String>[]>() {};
assertEquals(List[].class, token.getRawType());
assertThat(token.getType()).isInstanceOf(GenericArrayType.class);
}
代码示例来源:origin: google/guava
public void testGetSubtype_genericSubtypeOfGenericTypeWithFewerParameters() {
TypeToken<List<String>> supertype = new TypeToken<List<String>>() {};
TypeToken<MySpecialList<String, ?>> subtype = new TypeToken<MySpecialList<String, ?>>() {};
assertTrue(subtype.isSubtypeOf(supertype));
ParameterizedType actualSubtype =
(ParameterizedType) supertype.getSubtype(subtype.getRawType()).getType();
assertEquals(MySpecialList.class, actualSubtype.getRawType());
assertThat(actualSubtype.getActualTypeArguments()[0]).isEqualTo(String.class);
assertThat(actualSubtype.getActualTypeArguments()[1]).isInstanceOf(TypeVariable.class);
assertTrue(TypeToken.of(actualSubtype).isSubtypeOf(supertype));
}
代码示例来源:origin: google/guava
public void testGetSubtype_genericSubtypeOfNonGenericType() {
TypeToken<Serializable> supertype = new TypeToken<Serializable>() {};
TypeToken<ArrayList<String>> subtype = new TypeToken<ArrayList<String>>() {};
assertTrue(subtype.isSubtypeOf(supertype));
ParameterizedType actualSubtype =
(ParameterizedType) supertype.getSubtype(subtype.getRawType()).getType();
assertEquals(ArrayList.class, actualSubtype.getRawType());
assertThat(actualSubtype.getActualTypeArguments()[0]).isInstanceOf(TypeVariable.class);
assertTrue(TypeToken.of(actualSubtype).isSubtypeOf(supertype));
}
代码示例来源:origin: google/guava
public void testCreate() {
Subscriber s1 = Subscriber.create(bus, this, getTestSubscriberMethod("recordingMethod"));
assertThat(s1).isInstanceOf(Subscriber.SynchronizedSubscriber.class);
// a thread-safe method should not create a synchronized subscriber
Subscriber s2 = Subscriber.create(bus, this, getTestSubscriberMethod("threadSafeMethod"));
assertThat(s2).isNotInstanceOf(Subscriber.SynchronizedSubscriber.class);
}
代码示例来源:origin: google/guava
public void testSetWeakKeys() {
MapMakerInternalMap<Object, Object, ?, ?> map = makeMap(createMapMaker().weakKeys());
checkStrength(map, Strength.WEAK, Strength.STRONG);
assertThat(map.entryHelper)
.isInstanceOf(MapMakerInternalMap.WeakKeyStrongValueEntry.Helper.class);
}
代码示例来源:origin: google/guava
public void testCatchingAsync_getThrowsError() throws Exception {
ListenableFuture<Object> input = UncheckedThrowingFuture.throwingError(new MyError());
// We'd catch only MyError.class here, but then the test won't compile under GWT.
ListenableFuture<Object> output =
catchingAsync(input, Throwable.class, asyncIdentity(), directExecutor());
assertThat(getDone(output)).isInstanceOf(MyError.class);
}
代码示例来源:origin: google/guava
public void testCatching_getThrowsError() throws Exception {
ListenableFuture<Object> input = UncheckedThrowingFuture.throwingError(new MyError());
// We'd catch only MyError.class here, but then the test won't compile under GWT.
ListenableFuture<Object> output =
catching(input, Throwable.class, identity(), directExecutor());
assertThat(getDone(output)).isInstanceOf(MyError.class);
}
代码示例来源:origin: google/guava
public void testSetWeakValues() {
MapMakerInternalMap<Object, Object, ?, ?> map = makeMap(createMapMaker().weakValues());
checkStrength(map, Strength.STRONG, Strength.WEAK);
assertThat(map.entryHelper)
.isInstanceOf(MapMakerInternalMap.StrongKeyWeakValueEntry.Helper.class);
}
代码示例来源:origin: google/guava
public void testCatchingAsync_getThrowsRuntimeException() throws Exception {
ListenableFuture<Object> input =
UncheckedThrowingFuture.throwingRuntimeException(new MyRuntimeException());
// We'd catch only MyRuntimeException.class here, but then the test won't compile under GWT.
ListenableFuture<Object> output =
catchingAsync(input, Throwable.class, asyncIdentity(), directExecutor());
assertThat(getDone(output)).isInstanceOf(MyRuntimeException.class);
}
代码示例来源:origin: google/guava
public void testCatching_getThrowsRuntimeException() throws Exception {
ListenableFuture<Object> input =
UncheckedThrowingFuture.throwingRuntimeException(new MyRuntimeException());
// We'd catch only MyRuntimeException.class here, but then the test won't compile under GWT.
ListenableFuture<Object> output =
catching(input, Throwable.class, identity(), directExecutor());
assertThat(getDone(output)).isInstanceOf(MyRuntimeException.class);
}
代码示例来源:origin: google/guava
@Test
public void immutableValueGraph() {
MutableValueGraph<String, Integer> mutableValueGraph = ValueGraphBuilder.directed().build();
mutableValueGraph.addNode("A");
ImmutableValueGraph<String, Integer> immutableValueGraph =
ImmutableValueGraph.copyOf(mutableValueGraph);
assertThat(immutableValueGraph.asGraph()).isInstanceOf(ImmutableGraph.class);
assertThat(immutableValueGraph).isNotInstanceOf(MutableValueGraph.class);
assertThat(immutableValueGraph).isEqualTo(mutableValueGraph);
mutableValueGraph.addNode("B");
assertThat(immutableValueGraph).isNotEqualTo(mutableValueGraph);
}
代码示例来源:origin: google/guava
@Test
public void immutableNetwork() {
MutableNetwork<String, Integer> mutableNetwork = NetworkBuilder.directed().build();
mutableNetwork.addNode("A");
ImmutableNetwork<String, Integer> immutableNetwork = ImmutableNetwork.copyOf(mutableNetwork);
assertThat(immutableNetwork.asGraph()).isInstanceOf(ImmutableGraph.class);
assertThat(immutableNetwork).isNotInstanceOf(MutableNetwork.class);
assertThat(immutableNetwork).isEqualTo(mutableNetwork);
mutableNetwork.addNode("B");
assertThat(immutableNetwork).isNotEqualTo(mutableNetwork);
}
内容来源于网络,如有侵权,请联系作者删除!