executeUpdate(conn, "DROP TABLE doFields", true); executeUpdate(conn, "DROP TABLE dcDates", true); executeUpdate(conn, "CREATE TABLE doFields (\n" + "pid VARCHAR(64) NOT NULL,\n" + "label VARCHAR(255) NOT NULL,\n" + "dcCoverage CLOB,\n" + "dcRights CLOB)", false); executeUpdate(conn, "CREATE INDEX doFields_pid ON doFields (pid)", false); executeUpdate(conn, "CREATE TABLE dcDates (\n" + "pid VARCHAR(64) NOT NULL," + "dcDate BIGINT NOT NULL)", false); executeUpdate(conn, "CREATE INDEX dcDates_pid ON dcDates (pid)", false); cPool.free(conn);
public static junit.framework.Test suite() throws Exception { junit.framework.TestSuite suite = new junit.framework.TestSuite(AllIntegrationTests.class .getName()); suite.addTest(FieldSearchSQLImplIntegrationTest.suite()); return suite; }
@Test public void testIndexAndFindByDCIdentifier() throws Exception { init(maxResultsDefault, maxSecondsPerSessionDefault, true); // add one object with DC to index String pid1 = "test:1"; DigitalObject obj1 = getTestObject(pid1, pid1); String dcContent = "<dc:identifier>" + pid1 + "</dc:identifier>"; addXDatastream(obj1, "DC", getDC(dcContent)); setDates(obj1, new Date()); m_repo.putObject(obj1); DOReader reader1 = m_repo.getReader(false, null, pid1); m_impl.update(reader1); // query for it via dc:identifier FieldSearchQuery query = new FieldSearchQuery(Condition.getConditions("identifier~" + pid1)); int[] expected = new int[] { 1, 1 }; // first try with client requesting max TEN results per page // should get 1 page w/1 result checkResults(expected, countResults(query, 10)); // then try same, but with client requesting max ONE result per page // should still get 1 page w/1 result checkResults(expected, countResults(query, 1)); }
@Test public void testFindOneSeveralTimesNoDC() throws Exception { init(maxResultsDefault, maxSecondsPerSessionDefault, true); // add one object to index String pid1 = "test:1"; DigitalObject obj1 = getTestObject(pid1, pid1); setDates(obj1, new Date()); m_repo.putObject(obj1); DOReader reader1 = m_repo.getReader(false, null, pid1); m_impl.update(reader1); // query for everything several times // should get 1 page w/1 result each time // and cPool shouldn't be exhausted because the impl should // release each connection immediately after the query completes FieldSearchQuery query = new FieldSearchQuery("*"); int[] expected = new int[] { 1, 1 }; for (int i = 0; i < 20; i++) { checkResults(expected, countResults(query, 10)); } }