org.easymock.EasyMock.notNull()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(105)

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

EasyMock.notNull介绍

[英]Expects not null.
[中]期望值不为空。

代码示例

代码示例来源:origin: briandilley/jsonrpc4j

/**
 * The {@link com.googlecode.jsonrpc4j.JsonRpcBasicServer} is able to have an instance of
 * {@link com.googlecode.jsonrpc4j.InvocationListener} configured for it.  Prior to a
 * method being invoked, the lister is notified and after the method is invoked, the
 * listener is notified.  This test checks that these two events are hit correctly
 * when a method is invoked.
 */

@SuppressWarnings("unchecked")
@Test
public void callMethodWithInvocationListener() throws Exception {
  final InvocationListener invocationListener = EasyMock.niceMock(InvocationListener.class);
  Method m = ServiceInterface.class.getMethod("throwsMethod", String.class);
  invocationListener.willInvoke(eq(m), anyObject(List.class));
  invocationListener.didInvoke(eq(m), anyObject(List.class), EasyMock.notNull(), EasyMock.<Throwable>isNull(), EasyMock.geq(0L));
  
  jsonRpcServer.setInvocationListener(invocationListener);
  
  EasyMock.expect(mockService.throwsMethod(param1)).andReturn(param1);
  EasyMock.replay(mockService, invocationListener);
  
  jsonRpcServer.handleRequest(messageWithListParamsStream(1, "throwsMethod", param1), byteArrayOutputStream);
  
  EasyMock.verify(invocationListener, mockService);
  
  JsonNode json = decodeAnswer(byteArrayOutputStream);
  assertEquals(param1, json.get(JsonRpcBasicServer.RESULT).textValue());
  assertNull(json.get(JsonRpcBasicServer.ERROR));
}

代码示例来源:origin: briandilley/jsonrpc4j

/**
 * The {@link com.googlecode.jsonrpc4j.JsonRpcBasicServer} is able to have an instance of
 * {@link com.googlecode.jsonrpc4j.InvocationListener} configured for it.  Prior to a
 * method being invoked, the lister is notified and after the method is invoked, the
 * listener is notified.  This test checks that these two events are hit correctly in
 * the case that an exception is raised when the method is invoked.
 */

@Test
@SuppressWarnings("unchecked")
public void callMethodThrowingWithInvocationListener() throws Exception {
  final InvocationListener invocationListener = EasyMock.niceMock(InvocationListener.class);
  Method m = ServiceInterface.class.getMethod("throwsMethod", String.class);
  invocationListener.willInvoke(eq(m), anyObject(List.class));
  invocationListener.didInvoke(eq(m), anyObject(List.class), EasyMock.isNull(), EasyMock.<Throwable>notNull(), EasyMock.geq(0L));
  
  jsonRpcServer.setInvocationListener(invocationListener);
  
  EasyMock.expect(mockService.throwsMethod(param1)).andThrow(new CustomTestException(param1));
  EasyMock.replay(mockService, invocationListener);
  
  jsonRpcServer.handleRequest(messageWithListParamsStream(1, "throwsMethod", param1), byteArrayOutputStream);
  
  EasyMock.verify(invocationListener, mockService);
  
  JsonNode json = decodeAnswer(byteArrayOutputStream);
  assertNull(json.get(JsonRpcBasicServer.RESULT));
  assertNotNull(json.get(JsonRpcBasicServer.ERROR));
}

代码示例来源:origin: bedatadriven/activityinfo

private AsyncCallback makeCallbackThatExpectsNonNullSuccess() {
  AsyncCallback callback = createMock(AsyncCallback.class);
  callback.onSuccess(notNull());
  replay(callback);
  return callback;
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-gadgets

@SuppressWarnings("unchecked")
 private ConfigContributor mockContrib(Gadget gadget) {
  ConfigContributor contrib = EasyMock.createMock(ConfigContributor.class);
  createMock(ConfigContributor.class);
  if (gadget != null) {
   contrib.contribute((Map<String, Object>) notNull(), eq(gadget));
   expectLastCall();
  }
  replay(contrib);
  return contrib;
 }
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@SuppressWarnings("unchecked")
 private ConfigContributor mockContrib(Gadget gadget) {
  ConfigContributor contrib = EasyMock.createMock(ConfigContributor.class);
  createMock(ConfigContributor.class);
  if (gadget != null) {
   contrib.contribute((Map<String, Object>) notNull(), eq(gadget));
   expectLastCall();
  }
  replay(contrib);
  return contrib;
 }
}

