org.mockito.Mockito.anyBoolean()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(11.7k)|赞(0)|评价(0)|浏览(229)

本文整理了Java中org.mockito.Mockito.anyBoolean()方法的一些代码示例,展示了Mockito.anyBoolean()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mockito.anyBoolean()方法的具体详情如下:
包路径:org.mockito.Mockito
类名称:Mockito
方法名:anyBoolean

Mockito.anyBoolean介绍

暂无

代码示例

代码示例来源:origin: apache/hbase

private static void setMockLocation(ClusterConnection hc, byte[] row, RegionLocations result)
 throws IOException {
 Mockito.when(hc.locateRegion(Mockito.eq(DUMMY_TABLE), Mockito.eq(row), Mockito.anyBoolean(),
  Mockito.anyBoolean(), Mockito.anyInt())).thenReturn(result);
 Mockito.when(hc.locateRegion(Mockito.eq(DUMMY_TABLE), Mockito.eq(row), Mockito.anyBoolean(),
  Mockito.anyBoolean())).thenReturn(result);
}

代码示例来源:origin: apache/hbase

private static void setMockLocation(ClusterConnection hc, byte[] row,
  RegionLocations result) throws IOException {
 Mockito.when(hc.locateRegion(Mockito.eq(DUMMY_TABLE), Mockito.eq(row),
   Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anyInt())).thenReturn(result);
 Mockito.when(hc.locateRegion(Mockito.eq(DUMMY_TABLE), Mockito.eq(row),
   Mockito.anyBoolean(), Mockito.anyBoolean())).thenReturn(result);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testSuccess() throws Exception {
  @SuppressWarnings("unchecked")
  Future<Object> future = mock(Future.class);
  Object value = new Object();
  when(future.get()).thenReturn(value);
  Subscriber<Object> subscriber = TestHelper.mockSubscriber();
  TestSubscriber<Object> ts = new TestSubscriber<Object>(subscriber);
  Flowable.fromFuture(future).subscribe(ts);
  ts.dispose();
  verify(subscriber, times(1)).onNext(value);
  verify(subscriber, times(1)).onComplete();
  verify(subscriber, never()).onError(any(Throwable.class));
  verify(future, never()).cancel(anyBoolean());
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testFailure() throws Exception {
  @SuppressWarnings("unchecked")
  Future<Object> future = mock(Future.class);
  RuntimeException e = new RuntimeException();
  when(future.get()).thenThrow(e);
  Subscriber<Object> subscriber = TestHelper.mockSubscriber();
  TestSubscriber<Object> ts = new TestSubscriber<Object>(subscriber);
  Flowable.fromFuture(future).subscribe(ts);
  ts.dispose();
  verify(subscriber, never()).onNext(null);
  verify(subscriber, never()).onComplete();
  verify(subscriber, times(1)).onError(e);
  verify(future, never()).cancel(anyBoolean());
}

代码示例来源:origin: pentaho/pentaho-kettle

private void forcesToRecalculate_Sxssf( String property, boolean expectedFlag ) throws Exception {
 step.setVariable( ExcelWriterStep.STREAMER_FORCE_RECALC_PROP_NAME, property );
 data.wb = spy( new SXSSFWorkbook() );
 step.recalculateAllWorkbookFormulas();
 if ( expectedFlag ) {
  verify( data.wb ).setForceFormulaRecalculation( true );
 } else {
  verify( data.wb, never() ).setForceFormulaRecalculation( anyBoolean() );
 }
}

代码示例来源:origin: apache/hbase

private ClusterConnection createHConnection() throws IOException {
 ClusterConnection hc = createHConnectionCommon();
 setMockLocation(hc, DUMMY_BYTES_1, new RegionLocations(loc1));
 setMockLocation(hc, DUMMY_BYTES_2, new RegionLocations(loc2));
 setMockLocation(hc, DUMMY_BYTES_3, new RegionLocations(loc3));
 Mockito.when(hc.locateRegions(Mockito.eq(DUMMY_TABLE), Mockito.anyBoolean(),
   Mockito.anyBoolean())).thenReturn(Arrays.asList(loc1, loc2, loc3));
 setMockLocation(hc, FAILS, new RegionLocations(loc2));
 return hc;
}

代码示例来源:origin: bumptech/glide

@Test
public void requestManager_intoImageView_withSameByteArrayAndMemoryCacheEnabled_loadsFromMemory()
  throws IOException {
 final byte[] canonicalBytes = getCanonicalBytes();
 concurrency.loadOnMainThread(
   Glide.with(context)
     .load(canonicalBytes)
     .apply(skipMemoryCacheOf(false)),
   imageView);
 Glide.with(context).clear(imageView);
 concurrency.loadOnMainThread(
   Glide.with(context)
     .load(canonicalBytes)
     .listener(requestListener)
     .apply(skipMemoryCacheOf(false)),
   imageView);
 verify(requestListener).onResourceReady(
   anyDrawable(), any(), anyDrawableTarget(), eq(DataSource.MEMORY_CACHE), anyBoolean());
}

代码示例来源:origin: apache/hive

@Test
public void testQueryCloseOnError() throws Exception {
 ObjectStore spy = Mockito.spy(objectStore);
 spy.getAllDatabases(DEFAULT_CATALOG_NAME);
 spy.getAllFunctions(DEFAULT_CATALOG_NAME);
 spy.getAllTables(DEFAULT_CATALOG_NAME, DB1);
 spy.getPartitionCount();
 Mockito.verify(spy, Mockito.times(3))
   .rollbackAndCleanup(Mockito.anyBoolean(), Mockito.<Query>anyObject());
}

代码示例来源:origin: bumptech/glide

@Test
public void load_whenLoadSucceeds_butEncoderFails_doesNotCallOnLoadFailed() {
 WaitForErrorStrategy strategy = new WaitForErrorStrategy();
 Glide.init(context,
   new GlideBuilder()
     .setAnimationExecutor(GlideExecutor.newAnimationExecutor(/*threadCount=*/ 1, strategy))
     .setSourceExecutor(GlideExecutor.newSourceExecutor(strategy))
     .setDiskCacheExecutor(GlideExecutor.newDiskCacheExecutor(strategy)));
 Glide.get(context).getRegistry().prepend(Bitmap.class, new FailEncoder());
 concurrency.get(
   Glide.with(context)
     .load(ResourceIds.raw.canonical)
     .listener(requestListener)
     .submit());
 verify(requestListener)
   .onResourceReady(
     anyDrawable(),
     any(),
     anyDrawableTarget(),
     any(DataSource.class),
     anyBoolean());
 verify(requestListener, never())
   .onLoadFailed(any(GlideException.class), any(), anyDrawableTarget(), anyBoolean());
}

代码示例来源:origin: bumptech/glide

@Test
public void requestBuilder_intoImageView_withSameByteArrayAndMemoryCacheEnabled_loadsFromMemory()
  throws IOException {
 final byte[] canonicalBytes = getCanonicalBytes();
 concurrency.loadOnMainThread(
   Glide.with(context)
     .asDrawable()
     .load(canonicalBytes)
     .apply(skipMemoryCacheOf(false)),
   imageView);
 Glide.with(context).clear(imageView);
 concurrency.loadOnMainThread(
   Glide.with(context)
     .asDrawable()
     .load(canonicalBytes)
     .listener(requestListener)
     .apply(skipMemoryCacheOf(false)),
   imageView);
 verify(requestListener).onResourceReady(
   anyDrawable(), any(), anyDrawableTarget(), eq(DataSource.MEMORY_CACHE), anyBoolean());
}

代码示例来源:origin: bumptech/glide

@Test
public void load_whenEncoderFails_callsUncaughtThrowableStrategy() {
 WaitForErrorStrategy strategy = new WaitForErrorStrategy();
 Glide.init(context,
   new GlideBuilder()
     .setAnimationExecutor(GlideExecutor.newAnimationExecutor(/*threadCount=*/ 1, strategy))
     .setSourceExecutor(GlideExecutor.newSourceExecutor(strategy))
     .setDiskCacheExecutor(GlideExecutor.newDiskCacheExecutor(strategy)));
 Glide.get(context).getRegistry().prepend(Bitmap.class, new FailEncoder());
 concurrency.get(
   Glide.with(context)
     .load(ResourceIds.raw.canonical)
     .listener(requestListener)
     .submit());
 // Writing to the disk cache and therefore the exception caused by our FailEncoder may happen
 // after the request completes, so we should wait for the expected error explicitly.
 ConcurrencyHelper.waitOnLatch(strategy.latch);
 assertThat(strategy.error).isEqualTo(FailEncoder.TO_THROW);
 verify(requestListener, never())
   .onLoadFailed(any(GlideException.class), any(), anyDrawableTarget(), anyBoolean());
}

代码示例来源:origin: bumptech/glide

@Test
public void loadFromRequestManager_withSameByteArray_returnsFromLocal() throws IOException {
 byte[] data = getCanonicalBytes();
 Target<Drawable> target = concurrency.wait(
   GlideApp.with(context)
     .load(data)
     .submit());
 GlideApp.with(context).clear(target);
 concurrency.wait(
   GlideApp.with(context)
     .load(data)
     .listener(requestListener)
     .submit());
 verify(requestListener).onResourceReady(
   anyDrawable(), any(), anyDrawableTarget(), eq(DataSource.LOCAL), anyBoolean());
}

代码示例来源:origin: bumptech/glide

@Test
public void loadFromRequestBuilder_withSameByteArray_returnsFromLocal() throws IOException {
 byte[] data = getCanonicalBytes();
 Target<Drawable> target = concurrency.wait(
   GlideApp.with(context)
     .asDrawable()
     .load(data)
     .submit());
 GlideApp.with(context).clear(target);
 concurrency.wait(
   GlideApp.with(context)
     .asDrawable()
     .load(data)
     .listener(requestListener)
     .submit());
 verify(requestListener).onResourceReady(
   anyDrawable(), any(), anyDrawableTarget(), eq(DataSource.LOCAL), anyBoolean());
}

代码示例来源:origin: bumptech/glide

@Test
public void loadFromRequestManager_withSameByteArray_memoryCacheEnabled_returnsFromCache()
  throws IOException {
 byte[] data = getCanonicalBytes();
 Target<Drawable> target = concurrency.wait(
   GlideApp.with(context)
     .load(data)
     .skipMemoryCache(false)
     .submit());
 GlideApp.with(context).clear(target);
 concurrency.wait(
   GlideApp.with(context)
     .load(data)
     .skipMemoryCache(false)
     .listener(requestListener)
     .submit());
 verify(requestListener).onResourceReady(
   anyDrawable(), any(), anyDrawableTarget(), eq(DataSource.MEMORY_CACHE), anyBoolean());
}

代码示例来源:origin: bumptech/glide

@Test
public void submit_withDisabledMemoryCache_andResourceInActiveResources_loadsFromMemory() {
 Glide.init(
   context, new GlideBuilder().setMemoryCache(new MemoryCacheAdapter()));
 FutureTarget<Drawable> first =
   GlideApp.with(context)
     .load(raw.canonical)
     .submit();
 concurrency.get(first);
 concurrency.get(
   GlideApp.with(context)
     .load(ResourceIds.raw.canonical)
     .listener(requestListener)
     .submit());
 verify(requestListener)
   .onResourceReady(
     anyDrawable(),
     any(),
     anyDrawableTarget(),
     eq(DataSource.MEMORY_CACHE),
     anyBoolean());
}

代码示例来源:origin: bumptech/glide

@Test
public void loadFromRequestManager_withSameByteArrayAndMissingFromMemory_returnsFromLocal()
   throws IOException {
 byte[] data = getCanonicalBytes();
 Target<Drawable> target = concurrency.wait(
   GlideApp.with(context)
     .load(data)
     .submit());
 GlideApp.with(context).clear(target);
 concurrency.runOnMainThread(new Runnable() {
  @Override
  public void run() {
   GlideApp.get(context).clearMemory();
  }
 });
 concurrency.wait(
   GlideApp.with(context)
     .load(data)
     .listener(requestListener)
     .submit());
 verify(requestListener).onResourceReady(
   anyDrawable(), any(), anyDrawableTarget(), eq(DataSource.LOCAL), anyBoolean());
}

代码示例来源:origin: bumptech/glide

@Test
public void loadFromRequestBuilder_withSameByteArray_memoryCacheEnabled_returnsFromCache()
  throws IOException {
 byte[] data = getCanonicalBytes();
 Target<Drawable> target = concurrency.wait(
   GlideApp.with(context)
     .asDrawable()
     .load(data)
     .skipMemoryCache(false)
     .submit());
 GlideApp.with(context).clear(target);
 concurrency.wait(
   GlideApp.with(context)
     .asDrawable()
     .load(data)
     .skipMemoryCache(false)
     .listener(requestListener)
     .submit());
 verify(requestListener).onResourceReady(
   anyDrawable(), any(), anyDrawableTarget(), eq(DataSource.MEMORY_CACHE), anyBoolean());
}

代码示例来源:origin: bumptech/glide

@Test
public void loadFromBuilder_withDataDiskCacheStrategy_returnsFromSource() throws IOException {
 byte[] data = getCanonicalBytes();
 concurrency.wait(
   GlideApp.with(context)
     .asDrawable()
     .diskCacheStrategy(DiskCacheStrategy.DATA)
     .load(data)
     .submit());
 concurrency.wait(
   GlideApp.with(context)
     .asDrawable()
     .diskCacheStrategy(DiskCacheStrategy.DATA)
     .skipMemoryCache(true)
     .load(data)
     .listener(requestListener)
     .submit());
 verify(requestListener).onResourceReady(
   anyDrawable(),
   any(),
   anyDrawableTarget(),
   eq(DataSource.DATA_DISK_CACHE),
   anyBoolean());
}

代码示例来源:origin: bumptech/glide

@Test
public void loadFromRequestBuilder_withSameByteArrayAndMissingFromMemory_returnsFromLocal()
   throws IOException {
 byte[] data = getCanonicalBytes();
 Target<Drawable> target = concurrency.wait(
   GlideApp.with(context)
     .asDrawable()
     .load(data)
     .submit());
 GlideApp.with(context).clear(target);
 concurrency.runOnMainThread(new Runnable() {
  @Override
  public void run() {
   GlideApp.get(context).clearMemory();
  }
 });
 concurrency.wait(
   GlideApp.with(context)
     .asDrawable()
     .load(data)
     .listener(requestListener)
     .submit());
 verify(requestListener).onResourceReady(
   anyDrawable(), any(), anyDrawableTarget(), eq(DataSource.LOCAL), anyBoolean());
}

代码示例来源:origin: bumptech/glide

@Test
public void loadFromBuilder_withSkipMemoryCacheSetBeforeLoad_doesNotOverrideSkipMemoryCache()
  throws IOException {
 byte[] data = getCanonicalBytes();
 concurrency.wait(
   GlideApp.with(context)
     .asDrawable()
     .skipMemoryCache(false)
     .load(data)
     .submit());
 concurrency.runOnMainThread(new Runnable() {
  @Override
  public void run() {
   GlideApp.get(context).clearMemory();
  }
 });
 concurrency.wait(
   GlideApp.with(context)
     .asDrawable()
     .skipMemoryCache(false)
     .listener(requestListener)
     .load(data)
     .submit());
 verify(requestListener).onResourceReady(
   anyDrawable(), any(), anyDrawableTarget(), eq(DataSource.MEMORY_CACHE), anyBoolean());
}

相关文章