org.mockito.MockitoAnnotations#initMocks ( )源码实例Demo

下面列出了org.mockito.MockitoAnnotations#initMocks ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: grpc-nebula-java   文件: ManagedChannelImplTest.java
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  expectedUri = new URI(TARGET);
  when(mockLoadBalancerFactory.newLoadBalancer(any(Helper.class))).thenReturn(mockLoadBalancer);
  transports = TestUtils.captureTransports(mockTransportFactory);
  when(mockTransportFactory.getScheduledExecutorService())
      .thenReturn(timer.getScheduledExecutorService());
  when(executorPool.getObject()).thenReturn(executor.getScheduledExecutorService());
  when(balancerRpcExecutorPool.getObject())
      .thenReturn(balancerRpcExecutor.getScheduledExecutorService());

  channelBuilder = new ChannelBuilder()
      .nameResolverFactory(new FakeNameResolverFactory.Builder(expectedUri).build())
      .loadBalancerFactory(mockLoadBalancerFactory)
      .userAgent(USER_AGENT)
      .idleTimeout(AbstractManagedChannelImplBuilder.IDLE_MODE_MAX_TIMEOUT_DAYS, TimeUnit.DAYS);
  channelBuilder.executorPool = executorPool;
  channelBuilder.binlog = null;
  channelBuilder.channelz = channelz;
}
 
源代码2 项目: vividus   文件: BddStepsCounterTests.java
@Before
public void before()
{
    MockitoAnnotations.initMocks(this);
    PowerMockito.mockStatic(Vividus.class);
    PowerMockito.mockStatic(BeanFactory.class);
}
 
源代码3 项目: cubeai   文件: DocumentResourceIntTest.java
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    final DocumentResource documentResource = new DocumentResource(documentRepository, solutionRepository);
    this.restDocumentMockMvc = MockMvcBuilders.standaloneSetup(documentResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setControllerAdvice(exceptionTranslator)
        .setConversionService(createFormattingConversionService())
        .setMessageConverters(jacksonMessageConverter).build();
}
 
@Before
public void before() throws Exception {
    MockitoAnnotations.initMocks(this);

    InternalConfigurations.PERSISTENCE_CLOSE_RETRIES.set(3);
    InternalConfigurations.PERSISTENCE_CLOSE_RETRY_INTERVAL.set(5);
    InternalConfigurations.PAYLOAD_PERSISTENCE_BUCKET_COUNT.set(8);
    when(localPersistenceFileUtil.getVersionedLocalPersistenceFolder(anyString(), anyString())).thenReturn(temporaryFolder.newFolder());

    persistence = new PublishPayloadXodusLocalPersistence(localPersistenceFileUtil, new EnvironmentUtil(), new PersistenceStartup());
    persistence.start();
}
 
@Before
public void before() {
    MockitoAnnotations.initMocks(this);
    channelInitializerFactory = new TestChannelInitializerFactory(channelDependencies,
            sslFactory,
            nonSslHandlerProvider);
}
 
@Before
public void setUp() throws Exception {

    MockitoAnnotations.initMocks(this);
    handler = new SubscribeHandler(clientSessionSubscriptionPersistence, retainedMessagePersistence, sharedSubscriptionService, eventLog, retainedMessagesSender, mqttConfigurationService);

    channel = new EmbeddedChannel(handler);
    channel.attr(ChannelAttributes.CLIENT_ID).set("client");

    when(clientSessionSubscriptionPersistence.addSubscription(anyString(), any(Topic.class))).thenReturn(Futures.immediateFuture(null));
    when(clientSessionSubscriptionPersistence.addSubscriptions(anyString(), any(ImmutableSet.class))).thenReturn(Futures.<Void>immediateFuture(null));
    when(ctx.channel()).thenReturn(channel);
    when(ctx.writeAndFlush(anyObject())).thenReturn(channelFuture);
    when(ctx.executor()).thenReturn(ImmediateEventExecutor.INSTANCE);
}
 
