JPz'log Coin Coin and Plop da Plop

17Dec/082

The Fish shell

Do you feel like Bash is boring? ZSH complicated? Then I recommend switching to the Fish shell :-)

This shell provides a neat colorized completion for a lot of commands:

I also hear that it has a nice functional scripting language.

To install it on Mac OS X with MacPorts:

sudo port install fish

then go to the Terminal preferences and replace Bash (or whatever you had before) with /opt/local/bin/fish.

i'm sure you'll like it!

17Oct/080

JUnit and its clones are dead

If you had been using JUnit, TestNG or any other similar testing framework then you must stop doing so in your next projects. Seriously.

"Behavior driven development" has been in the air for some time now. The very gross idea is that unit tests often suck when you have to read them. Instead, you would prefer expressing how your classes should behave under various scenarios, like: "when something is done, this should happen". In turn those stories become immediately natural to read. You can of course write JUnit tests that are easy to read and understand, but this requires more discipline.

I recently came across Easyb, a BDD framework written in Groovy. It provides a very cool internal DSL for writing such scenarios / specifications.

Let's have a look at a small example. We write a very stupid calculator class in Java:

package my;
 
public class Calculator {
 
    public int plus(int a, int b) {
        return a + b;
    }
 
    public int times(int a, int b) {
        return a * b;
    }
 
    public int divide(int a, int b) {
        if (b == 0) {
            throw new RuntimeException("Division by zero attempted!");
        }
        return a / b;
    }
 
}

Instead of writing the CalculatorTest class that you would expect in JUnit/TestNG and clones testing frameworks, you can write the following scenario:

import my.Calculator
 
scenario "calculator manipulation", {
 
    given "a calculator", {
        calc = new Calculator()
    }
 
    then "sum should work", {
        calc.plus(1, 2).shouldBe 3
        calc.plus(0, 2).shouldBe 2
    }
 
    and "times should work", {
        calc.times(1, 1).shouldBe 1
        calc.times(1, 0).shouldBe 0
        calc.times(2, 2).shouldBe 4
    }
 
    and "divide should work", {
        calc.divide(4, 2).shouldBe 2
        calc.divide(1, 1).shouldBe 1
    }
 
    and "dividing by zero should fail", {
        ensureThrows(RuntimeException) {
            calc.divide(10, 0)
        }
    }
 
}

Isn't that way easier to read? :-)

Finally, easyb is able to write various kind of reports in text files or XML such as this one:

 1 scenario executed successfully

  Story: calculator

    scenario calculator manipulation
      given a calculator
      then sum should work
      then times should work
      then divide should work
      then dividing by zero should fail

That's just too good ;-) What do you think?

14Oct/080

Glassfish alternate community distributions

As mentioned in this recent blog post, IzPack offers another solution to install Glassfish. Especially, the IzPack-based installers works on any Java-enabled operating system, and it provides a smooth initial configuration experience.

The post also mentions alternative packagings for Linux distributions, which is always nice to have (different installation contexts require different solutions).

In the v3 IzPack installer that is mentioned, I'd like to add that we offer a complement to the IPS-based update center in Glassfish: IzPack provides the initial installation / final uninstallation while the update center provides the updates and add-ons, just as Christopher Kampmeier from Sun Microsystems nicely blogged about a few weeks back.

Filed under: IzPack, Java, Reviews No Comments
21Aug/084

Dropbox: I like it

Dropbox

I've been using Dropbox for a few months and I must admit that it is a really great and useful service.

Dropbox provides you with a 2Gb space for storing and synchronizing files across several computers (e.g., work and home). It works in a seamless fashion:

  • install a Windows / MacOS X client (a Linux version is apparently in the works, and there is still a web interface)
  • put some files in the Dropbox folder
  • ...and voila, they are automatically synchronized.

Dropbox also supports a notion of shared folders so that you can easily exchange some stuff with friends. You can also have public folders and give the URL of a file there to the world.

Last but not least, it works well across firewalls (I can speak of that as I've been through some very picky ones). I don't know if they are using a WebDAV protocol or a custom one... did anyone sniff the network traffic?

It is currently an invitation-only service (thanks Guillaume!), so leave me an email if you want to try out, I have a few invitations left!

Filed under: English, Reviews 4 Comments

JPz'log is Digg proof thanks to caching by WP Super Cache