This post explains how to stub a final method. The class to be tested is as shown below Class1 package package5; public class Class1 { public final int method1(int value) { return value * value; } } The test class is as shown below Test Class 1 package package5; 2 3 import org.junit.Before; 4 import…… Continue reading Stubbing final methods
Spring depends-on attribute
When Spring loads the application context, it creates the beans following its own particular order. Irrespective of the order in which it creates the beans, it makes sure that a bean’s dependency (which are other beans) are set before the beans is ready of use. Below code will give you an example of what I am…… Continue reading Spring depends-on attribute
Changing the default log message format
In this post I will be explaining how to change the default log message format provided by java util loggging. In case of logging to console (done by ConsoleHandler), the default format used is an instance of java.util.logging.SimpleFormatter. In case of logging to file (done by FileHandler), the default format used is an instance of…… Continue reading Changing the default log message format
Redirecting logging to a file
In this post I will explain how to program the logger to log messages to a file instead of logging to console. Below is the code Main code 1 package Logging; 2 3 import java.io.IOException; 4 import java.util.logging.FileHandler; 5 import java.util.logging.Logger; 6 7 public class LoggingDemo2 { 8 public static void main(String[] args) throws IOException…… Continue reading Redirecting logging to a file
Java logging simple example
This post explains java logging with simple example. Main code 1 package Logging; 2 3 import java.io.IOException; 4 import java.util.logging.Logger; 5 6 public class LoggingDemo1 { 7 public static void main(String[] args) throws IOException { 8 Logger logger = Logger.getLogger(“logger1”); 9 logger.info(“Hello my name is Mathew”); 10 logger.warning(“Hello my name is Mathew”); 11 logger.config(“Hello my…… Continue reading Java logging simple example
Operations that can be performed using JSON Pointer
This post explains the operations that can be performance on json data with the help of new JSONP 1.1 api. As we know from our previuos post JSON Pointer is a string syntax used to identify and locate a particular field or property in a json file. Once identified and located we can perform the…… Continue reading Operations that can be performed using JSON Pointer
JSON Pointer Example
This post explains JSON Pointer with an example. JSON Pointer is a standard that defines a string syntax, which can used to access a particular field or key value in the entire json document. For example in the below json document json document { “firstName”: “Duke”, “lastName”: “Java”, “age”: 18, “streetAddress”: “100 Internet Dr”, “city”:…… Continue reading JSON Pointer Example
Decompressing JAR file
JAR file is file archiver which collects/groups different files and folder into a format which represents one file. The format of JAR file is an uncompressed format. Pack200 is a tool that can be used to compress and decompress a jar file. Below is a simple example of how we can use Pack200 tool to…… Continue reading Decompressing JAR file
Compressing JAR file
JAR file is file archiver which collects/groups different files and folder into a format which represents one file. The format of JAR file is an uncompressed format. Pack200 is a tool that can be used to compress jar file. Below is a simple example of how we can use Pack200 tool to compress the file…… Continue reading Compressing JAR file
Binding single http request type to multiple web resource methods in JAX-RS Application
This post explains how to bind one type of http request to multiple methods of a web resource. Sometimes we need to design a web resource in such a way that we can bind two different yet related web url to different methods. 1) Different url meaning different in their purpose 2) Related url meaning…… Continue reading Binding single http request type to multiple web resource methods in JAX-RS Application