/** 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);
  }
  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);
  }
Esempio n. 3
0
    protected void validatePatch(List<SchemaPatch> patches, SchemaPatch testPatch) {
      if (testPatch.getPriorVersion() > testPatch.getNextVersion()) {
        throw new TajoInternalError("Prior version cannot proceed to next version of patch.");
      }

      for (SchemaPatch patch : patches) {
        if (testPatch.equals(patch)) {
          continue;
        }

        if (testPatch.getPriorVersion() == patch.getPriorVersion()) {
          LOG.warn("It has the same prior version (" + testPatch.getPriorVersion() + ") of patch.");

          if (testPatch.getNextVersion() == patch.getNextVersion()) {
            throw new TajoInternalError(
                "Duplicate versions of patch found. It will terminate Catalog Store. ");
          }
        }

        if (testPatch.getNextVersion() == patch.getNextVersion()) {
          LOG.warn("It has the same next version (" + testPatch.getPriorVersion() + ") of patch.");
        }
      }
    }
Esempio n. 4
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);
    }