Crisp Home

Tag Archives: java

On Unit Testing and Mockito

Posted on by Per Lundholm.

This is just a blog post to point to my presentation of the aforementioned subject. Or should I say, “prezi”, because there are no slides, just a big picture with a path through it. That’s is the way of Prezi presentations and as a first timer, I felt liberated. Slides are so dull!

The content of my presentation is aimed at those with some experience of unit testing that would like a dose of philosophy on testing styles. Classical or Mockist? State or Behavior? Also, if you are not that familiar with Mockito, take this prezi for a spin!

Here is the link to the prezi! That’s all for now.

read more »

Functional Java

Posted on by Anders Laestadius.

I have just finished reading a neat little book about functional programming for Java developers by Dean Wampler. The book is only sixty pages long so it’s a really fast reading. This is a book for Java programmers and others working in the object oriented paradigm that haven’t read about or done any functional programming before. If that fits you then this book may be a good choice to read. Otherwise, I recommend that you seek more advanced and in-depth books in the subject instead. But this text will not be a review of the book. I will instead comment on the use of the functional structure and its paradigm in languages like Java that is not designed for it.

read more »

Mönster för flertrådade enhetstester

Posted on by Olle Hallin.

Detta är ett designmönster för hur man skriver ett enhetstest som utför samma test samtidigt i flera trådar.

Genom att utnyttja java.util.concurrent på ett smart sätt säkerställer man maximal samtidighet, vilken kan avslöja trådbuggar.

Kom ihåg: det går inte att bevisa att ett program är fritt från trådbuggar. Det handlar om att göra det sannolikt att det fungerar i en flertrådad miljö.

Kodmall



    @Test
    public void testSomething() {
        assertTrue(true);
    }

    @Test
    public void testConcurrentAuthInfoResponse() throws InterruptedException {
        final int threads = 100;

        final CountDownLatch readyToStart = new CountDownLatch(threads);
        final CountDownLatch startingGun = new CountDownLatch(1);
        final CountDownLatch finishLine = new CountDownLatch(threads);
        final AtomicInteger failCount = new AtomicInteger();

        for (int i=0; i

Visserligen en hel del boilerplate, men det kan man faktorera ut till en Template á là Springs JdbcTemplate.

Some Gotchas for Java Developers Learning JavaFX

Posted on by Per Lundholm.

In an earlier post, I had attached slides from a presentation on JavaFX that contained some code examples. I discovered that at least one of them, the ball game, stopped working when I switched to JavaFX 1.3.

I would say it is a quite subtle difference.

What happened was that the onKeyPressed and onKeyReleased were not called. My immediate reaction was that it was due to some bug in JavaFX but yesterday I realized what had happened.

read more »

Technology stressed? Perhaps it is time to panic!

Posted on by Mats Henricson.

Four years ago I spent a few months assembling a rather wide-spread document which I named "State of the art in Server Side Java". It was at the time well researched enough to end up as an entry on The Server Side.

Soon thereafter I got sidetracked to follow Ajax for a few years. I even went as the only Swede to the first ever Ajax conference in San Francisco, and blogged a lot from there.

These days there are simply so much things going on in Server Side Java land to have a slight clue as to where that freight-train is heading. There’s Hadoop and all its cousins for distributed computing, Actors, Terracotta, a school of new whacky persistence paradigms, a handful of JVM-based languages that only Ola Bini has the energy to follow. Annotations have, as I predicted, totally changed the way we program, and just about every day I bump into a new annotation I’ve never seen before (yesterday it was @PathParam).

It would feel OK if this plethora of technologies were somewhat obscure, but in my current project we use a lot of stuff I don’t know well enough, such as Maven, Jersey, WebLogic, Spring transactions and JPA, just to mention a few.

And even though the Ajax anarchy has somewhat collapsed into a few leaders, such as jQuery, Dojo, DWR and GWT, the whole arena is just all over the place. I’ve stopped following Ajax these days, there is just too much going on.

So, what do I spend time on, if I don’t stay up-to-date with server side Java or Ajax? Well, I’m swamped by RSS and Twitter. I abuse technology news like a drug addict, and believed I was reasonably knowledgeable, until I read this blog post yesterday which listed 14 technologies to follow at JavaOne. I had heard of 3 of them, which made me start thinking.

What the heck is going on? Is this technology race accelerating, not just at the rate of the SW industry expanding, but at a pace where it is getting out of control? Have humans triggered the singularity themselves, without the need for a Super Intelligence? Well, perhaps not. The slice of knowledge any human can follow has been shrinking constantly for a long time. But I can’t help getting this idea that the explosion of open source software is giving us the shoulders of giants we can stand on to accelerate our knowledge. And more of it is coming from unexpected countries. Recently I bumped into Debasish Ghosh. Following this guy from India on Twitter is like riding a rollercoaster – new exciting stuff all the time.

So, should we panic? Should we give up? Will every future job search have a list of required skills from a potential list of skills so huge that nobody will ever have a full set? What if we go with maximum speed into polyglot programming, and fragment even further in all directions? Today I heard about two sites where they used Clojure on the server, with Rails as UI. Who the hell can fill that skill set?