源代码7 项目: cubeai   文件: DescriptionResourceIntTest.java
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    final DescriptionResource descriptionResource = new DescriptionResource(descriptionRepository);
    this.restDescriptionMockMvc = MockMvcBuilders.standaloneSetup(descriptionResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setControllerAdvice(exceptionTranslator)
        .setConversionService(createFormattingConversionService())
        .setMessageConverters(jacksonMessageConverter).build();
}
 
源代码8 项目: cubeai   文件: VerifyCodeResourceIntTest.java
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    final VerifyCodeResource verifyCodeResource = new VerifyCodeResource(verifyCodeRepository, verifyCodeService);
    this.restVerifyCodeMockMvc = MockMvcBuilders.standaloneSetup(verifyCodeResource)
        .setCustomArgumentResolvers(pageableArgumentResolver)
        .setControllerAdvice(exceptionTranslator)
        .setConversionService(createFormattingConversionService())
        .setMessageConverters(jacksonMessageConverter).build();
}
 
源代码9 项目: rqueue   文件: DelayedMessageSchedulerTest.java
@Before
public void init() {
  MockitoAnnotations.initMocks(this);
  QueueRegistry.delete();
  QueueRegistry.register(fastQueueDetail);
  QueueRegistry.register(slowQueueDetail);
}
 
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    when(channel.eventLoop()).thenReturn(new DefaultEventLoop(Executors.newSingleThreadExecutor()));
}
 
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
}
 
@Before
public void setUp() {
	MockitoAnnotations.initMocks(this);
}
 
@Before
public void before() {
    MockitoAnnotations.initMocks(this);
    comparator = new PluginPriorityComparator(hiveMQExtensions);
}
 
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    embeddedChannel = new EmbeddedChannel(TestMqttDecoder.create());
}
 
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    networkInterface = NetworkInterface.getByName("Does_Not_Exist");
    networkInterfaceInformation = new NetworkInterfaceInformation();
}
 
源代码16 项目: grpc-nebula-java   文件: NettyClientHandlerTest.java
/**
 * Set up for test.
 */
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);

  doAnswer(
        new Answer<Void>() {
          @Override
          public Void answer(InvocationOnMock invocation) throws Throwable {
            StreamListener.MessageProducer producer =
                (StreamListener.MessageProducer) invocation.getArguments()[0];
            InputStream message;
            while ((message = producer.next()) != null) {
              streamListenerMessageQueue.add(message);
            }
            return null;
          }
        })
    .when(streamListener)
    .messagesAvailable(Matchers.<StreamListener.MessageProducer>any());

  lifecycleManager = new ClientTransportLifecycleManager(listener);
  // This mocks the keepalive manager only for there's in which we verify it. For other tests
  // it'll be null which will be testing if we behave correctly when it's not present.
  if (setKeepaliveManagerFor.contains(testNameRule.getMethodName())) {
    mockKeepAliveManager = mock(KeepAliveManager.class);
  }

  initChannel(new GrpcHttp2ClientHeadersDecoder(GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE));
  streamTransportState = new TransportStateImpl(
      handler(),
      channel().eventLoop(),
      DEFAULT_MAX_MESSAGE_SIZE,
      transportTracer);
  streamTransportState.setListener(streamListener);

  grpcHeaders = new DefaultHttp2Headers()
      .scheme(HTTPS)
      .authority(as("www.fake.com"))
      .path(as("/fakemethod"))
      .method(HTTP_METHOD)
      .add(as("auth"), as("sometoken"))
      .add(CONTENT_TYPE_HEADER, CONTENT_TYPE_GRPC)
      .add(TE_HEADER, TE_TRAILERS);

  // Simulate receipt of initial remote settings.
  ByteBuf serializedSettings = serializeSettings(new Http2Settings());
  channelRead(serializedSettings);
}
 
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
}
 
源代码18 项目: flair-engine   文件: PostgresQueryTest.java
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    connection = connectionRepository.findByLinkId(POSTGRE_ID);
}
 
@Before
public void before() {
    MockitoAnnotations.initMocks(this);

    asyncer = new PluginOutputAsyncerImpl(shutdownHooks);
}
 
@Before
public void setUp() throws Exception {

    MockitoAnnotations.initMocks(this);

    messageDroppedService = new MessageDroppedServiceImpl(new MetricsHolder(new MetricRegistry()), eventLog);
}
 
 同类方法