When running an Java EE application, in different situations it’s useful to know it’s own module and application name. In order to get these it is possible to access them via JNDI. Continue reading
Category Archives: Java
Generating JAXB classes with xjc
When working with Java and XML there is a number of frameworks that support working with that technology. Furthermore when working with an already working api there must be code in order be able to convert Java objects into XML and vice versa. Using xjc
is an easy way to generate Java classes in order to “talk” XML. Continue reading
Comparing Serialization Performance
When transmitting data, all the information must be serialized. When Serializing there are two relevant criteria in order to select a suitable format: size and performance. This article compares the efficiency of different serialization formats (Java Serialization, ByteBuffer, Unsafe, Json and Protobuf). Continue reading
Mocking Resources using JUnit @Rule
When writing unit tests in Java there might be the need to access a resource in the class that should be tested. A common way is to mock the resource. But mocking a simple resource is quite easy. This is supported by mocking frameworks like Mockito, EasyMock or PowerMock. It is a good idea in case you want to test a single action on the mocked resource – e.g. returning a value when accessing a map that contains master data. The following exmaple describes mocking a resource using Mockito. But in case there are complex operations on this resource mocking it is going to be really nasty.
Continue reading