Example #1
0
 /**
  * Test of appendQueryBodyToSql method, of class
  * org.mmbase.storage.search.implementation.database.ChainedSqlHandler.
  */
 public void testAppendQueryBodyToSql() throws Exception {
   StringBuilder sb = new StringBuilder();
   instance.appendQueryBodyToSql(sb, query, instance);
   String queryBody = sb.toString();
   sb.setLength(0);
   testSuccessor.appendQueryBodyToSql(sb, query, instance);
   String queryBody2 = sb.toString();
   assertTrue(queryBody.length() > 0);
   assertTrue(queryBody.equals(queryBody2));
 }
Example #2
0
 /**
  * Test of appendConstraintToSql method, of class
  * org.mmbase.storage.search.implementation.database.ChainedSqlHandler.
  */
 public void testAppendConstraintToSql() throws Exception {
   StringBuilder sb = new StringBuilder();
   Constraint constraint = new BasicCompositeConstraint(CompositeConstraint.LOGICAL_AND);
   instance.appendConstraintToSql(sb, constraint, query, false, false);
   String strConstraint = sb.toString();
   sb.setLength(0);
   testSuccessor.appendConstraintToSql(sb, constraint, query, false, false);
   String queryBody2 = sb.toString();
   assertTrue(strConstraint.length() > 0);
   assertTrue(strConstraint.equals(queryBody2));
 }
 private String stateMessage(StringBuilder builder) {
   for (Call receivedCall : receivedCalls) builder.append("\n  Received ").append(receivedCall);
   builder.append("\n");
   if (pendingCalls.isEmpty()) builder.append("\n  Awaiting no further calls");
   else for (Call pendingCall : pendingCalls) builder.append("\n  Awaiting ").append(pendingCall);
   return builder.toString();
 }
Example #4
0
  /**
   * Test that <code>Clob.getCharacterStream(long,long)</code> works on CLOBs that are streamed from
   * store. (DERBY-2891)
   */
  public void testGetCharacterStreamLongOnLargeClob() throws Exception {
    getConnection().setAutoCommit(false);

    // create large (>32k) clob that can be read from store
    final int size = 33000;
    StringBuilder sb = new StringBuilder(size);
    for (int i = 0; i < size; i += 10) {
      sb.append("1234567890");
    }

    final int id = BlobClobTestSetup.getID();
    PreparedStatement ps =
        prepareStatement("insert into blobclob(id, clobdata) values (?,cast(? as clob))");
    ps.setInt(1, id);
    ps.setString(2, sb.toString());
    ps.executeUpdate();
    ps.close();

    Statement s = createStatement();
    ResultSet rs = s.executeQuery("select clobdata from blobclob where id = " + id);
    assertTrue(rs.next());
    Clob c = rs.getClob(1);

    // request a small region of the clob
    BufferedReader r = new BufferedReader(c.getCharacterStream(4L, 3L));
    assertEquals("456", r.readLine());

    r.close();
    c.free();
    rs.close();
    s.close();
    rollback();
  }
    public String toString() {
      StringBuilder buffer = new StringBuilder();

      buffer.append(_methodName);
      buffer.append("( ");

      if (_argTypes != null) {
        int count = _argTypes.length;

        for (int i = 0; i < count; i++) {
          if (i > 0) {
            buffer.append(", ");
          }

          buffer.append(_argTypes[i].getName());
        }
      }

      buffer.append(" )");

      return buffer.toString();
    }