Tag: Java
-
Jenkins: Getting Karma Generated Test Results to Appear in Maven Project Job
PROBLEM Jenkins, for some reason, does not pick up Karma generated JUnit test reports even though they are created in the right directory… and apparently, it is a known problem. While Freestyle project job allows us to manually publish these JUnit reports, my intention is to rely on Maven project job to do the same… Read More…
-
IntelliJ: Overriding Log4J Configuration Globally for JUnit
PROBLEM Most of the time, we may have several Log4J configurations depending on the environments, for example:- Since log4j.xml and log4j2.xml are the default configuration files for Log4J and Log4J2, these configurations will always be used unless we override the configuration file path. In another word, if we don’t override the configuration file path and… Read More…
-
Java + Groovy: Creating Immutable List
Java: Mutable List Java: Immutable List Java: Immutable List using Guava Groovy: Immutable List Read More…
-
Java: Promoting Testability by Having Enum Implementing an Interface
OVERVIEW This post illustrates how we can easily write a better test case without polluting our production code with non-production code by performing a minor refactoring to the production code. PROBLEM Let’s assume we have a simple Data Reader that reads all the lines of a given algorithm data file and returns them:- This API… Read More…
-
Spring Security: Forcing URLs to use HTTPS
PROBLEM Your web application supports both HTTP and HTTPS. You want to force all URLs to use HTTPS. SOLUTION Spring Security has a simple configuration that allows us to redirect all HTTP-based URLs to HTTPS. All we have to do is to set requires-channel=”https” on <security:intercept-url/> tag. For example:- With this configuration, when the user… Read More…
-
Java + HTTPS: Unable to Find Valid Certification Path to Requested Target
PROBLEM When trying to invoke HTTPS-based web service (ex: https://server:1234/myapp/web-service), the following exceptions occurred:- SOLUTION I do not want to take any credits away from @mkyong, but this author wrote a great solution to this problem at http://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/ . Kudos to him. The only thing I want to point out here is the link to… Read More…