Exemplo n.º 1
0
  /** Tested. */
  public void testFindItem() {
    // create 10 items
    final String title = "my-title";
    TestCaseDaoHelper.fixCreateItems(mItemDAO, title, 10);
    final Item query = new Item.Builder().title(title).build();
    final List<Item> items = mItemDAO.findItems(query, 0, 10);

    assertNotNull("Object is not empty query - " + query, items);
    assertTrue("10 Items retrieved", items.size() == 10);
    LOG.debug("items - " + items);
  }
Exemplo n.º 2
0
  public void testUpdate() {
    // create items
    final List<Integer> items = TestCaseDaoHelper.fixCreateItems(mItemDAO, 1);
    final Item item = mItemDAO.findItem(items.get(0));
    LOG.debug("Old item title - " + item.getTitle());
    item.setTitle(DOCUMENT_NEW_TITLE);

    // update item object
    mItemDAO.updateItem(item);
    assertNotNull("Object has been changed.", item);
    assertEquals("Newly assigned Object tite doesn't match.", item.getTitle(), DOCUMENT_NEW_TITLE);
  }
Exemplo n.º 3
0
    public ResultSetIterator(String query) {

      final List<String> colNames;
      try {
        Connection c = getConnection();
        stmt = createStatement(c);
        LOG.debug("Executing SQL: " + query);
        long start = System.nanoTime();
        resultSet = executeStatement(stmt, query);
        LOG.trace(
            "Time taken for sql :"
                + TimeUnit.MILLISECONDS.convert(System.nanoTime() - start, TimeUnit.NANOSECONDS));
        colNames = readFieldNames(resultSet.getMetaData());
      } catch (Exception e) {
        wrapAndThrow(SEVERE, e, "Unable to execute query: " + query);
        return;
      }
      if (resultSet == null) {
        rSetIterator = new ArrayList<Map<String, Object>>().iterator();
        return;
      }

      rSetIterator = createIterator(stmt, resultSet, convertType, colNames, fieldNameVsType);
    }