Tag: Java
-
Spring’s queryForStream Method
During one of my recent Spring and Spring Boot training course, I talked about the three major ways to access relational data from Spring: Send already-worked-out SQL using the JdbcTemplate, Work with Hibernate by injecting the JPA EntityManager using the @PersistenceContext annotation, and Simply extend one of the Spring Data interfaces, like CrudRepository. I told my students how I always struggle…
-
Simple Demo of Gradle Parallel Tests
The maxParallelForks property runs test classes in parallel, but not individual tests in a class.
-
Solving the Daily Jumble
Recently I decided to subscribe to my local newspaper (the Hartford Courant, pronounced current) again. That’s been valuable by itself, and brought some benefits I forgot about (like a comics page), but one of the unexpected side effects has been the Daily Jumble. The idea is to unscramble the clues to form words. All of…
-
Why Use Mocks?
Testing A Simple Publisher/Subscriber System With Mockito One of the challenges I find when teaching Java testing with Mockito is that the docs, while complete, don’t motivate why you want to use mocks in the first place. This post includes a simple example to show why mocking frameworks are important and where they are useful.…
-
Java 11 HttpClient, Gson, Gradle, and Modularization
This post describes a simple system that uses the new HttpClient class that comes with Java 11 to access a RESTful web service. After demonstrating basic functionality, changes are made to parse the results using Gson, and even modularize the code and have it work with Gradle. The goal is to provide an example for…
-
Fun with Time Zones in Java 8
[Note: Revised based on suggestions in the comments.] They say that one way to identify a software developer is to whisper the word “timezone” in their ear and see if they shudder. That’s certainly true for me, though my reaction is based more on travel and trying to arrange conference calls across time zones than…
-
Groovy Weather: A New Groovy Example at Java.net
One of the main goals of Making Java Groovy is to show Java developers how much Groovy can make their lives easier. To that end, I just published a blog post (through Manning’s account) over a Java.net entitled, Groovy Weather: POGOs, Gson, and Open Weather. The blog post comes with a coupon code for 45%…
-
Making Java Groovy at JavaOne 2013
Monday morning I gave my “Making Java Groovy” presentation at JavaOne in San Francisco. This is my first trip to JavaOne, and the sheer size of it is rather overwhelming. Of course, it’s also obvious at almost every turn that JavaOne is the weak sister of Oracle Open World, but hey, it could have been…
-
Making Java Groovy: Operator Overloading
This is partly a spoiler for my “Making Java Groovy” talk that I normally do at NFJS events and plan to use in my similar talk at JavaOne, but to celebrate the book going to the printer I thought I’d try to contribute something technical here. I’ve always felt that one of the keys to…
-
NetBeans 6.1 is a lot better than I thought
This week I’m in New Haven, CT, teaching a class that combines UML and Java Web Services (an odd combination to be sure). The client wanted to use NetBeans as their primary IDE, and I always try to accommodate that if I can. My last exposure to NetBeans was back in version 5.5, I think,…