本文整理匯總了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();
}
示例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();
}
示例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();
}
示例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();
}
}
};
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例9: validate
import org.mockito.Mockito; //導入方法依賴的package包/類
@After
public void validate() {
Mockito.validateMockitoUsage();
}
示例10: afterEach
import org.mockito.Mockito; //導入方法依賴的package包/類
@Override
public void afterEach(ExtensionContext context) throws Exception {
Mockito.validateMockitoUsage();
}
示例11: teardown
import org.mockito.Mockito; //導入方法依賴的package包/類
@AfterMethod
public void teardown() {
Mockito.validateMockitoUsage();
}
示例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();
}