-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
select from collection implementation
- Loading branch information
Showing
12 changed files
with
216 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<settings> | ||
<mirrors> | ||
<mirror> | ||
<id>wso2.releases</id> | ||
<mirrorOf>wso2.releases</mirrorOf> | ||
<name></name> | ||
<url>http://maven.wso2.org/nexus/content/repositories/releases/</url> | ||
</mirror> | ||
<mirror> | ||
<id>wso2.snapshots</id> | ||
<mirrorOf>wso2.snapshots</mirrorOf> | ||
<name></name> | ||
<url>http://maven.wso2.org/nexus/content/repositories/snapshots/</url> | ||
</mirror> | ||
<mirror> | ||
<id>wso2-nexus</id> | ||
<mirrorOf>wso2-nexus</mirrorOf> | ||
<name></name> | ||
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url> | ||
</mirror> | ||
</mirrors> | ||
</settings> | ||
|
||
<!--<settings xmlns="http://maven.apache.org/POM/4.0.0"--> | ||
<!-- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"--> | ||
<!-- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">--> | ||
<!-- <mirrors>--> | ||
<!-- <mirror>--> | ||
<!-- <id>wso2.releases</id>--> | ||
<!-- <mirrorOf>wso2.releases</mirrorOf>--> | ||
<!-- <name></name>--> | ||
<!-- <url>http://maven.wso2.org/nexus/content/repositories/releases/</url>--> | ||
<!-- </mirror>--> | ||
<!-- <mirror>--> | ||
<!-- <id>wso2.snapshots</id>--> | ||
<!-- <mirrorOf>wso2.snapshots</mirrorOf>--> | ||
<!-- <name></name>--> | ||
<!-- <url>http://maven.wso2.org/nexus/content/repositories/snapshots/</url>--> | ||
<!-- </mirror>--> | ||
<!-- <mirror>--> | ||
<!-- <id>wso2-nexus</id>--> | ||
<!-- <mirrorOf>wso2-nexus</mirrorOf>--> | ||
<!-- <name></name>--> | ||
<!-- <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>--> | ||
<!-- </mirror>--> | ||
<!-- </mirrors>--> | ||
<!--</settings>--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--settings ./.mvn/local-settings.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
component/src/main/java/io/siddhi/extension/io/live/utils/LiveSourceConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package io.siddhi.extension.io.live.utils; | ||
|
||
public class LiveSourceConstants { | ||
public static final String SQLQUERY = "sql"; | ||
public static final String SQLQUERY = "sql.query"; | ||
public static final String HOSTNAME = "host.name"; | ||
public static final String APIKEY = "api.key"; | ||
} |
96 changes: 94 additions & 2 deletions
96
component/src/test/java/io/siddhi/extension/io/live/source/TestCaseOfLiveSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,101 @@ | ||
package io.siddhi.extension.io.live.source; | ||
|
||
import io.siddhi.core.SiddhiAppRuntime; | ||
import io.siddhi.core.SiddhiManager; | ||
import io.siddhi.core.event.Event; | ||
import io.siddhi.core.query.output.callback.QueryCallback; | ||
import io.siddhi.core.util.EventPrinter; | ||
import io.siddhi.core.util.SiddhiTestHelper; | ||
import io.siddhi.core.util.persistence.InMemoryPersistenceStore; | ||
import io.siddhi.core.util.persistence.PersistenceStore; | ||
import io.siddhi.extension.map.xml.sourcemapper.XmlSourceMapper; | ||
import org.apache.log4j.LogManager; | ||
import org.apache.log4j.Logger; | ||
|
||
import org.testng.Assert; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
import java.net.URI; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
/** | ||
* Testcase of LiveSource. | ||
*/ | ||
public class TestCaseOfLiveSource { | ||
// If you will know about this related testcase, | ||
//refer https://github.com/siddhi-io/siddhi-io-file/blob/master/component/src/test | ||
private static final Logger logObj = (Logger) LogManager.getLogger(TestCaseOfLiveSource.class); | ||
private AtomicInteger eventCount = new AtomicInteger(0); | ||
private int waitTime = 50; | ||
private int timeout = 30000; | ||
|
||
@BeforeMethod | ||
public void init() { | ||
eventCount.set(0); | ||
} | ||
|
||
/** | ||
* Creating test. | ||
* | ||
* @throws Exception Interrupted exception | ||
*/ | ||
@Test | ||
public void liveSelect() throws Exception { | ||
logObj.info(" Creating test for publishing events without URL."); | ||
// URI baseURI = URI.create(String.format("http://%s:%d", "0.0.0.0", 8280)); | ||
List<String> receivedEventNameList = new ArrayList<>(2); | ||
PersistenceStore persistenceStore = new InMemoryPersistenceStore(); | ||
SiddhiManager siddhiManager = new SiddhiManager(); | ||
siddhiManager.setPersistenceStore(persistenceStore); | ||
siddhiManager.setExtension("xml-input-mapper", XmlSourceMapper.class); | ||
String inStreamDefinition = "@App:name('TestSiddhiApp')" + | ||
"@source(type='live', sql.query='select count from network_traffic', host.name='api-varden-4f0f3c4f.paas.macrometa.io'," + | ||
"api.key = 'madu140_gmail.com.AccessPortal.2PL8EeyIAMn2sx7YHKWMM58tmJLES4NyIWq6Cnsj0BTMjygJyF3b14zb2sidcauXccccb8'," + | ||
" @map(type='keyvalue'), @attributes(id = 'id', name = 'name'))," + | ||
"define stream inputStream (count int)"; | ||
String query = ("@info(name = 'query') " | ||
+ "from inputStream " | ||
+ "select * " | ||
+ "insert into outputStream;" | ||
); | ||
SiddhiAppRuntime siddhiAppRuntime = siddhiManager | ||
.createSiddhiAppRuntime(inStreamDefinition + query); | ||
|
||
siddhiAppRuntime.addCallback("query", new QueryCallback() { | ||
@Override | ||
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { | ||
EventPrinter.print(timeStamp, inEvents, removeEvents); | ||
for (Event event : inEvents) { | ||
eventCount.incrementAndGet(); | ||
receivedEventNameList.add(event.getData(0).toString()); | ||
} | ||
} | ||
}); | ||
siddhiAppRuntime.start(); | ||
// publishing events | ||
List<String> expected = new ArrayList<>(1); | ||
expected.add("99"); | ||
// expected.add("Mike"); | ||
// String event1 = "<events>" | ||
// + "<event>" | ||
// + "<name>John</name>" | ||
// + "<age>100</age>" | ||
// + "<country>AUS</country>" | ||
// + "</event>" | ||
// + "</events>"; | ||
// String event2 = "<events>" | ||
// + "<event>" | ||
// + "<name>Mike</name>" | ||
// + "<age>20</age>" | ||
// + "<country>USA</country>" | ||
// + "</event>" | ||
// + "</events>"; | ||
// HttpTestUtil.httpPublishEventDefault(event1, baseURI); | ||
// HttpTestUtil.httpPublishEventDefault(event2, baseURI); | ||
SiddhiTestHelper.waitForEvents(waitTime, 1, eventCount, timeout); | ||
Assert.assertEquals(receivedEventNameList.toString(), expected.toString()); | ||
siddhiAppRuntime.shutdown(); | ||
} | ||
} |
Binary file removed
BIN
-2.17 KB
component/target/classes/io/siddhi/extension/io/live/sink/LiveSink.class
Binary file not shown.
Binary file modified
BIN
-2.7 KB
(56%)
component/target/classes/io/siddhi/extension/io/live/source/LiveSource.class
Binary file not shown.
Binary file removed
BIN
-423 Bytes
component/target/classes/io/siddhi/extension/io/live/utils/LiveSourceConstants.class
Binary file not shown.
Binary file removed
BIN
-345 Bytes
component/target/test-classes/io/siddhi/extension/io/live/sink/TestCaseOfLiveSink.class
Binary file not shown.
Binary file modified
BIN
+3.49 KB
(1100%)
component/target/test-classes/io/siddhi/extension/io/live/source/TestCaseOfLiveSource.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters