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

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

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

EasyMock.isNull介绍

[英]Expects null.
[中]预期为空。

代码示例

代码示例来源:origin: apache/incubator-druid

@Test
public void testNext()
{
 boolean expected = true;
 EasyMock.expect(peekIterator.hasNext()).andReturn(expected).times(4);
 String defaultString = "S1";
 String resString = "S2";
 EasyMock.expect(peekIterator.next()).andReturn(defaultString);
 EasyMock.expect(binaryFn.apply(EasyMock.eq(defaultString), EasyMock.isNull()))
   .andReturn(resString);
 EasyMock.expect(peekIterator.next()).andReturn(defaultString);
 EasyMock.expect(comparator.compare(EasyMock.eq(resString), EasyMock.eq(defaultString)))
   .andReturn(0);
 EasyMock.expect(peekIterator.next()).andReturn(defaultString);
 EasyMock.expect(binaryFn.apply(EasyMock.eq(resString), EasyMock.eq(defaultString)))
   .andReturn(resString);
 EasyMock.expect(comparator.compare(EasyMock.eq(resString), EasyMock.eq(defaultString)))
   .andReturn(1);
 EasyMock.replay(peekIterator);
 EasyMock.replay(binaryFn);
 EasyMock.replay(comparator);
 String actual = testingIterator.next();
 Assert.assertEquals(resString, actual);
 EasyMock.verify(peekIterator);
 EasyMock.verify(comparator);
 EasyMock.verify(binaryFn);
}

代码示例来源:origin: apache/incubator-druid

@Before
public void setUp() throws IOException
{
 SERVICE_EMITTER.flush();
 EVENT_EMITS.set(0L);
 EasyMock.reset(lookupNodeDiscovery);
 EasyMock.reset(configManager);
 EasyMock.expect(
   configManager.watch(
     EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY),
     EasyMock.<TypeReference>anyObject(),
     EasyMock.<AtomicReference>isNull()
   )
 ).andReturn(
   new AtomicReference<>(null)
 ).anyTimes();
 EasyMock.expect(
   configManager.watch(
     EasyMock.eq(LookupCoordinatorManager.OLD_LOOKUP_CONFIG_KEY),
     EasyMock.<TypeReference>anyObject(),
     EasyMock.<AtomicReference>isNull()
   )
 ).andReturn(
   new AtomicReference<>(null)
 ).anyTimes();
 EasyMock.replay(configManager);
}

代码示例来源:origin: apache/incubator-druid

EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY),
        EasyMock.<TypeReference>anyObject(),
        EasyMock.<AtomicReference>isNull()
      )).andReturn(
new AtomicReference<Map<String, Map<String, Map<String, Object>>>>(null)).once();
  EasyMock.eq(LookupCoordinatorManager.OLD_LOOKUP_CONFIG_KEY),
  EasyMock.<TypeReference>anyObject(),
  EasyMock.<AtomicReference>isNull()

代码示例来源:origin: apache/incubator-druid

EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY),
EasyMock.<TypeReference>anyObject(),
EasyMock.<AtomicReference>isNull()

代码示例来源:origin: apache/incubator-druid

EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY),
  EasyMock.<TypeReference>anyObject(),
  EasyMock.<AtomicReference>isNull()
)).andReturn(new AtomicReference<List<LookupExtractorFactoryMapContainer>>(null)).once();
  EasyMock.eq(LookupCoordinatorManager.OLD_LOOKUP_CONFIG_KEY),
  EasyMock.<TypeReference>anyObject(),
  EasyMock.<AtomicReference>isNull()
)).andReturn(new AtomicReference<List<Map<String, Object>>>(null)).once();

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testCreateSnapshotWithOptions() {
 Capture<Map<ComputeRpc.Option, Object>> capturedOptions = Capture.newInstance();
 EasyMock.expect(
     computeRpcMock.createSnapshot(
       eq(DISK_ID.getZone()),
       eq(DISK_ID.getDisk()),
       eq(SNAPSHOT_ID.getSnapshot()),
       EasyMock.<String>isNull(),
       capture(capturedOptions)))
   .andReturn(zoneOperation.toPb());
 EasyMock.replay(computeRpcMock);
 compute = options.getService();
 Operation operation = compute.create(SNAPSHOT, OPERATION_OPTION_FIELDS);
 String selector =
   (String) capturedOptions.getValue().get(OPERATION_OPTION_FIELDS.getRpcOption());
 assertTrue(selector.contains("selfLink"));
 assertTrue(selector.contains("id"));
 assertTrue(selector.contains("description"));
 assertEquals(23, selector.length());
 assertEquals(zoneOperation, operation);
}

代码示例来源:origin: apache/incubator-druid

final LoadQueuePeon mockPeon2 = createEmptyPeon();
mockPeon2.loadSegment(EasyMock.anyObject(), EasyMock.isNull());
EasyMock.expectLastCall().once();

代码示例来源:origin: apache/incubator-druid

EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY),
        EasyMock.<TypeReference>anyObject(),
        EasyMock.<AtomicReference>isNull()
      )).andReturn(
new AtomicReference<>(Collections.EMPTY_MAP)).anyTimes();

代码示例来源:origin: com.google.inject.extensions/guice-servlet

