Java Archive

Parallel and Concurrent in regards to Garbage Collectors

Although the words “Parallel” and “Concurrent” are used synonymously, when used in reference to Java garbage collection they are not the same. Unfortunately is can often lead to confusion when developers delve into the the world of the JVM and garbage collection, so lets clear it up here. Parallel collector belongs to the family of pure-stop-the-world collectors. That [&hellip

Read More…

Language Agnostic: Unit Test Principles

After spending a few days churning out unit tests for a recent project of mine, I took a step back and asked myself: What are the properties of good unit tests? Tests are seen as something of a burden that devs have to do to keep business happy, but in reality they can save countless [&hellip

Read More…

JUnit: Testing Private Methods and Fields

I’m working with somewhat legacy code at the moment which needs to be tested. Unfortunately with most legacy code, changing it is something that is not within my current scope…even though the visibility of some fields need to be changed or getter/setters put in place to allow for testing. Found yourself in this situation? There [&hellip

Read More…

JUnit Assert: Which One to Choose?

Unit tests, the bane of any engineers day, but a necessity and something that has proven itself to me over time to be invaluable if done correctly. For any developer that has just sat down to write their first test they may be confronted with the following problem when trying to use JUnit’s Assert functionality. [&hellip

Read More…

@Inject vs @Autowired

The annotation @Inject (javax.inject.Inject) is part of the Java CDI standard introduced in Java EE 6 (JSR-330), which Spring has chosen to support using @Inject synonymously with their own @Autowired annotation. The annotation @Autowired is springs own annotation. @Inject is part of a new Java technology called CDI that defines a standard for dependency injection [&hellip

Read More…

Spring Autowiring using @Qualifier

In Spring, the annotation @Qualifier specifies which bean is autowired on a field. The following scenario shows an instance where using @Autowired alone is not sufficent. Autowiring Example See below example, it will autowired a “person” bean into customer’s person property. But, two similar beans “ie.markreddy.Person” are declared in bean configuration file. Will Spring know [&hellip

Read More…

Unit Test Hanging During Sonar Analysis (JMockit, Maven, Sonar, JaCoCo and Jenkins)

Recently I  deployed a new batch of unit tests based on the JMockit framework in our new Jenkins + Sonar environment and after building successfully the tests were hanging during sonar analysis. Even the tests that don’t use JMockit (simple JUnit) stopped to work. It was strange that during the build phase with test there was no problem [&hellip

Read More…

Plan for the New Year

As the New Year approaches I’m posting my ‘programming resolutions’, I’m defiantly looking to learn a new language…plenty of choice out there thats for sure. What else could I pick up or improve, a framework, database theory/design, some new tools of the trade etc. No time like the present, so here is my list: The big one: Scala  [&hellip

Read More…

Converting Java Properties File into XML

Many developers may not aware that the java.util.Properties class comes with a storeToXML() method to convert existing properties data into a XML file. The above example will write the properties detail into a XML file “c:/email-configuration.xml“

Read More…

Know your tools!

There is a huge number of tools specialising in different disciplines like: requirements management, software & database design, software configuration management, build & deploy, continuous integration, development, debugging, profiling, code analysis or testing. A software engineer can’t know all tools in detail, but he/she should know the key concepts and underlying technologies. Knowing the right [&hellip

Read More…