Dependency Injection is a great approach to decouple software components. Furthermore it is possible to inject the current context (state) of a software component. In Java EE 6 there are four scopes. With Java EE 7 a new scope was added. This post describes how to implement an additional scope that lives in its own lifecycle.
Continue reading
Tag Archives: Java EE
Constants for Java EE
When working with Java EE there are situations, in that constants occur. As there are no enums but only int constants this is a pretty tough task in case you don’t remember the values of the constants. But of course there is a solutions for that. 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