public final void testDispatchThruGuiceFilter() throws ServletException, IOException {
 //create mocks
 FilterConfig filterConfig = createMock(FilterConfig.class);
 ServletContext servletContext = createMock(ServletContext.class);
 HttpServletRequest request = createMock(HttpServletRequest.class);
 FilterChain proceedingFilterChain = createMock(FilterChain.class);
 //begin mock script ***
 expect(filterConfig.getServletContext()).andReturn(servletContext).once();
 expect(request.getRequestURI()).andReturn("/public/login.jsp").anyTimes();
 expect(request.getContextPath()).andReturn("").anyTimes();
 //at the end, proceed down webapp's normal filter chain
 proceedingFilterChain.doFilter(isA(HttpServletRequest.class), (ServletResponse) isNull());
 expectLastCall().once();
 //run mock script ***
 replay(filterConfig, servletContext, request, proceedingFilterChain);
 final GuiceFilter webFilter = new GuiceFilter();
 webFilter.init(filterConfig);
 webFilter.doFilter(request, null, proceedingFilterChain);
 webFilter.destroy();
 //assert expectations
 verify(filterConfig, servletContext, request, proceedingFilterChain);
}

代码示例来源:origin: com.google.inject.extensions/guice-servlet

proceedingFilterChain.doFilter(isA(HttpServletRequest.class), (ServletResponse) isNull());
expectLastCall().once();
proceedingFilterChain2.doFilter(isA(HttpServletRequest.class), (ServletResponse) isNull());
expectLastCall().once();

代码示例来源: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: com.lmco.shindig/shindig-gadgets

@Test
public void conditionIsTrue() throws Exception {
 Document doc = documentProvider.createDocument(null, null, null);
 // Create a mock tag;  the name doesn't truly matter
 Element tag = doc.createElement("if");
 tag.setAttribute(IfTagHandler.CONDITION_ATTR, "fakeExpression");
 
 processor.expressionResults = ImmutableMap.of("fakeExpression", true);
 processor.processChildNodes((Node) isNull(), same(tag));
 
 replay(processor);
 handler.process(null, tag, processor);
 verify(processor);
}

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

@Test
public void conditionIsTrue() throws Exception {
 Document doc = documentProvider.createDocument(null, null, null);
 // Create a mock tag;  the name doesn't truly matter
 Element tag = doc.createElement("if");
 tag.setAttribute(IfTagHandler.CONDITION_ATTR, "fakeExpression");
 processor.expressionResults = ImmutableMap.of("fakeExpression", true);
 processor.processChildNodes((Node) isNull(), same(tag));
 replay(processor);
 handler.process(null, tag, processor);
 verify(processor);
}

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

@SuppressWarnings("unchecked")
private FeatureRegistry mockRegistry(LookupResult lookupMock) {
 FeatureRegistry result = createMock(FeatureRegistry.class);
 expect(result.getFeatureResources(
   isA(GadgetContext.class), isA(List.class), EasyMock.isNull(List.class))).
   andReturn(lookupMock).anyTimes();
 replay(result);
 return result;
}

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

private void expectReq(String feature, String content) {
  FeatureResource resource = new FeatureResource.Simple(content, "", "js");
  Collection<String> libs = Lists.newArrayList(feature);
  List<String> loaded = ImmutableList.of();
  List<FeatureResource> resources = Lists.newArrayList(resource);
  final FeatureRegistry.LookupResult lr = createMock(FeatureRegistry.LookupResult.class);
  expect(lr.getResources()).andReturn(resources).anyTimes();
  replay(lr);
  expect(registry.getFeatureResources(isA(GadgetContext.class), eq(libs),
    EasyMock.<List<String>>isNull())).andReturn(lr).anyTimes();
 }
}

代码示例来源:origin: com.lmco.shindig/shindig-gadgets

@Test
public void getValueFromTag() {
 Element element = document.createElement("test");
 element.setAttribute("key", "expression");
 expect(templateProcessor.evaluate(eq("expression"), eq(String.class), (String) isNull()))
   .andReturn("evaluated");
 replay(templateProcessor);
 
 assertEquals("evaluated",
   handler.getValueFromTag(element, "key", templateProcessor, String.class));
 verify(templateProcessor);
}

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

@Test
public void getValueFromTag() {
 Element element = document.createElement("test");
 element.setAttribute("key", "expression");
 expect(templateProcessor.evaluate(eq("expression"), eq(String.class), (String) isNull()))
   .andReturn("evaluated");
 replay(templateProcessor);
 assertEquals("evaluated",
   handler.getValueFromTag(element, "key", templateProcessor, String.class));
 verify(templateProcessor);
}

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

@SuppressWarnings("unchecked")
private void setupMockRegistry(List<String> features) {
 EasyMock.expect(mockRegistry.getFeatures(EasyMock.isA(Collection.class)))
     .andReturn(Lists.newArrayList(features)).anyTimes();
 FeatureBundle featureBundle = createMockFeatureBundle();
 FeatureRegistry.LookupResult lr = createMockLookupResult(ImmutableList.of(featureBundle));
 EasyMock.expect(
     mockRegistry.getFeatureResources(isA(GadgetContext.class),
         eq(Lists.newArrayList(features)), EasyMock.<List<String>> isNull()))
     .andReturn(lr).anyTimes();
 replay();
}

代码示例来源:origin: org.nakedobjects/nof-reflector-core

public void testExecuteOK() {
  ServerActionResultData results = encoder.createServerActionResult((Naked) eq(adapter), aryEq(new ObjectData[0]),
      aryEq(new ReferenceData[0]), (ObjectData) isNull(), aryEq(new ObjectData[0]), aryEq(new String[0]),
      aryEq(new String[0]));
  expectLastCall().andReturn(null);
  replay(encoder, action);
  ServerActionResultData result = server.executeServerAction(new NullSession(), NakedObjectAction.USER.getName(),
      Movie.class.getName() + "#action()", targetData, parameterData);
  verify(encoder, action);
  assertEquals(results, result);
}

相关文章