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


Java Mockito.verifyZeroInteractions方法代码示例

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


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

示例1: testSetNavigator

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testSetNavigator()
{
    navigationStateManager.setNavigator(null);
    Mockito.verifyZeroInteractions(popStateListenerRegistration);
    Mockito.verifyZeroInteractions(page);

    Mockito.when(page.addPopStateListener(ArgumentMatchers.any(Page.PopStateListener.class)))
            .thenReturn(popStateListenerRegistration);
    navigationStateManager.setNavigator(navigator);
    Mockito.verify(page)
            .addPopStateListener(ArgumentMatchers.any(Page.PopStateListener.class));

    navigationStateManager.setNavigator(null);
    Mockito.verify(popStateListenerRegistration).remove();
}
 
开发者ID:apm78,项目名称:history-api-navigation,代码行数:17,代码来源:HistoryApiNavigationStateManagerTest.java

示例2: should_not_spy_on_spy

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void should_not_spy_on_spy() {
	//given
	final String spyName = "myService";
	final Service spy = Mockito.spy(new Service());
	final DoubleDefinition spyDefinition = doubleDefinition(Service.class, spyName);
	final ToSpyReplacingProcessor postProcessor = new TestContextBuilder()
			.withSpyBean(spyName, spy, spyDefinition)
			.withSpy(spyDefinition)
			.build()
			.toSpyReplacingProcessor;

	//when
	postProcessor.postProcessAfterInitialization(spy, spyName);

	//then
	Mockito.verifyZeroInteractions(doubleFactory);
}
 
开发者ID:pchudzik,项目名称:springmock,代码行数:19,代码来源:ToSpyReplacingProcessorTest.java

示例3: should_never_reset_mock

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void should_never_reset_mock() throws Exception {
	//given
	final Object mock = Mockito.mock(Object.class, "mock to reset");
	final String noResetMockName = "no reset mock";
	final TestContext testContext = createTestContext(
			new DoubleRegistry(
					singletonList(
							DoubleDefinition.builder()
									.name(noResetMockName)
									.doubleClass(Object.class)
									.doubleConfiguration(neverReset())
									.build()),
					emptyList()),
			Stream.of(bean(noResetMockName, mock)));

	//when
	executionListener.beforeTestMethod(testContext);
	executionListener.afterTestMethod(testContext);

	//then
	Mockito.verifyZeroInteractions(resetExecutor);
}
 
开发者ID:pchudzik,项目名称:springmock,代码行数:24,代码来源:MockitoMockResetTestExecutionListenerTest.java

示例4: cpuUsageModuleConstructors

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void cpuUsageModuleConstructors() {
    new CpuUsageModule();
    new CpuUsageModule(0);
    new CpuUsageModule(0, 0);
    new CpuUsageModule(mockViewModule);
    new CpuUsageModule(0, mockViewModule);

    Mockito.verifyZeroInteractions(mockViewModule);
}
 
开发者ID:Manabu-GT,项目名称:DebugOverlay-Android,代码行数:11,代码来源:DebugOverlayNoOpTest.java

示例5: testEmfWithoutProps

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
  public void testEmfWithoutProps() throws InvalidSyntaxException, ConfigurationException {
  	ManagedEMF emf = new ManagedEMF(builder, "test");
      emf.updated(null);
      Mockito.verifyZeroInteractions(builder);
      
      Hashtable<String, Object> props = new Hashtable<String, Object>();
emf.updated(props);
      verify(builder).createEntityManagerFactory(props);
      
      emf.updated(null);
      verify(builder).closeEMF();
      
  }
 
开发者ID:apache,项目名称:aries-jpa,代码行数:15,代码来源:ManagedEMFTest.java

