If you need to return an image file in a response one of your REST API, you can do this with following these steps:
- read the image file
- convert to byte array
- encode to Base64
- return encoded value as String
If you mock a method for a unit test the actual method is not invoked, but what about you want to call the actual method but just mock the return value?
Mockito gives you the @Spy for “partial mocking, real methods are invoked but still can be verified and stubbed”  which is perfect, but what if you want to invoke the actual method for one of the methods from the spied object and just manipulate the return value, but also do not want to call the actual implementation for another one from the exact same spied object and just need the manipulated return value. Luckily, Mockito gives you another two options : Continue reading
There are three popular questions in Java code interviews:
We can find the answers with this simple example. Please try to guess what will be the output.
It is pretty easy to preview pdf files with PrimeFaces media component as explained in official page.
If you try this already there are two common problems that may find you.
Jersey RESTful Web Services framework is open source, production quality, framework for developing RESTful Web Services in Java that provides support for JAX-RS APIs and serves as a JAX-RS (JSR 311 & JSR 339) Reference Implementation.