Tales from the jar side: Mockito, Reactive Spring, and A Groovy Publication
Welcome to Tales from the jar side, the Kousen IT newsletter, for the week of Jan 5 - 12, 2020. This week I taught classes in Mockito and the Hamcrest Matchers and Reactive Spring, had a contribution accepted to the 97 Things anthology, and went on vacation to Cancún, Mexico.
My producer during the Reactive Spring course this week added a link to my newsletter in the class resources. I mentioned it, but said it wasn't necessarily relevant to that class. Still, about a dozen people signed up, so I feel obligated to share a reactive joke I made this week:
They say if you have to explain a joke, it's not funny, but here goes anyway. The reactive streams specification defines publishers and subscribers. Publishers send signals and subscribers receive them. The key is, if there are no subscribers, publishers don't do anything. Thus the joke. Ha.
I felt obligated to mention that joke both to welcome the new newsletter subscribers (no pun intended -- OR WAS IT?), and because I'm concerned I didn't emphasize that principle enough during the class. So I can greet people and assuage my guilt at the same moment, which is a win-win.
Mockito/Hamcrest
The Powers That Be (TM) at the O'Reilly Learning Platform have decided not to offer my course on Mockito and the Hamcrest Matchers any more (at least until I can persuade them otherwise), which I find sad. I still spend too much time during the class on Hamcrest and not enough on Mockito, but the course is an interesting one either way, and was very well attended when we ran it this week. Mockito, in particular, is badly in need of a decent tutorial. The online documentation is fine at showing how to set expectations and validate them, but is very weak at explaining why to do what it can do.
Recently my blog posts have used Kotlin, partly to market my Kotlin Cookbook. It might be time to add a couple of interesting Mockito demos instead. If I get around to that, I'll be sure to mention it here.
Speaking of testing libraries, the Spring framework people appear to be fond of the AssertJ library, which is a good enough reason for me to look into it. I haven't yet, but it's on my list of things to learn sooner rather than later.
Also this week Philipp Hauer (@philipp_hauer on Twitter) asked what test frameworks people were using for Kotlin projects. I answered JUnit 5, and that turned out to be a surprisingly popular choice. The Kotlin space is filled with potentially useful testing frameworks, like kotlintest, MockK, Spek, and more. Right now there's no definitive choice, however, and when that's the case, most people fall back on what they know. That's what happened with me, anyway.
Of course, Philipp's blog helped too, and I mentioned it in my Kotlin Cookbook.
Groovy Code in 97 Things Java
Late last year I mentioned the 97 Things Java Developers Should Know anthology, which is another in the 97 Things series. I said that I decided to submit an article that didn't follow the required conventions or fit the length requirements, but that I liked it so I thought I'd send it in anyway.
This week I heard back from the (technical) editor, Kevlin Henney, who really liked it. That meant I needed to spend time this week cutting the length down to their requirements (more or less), but with his help I was able to achieve that more easily than I expected.
The result is that my article Make Your Java Groovier is now part of the book. I may flesh it out a bit and add it to my own blog (the book grants those rights), but if you want the full code, they're hosted as GitHub "gists" as astronauts0.groovy, astronauts1.groovy, astronauts2.groovy, and astronauts3.groovy. The individual snippet are embedded into the article, but you might find them easier to read and/or execute in their scripted form at the links provided.
I'm rather pleased with the article, partly because it was fun to write, and partly because it feels somewhat subversive to get Groovy code into a Java anthology. Of course, that's how Groovy is used anyway. It's the only language I know of that isn't intended to replace what came before (Java) but rather to augment it and make it better.
Incidentally, I assume most readers will get the reference in the first line ("The screen was the color of an old cyberpunk novel opened to the first line"). Just in case you didn't, it's a connection to William Gibson's classic dystopian novel Neuromancer (1984), which pretty much created the whole cyberpunk genre. That book has one of the most famous opening lines in all of science fiction, which is: "The sky above the port was the color of television, tuned to a dead channel."
See? More value added for reading this newsletter.
Vacation Time
Each year a handful of couples that includes current and former No Fluff, Just Stuff speakers goes on vacation together. This year we're in Cancún, Mexico, at a very nice, all-inclusive resort.
Pricey, but hey, my son's inheritance isn't going to spend itself. As Saul Bloom says in Ocean's Twelve, "I want the last check I write to bounce".
We're wildly adventurous people, which means we play a lot of board games, plan spa visits, and go to all the restaurants. I also rather enjoyed watching the NFL playoffs with Spanish commentators, which were way better than most of the regular American ones even though I had no idea what they were saying.
"... Spanish ... Spanish ... Spanish ...Touchdown, Kansas City!! ... Spanish ... Spanish ... Spanish ..."
Since I expect you're thinking "pictures or it didn't happen", I just took a couple from my hotel room and even tried to do a selfie, which I'm really bad at. Unfortunately, when I tried to upload the pictures to this newsletter, TinyLetter rotates them sideways. I know I shouldn't complain about a free tool, but this is getting annoying. In previous weeks I've found I can't easily embed tweets, or add YouTube videos, and now I'm having problems with images. It might be time to look at alternatives. If I resolve this, I'll add some pics next week.
My geek nature means that if I don't have a comfortable room and high-speed internet access it really isn't a vacation, but this certainly qualifies. We played games this morning and my wife should be getting back from her spa visit soon, so I need to finish this so I can start thinking about going to another restaurant. It's tough, but somebody has to do it.
Last week:
Mockito and the Hamcrest Matchers online on Safari
Reactive Spring online at Safari
Published Make Your Java Groovier with 97 Things
Vacation time!
This week:
JUnit 5 online at Safari
Introduction to Gradle online for Gradle, Inc.
Plan additional training courses