Search in sources :

Example 31 with Table

use of org.wso2.siddhi.core.table.Table in project siddhi by wso2.

the class DefineTableTestCase method testQuery18.

@Test
public void testQuery18() {
    log.info("testTableDefinition18 - Table w/ ref and additional properties");
    Map<String, String> systemConfigs = new HashMap<>();
    systemConfigs.put("test1.type", "test");
    systemConfigs.put("test1.uri", "http://localhost");
    InMemoryConfigManager inMemoryConfigManager = new InMemoryConfigManager(null, systemConfigs);
    inMemoryConfigManager.extractSystemConfigs("test1");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setConfigManager(inMemoryConfigManager);
    siddhiManager.setExtension("store:test", TestStore.class);
    String siddhiApp = "" + "@store(ref='test1', uri='http://localhost:8080', table.name ='Foo')" + "define table testTable (symbol string, price int, volume float); ";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
    siddhiAppRuntime.shutdown();
    Map<String, String> expectedSystemConfigs = new HashMap<>();
    expectedSystemConfigs.put("type", "test");
    expectedSystemConfigs.put("uri", "http://localhost:8080");
    expectedSystemConfigs.put("table.name", "Foo");
    AssertJUnit.assertEquals("Test store initialization failure", expectedSystemConfigs, TestStore.systemConfigs);
}
Also used : InMemoryConfigManager(org.wso2.siddhi.core.util.config.InMemoryConfigManager) HashMap(java.util.HashMap) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 32 with Table

use of org.wso2.siddhi.core.table.Table in project siddhi by wso2.

the class DefineTableTestCase method testQuery6.

@Test(expectedExceptions = DuplicateDefinitionException.class)
public void testQuery6() throws InterruptedException {
    log.info("testTableDefinition6 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String definitions = "define stream TestTable(symbol string, price int, volume float); " + "define table TestTable(symbol string, price int, volume float); ";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(definitions);
    siddhiAppRuntime.shutdown();
}
Also used : SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 33 with Table

use of org.wso2.siddhi.core.table.Table in project siddhi by wso2.

the class DefineTableTestCase method testQuery21.

@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testQuery21() {
    log.info("testTableDefinition21 - Table w/ ref to an undefined store type");
    Map<String, String> systemConfigs = new HashMap<>();
    systemConfigs.put("test1.type", "testdb");
    systemConfigs.put("test1.uri", "http://localhost");
    InMemoryConfigManager inMemoryConfigManager = new InMemoryConfigManager(null, systemConfigs);
    inMemoryConfigManager.extractSystemConfigs("test2");
    SiddhiManager siddhiManager = new SiddhiManager();
    siddhiManager.setConfigManager(inMemoryConfigManager);
    siddhiManager.setExtension("store:test", TestStore.class);
    String siddhiApp = "" + "@store(ref='test2', uri='http://localhost:8080', table.name ='Foo')" + "define table testTable (symbol string, price int, volume float); ";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
    siddhiAppRuntime.shutdown();
}
Also used : InMemoryConfigManager(org.wso2.siddhi.core.util.config.InMemoryConfigManager) HashMap(java.util.HashMap) SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 34 with Table

use of org.wso2.siddhi.core.table.Table in project siddhi by wso2.

the class DefineTableTestCase method testQuery9.

@Test(expectedExceptions = DuplicateDefinitionException.class)
public void testQuery9() throws InterruptedException {
    log.info("testTableDefinition9 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String siddhiApp = "" + "define stream StockStream(symbol string, price int, volume float);" + "define table OutputStream (symbol string, price float, volume long); " + "" + "from StockStream " + "select symbol, price, volume " + "insert into OutputStream;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
    siddhiAppRuntime.shutdown();
}
Also used : SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Example 35 with Table

use of org.wso2.siddhi.core.table.Table in project siddhi by wso2.

the class DefineTableTestCase method testQuery12.

@Test
public void testQuery12() throws InterruptedException {
    log.info("testTableDefinition12 - OUT 0");
    SiddhiManager siddhiManager = new SiddhiManager();
    String siddhiApp = "" + "define stream StockStream(symbol string, price int, volume float);" + "define table OutputStream (symbol string, price int, volume float); " + "" + "from StockStream " + "select * " + "insert into OutputStream;";
    SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
    siddhiAppRuntime.shutdown();
}
Also used : SiddhiAppRuntime(org.wso2.siddhi.core.SiddhiAppRuntime) SiddhiManager(org.wso2.siddhi.core.SiddhiManager) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)183 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)176 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)176 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)140 Event (org.wso2.siddhi.core.event.Event)119 QueryCallback (org.wso2.siddhi.core.query.output.callback.QueryCallback)102 ArrayList (java.util.ArrayList)47 VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)23 HashMap (java.util.HashMap)22 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)20 ExpressionExecutor (org.wso2.siddhi.core.executor.ExpressionExecutor)19 Attribute (org.wso2.siddhi.query.api.definition.Attribute)19 Table (org.wso2.siddhi.core.table.Table)11 Expression (org.wso2.siddhi.query.api.expression.Expression)11 Variable (org.wso2.siddhi.query.api.expression.Variable)11 MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)10 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)10 TableDefinition (org.wso2.siddhi.query.api.definition.TableDefinition)9 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)8 ConstantExpressionExecutor (org.wso2.siddhi.core.executor.ConstantExpressionExecutor)8