title: How to unit test Clob conversion to String?
body: <p>This simple method returns all the content of a <code>Clob</code> retrieved from the database as <code>String</code>.</p>
  
  <p>How can I test/mock it properly, guaranteeing it will always return the full content of the <code>Clob</code> argument (assuming its size will not be higher than an Integer)?</p>
  
  <pre><code>import java.sql.Clob;
  
  public class ClobUtils {
  
      public static String clobToString(Clob clob) throws Exception {
  
          if(clob.length() &gt; Integer.MAX_VALUE) {
              throw new Exception("Clob is too big to be handled by the application.");
          }
  
          // Assumes that Clob content can fit in the String
          return clob.getSubString(1, Long.valueOf(clob.length()).intValue());
      }
  
  }
  </code></pre>