当前位置: 首页>>代码示例>>Java>>正文


Java InvocationOnMock.getArguments方法代码示例

本文整理汇总了Java中org.mockito.invocation.InvocationOnMock.getArguments方法的典型用法代码示例。如果您正苦于以下问题:Java InvocationOnMock.getArguments方法的具体用法?Java InvocationOnMock.getArguments怎么用?Java InvocationOnMock.getArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mockito.invocation.InvocationOnMock的用法示例。


在下文中一共展示了InvocationOnMock.getArguments方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createOkResponseWithCookie

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
private Answer<HttpResponse> createOkResponseWithCookie() {
    return new Answer<HttpResponse>() {
        @Override
        public HttpResponse answer(InvocationOnMock invocation) throws Throwable {
            HttpContext context = (HttpContext) invocation.getArguments()[1];
            if (context.getAttribute(ClientContext.COOKIE_STORE) != null) {
                BasicCookieStore cookieStore =
                        (BasicCookieStore) context.getAttribute(ClientContext.COOKIE_STORE);
                BasicClientCookie cookie = new BasicClientCookie("cookie", "meLikeCookie");
                cookieStore.addCookie(cookie);
            }

            return OK_200_RESPONSE;
        }
    };
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:17,代码来源:WebDavStoreTest.java

示例2: addConsoleDebug

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
/**
 * Adds a little (not complete) console debug output to a mocked logger.
 *
 * @param mogger
 *            the mocked logger
 */
public static void addConsoleDebug(SimpleLogger mogger) {
    Answer<Void> answer = new Answer<Void>() {
        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            Object[] arguments = invocation.getArguments();
            if (arguments != null && arguments.length > 0
                    && arguments[0] != null) {
                System.out.println(arguments[0]);
            }
            return null;
        }
    };
    Mockito.doAnswer(answer).when(mogger).debug(Matchers.anyString());
    Mockito.doAnswer(answer).when(mogger).debug(Matchers.anyString(),
            Matchers.any(Throwable.class));
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:23,代码来源:LoggerMocking.java

示例3: answer

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
  Object[] args = invocation.getArguments();
  for (int i = 0; i < args.length; i++) {
    if (args[i] instanceof Message) {
      Message msg = (Message) args[i];
      Object content = null;
      content = msg.getBuffer();
      if (content instanceof byte[]) {
        if (pingPonger.isPingMessage((byte[]) content)) {
          pingCount++;
          if (simulatedPongRespondersByPort.contains(((JGAddress) msg.getDest()).getPort())) {
            channel.getReceiver()
                .receive(pingPonger.createPongMessage(msg.getDest(), msg.getSrc()));
          }
        }
      }
    }
  }
  return null;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:22,代码来源:GMSQuorumCheckerJUnitTest.java

示例4: createClientSocketChannel

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
/**
 * Mock a client channel with a connection request and a watches message
 * inside.
 * 
 * @return a socket channel
 * @throws IOException
 */
private SocketChannel createClientSocketChannel() throws IOException {

    SocketChannel socketChannel = mock(SocketChannel.class);
    Socket socket = mock(Socket.class);
    InetSocketAddress socketAddress = new InetSocketAddress(1234);
    when(socket.getRemoteSocketAddress()).thenReturn(socketAddress);
    when(socketChannel.socket()).thenReturn(socket);

    // Send watches packet to server connection
    final ByteBuffer connRequest = createConnRequest();
    final ByteBuffer watchesMessage = createWatchesMessage();
    final ByteBuffer request = ByteBuffer.allocate(connRequest.limit()
            + watchesMessage.limit());
    request.put(connRequest);
    request.put(watchesMessage);

    Answer<Integer> answer = new Answer<Integer>() {
        int i = 0;

        @Override
        public Integer answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();
            ByteBuffer bb = (ByteBuffer) args[0];
            for (int k = 0; k < bb.limit(); k++) {
                bb.put(request.get(i));
                i = i + 1;
            }
            return bb.limit();
        }
    };
    when(socketChannel.read(any(ByteBuffer.class))).thenAnswer(answer);
    return socketChannel;
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:41,代码来源:WatchLeakTest.java

示例5: answer

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
@Override
public LocatedBlocks answer(InvocationOnMock invocation) throws IOException {
  Object args[] = invocation.getArguments();
  LocatedBlocks realAnswer = realNN.getBlockLocations(
    (String)args[0],
    (Long)args[1],
    (Long)args[2]);

  if (failuresLeft-- > 0) {
    NameNode.LOG.info("FailNTimesAnswer injecting failure.");
    return makeBadBlockList(realAnswer);
  }
  NameNode.LOG.info("FailNTimesAnswer no longer failing.");
  return realAnswer;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:TestDFSClientRetries.java

示例6: answer

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
  DataFetcher.DataCallback<T> callback =
      (DataFetcher.DataCallback<T>) invocationOnMock.getArguments()[1];
  callback.onDataReady(data);
  return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:Util.java

示例7: addDiskImageAnswer

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
private void addDiskImageAnswer() throws Exception {
    Answer<DiskImage> answerDiskImage = new Answer<DiskImage>() {
        @Override
        public DiskImage answer(InvocationOnMock invocation)
                throws Throwable {
            Object[] arguments = invocation.getArguments();
            if (arguments != null && arguments.length > 0) {
                return diskImages.get(arguments[0]);
            }
            return null;
        }
    };
    Mockito.doAnswer(answerDiskImage).when(vServerProcessor)
            .isDiskImageIdValid(anyString(), any(PropertyHandler.class));
}
 
开发者ID:servicecatalog,项目名称:oscm-app,代码行数:16,代码来源:VSystemProcessorBeanTest.java

示例8: answer

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public T answer(InvocationOnMock invocation) throws Throwable {
    Object[] args = invocation.getArguments();
    //noinspection unchecked
    return (T) args[0];
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:EnumRuleTest.java

示例9: getFromMap

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
@NonNull
private Answer getFromMap(final HashMap<String, String> store) {
    return new Answer() {
        @Override
        public String answer(final InvocationOnMock invocation) throws Throwable {
            final Object[] args = invocation.getArguments();
            //noinspection RedundantCast
            return store.get((String) args[0]);
        }
    };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:AbstractPresenterDestroyTest.java

示例10: setupWrites

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
private void setupWrites() {
    final Answer<Void> writeSingleValueAnswer = new Answer<Void>() {
        @Override
        public Void answer(final InvocationOnMock invocation) throws Throwable {
            final Object parameter = invocation.getArguments()[0];
            mObjects.add(parameter);
            return null;
        }
    };
    doAnswer(writeSingleValueAnswer).when(mParcel).writeString(anyString());
    doAnswer(writeSingleValueAnswer).when(mParcel).writeInt(anyInt());
    doAnswer(writeSingleValueAnswer).when(mParcel).writeLong(anyLong());
    doAnswer(writeSingleValueAnswer).when(mParcel).writeIntArray(Matchers.<int[]>any());
    doAnswer(writeSingleValueAnswer).when(mParcel).writeLongArray(Matchers.<long[]>any());
}
 
开发者ID:GlobusLTD,项目名称:primitive-collections-android,代码行数:16,代码来源:MockParcel.java

示例11: setupOther

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
private void setupOther() {
    final Answer<Void> setDataPositionAnswer = new Answer<Void>() {
        @Override
        public Void answer(final InvocationOnMock invocation) throws Throwable {
            mPosition = ((Integer) invocation.getArguments()[0]);
            return null;
        }
    };
    doAnswer(setDataPositionAnswer).when(mParcel).setDataPosition(anyInt());
}
 
开发者ID:GlobusLTD,项目名称:primitive-collections-android,代码行数:11,代码来源:MockParcel.java

示例12: answer

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
  SizeReadyCallback cb = (SizeReadyCallback) invocationOnMock.getArguments()[0];
  cb.onSizeReady(width, height);
  return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:SingleRequestTest.java

示例13: answer

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
  Bitmap bitmap = (Bitmap) invocationOnMock.getArguments()[0];
  bitmaps.add(bitmap);
  return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:BitmapPreFillRunnerTest.java

示例14: answer

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
  Object[] args = invocation.getArguments();
  mFrameCallback = (ChoreographerCompat.FrameCallback) args[1];
  return null;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:7,代码来源:TimingModuleTest.java

示例15: updateFlowAnswer

import org.mockito.invocation.InvocationOnMock; //导入方法依赖的package包/类
private Answer<FlowEntity> updateFlowAnswer() {
    return (InvocationOnMock invocation) -> {
        final FlowEntity flowEntity = (FlowEntity) invocation.getArguments()[0];
        return flowEntity;
    };
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:7,代码来源:TestRegistryService.java


注:本文中的org.mockito.invocation.InvocationOnMock.getArguments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。