示例6: shouldNotDragStickieWithoutDragStart

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void shouldNotDragStickieWithoutDragStart() throws Exception {
    Point<Integer> currentStickiePosition = stickieProperties.getPosition();

    Point<Integer> point = new Point<Integer>(666, 777);
    stickieDragController.dragMove(point);

    Mockito.verifyZeroInteractions(stickiePresenter);
    assertEquals(currentStickiePosition, stickieProperties.getPosition());
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:11,代码来源:StickieDragControllerJUnitTest.java

示例7: installModule

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void installModule() throws Exception {
    new DebugOverlay.Builder(mockApplication)
            .modules(mockOverlayModule)
            .build()
            .install();
    Mockito.verifyZeroInteractions(mockApplication, mockOverlayModule);
}
 
开发者ID:Manabu-GT,项目名称:DebugOverlay-Android,代码行数:9,代码来源:DebugOverlayNoOpTest.java

示例8: testDisallowedMethod

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testDisallowedMethod() throws ServletException, IOException {

  // Setup the configuration settings of the server
  Map<String, String> conf = new HashMap<String, String>();
  conf.put(CrossOriginFilter.ALLOWED_ORIGINS, "example.com");
  FilterConfig filterConfig = new FilterConfigTest(conf);

  // Origin is not specified for same origin requests
  HttpServletRequest mockReq = Mockito.mock(HttpServletRequest.class);
  Mockito.when(mockReq.getHeader(CrossOriginFilter.ORIGIN)).thenReturn("example.com");
  Mockito.when(
      mockReq.getHeader(CrossOriginFilter.ACCESS_CONTROL_REQUEST_METHOD))
      .thenReturn("DISALLOWED_METHOD");

  // Objects to verify interactions based on request
  HttpServletResponse mockRes = Mockito.mock(HttpServletResponse.class);
  FilterChain mockChain = Mockito.mock(FilterChain.class);

  // Object under test
  CrossOriginFilter filter = new CrossOriginFilter();
  filter.init(filterConfig);
  filter.doFilter(mockReq, mockRes, mockChain);

  Mockito.verifyZeroInteractions(mockRes);
  Mockito.verify(mockChain).doFilter(mockReq, mockRes);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:28,代码来源:TestCrossOriginFilter.java

示例9: installAppLayer

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void installAppLayer() {
    new DebugOverlay.Builder(mockApplication)
            .allowSystemLayer(false)
            .modules(mockOverlayModule)
            .build()
            .install();

    Mockito.verifyZeroInteractions(mockApplication, mockOverlayModule);
}
 
开发者ID:Manabu-GT,项目名称:DebugOverlay-Android,代码行数:11,代码来源:DebugOverlayNoOpTest.java

示例10: installModulesWithPosition

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void installModulesWithPosition() {
    assertEquals(9, Position.values().length);

    new DebugOverlay.Builder(mockApplication)
            .modules(mockOverlayModule,
                    new MemInfoModule(mockApplication),
                    new FpsModule())
            .position(Position.values()[0])
            .build()
            .install();

    Mockito.verifyZeroInteractions(mockApplication, mockOverlayModule);
}
 
开发者ID:Manabu-GT,项目名称:DebugOverlay-Android,代码行数:15,代码来源:DebugOverlayNoOpTest.java

示例11: shouldntThrowEventWhenIndexOfCurrentPersonaNotChanged

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void shouldntThrowEventWhenIndexOfCurrentPersonaNotChanged() throws Exception {
    // given
    int samePersonaIndex = 0;

    // when
    personaService.setCurrentPersonaIndex(samePersonaIndex);

    // then
    Mockito.verifyZeroInteractions(eventsBus);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:12,代码来源:PersonaServiceTest.java

示例12: taskNotCalledAsPeriodIsNotPassedYet

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void taskNotCalledAsPeriodIsNotPassedYet() throws InterruptedException {
    scheduler.schedulePeriodicTask(task, Long.MAX_VALUE);
    Thread.sleep(PERIOD);
    scheduler.runTasks();

    Mockito.verifyZeroInteractions(task);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:9,代码来源:SchedulerUnitTest.java

示例13: testNotificationListenerUnknownNetconfNotification

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testNotificationListenerUnknownNetconfNotification() throws Exception {
    final ConfigPersisterNotificationListener testeListener = new ConfigPersisterNotificationListener(persisterAggregator, facadeFactory);
    try {
        testeListener.handleNotification(unknownNetconfNotif, null);
        Assert.fail("Unknown netconf notification should fail");
    } catch (final IllegalStateException e) {
        Mockito.verifyZeroInteractions(mockPersister);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:11,代码来源:ConfigPersisterNotificationListenerTest.java

示例14: testNoHeaderDefaultConfig_badRequest

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testNoHeaderDefaultConfig_badRequest()
    throws ServletException, IOException {
  // Setup the configuration settings of the server
  FilterConfig filterConfig = Mockito.mock(FilterConfig.class);
  Mockito.when(filterConfig.getInitParameter(
    RestCsrfPreventionFilter.CUSTOM_HEADER_PARAM)).thenReturn(null);
  Mockito.when(filterConfig.getInitParameter(
    RestCsrfPreventionFilter.CUSTOM_METHODS_TO_IGNORE_PARAM)).
    thenReturn(null);

  // CSRF has not been sent
  HttpServletRequest mockReq = Mockito.mock(HttpServletRequest.class);
  Mockito.when(mockReq.getHeader(RestCsrfPreventionFilter.HEADER_DEFAULT)).
  thenReturn(null);
  Mockito.when(mockReq.getHeader(RestCsrfPreventionFilter.HEADER_USER_AGENT)).
    thenReturn(BROWSER_AGENT);

  // Objects to verify interactions based on request
  HttpServletResponse mockRes = Mockito.mock(HttpServletResponse.class);
  FilterChain mockChain = Mockito.mock(FilterChain.class);

  // Object under test
  RestCsrfPreventionFilter filter = new RestCsrfPreventionFilter();
  filter.init(filterConfig);
  filter.doFilter(mockReq, mockRes, mockChain);

  verify(mockRes, atLeastOnce()).sendError(
      HttpServletResponse.SC_BAD_REQUEST, EXPECTED_MESSAGE);
  Mockito.verifyZeroInteractions(mockChain);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:32,代码来源:TestRestCsrfPreventionFilter.java

示例15: testNoHeaderCustomAgentConfig_badRequest

import org.mockito.Mockito; //导入方法依赖的package包/类
@Test
public void testNoHeaderCustomAgentConfig_badRequest()
    throws ServletException, IOException {
  // Setup the configuration settings of the server
  FilterConfig filterConfig = Mockito.mock(FilterConfig.class);
  Mockito.when(filterConfig.getInitParameter(
    RestCsrfPreventionFilter.CUSTOM_HEADER_PARAM)).thenReturn(null);
  Mockito.when(filterConfig.getInitParameter(
    RestCsrfPreventionFilter.CUSTOM_METHODS_TO_IGNORE_PARAM)).
    thenReturn(null);
  Mockito.when(filterConfig.getInitParameter(
      RestCsrfPreventionFilter.BROWSER_USER_AGENT_PARAM)).
      thenReturn("^Mozilla.*,^Opera.*,curl");

  // CSRF has not been sent
  HttpServletRequest mockReq = Mockito.mock(HttpServletRequest.class);
  Mockito.when(mockReq.getHeader(RestCsrfPreventionFilter.HEADER_DEFAULT)).
  thenReturn(null);
  Mockito.when(mockReq.getHeader(RestCsrfPreventionFilter.HEADER_USER_AGENT)).
    thenReturn("curl");

  // Objects to verify interactions based on request
  HttpServletResponse mockRes = Mockito.mock(HttpServletResponse.class);
  FilterChain mockChain = Mockito.mock(FilterChain.class);

  // Object under test
  RestCsrfPreventionFilter filter = new RestCsrfPreventionFilter();
  filter.init(filterConfig);
  filter.doFilter(mockReq, mockRes, mockChain);

  verify(mockRes, atLeastOnce()).sendError(
      HttpServletResponse.SC_BAD_REQUEST, EXPECTED_MESSAGE);
  Mockito.verifyZeroInteractions(mockChain);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:35,代码来源:TestRestCsrfPreventionFilter.java


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