Tag Archives: Java

Random Number Generator provider abstract class

I had a need to support multiple hardware random number generators (RNG) in a project. I started with an RngProvider abstract class. This class defines the functionality that will be the same and defines a method that will contain the … Continue reading

Posted in Java | Tagged , , , , , , , , , , | Leave a comment

Filling a queue asynchronously via a thread

I was working with a hardware random number generator (RNG) and what it came down to was we needed a cache of numbers that were available, but also needed the fill the numbers without slowing the process of giving out … Continue reading

Posted in Java | Tagged , , , , , , | Leave a comment

Apache HttpClient 4 String get example

This was an older piece of code that I had. Add the following dependency. I made a wrapper method that performs a get of a given URL and returns a string.

Posted in Java | Tagged , , , , | 1 Comment

How to run a JUnit test multiple times

I had a Spring-enabled JUnit test that I needed to run multiple times. I thought there used to be a JUnit annotation, but I couldn’t find it. I found and used the Spring @Repeat annotation. I used to set breakpoints … Continue reading

Posted in JUnit, Spring, Test Driven Development, Unit Tests | Tagged , , , , , | Leave a comment

Cucumber Spring Integration

I have a normal Spring-enabled project arranged as a Maven project. There were already JUnit tests in the project, along with the requisite Spring configuration. I needed to add Cucumber tests to the project. I started by adding a cucumber … Continue reading

Posted in Cucumber, Integration Tests, Java, JUnit, Spring, TDD, Test Driven Development, Unit Tests | Tagged , , , , , , , , , | Leave a comment

Creating an enum from it’s values

Enum’s provide valueOf(String) to get an enum via it’s String value.  This is good, but doesn’t help if we need to get an enum from one of it’s other values.  I added the following method to an enum. The Enum … Continue reading

Posted in Java | Tagged , | Leave a comment

Injecting value from Spring Properties in Java

This is so easy, but I rarely use it and always forget how to use it. This is how you define a properties: The contents of the properties file is: To inject it into a class:

Posted in Java, Spring | Tagged , , | Leave a comment