Use it to capture argument values for further assertions.
It should be used during verifications. It is very useful when assert on argument values to complete verification.
It can also be fined through annotation: @Captor
More info here: http://docs.mockito.googlecode.com/hg/org/mockito/ArgumentCaptor.html
and : http://docs.mockito.googlecode.com/hg/org/mockito/Captor.html
Tuesday, 31 July 2012
Mockito Matchers
When using Mockito you can use MockitoMatchers. You can use predefined ones or create own implementation.
F.e.
F.e.
assertThat(object, CoreMatchers.equalTo(0));More examples as well as own implementations here: http://docs.mockito.googlecode.com/hg/org/mockito/Matchers.html
Cannot map request parameters as a Map parameter in Spring MVC
In Spring MVC you cannot map request parameters as a Map parameter in controller method using annotation @RequestParam
It is due to implementation of HandlerMethodInvoker.java, where Spring puts all parameters of the request to the parameter of Map type. Moreover the result map type is MultiValueMap or Linked HashMap.
It is due to implementation of HandlerMethodInvoker.java, where Spring puts all parameters of the request to the parameter of Map type. Moreover the result map type is MultiValueMap or Linked HashMap.
CachingConnectionFactory for Spring JMS
CachingConnectionFactory is used as the proxy wrapping JMS Connection in the Spring JMS. It prevents from agressively closing and reopening JMS sessions and connections.
It is used for adding caching during usage Spring JMS templates.
It is used for adding caching during usage Spring JMS templates.
<bean id="cachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory"> <property name="targetConnectionFactory" ref="connectionFactory"/> </bean>
Creating directories hierarchical on Linux
Use
mkdir -p directory
to create directory with no error if existing and make parent directories as needed.
mkdir -p directory
to create directory with no error if existing and make parent directories as needed.
Monday, 30 July 2012
@InjectMocks - Mockito
It is an annotation used in Mockito on the variable definition telling Mockito to try to inject by type already defined mocks or spies on the annotated object
f.e.:
f.e.:
@InjectMocks private MyService service = new MyService();
More info here: http://docs.mockito.googlecode.com/hg/org/mockito/InjectMocks.html
Actions throwing exceptions in Spring MVC
When an action in the Spring MVC throws exception, you can handle it with specifying http response code, by annotation on the exception class definition: @ResponseStatus(httpStatus).
When you cannot annotate class, f.e. it is not your exception definition, you can add in the controller a method which is annotated with @ExceptionHandler(yourExceptionClass) and @ResponseStatus(httpStatus)
When you cannot annotate class, f.e. it is not your exception definition, you can add in the controller a method which is annotated with @ExceptionHandler(yourExceptionClass) and @ResponseStatus(httpStatus)
Subscribe to:
Posts (Atom)