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

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

本文整理了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

  1. /**
  2. * The {@link com.googlecode.jsonrpc4j.JsonRpcBasicServer} is able to have an instance of
  3. * {@link com.googlecode.jsonrpc4j.InvocationListener} configured for it. Prior to a
  4. * method being invoked, the lister is notified and after the method is invoked, the
  5. * listener is notified. This test checks that these two events are hit correctly
  6. * when a method is invoked.
  7. */
  8. @SuppressWarnings("unchecked")
  9. @Test
  10. public void callMethodWithInvocationListener() throws Exception {
  11. final InvocationListener invocationListener = EasyMock.niceMock(InvocationListener.class);
  12. Method m = ServiceInterface.class.getMethod("throwsMethod", String.class);
  13. invocationListener.willInvoke(eq(m), anyObject(List.class));
  14. invocationListener.didInvoke(eq(m), anyObject(List.class), EasyMock.notNull(), EasyMock.<Throwable>isNull(), EasyMock.geq(0L));
  15. jsonRpcServer.setInvocationListener(invocationListener);
  16. EasyMock.expect(mockService.throwsMethod(param1)).andReturn(param1);
  17. EasyMock.replay(mockService, invocationListener);
  18. jsonRpcServer.handleRequest(messageWithListParamsStream(1, "throwsMethod", param1), byteArrayOutputStream);
  19. EasyMock.verify(invocationListener, mockService);
  20. JsonNode json = decodeAnswer(byteArrayOutputStream);
  21. assertEquals(param1, json.get(JsonRpcBasicServer.RESULT).textValue());
  22. assertNull(json.get(JsonRpcBasicServer.ERROR));
  23. }

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

  1. /**
  2. * The {@link com.googlecode.jsonrpc4j.JsonRpcBasicServer} is able to have an instance of
  3. * {@link com.googlecode.jsonrpc4j.InvocationListener} configured for it. Prior to a
  4. * method being invoked, the lister is notified and after the method is invoked, the
  5. * listener is notified. This test checks that these two events are hit correctly in
  6. * the case that an exception is raised when the method is invoked.
  7. */
  8. @Test
  9. @SuppressWarnings("unchecked")
  10. public void callMethodThrowingWithInvocationListener() throws Exception {
  11. final InvocationListener invocationListener = EasyMock.niceMock(InvocationListener.class);
  12. Method m = ServiceInterface.class.getMethod("throwsMethod", String.class);
  13. invocationListener.willInvoke(eq(m), anyObject(List.class));
  14. invocationListener.didInvoke(eq(m), anyObject(List.class), EasyMock.isNull(), EasyMock.<Throwable>notNull(), EasyMock.geq(0L));
  15. jsonRpcServer.setInvocationListener(invocationListener);
  16. EasyMock.expect(mockService.throwsMethod(param1)).andThrow(new CustomTestException(param1));
  17. EasyMock.replay(mockService, invocationListener);
  18. jsonRpcServer.handleRequest(messageWithListParamsStream(1, "throwsMethod", param1), byteArrayOutputStream);
  19. EasyMock.verify(invocationListener, mockService);
  20. JsonNode json = decodeAnswer(byteArrayOutputStream);
  21. assertNull(json.get(JsonRpcBasicServer.RESULT));
  22. assertNotNull(json.get(JsonRpcBasicServer.ERROR));
  23. }

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

  1. private AsyncCallback makeCallbackThatExpectsNonNullSuccess() {
  2. AsyncCallback callback = createMock(AsyncCallback.class);
  3. callback.onSuccess(notNull());
  4. replay(callback);
  5. return callback;
  6. }

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

  1. @SuppressWarnings("unchecked")
  2. private ConfigContributor mockContrib(Gadget gadget) {
  3. ConfigContributor contrib = EasyMock.createMock(ConfigContributor.class);
  4. createMock(ConfigContributor.class);
  5. if (gadget != null) {
  6. contrib.contribute((Map<String, Object>) notNull(), eq(gadget));
  7. expectLastCall();
  8. }
  9. replay(contrib);
  10. return contrib;
  11. }
  12. }

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

  1. @SuppressWarnings("unchecked")
  2. private ConfigContributor mockContrib(Gadget gadget) {
  3. ConfigContributor contrib = EasyMock.createMock(ConfigContributor.class);
  4. createMock(ConfigContributor.class);
  5. if (gadget != null) {
  6. contrib.contribute((Map<String, Object>) notNull(), eq(gadget));
  7. expectLastCall();
  8. }
  9. replay(contrib);
  10. return contrib;
  11. }
  12. }

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

  1. @SuppressWarnings("unchecked")
  2. private ConfigContributor mockContrib(String host) {
  3. ConfigContributor contrib = EasyMock.createMock(ConfigContributor.class);
  4. createMock(ConfigContributor.class);
  5. if (host != null) {
  6. contrib.contribute((Map<String, Object>) notNull(), eq(CONTAINER), eq(host));
  7. expectLastCall();
  8. }
  9. replay(contrib);
  10. return contrib;
  11. }

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

  1. @SuppressWarnings("unchecked")
  2. private ConfigContributor mockContrib(String host) {
  3. ConfigContributor contrib = EasyMock.createMock(ConfigContributor.class);
  4. createMock(ConfigContributor.class);
  5. if (host != null) {
  6. contrib.contribute((Map<String, Object>) notNull(), eq(CONTAINER), eq(host));
  7. expectLastCall();
  8. }
  9. replay(contrib);
  10. return contrib;
  11. }

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

  1. public void testIncludeUrl() throws Exception {
  2. final String url = "http://example.com/";
  3. final String urlkey = "example.com)/";
  4. EasyMock.expect(adminFilter.filterObject(EasyMock.<CaptureSearchResult>notNull())).andAnswer(
  5. new CheckCaptureSearchResult(url, urlkey, null));
  6. EasyMock.expect(robotsFilter.filterObject(EasyMock.<CaptureSearchResult>notNull())).andAnswer(
  7. new CheckCaptureSearchResult(url, urlkey, null));
  8. // expects no calls to scopeFilter
  9. EasyMock.replay(adminFilter, robotsFilter, scopeFilter);
  10. boolean result = cut.includeUrl(urlkey, url);
  11. assertTrue(result);
  12. EasyMock.verify(adminFilter, robotsFilter, scopeFilter);
  13. }

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

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

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

  1. public void testRenderResource_BasicCapture() throws Exception {
  2. final String ct = "image/gif";
  3. WARCRecordInfo recinfo = TestWARCRecordInfo.createHttpResponse(ct, TestWARCRecordInfo.PAYLOAD_GIF);
  4. TestWARCReader ar = new TestWARCReader(recinfo);
  5. WARCRecord rec = ar.get(0);
  6. Resource payloadResource = new WarcResource(rec, ar);
  7. payloadResource.parseHeaders();
  8. Resource headersResource = payloadResource;
  9. TestServletOutputStream servletOutput = new TestServletOutputStream();
  10. response.setStatus(200);
  11. EasyMock.expect(response.getOutputStream()).andReturn(servletOutput);
  12. response.setHeader("Content-Type", ct);
  13. // ??? RedirectRewritingHttpHeaderProcessor drops Content-Length header. is this really
  14. // it is supposed to do?
  15. //response.setHeader("Content-Length", Integer.toString(payloadBytes.length));
  16. response.setHeader(EasyMock.<String>notNull(), EasyMock.<String>notNull());
  17. EasyMock.expectLastCall().anyTimes();
  18. EasyMock.replay(response);
  19. cut.renderResource(request, response, wbRequest, result,
  20. headersResource, payloadResource, uriConverter, results);
  21. EasyMock.verify(response);
  22. byte[] content = servletOutput.getBytes();
  23. assertTrue("servlet output", Arrays.equals(TestWARCRecordInfo.PAYLOAD_GIF, content));
  24. }

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

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

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

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

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

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

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

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

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

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

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

  1. @BeforeMethod
  2. public void setUpAgain() throws Exception {
  3. m_dummyInputStream = new FileInputStream(m_dummyFile);
  4. DownloadResult downloadResult = addTestMock(DownloadResult.class);
  5. expect(downloadResult.isComplete()).andReturn(true).anyTimes();
  6. expect(downloadResult.getInputStream()).andReturn(m_dummyInputStream).anyTimes();
  7. Future<DownloadResult> future = addTestMock(Future.class);
  8. expect(future.get()).andReturn(downloadResult).anyTimes();
  9. DownloadHandle downloadHandle = addTestMock(DownloadHandle.class);
  10. expect(downloadHandle.start(isNull(DownloadProgressListener.class))).andReturn(future).anyTimes();
  11. DeploymentHandler deploymentHandler = addTestMock(DeploymentHandler.class);
  12. expect(deploymentHandler.getInstalledVersion()).andReturn(m_version2).anyTimes();
  13. expect(deploymentHandler.getAvailableVersions()).andReturn(m_availableVersions).anyTimes();
  14. expect(deploymentHandler.getDownloadHandle(eq(m_version3), eq(true))).andReturn(downloadHandle).once();
  15. deploymentHandler.install(notNull(InputStream.class));
  16. expectLastCall().once();
  17. m_agentContext = mockAgentContext();
  18. m_agentContext.setHandler(DeploymentHandler.class, deploymentHandler);
  19. replayTestMocks();
  20. m_agentContext.start();
  21. m_agentControl = new AgentControlImpl(m_agentContext);
  22. }

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

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

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

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

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

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

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

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

相关文章