October 4th, 2013

by Ivan St. Ivanov

It’s Arquillian time

Day three of JavaOne started and finished for me with Arquillian. In the morning I went to the talk by Andrew Rubinger and Aslak Knutsen about the ABC of integration testing. I hope most of the people reading this blog know what Arquillian is and does, but I will summarize it in one sentence: it makes your Java EE application unit tests run inside the container so that you don’t have to mock all the services that it provides: persistence, CDI, transactions, etc.

I think this is my 5th or 6th session in which I listen about the library. I blogged about it while it was in its alpha releases. I have even used in some of my projects). So I was pretty aware of most of the things they presented. However, I learned some new cool stuff. And as I always say: you have to be patient with the speakers giving their introductions which you are familiar with. You have to give the people that attend such sessions for the first time the chance to get the initial feel of how everything works. And I really recommend getting Andrew and Aslak’s new book, which I hope will be available end of November.

I spent the afternoon hacking Arquillian itself as part of the code garden initiative. There the leads of popular open source project gave the opportunity to community members to contribute small features. So I spent some time with Aslak while he explained me the task that I was supposed to work on. Then I spent some more time to understand how that particular part of Arquillian core works by running and debugging the unit tests. Finally I hacked it and at the end of the day I sent my pull request. Cheers!

Java APIs and the Internet of Things

One of the trending topics of this year’s JavaOne was Java in the Internet of Things. During the community day I saw what cool stuff the SouJava members did with some Raspberry PIs and Arduinos. But now was time for real hacking. Robert Savage showed us how we can use the pi4j library to write event based Java programs which can control devices attached to various ports of a Raspberry PI.

First of all, what is Raspberry PI? It’s a small, cheap (just $35) computer, which has 700 MHz ARM processor, 512 MBs RAM, very good GPU, an SD card slot, two USB ports, HDMI, audio output, WiFi and some low level I/O peripherals. It runs various versions of Linux and most importantly Java can also run there. The pi4j library abstracts away exactly the low level I/O (GPIO, serial ports and some other peripherals that I don’t really understand).

GPIO comes from General Purpose Input/Output. It’s a 26-pin chip. You can connect devices to most of these pins. If you want to check their state or control them with pi4j, you first have to create a GpioController and then use that to obtain handle to a device by providing the ID (simple number) of the PIN, where the device is attached. The good thing here is that there is a component API that supports most of the popular devices (keypad, led, LCD, relay, temperature sensor to name a few), so you are not concerned with low level hardware stuff. Once you get a handle to the device you can register listeners on events (like pushing a connected button for example), for which you can change the state of other devices (like lighting a led). There is also serial device API, which allows you to open the port and send commands there.

What you can also do is run a web server (like Jetty or Glassfish) and react on some events by sending an email or a tweet for example. I can’t believe what a real hardware newbie like me can do with this amazing computer and the pi4j library!

Leave a Reply


5 − = zero