lundi 27 avril 2015

How to unit test Clob convertion to String?

This simple method returns all the content of a Clob retrieved from the database as String.

How can I test/mock it properly, guaranteeing it will always return the full content of the Clob argument?

import java.sql.Clob;

public class ClobUtils {

    public static String clobToString(Clob clob) throws Exception {
        return clob.getSubString(1, Long.valueOf(clob.length()).intValue());
    }
}

Aucun commentaire:

Enregistrer un commentaire