001package org.xbib.elasticsearch.river.jdbc.strategy.simple;
002
003import org.testng.annotations.Parameters;
004import org.testng.annotations.Test;
005import org.xbib.elasticsearch.river.jdbc.RiverSource;
006
007public class SimpleRiverDataTests extends AbstractSimpleRiverTest {
008
009    @Override
010    public RiverSource newRiverSource() {
011        return new SimpleRiverSource();
012    }
013
014    @Override
015    public SimpleRiverContext newRiverContext() {
016        return new SimpleRiverContext();
017    }
018
019    /**
020     * Start the river and execute a simple star query
021     * @throws Exception if test fails
022     */
023    @Test
024    @Parameters({"river1", "sql1"})
025    public void testSimpleRiverOnce(String riverResource, String sql) throws Exception {
026        createRandomProducts(sql, 100);
027        performRiver(riverResource);
028        logger.info("success");
029    }
030
031    /**
032     * Product table (star query)
033     *
034     * @param riverResource the river resource
035     * @throws Exception if test fails
036     */
037    @Test
038    @Parameters({"river2", "sql1"})
039    public void testSimpleRiverRandom(String riverResource, String sql) throws Exception {
040        createRandomProducts(sql, 100);
041        performRiver(riverResource);
042        assertHits("1", 104);
043        logger.info("success");
044    }
045
046    /**
047     * Product table
048     *
049     * @param riverResource the river
050     * @param sql           the SQL statement
051     * @throws Exception if test fails
052     */
053    @Test
054    @Parameters({"river3", "sql1"})
055    public void testSimpleRiverMaxrows(String riverResource, String sql) throws Exception {
056        createRandomProducts(sql, 100);
057        performRiver(riverResource);
058        assertHits("1", 104);
059        assertTimestampSort("1", 104);
060        logger.info("success");
061    }
062
063}