當前位置: 首頁>>代碼示例>>Java>>正文


Java Mockito.validateMockitoUsage方法代碼示例

本文整理匯總了Java中org.mockito.Mockito.validateMockitoUsage方法的典型用法代碼示例。如果您正苦於以下問題:Java Mockito.validateMockitoUsage方法的具體用法?Java Mockito.validateMockitoUsage怎麽用?Java Mockito.validateMockitoUsage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mockito.Mockito的用法示例。


在下文中一共展示了Mockito.validateMockitoUsage方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doFilterNoAuthority

import org.mockito.Mockito; //導入方法依賴的package包/類
/**
 * No authority
 */
@Test
public void doFilterNoAuthority() throws Exception {
	final FilterChain chain = Mockito.mock(FilterChain.class);
	final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
	final ServletContext servletContext = Mockito.mock(ServletContext.class);
	Mockito.when(servletContext.getContextPath()).thenReturn("context");
	Mockito.when(request.getRequestURI()).thenReturn("context/rest/any");
	Mockito.when(request.getMethod()).thenReturn("GET");
	final ServletOutputStream outputStream = Mockito.mock(ServletOutputStream.class);
	final HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
	Mockito.when(response.getOutputStream()).thenReturn(outputStream);
	authorizingFilter.setServletContext(servletContext);
	authorizingFilter.doFilter(request, response, chain);
	Mockito.verify(outputStream, Mockito.atLeastOnce()).write(ArgumentMatchers.any(byte[].class));
	Mockito.verify(chain, Mockito.never()).doFilter(request, response);
	Mockito.validateMockitoUsage();
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:21,代碼來源:AuthorizingFilterTest.java

示例2: doFilterAttachedAuthority

import org.mockito.Mockito; //導入方法依賴的package包/類
/**
 * Plenty attached authority
 */
@Test
public void doFilterAttachedAuthority() throws Exception {
	cacheResource.invalidate("authorizations");
	attachRole(DEFAULT_ROLE, "other");
	final FilterChain chain = Mockito.mock(FilterChain.class);
	final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
	final ServletContext servletContext = Mockito.mock(ServletContext.class);
	Mockito.when(servletContext.getContextPath()).thenReturn("context");
	Mockito.when(request.getRequestURI()).thenReturn("context/rest/any");
	Mockito.when(request.getMethod()).thenReturn("GET");
	final ServletOutputStream outputStream = Mockito.mock(ServletOutputStream.class);
	final HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
	Mockito.when(response.getOutputStream()).thenReturn(outputStream);
	authorizingFilter.setServletContext(servletContext);
	authorizingFilter.doFilter(request, response, chain);
	authorizingFilter.doFilter(request, response, chain);
	Mockito.verify(outputStream, Mockito.atLeastOnce()).write(ArgumentMatchers.any(byte[].class));
	Mockito.verify(chain, Mockito.never()).doFilter(request, response);
	Mockito.validateMockitoUsage();
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:24,代碼來源:AuthorizingFilterTest.java

示例3: doFilterAttachedAuthority3

import org.mockito.Mockito; //導入方法依賴的package包/類
/**
 * Plenty attached authority
 */
@Test
public void doFilterAttachedAuthority3() throws Exception {
	attachRole(DEFAULT_ROLE, "role2");
	addSystemAuthorization(HttpMethod.GET, "role2", "^rest/match$");
	em.flush();
	em.clear();
	cacheResource.invalidate("authorizations");
	final FilterChain chain = Mockito.mock(FilterChain.class);
	final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
	final ServletContext servletContext = Mockito.mock(ServletContext.class);
	Mockito.when(servletContext.getContextPath()).thenReturn("/context");
	Mockito.when(request.getRequestURI()).thenReturn("/context/rest/match");
	Mockito.when(request.getQueryString()).thenReturn("query");
	Mockito.when(request.getMethod()).thenReturn("GET");
	final ServletOutputStream outputStream = Mockito.mock(ServletOutputStream.class);
	final HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
	Mockito.when(response.getOutputStream()).thenReturn(outputStream);
	authorizingFilter.setServletContext(servletContext);
	authorizingFilter.doFilter(request, response, chain);
	Mockito.when(request.getMethod()).thenReturn("HEAD");
	authorizingFilter.doFilter(request, response, chain);
	Mockito.verify(chain, Mockito.atLeastOnce()).doFilter(request, response);
	Mockito.validateMockitoUsage();
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:28,代碼來源:AuthorizingFilterTest.java

示例4: apply

import org.mockito.Mockito; //導入方法依賴的package包/類
@Override
public Statement apply(final Statement base, FrameworkMethod method, final Object target) {
  return new Statement() {
    @Override
    public void evaluate() throws Throwable {
      MockitoAnnotations.initMocks(target);
      try {
        base.evaluate();
      } finally {
        Mockito.validateMockitoUsage();
      }
    }
  };
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:15,代碼來源:MockitoTestRule.java

示例5: doFilterPlentyAuthority

import org.mockito.Mockito; //導入方法依賴的package包/類
/**
 * Plenty defined authority
 */
@Test
public void doFilterPlentyAuthority() throws Exception {

	for (final HttpMethod method : HttpMethod.values()) {
		addSystemAuthorization(method, "role1", "^myurl");
		addSystemAuthorization(method, "role2", "^myurl");
	}
	em.flush();
	em.clear();
	cacheResource.invalidate("authorizations");
	final FilterChain chain = Mockito.mock(FilterChain.class);
	final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
	final ServletContext servletContext = Mockito.mock(ServletContext.class);
	Mockito.when(servletContext.getContextPath()).thenReturn("context");
	Mockito.when(request.getRequestURI()).thenReturn("context/rest/any");
	Mockito.when(request.getMethod()).thenReturn("GET");
	final ServletOutputStream outputStream = Mockito.mock(ServletOutputStream.class);
	final HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
	Mockito.when(response.getOutputStream()).thenReturn(outputStream);
	authorizingFilter.setServletContext(servletContext);
	authorizingFilter.doFilter(request, response, chain);
	authorizingFilter.doFilter(request, response, chain);
	Mockito.verify(outputStream, Mockito.atLeastOnce()).write(ArgumentMatchers.any(byte[].class));
	Mockito.verify(chain, Mockito.never()).doFilter(request, response);
	Mockito.validateMockitoUsage();
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:30,代碼來源:AuthorizingFilterTest.java

示例6: doFilterAnonymous

import org.mockito.Mockito; //導入方法依賴的package包/類
/**
 * Anonymous user / role
 */
@Test
public void doFilterAnonymous() throws Exception {
	cacheResource.invalidate("authorizations");
	attachRole("ROLE_ANONYMOUS");
	final FilterChain chain = Mockito.mock(FilterChain.class);
	final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
	final HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
	authorizingFilter.doFilter(request, response, chain);
	Mockito.verify(chain, Mockito.atLeastOnce()).doFilter(request, response);
	Mockito.validateMockitoUsage();
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:15,代碼來源:AuthorizingFilterTest.java

示例7: doFilterAttachedAuthority2

import org.mockito.Mockito; //導入方法依賴的package包/類
/**
 * Plenty attached authority
 */
@Test
public void doFilterAttachedAuthority2() throws Exception {
	attachRole(DEFAULT_ROLE, "role1", "role2", "role3");
	for (final HttpMethod method : HttpMethod.values()) {
		addSystemAuthorization(method, "role1", "^myurl");
		addSystemAuthorization(method, "role2", "^myurl");
		addSystemAuthorization(null, "role1", "^youurl");
		addSystemAuthorization(null, "role2", "^yoururl");
	}
	em.flush();
	em.clear();
	cacheResource.invalidate("authorizations");
	final FilterChain chain = Mockito.mock(FilterChain.class);
	final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
	final ServletContext servletContext = Mockito.mock(ServletContext.class);
	Mockito.when(servletContext.getContextPath()).thenReturn("context");
	Mockito.when(request.getRequestURI()).thenReturn("context/rest/any");
	Mockito.when(request.getMethod()).thenReturn("GET");
	final ServletOutputStream outputStream = Mockito.mock(ServletOutputStream.class);
	final HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
	Mockito.when(response.getOutputStream()).thenReturn(outputStream);
	authorizingFilter.setServletContext(servletContext);
	authorizingFilter.doFilter(request, response, chain);
	Mockito.when(request.getMethod()).thenReturn("HEAD");
	authorizingFilter.doFilter(request, response, chain);
	Mockito.verify(outputStream, Mockito.atLeastOnce()).write(ArgumentMatchers.any(byte[].class));
	Mockito.verify(chain, Mockito.never()).doFilter(request, response);
	Mockito.validateMockitoUsage();
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:33,代碼來源:AuthorizingFilterTest.java

示例8: checkForwardTo

import org.mockito.Mockito; //導入方法依賴的package包/類
/**
 * Test use case forward.
 */
private void checkForwardTo(final String from, final String to, final String suffix) throws IOException, ServletException {
	final HtmlProxyFilter htmlProxyFilter = new HtmlProxyFilter();
	htmlProxyFilter.setSuffix(suffix);

	final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
	final HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
	Mockito.when(request.getServletPath()).thenReturn(from);
	final RequestDispatcher requestDispatcher = Mockito.mock(RequestDispatcher.class);
	Mockito.when(request.getRequestDispatcher(to)).thenReturn(requestDispatcher);
	htmlProxyFilter.doFilter(request, response, null);
	Mockito.verify(requestDispatcher, Mockito.atLeastOnce()).forward(request, response);
	Mockito.validateMockitoUsage();
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:17,代碼來源:HtmlProxyFilterTest.java

示例9: validate

import org.mockito.Mockito; //導入方法依賴的package包/類
@After
public void validate() {
  Mockito.validateMockitoUsage();
}
 
開發者ID:davidgamez,項目名稱:parrot-rest,代碼行數:5,代碼來源:ListenTalkMapIT.java

示例10: afterEach

import org.mockito.Mockito; //導入方法依賴的package包/類
@Override
public void afterEach(ExtensionContext context) throws Exception {
  Mockito.validateMockitoUsage();
}
 
開發者ID:JeffreyFalgout,項目名稱:junit5-extensions,代碼行數:5,代碼來源:MockitoExtension.java

示例11: teardown

import org.mockito.Mockito; //導入方法依賴的package包/類
@AfterMethod
public void teardown() {
    Mockito.validateMockitoUsage();
}
 
開發者ID:SolarNetwork,項目名稱:killbill-easytax-plugin,代碼行數:5,代碼來源:EasyTaxTaxCalculatorTests.java

示例12: teardown

import org.mockito.Mockito; //導入方法依賴的package包/類
@AfterTest
public void teardown() {
    Mockito.validateMockitoUsage();
}
 
開發者ID:SolarNetwork,項目名稱:killbill-easytax-plugin,代碼行數:5,代碼來源:AccountCustomFieldTaxZoneResolverTests.java

示例13: teardown

import org.mockito.Mockito; //導入方法依賴的package包/類
@AfterTest
public void teardown() {
    Mockito.verifyZeroInteractions(killbillApi);
    Mockito.validateMockitoUsage();
}
 
開發者ID:SolarNetwork,項目名稱:killbill-easytax-plugin,代碼行數:6,代碼來源:SimpleTaxDateResolverTests.java


注:本文中的org.mockito.Mockito.validateMockitoUsage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。