代码示例来源:origin: org.apache.shindig/shindig-gadgets

@SuppressWarnings("unchecked")
private ConfigContributor mockContrib(String host) {
 ConfigContributor contrib = EasyMock.createMock(ConfigContributor.class);
 createMock(ConfigContributor.class);
 if (host != null) {
  contrib.contribute((Map<String, Object>) notNull(), eq(CONTAINER), eq(host));
  expectLastCall();
 }
 replay(contrib);
 return contrib;
}

代码示例来源:origin: org.wso2.org.apache.shindig/shindig-gadgets

@SuppressWarnings("unchecked")
private ConfigContributor mockContrib(String host) {
 ConfigContributor contrib = EasyMock.createMock(ConfigContributor.class);
 createMock(ConfigContributor.class);
 if (host != null) {
  contrib.contribute((Map<String, Object>) notNull(), eq(CONTAINER), eq(host));
  expectLastCall();
 }
 replay(contrib);
 return contrib;
}

代码示例来源:origin: iipc/openwayback

public void testIncludeUrl() throws Exception {
  final String url = "http://example.com/";
  final String urlkey = "example.com)/";
  EasyMock.expect(adminFilter.filterObject(EasyMock.<CaptureSearchResult>notNull())).andAnswer(
    new CheckCaptureSearchResult(url, urlkey, null));
  EasyMock.expect(robotsFilter.filterObject(EasyMock.<CaptureSearchResult>notNull())).andAnswer(
    new CheckCaptureSearchResult(url, urlkey, null));
  // expects no calls to scopeFilter
  EasyMock.replay(adminFilter, robotsFilter, scopeFilter);
  boolean result = cut.includeUrl(urlkey, url);
  assertTrue(result);
  EasyMock.verify(adminFilter, robotsFilter, scopeFilter);
}

代码示例来源:origin: iipc/openwayback

protected HttpServletRequest getRequestMock(String requestURI, String query) {
  HttpServletRequest mock = EasyMock.createNiceMock(HttpServletRequest.class);
  // DatelessReplayRequestParser checks out Accept-Datetime HTTP header. If we
  // want to test it, we need to setup return value for getHeader() method.
  // RequestMapper accesses HttpServletequest.getAttribute(RequestMapper.REQUEST_CONTEXT_PREFIX)
  // which can be null. so we leave it null.
  // prefix must end with "/" (see RequestMapper#handleRequest(HttpServletRequest, HttpServletResponse)
  EasyMock.expect(mock.getAttribute(EasyMock.eq("webapp-request-context-path-prefix"))).andStubReturn("/web/");
  EasyMock.expect(mock.getRequestURI()).andStubReturn(requestURI);
  EasyMock.expect(mock.getQueryString()).andStubReturn(query);
  EasyMock.expect(mock.getHeader(MementoConstants.ACCEPT_DATETIME)).andStubReturn(acceptDatetimeHeader);
  EasyMock.expect(mock.getHeader("Accept-Timestamp")).andStubReturn(acceptTimestampHeader);
  // used by OpenSearchRequestParser, TimeMapRequestParser
  final Map<String, String[]> parameterMap = parseParameters(requestURI);
  EasyMock.expect(mock.getParameterMap()).andStubReturn(parameterMap);
  EasyMock.expect(mock.getParameter(EasyMock.<String>notNull()))
  .andStubAnswer(new IAnswer<String>() {
    @Override
    public String answer() throws Throwable {
      String name = (String)EasyMock.getCurrentArguments()[0];
      String[] va = parameterMap.get(name);
      return va != null ? va[0] : null;
    }
  });
  return mock;
}

代码示例来源:origin: iipc/openwayback

public void testRenderResource_BasicCapture() throws Exception {
  final String ct = "image/gif";
  WARCRecordInfo recinfo = TestWARCRecordInfo.createHttpResponse(ct, TestWARCRecordInfo.PAYLOAD_GIF);
  TestWARCReader ar = new TestWARCReader(recinfo);
  WARCRecord rec = ar.get(0);
  Resource payloadResource = new WarcResource(rec, ar);
  payloadResource.parseHeaders();
  Resource headersResource = payloadResource;
  
  TestServletOutputStream servletOutput = new TestServletOutputStream();
  response.setStatus(200);
  EasyMock.expect(response.getOutputStream()).andReturn(servletOutput);
  response.setHeader("Content-Type", ct);
  // ??? RedirectRewritingHttpHeaderProcessor drops Content-Length header. is this really
  // it is supposed to do?
  //response.setHeader("Content-Length", Integer.toString(payloadBytes.length));
  response.setHeader(EasyMock.<String>notNull(), EasyMock.<String>notNull());
  EasyMock.expectLastCall().anyTimes();
  EasyMock.replay(response);
  cut.renderResource(request, response, wbRequest, result,
      headersResource, payloadResource, uriConverter, results);
  
  EasyMock.verify(response);
  byte[] content = servletOutput.getBytes();
  assertTrue("servlet output", Arrays.equals(TestWARCRecordInfo.PAYLOAD_GIF, content));
}

