Archive for January, 2007

Ron Jeffries: Features, not tasks

Ron Jeffries reminds us: “… hours aren’t burndown. Accomplishments are. A team that focuses on hours isn’t focusing on getting things done.[...] The point [...] is getting backlog items done, not getting tasks done” This really cannot be said too often!

Via Jason Yip

Comments

Colorless Green Ideas Sleep Furiously

This phase has been stuck in my head lately: Colorless green ideas sleep furiously. It was first used by the linguist Noam Chomsky as an example of a sentence that is grammatically correct, yet has no meaning.

Interestingly, in 1985 this was taken up as a challenge. The result was a literary competition to write a short text that gives the sentence meaning. Before you continue reading, think for a while about how the sentence could have meaning.

Read the rest of this entry »

Comments

commons-logging: you’re on notice!

Hey, commons-logging team, you’re on notice!

Here is a dump of the Maven 2 dependencies from the project I use for my article on embedded integration testing:

 no.brodwall.demo:web-demo:war:1.0-SNAPSHOT
   org.springframework:spring:jar:2.0.1:compile
     commons-logging:commons-logging:jar:1.1:compile
       avalon-framework:avalon-framework:jar:4.1.3:compile
       javax.servlet:servlet-api:jar:2.5:test
       javax.servlet:servlet-api:jar:2.5:compile
       logkit:logkit:jar:1.0.1:compile
       log4j:log4j:jar:1.2.12:compile

Never mind the fact that commons-logging was meant to be a thin facade on top of other logging frameworks. commons-logging 1.1 actually include compile dependencies on: log4j, servlet-api, avalon-framework, and logkit! servlet-api!?! WTF!?

Read the rest of this entry »

Comments (5)

Superceeded Article: Embedded Web Integration Testing with Jetty

Do you speak test? In that case: Hello web application:


public class WebIntegrationTest extends net.sourceforge.jwebunit.WebTestCase {

    public void testIndex() {
        beginAt("/index.html");
        assertTextPresent("Hello world");
    }

    private org.mortbay.jetty.Server server;

    protected void setUp() throws Exception {
        server = new org.mortbay.jetty.Server(0);
        server.addHandler(
                new org.mortbay.jetty.webapp.WebAppContext("src/main/webapp", "/my-context"));
        server.start();

        int actualPort = server.getConnectors()[0].getLocalPort();
        getTestContext().setBaseUrl("http://localhost:" + actualPort + "/my-context");
    }
}

This code runs with no application server, no separate deployment step, just like that.

If this looks interesting, see my full-sized article on java.net

Comments (14)

The java.util.Map DAO

The more I code, the fewer dependencies I am willing to create.

For example, I used to have a common super interface that all persistent objects must inherit from in order to have an id-field. I used to have a common DAO interface that all DAOs implemented. But these add hard dependencies in my code.

Hiding the super interface for all entities was easy. Doing away with the DAO is harder. But I can use Maps to get rid of almost all custom code. There are two exceptions so far: Querying and some DAO utility operations like flushing.

Read the rest of this entry »

Comments

The coolest Eclipse plugin ever!

I have just one thing to say: w00t!

Failing unit test

Unit Test Fails

Unit test succeeds

Unit Test Succeeds

Thanks to Litrik de Roy

Litrik used my C code to control the lights of the Dell XPS computer and integrated them into an Eclipse plugin. Coolest plugin EWAR!!one!! See more about it on the project blog.

Comments (6)

Ralph Johnson: RDBMS as a pattern

Ralph Johnson discusses the use of Relational Database Management Systems (RDBMS)

If you don’t have good architects, big systems will end up as big balls of mud. A lot of companies live with it, but there are certainly big payoffs if you can avoid it. The main problem is that there aren’t enough good architects to go around. One of the advantage of a RDBMS is that it is fairly easy to understand so below average programmers can still get systems running. Below average programmers will not build the best architectures, though. So, the fact that RDBMs lead to big balls of mud is actually a sign of an advantage. You can use a RDBMS when you have good architects and when you don’t. You’ll end up with completely different systems, but that is because of the quality of your architects, not because of the technology you use.

He discusses RDBMS mostly in relationship with OODBMS and things like Prevaylor. I am looking forward to seeing more on this from Ralph, as it in many ways ties in to my own thoughts on use of databases.

Comments

Integration testing: Many-to-one relationships with select-fields

This post is an entry in my ongoing series about web integration testing with Jetty. See post 1, 2 and 3 in the series for more information.

I often find that a web interface needs to let a user select one of a list of objects as a relation to the object he is editing. This is the basic and simple way of dealing with many-to-one relationships. However, most web frameworks don’t make this as easy or well-documented as it should be. In this post, I will describe how to make a select-field with Spring-MVC and FreeMarker.

As always, I will start with a test:


public void testEditParent() {
    // Create a hierarchy of test categories
    Category parentCategory = new Category("parent category " + System.currentTimeMillis());
    Category subcategory = parentCategory.addSubcategory("first subcategory " + System.currentTimeMillis());
    Category newParent = new Category("new parent category " + System.currentTimeMillis());
    categoryDao.insert(parentCategory);
    categoryDao.insert(subcategory);
    categoryDao.insert(newParent);

    // go to the subcategory
    beginAt("/category/edit.html?id=" + subcategory.getId()));
    assertOptionEquals("parent", subcategory.getParent().getName());

    // Update the parent field
    selectOption("parent", newParent.getName());
    submit();
    assertTextInElement("parent", newParent.getName());

    // Check that the new parent has the subcategory
    beginAt("/category/edit.html?id=" + extrasubcategory.getId()));
    assertTextInTable("subcategories", subcategory.getName());

    // Check that the old parent no longer has the subcategory
    beginAt("/category/edit.html?id=" + parentCategory.getId()));
    assertTextNotInTable("subcategories", subcategory.getName());
}

Read the rest of this entry »

Comments (3)

Integration testing: Validation and relationships

In my previous two posts about integration testing with jetty [1][2], I have showed how to test a simple web application with Jetty and how to expand this application with a fake DAO implementation to test display and updates of data through the web interface. In this penultimate post, I will describe how to work with more advanced edit scenarios.

Most web applications have some degree of requirements for validation of input and a bit more advanced data structure than the one we’ve worked with so far. I will expand the example to show how to do validation using Spring-MVC and how to handle many-to-one relationships between domain objects.

Read the rest of this entry »

Comments

Creative Commons Attribution 3.0 Unported
This work is licensed under a Creative Commons Attribution 3.0 Unported.