Search in sources :

Example 1 with KeyValueStreamListener

use of org.xbib.elasticsearch.common.keyvalue.KeyValueStreamListener in project elasticsearch-jdbc by jprante.

the class MockTests method testMockHighBills.

@Test
@Parameters({ "sql3" })
public void testMockHighBills(String sql) throws Exception {
    List<Object> params = new LinkedList<Object>();
    params.add(2.00);
    Sink output = new MockSink() {

        @Override
        public void index(IndexableObject object, boolean create) throws IOException {
            logger.debug("sql3={}", object);
        }
    };
    PreparedStatement statement = source.prepareQuery(sql);
    source.bind(statement, params);
    ResultSet results = source.executeQuery(statement);
    KeyValueStreamListener listener = new StringKeyValueStreamListener().output(output);
    source.beforeRows(results, listener);
    long rows = 0L;
    while (source.nextRow(results, listener)) {
        rows++;
    }
    source.afterRows(results, listener);
    assertEquals(rows, 2);
    source.close(results);
    source.close(statement);
}
Also used : Sink(org.xbib.elasticsearch.jdbc.strategy.Sink) StringKeyValueStreamListener(org.xbib.elasticsearch.common.util.StringKeyValueStreamListener) ResultSet(java.sql.ResultSet) IndexableObject(org.xbib.elasticsearch.common.util.IndexableObject) PreparedStatement(java.sql.PreparedStatement) IndexableObject(org.xbib.elasticsearch.common.util.IndexableObject) LinkedList(java.util.LinkedList) KeyValueStreamListener(org.xbib.elasticsearch.common.keyvalue.KeyValueStreamListener) StringKeyValueStreamListener(org.xbib.elasticsearch.common.util.StringKeyValueStreamListener) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) AbstractSinkTest(org.xbib.elasticsearch.jdbc.strategy.standard.AbstractSinkTest)

Aggregations

PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 LinkedList (java.util.LinkedList)1 Parameters (org.testng.annotations.Parameters)1 Test (org.testng.annotations.Test)1 KeyValueStreamListener (org.xbib.elasticsearch.common.keyvalue.KeyValueStreamListener)1 IndexableObject (org.xbib.elasticsearch.common.util.IndexableObject)1 StringKeyValueStreamListener (org.xbib.elasticsearch.common.util.StringKeyValueStreamListener)1 Sink (org.xbib.elasticsearch.jdbc.strategy.Sink)1 AbstractSinkTest (org.xbib.elasticsearch.jdbc.strategy.standard.AbstractSinkTest)1