代码示例来源:origin: iipc/openwayback

Locale.CANADA_FRENCH);
EasyMock.expect(
  httpRequest.getRequestDispatcher(EasyMock.<String>notNull()))
  .andStubReturn(requestDispatcher);

代码示例来源:origin: iipc/openwayback

EasyMock.expect(adminFilter.filterObject(EasyMock.<CaptureSearchResult>notNull())).andAnswer(
  new CheckCaptureSearchResult(url, urlkey, timestamp));
EasyMock.expect(robotsFilter.filterObject(EasyMock.<CaptureSearchResult>notNull())).andAnswer(
  new CheckCaptureSearchResult(url, urlkey, timestamp));
EasyMock.expect(scopeFilter.include(EasyMock.<CDXLine>notNull())).andAnswer(
  new IAnswer<Boolean>() {
    @Override

代码示例来源:origin: iipc/openwayback

response.setHeader(EasyMock.<String>notNull(), EasyMock.<String>notNull());
EasyMock.expectLastCall().anyTimes();
EasyMock.replay(response);

代码示例来源:origin: iipc/openwayback

response.setHeader(EasyMock.<String>notNull(), EasyMock.<String>notNull());
EasyMock.expectLastCall().anyTimes();

代码示例来源:origin: iipc/openwayback

EasyMock.expect(servletContext.getRealPath(EasyMock.<String>notNull()))
  .andStubReturn(null);
cut.setServletContext(servletContext);

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

@BeforeMethod
public void setUpAgain() throws Exception {
  m_dummyInputStream = new FileInputStream(m_dummyFile);
  DownloadResult downloadResult = addTestMock(DownloadResult.class);
  expect(downloadResult.isComplete()).andReturn(true).anyTimes();
  expect(downloadResult.getInputStream()).andReturn(m_dummyInputStream).anyTimes();
  
  Future<DownloadResult> future = addTestMock(Future.class);
  expect(future.get()).andReturn(downloadResult).anyTimes();
  DownloadHandle downloadHandle = addTestMock(DownloadHandle.class);
  expect(downloadHandle.start(isNull(DownloadProgressListener.class))).andReturn(future).anyTimes();
  DeploymentHandler deploymentHandler = addTestMock(DeploymentHandler.class);
  expect(deploymentHandler.getInstalledVersion()).andReturn(m_version2).anyTimes();
  expect(deploymentHandler.getAvailableVersions()).andReturn(m_availableVersions).anyTimes();
  expect(deploymentHandler.getDownloadHandle(eq(m_version3), eq(true))).andReturn(downloadHandle).once();
  deploymentHandler.install(notNull(InputStream.class));
  expectLastCall().once();
  m_agentContext = mockAgentContext();
  m_agentContext.setHandler(DeploymentHandler.class, deploymentHandler);
  replayTestMocks();
  m_agentContext.start();
  m_agentControl = new AgentControlImpl(m_agentContext);
}

代码示例来源:origin: iipc/openwayback

response.setHeader(EasyMock.<String>notNull(), EasyMock.<String>notNull());
EasyMock.expectLastCall().anyTimes();

代码示例来源:origin: iipc/openwayback

response.setHeader(EasyMock.<String>notNull(), EasyMock.<String>notNull());
EasyMock.expectLastCall().anyTimes();

代码示例来源:origin: iipc/openwayback

response.setHeader(TextReplayRenderer.GUESSED_CHARSET_HEADER, "UTF-8");
response.setHeader("Content-Type", "text/html");
response.setHeader(EasyMock.matches("X-Archive-Orig-.*"), EasyMock.<String>notNull());
EasyMock.expectLastCall().anyTimes();

代码示例来源:origin: iipc/openwayback

response.setHeader(TextReplayRenderer.GUESSED_CHARSET_HEADER, "UTF-8");
response.setHeader("Content-Type", "text/html");
response.setHeader(EasyMock.matches("X-Archive-Orig-.*"), EasyMock.<String>notNull());
EasyMock.expectLastCall().anyTimes();

相关文章