Tuesday, 31 July 2012
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
assertThat(object, CoreMatchers.equalTo(0));More examples as well as own implementations here: http://docs.mockito.googlecode.com/hg/org/mockito/Matchers.html
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 used for adding caching during usage Spring JMS templates.
<bean id="cachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory"> <property name="targetConnectionFactory" ref="connectionFactory"/> </bean>
Monday, 30 July 2012
@InjectMocks private MyService service = new MyService();
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)
Saturday, 28 July 2012
More information here: http://www.thaiopensource.com/relaxng/trang-manual.html
<ws:dynamic-wsdl id="definitionName" portTypeName="Type" locationUri="http://host:8080/serviceName/"> <ws:xsd location="/WEB-INF/transfer.xsd"/> </ws:dynamic-wsdl>
It generates WSDL from XSD file. The wsdl can now be accessed through: http://host:8080/serviceName/definitionName.wsdl
The goal is: A standard module system for the Java Platform will ease the construction, maintenance, and distribution of large applications, at last allowing developers to escape the “JAR hell” of the brittle and error-prone class-path mechanism.
Chief Java architect on his blog describes the situation: http://mreinhold.org/blog/late-for-the-train.
Project Jigsaw home page: http://openjdk.java.net/projects/jigsaw/
Sunday, 15 July 2012
A CountDownLatch is initialized with a given count. The await methods block until the current count reaches zero due to invocations of the countDown() method, after which all waiting threads are released and any subsequent invocations of await return immediately. This is a one-shot phenomenon -- the count cannot be reset. If you need a version that resets the count, consider using a CyclicBarrier.
It is a google product which is free for commercial and non-commercial usage.
Try it whether it helps in your development. F.e. Dead Code function is not working good with Spring applications and annotations. Finding similar code for me is the best!
More info on : https://developers.google.com/java-dev-tools/codepro/doc/
You can read hera how to install Fingbugs plugin for Eclipse: http://findbugs.sourceforge.net/manual/eclipse.html
More on: http://static.springsource.org/spring/docs/1.2.x/api/org/springframework/util/FileCopyUtils.html
More on: http://code.google.com/p/subethasmtp/wiki/Wiser
Saturday, 14 July 2012
Javadoc : http://static.springsource.org/spring/docs/3.0.0.M3/javadoc-api/org/springframework/jdbc/datasource/embedded/ResourceDatabasePopulator.html
Friday, 13 July 2012
- The differences between two pieces of XML
- The outcome of transforming a piece of XML using XSLT
- The evaluation of an XPath expression on a piece of XML
- The validity of a piece of XML
- Individual nodes in a piece of XML that are exposed by DOM Traversal
More information in the tutorial: http://xmlunit.sourceforge.net/userguide/html/index.html
- Lightning-fast; thousands of operations/sec.
- Fail-safe; no losing data after crashes.
- Dynamically scales as new servers added.
- Super-easy to use; include a single jar.
With its various distributed data structures, distributed caching capabilities, elastic nature, memcache support, integration with Spring and Hibernate and more importantly so many happy users, Hazelcast is feature-rich, enterprise-ready and developer-friendly in-memory data grid solution.
To run it you just run a single jar file!
Presentation is available here: http://www.hazelcast.com/screencast.jsp
This project adds a new runner to JUnit and provides much easier and readable parameterised tests for JUnit >=4.6.
Main differences to standard JUnit Parameterized runner:
- more explicit - params are in test method params, not class fields
- less code - you don't need a constructor to set up parameters
- you can mix parameterised with non-parameterised methods in one class
- params can be passed as a CSV string or from a parameters provider class
- parameters provider class can have as many parameters providing methods as you want, so that you can group different cases
- you can have a test method that provides parameters (no external classes or statics anymore)
- you can see actual parameter values in your IDE (in JUnit's Prameterized it's only consecutive numbers of parameters):
More on project page: http://code.google.com/p/junitparams/
It is a great library for complicated operations on Collections in one line.
More on: http://www.op4j.org/
Tuesday, 10 July 2012
Project lombok is a java library which prevents you from implementing or generating getters and setters for POJOs. You just add annotation on the class or on the individual property. Having such code, that just gets and sets properties is unmaintainable and bad for class clarity.
This library has also some other useful features like f.e. @Delegate - annotation that ease creating classes with delegation methods.
Here you can see examples:http://projectlombok.org/features/index.html
May 22, 2012 10:02:48 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [131,611] milliseconds.This problem appears due to Tomcat 7+ usage of SecureRandom class to provide random values for its session ids. You can use non-blocking setup, just set the following system property: -Djava.security.egd=file:/dev/./urandom
You can read more on this subject in tomcat wiki: http://wiki.apache.org/tomcat/HowTo/FasterStartUp
Monday, 9 July 2012
He has shown that it has a very big impact on the java development, not only on dynamic languages on JVM. Using invoke dynamic in java you can have dynamic behavior with speed comparable to static invocation.
You can see examples and benchmarks here: https://github.com/waldekkot/Confitura2012_InvokeDynamic
Wednesday, 4 July 2012
If you want to train implementing algorithms you can go to the Project Euler.
Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.
The motivation for starting Project Euler, and its continuation, is to provide a platform for the inquiring mind to delve into unfamiliar areas and learn new concepts in a fun and recreational context.
His leaving post: blog.springsource.org/2012/07/03/oh-the-places-youll-go/
Sunday, 1 July 2012
- Declare in the application configuration: <context:mbean-export/>
- Annotate java class with @ManagedResource
- Annotate getters or setters with <@ManagedAttribute>
You can also use annotations: @ManagedOperation, @ManagedNotification for methods that are not setters or getters.