本文整理匯總了Java中org.testng.AssertJUnit.fail方法的典型用法代碼示例。如果您正苦於以下問題:Java AssertJUnit.fail方法的具體用法?Java AssertJUnit.fail怎麽用?Java AssertJUnit.fail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.testng.AssertJUnit
的用法示例。
在下文中一共展示了AssertJUnit.fail方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testClassificationStreamProcessorExtension2
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void testClassificationStreamProcessorExtension2() throws InterruptedException {
logger.info("HoeffdingClassifierStreamProcessorExtension TestCase - Features are not of numeric type");
SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 " +
"double, attribute_3 bool );";
String query = ("@info(name = 'query1') from StreamA#streamingml:hoeffdingTreeClassifier('model1', " +
" attribute_0, attribute_1, attribute_2, attribute_3) \n" +
"select attribute_0, attribute_1, attribute_2, attribute_3, prediction, confidenceLevel " +
"insert into outputStream;");
try {
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query);
AssertJUnit.fail();
} catch (Exception e) {
logger.error(e.getCause().getMessage());
AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
AssertJUnit.assertTrue(e.getCause().getMessage().contains("model.features in 5th parameter is not " +
"a numerical type attribute. Found BOOL. Check the input stream definition"));
}
}
開發者ID:wso2-extensions,項目名稱:siddhi-gpl-execution-streamingml,代碼行數:23,代碼來源:HoeffdingClassifierStreamProcessorExtensionTestCase.java
示例2: testClassificationStreamProcessorExtension3
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void testClassificationStreamProcessorExtension3() throws InterruptedException {
logger.info("HoeffdingClassifierStreamProcessorExtension TestCase - model.name is not String");
SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 " +
"double, attribute_3 double );";
String query = ("@info(name = 'query1') from StreamA#streamingml:hoeffdingTreeClassifier(123, " +
"attribute_0, attribute_1, attribute_2, attribute_3) \n" + "" +
"select attribute_0, attribute_1, attribute_2, attribute_3, prediction, confidenceLevel " +
"insert into outputStream;");
try {
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query);
AssertJUnit.fail();
} catch (Exception e) {
logger.error(e.getCause().getMessage());
AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
AssertJUnit.assertTrue(e.getCause().getMessage().contains("Invalid parameter type found for " +
"the model.name argument, required STRING but found INT"));
}
}
開發者ID:wso2-extensions,項目名稱:siddhi-gpl-execution-streamingml,代碼行數:23,代碼來源:HoeffdingClassifierStreamProcessorExtensionTestCase.java
示例3: testClassificationStreamProcessorExtension4
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void testClassificationStreamProcessorExtension4() throws InterruptedException {
logger.info("HoeffdingClassifierStreamProcessorExtension TestCase - invalid model name");
SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 " +
"double, attribute_3 double, attribute_4 string );";
String query = ("@info(name = 'query1') from StreamA#streamingml:hoeffdingTreeClassifier(attribute_4, " +
"attribute_0, attribute_1, attribute_2, attribute_3, attribute_4) \n"
+ "select attribute_0, attribute_1, attribute_2, attribute_3, prediction, confidenceLevel" +
" insert into outputStream;");
try {
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query);
AssertJUnit.fail();
} catch (Exception e) {
logger.error(e.getCause().getMessage());
AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
AssertJUnit.assertTrue(e.getCause().getMessage().contains("Parameter model.name must be a constant "
+ "but found org.wso2.siddhi.core.executor.VariableExpressionExecutor"));
}
}
開發者ID:wso2-extensions,項目名稱:siddhi-gpl-execution-streamingml,代碼行數:23,代碼來源:HoeffdingClassifierStreamProcessorExtensionTestCase.java
示例4: testClassificationStreamProcessorExtension5
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void testClassificationStreamProcessorExtension5() throws InterruptedException {
logger.info("HoeffdingClassifierStreamProcessorExtension TestCase - incorrect initialization");
SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 " +
"double, attribute_3 double, attribute_4 string );";
String query = ("@info(name = 'query1') from StreamA#streamingml:hoeffdingTreeClassifier() \n"
+ "select attribute_0, attribute_1, attribute_2, attribute_3, prediction, confidenceLevel " +
"insert into outputStream;");
try {
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query);
AssertJUnit.fail();
} catch (Exception e) {
logger.error(e.getCause().getMessage());
AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
AssertJUnit.assertTrue(e.getCause().getMessage().contains("Invalid number of parameters " +
"for streamingml:hoeffdingTreeClassifier. This Stream Processor requires at least 3 parameters," +
" namely, model.name and at least 2 feature_attributes, but found 0 parameters"));
}
}
開發者ID:wso2-extensions,項目名稱:siddhi-gpl-execution-streamingml,代碼行數:23,代碼來源:HoeffdingClassifierStreamProcessorExtensionTestCase.java
示例5: testClassificationStreamProcessorExtension6
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void testClassificationStreamProcessorExtension6() throws InterruptedException {
logger.info("HoeffdingClassifierStreamProcessorExtension TestCase - Incompatible model");
SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 " +
"double, attribute_3 double);";
String query = ("@info(name = 'query1') from StreamA#streamingml:hoeffdingTreeClassifier('model1', " +
"attribute_0, attribute_1, attribute_2) \n"
+ "select attribute_0, attribute_1, attribute_2, attribute_3, prediction, confidenceLevel " +
"insert into outputStream;");
try {
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(trainingStream +
inStreamDefinition + trainingQuery + query);
AssertJUnit.fail();
} catch (Exception e) {
logger.error(e.getCause().getMessage());
AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
AssertJUnit.assertTrue(e.getCause().getMessage().contains("Invalid number of feature attributes " +
"for streamingml:hoeffdingTreeClassifier. This Stream Processor is defined with " +
"4 features, but found 3 feature"));
}
}
開發者ID:wso2-extensions,項目名稱:siddhi-gpl-execution-streamingml,代碼行數:25,代碼來源:HoeffdingClassifierStreamProcessorExtensionTestCase.java
示例6: testClassificationStreamProcessorExtension10
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void testClassificationStreamProcessorExtension10() throws InterruptedException {
logger.info("HoeffdingClassifierUpdaterStreamProcessorExtension TestCase - Incompatible model (reverse)");
SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 " +
"double, attribute_3 double);";
String query = ("@info(name = 'query1') from StreamA#streamingml:hoeffdingTreeClassifier('model1', " +
"attribute_0, attribute_1, attribute_2) \n"
+ "select attribute_0, attribute_1, attribute_2, attribute_3, prediction, confidenceLevel " +
"insert into outputStream;");
try {
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(trainingStream +
inStreamDefinition + query + trainingQuery);
AssertJUnit.fail();
} catch (Exception e) {
logger.error(e.getCause().getMessage());
AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
AssertJUnit.assertTrue(e.getCause().getMessage().contains("Invalid number of feature attributes "
+ "for streamingml:hoeffdingTreeClassifier. This Stream Processor is defined with 4 features, "
+ "but found 3 feature attributes"));
}
}
開發者ID:wso2-extensions,項目名稱:siddhi-gpl-execution-streamingml,代碼行數:25,代碼來源:HoeffdingClassifierStreamProcessorExtensionTestCase.java
示例7: testRegressionStreamProcessorExtension2
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void testRegressionStreamProcessorExtension2() throws InterruptedException {
logger.info("RegressionLearningStreamProcessorExtension TestCase - Features are not of numeric type");
SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 "
+ "double, attribute_3 bool );";
String query = ("@info(name = 'query1') from StreamA#streamingml:AMRulesRegressor('ml', "
+ " attribute_0, attribute_1, attribute_2, attribute_3) \n"
+ "select attribute_0, attribute_1, attribute_2, attribute_3, prediction, meanSquaredError "
+ "insert into outputStream;");
try {
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(trainingStream + inStreamDefinition
+ trainingQuery + query);
AssertJUnit.fail();
} catch (Exception e) {
logger.error(e.getCause().getMessage());
AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
AssertJUnit.assertTrue(e.getCause().getMessage().contains("model.features in 5th parameter is not a"
+ " numerical type attribute. Found BOOL. Check the input stream definition."));
}
}
開發者ID:wso2-extensions,項目名稱:siddhi-gpl-execution-streamingml,代碼行數:23,代碼來源:AdaptiveModelRulesRegressorStreamProcessorExtensionTestcase.java
示例8: testRegressionStreamProcessorExtension3
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void testRegressionStreamProcessorExtension3() throws InterruptedException {
logger.info("RegressionLearningStreamProcessorExtension TestCase - model.name is not String");
SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 "
+ "double, attribute_3 double );";
String query = ("@info(name = 'query1') from StreamA#streamingml:AMRulesRegressor(123, "
+ "attribute_0, attribute_1, attribute_2, attribute_3) \n" + ""
+ "select attribute_0, attribute_1, attribute_2, attribute_3, prediction, meanSquaredError "
+ "insert into outputStream;");
try {
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query);
AssertJUnit.fail();
} catch (Exception e) {
logger.error(e.getCause().getMessage());
AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
AssertJUnit.assertTrue(e.getCause().getMessage().contains("Invalid parameter type found for the model.name"
+ " argument, required STRING, but found INT."));
}
}
開發者ID:wso2-extensions,項目名稱:siddhi-gpl-execution-streamingml,代碼行數:22,代碼來源:AdaptiveModelRulesRegressorStreamProcessorExtensionTestcase.java
示例9: testRegressionStreamProcessorExtension4
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void testRegressionStreamProcessorExtension4() throws InterruptedException {
logger.info("RegressionLearningStreamProcessorExtension TestCase - invalid model name");
SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 "
+ "double, attribute_3 double, attribute_4 string );";
String query = ("@info(name = 'query1') from StreamA#streamingml:AMRulesRegressor(attribute_4, "
+ "attribute_0, attribute_1, attribute_2, attribute_3, attribute_4) \n"
+ "select attribute_0, attribute_1, attribute_2, attribute_3, prediction, meanSquaredError"
+ " insert into outputStream;");
try {
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query);
AssertJUnit.fail();
} catch (Exception e) {
logger.error(e.getCause().getMessage());
AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
AssertJUnit.assertTrue(e.getCause().getMessage().contains("Parameter model.name must be a constant "
+ "but found org.wso2.siddhi.core.executor.VariableExpressionExecutor"));
}
}
開發者ID:wso2-extensions,項目名稱:siddhi-gpl-execution-streamingml,代碼行數:22,代碼來源:AdaptiveModelRulesRegressorStreamProcessorExtensionTestcase.java
示例10: testRegressionStreamProcessorExtension5
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void testRegressionStreamProcessorExtension5() throws InterruptedException {
logger.info("RegressionLearningStreamProcessorExtension TestCase - incorrect initialization");
SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 "
+ "double, attribute_3 double, attribute_4 double );";
String query = ("@info(name = 'query1') from StreamA#streamingml:AMRulesRegressor() \n"
+ "select attribute_0, attribute_1, attribute_2, attribute_3, prediction, meanSquaredError "
+ "insert into outputStream;");
try {
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query);
AssertJUnit.fail();
} catch (Exception e) {
logger.error(e.getCause().getMessage());
AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
AssertJUnit.assertTrue(e.getCause().getMessage().contains("streamingML:AMRulesRegressor needs exactly"
+ " model.name and 5 feature atttributes, but found 0."));
}
}
開發者ID:wso2-extensions,項目名稱:siddhi-gpl-execution-streamingml,代碼行數:21,代碼來源:AdaptiveModelRulesRegressorStreamProcessorExtensionTestcase.java
示例11: testRegressionStreamProcessorExtension6
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void testRegressionStreamProcessorExtension6() throws InterruptedException {
logger.info("RegressionLearningStreamProcessorExtension TestCase - Incompatible model");
SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 "
+ "double, attribute_3 double);";
String query = ("@info(name = 'query1') from StreamA#streamingml:AMRulesRegressor('ml', "
+ "attribute_0, attribute_1, attribute_2) \n"
+ "select attribute_0, attribute_1, attribute_2, attribute_3, prediction, meanSquaredError "
+ "insert into outputStream;");
try {
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(trainingStream +
inStreamDefinition + trainingQuery + query);
AssertJUnit.fail();
} catch (Exception e) {
logger.error(e.getCause().getMessage());
AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException);
AssertJUnit.assertTrue(e.getCause().getMessage().contains("Invalid number of parameters for "
+ "streamingml:AMRulesRegressor. This Stream Processor requires 5 parameters, namely, "
+ "model.name and 4 feature_attributes, but found 3 parameters"));
}
}
開發者ID:wso2-extensions,項目名稱:siddhi-gpl-execution-streamingml,代碼行數:24,代碼來源:AdaptiveModelRulesRegressorStreamProcessorExtensionTestcase.java
示例12: testClassificationStreamProcessorExtension15
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void testClassificationStreamProcessorExtension15() throws InterruptedException {
logger.info("HoeffdingClassifierStreamProcessorExtension TestCase - model is visible only within the "
+ "SiddhiApp");
SiddhiManager siddhiManager = new SiddhiManager();
String trainingStream1 = "@App:name('HoeffdingTreeTestApp1') \n"
+ "define stream StreamTrain (attribute_0 double, "
+ "attribute_1 double, attribute_2 double, attribute_3 double, attribute_4 string );";
String trainingQuery1 = ("@info(name = 'query-train') "
+ "from StreamTrain#streamingml:updateHoeffdingTree('ml', 4, "
+ "attribute_0, attribute_1, attribute_2, attribute_3, attribute_4) \n"
+ "insert all events into trainOutputStream;\n");
String trainingStrream2 = "@App:name('HoeffdingTreeTestApp2') define stream StreamTrain (attribute_0 double, "
+ "attribute_1 double, attribute_2 double,attribute_3 string );";
String trainingQuery2 = ("@info(name = 'query-train') "
+ "from StreamTrain#streamingml:updateHoeffdingTree('ml', 3, "
+ "attribute_0, attribute_1 , attribute_2 ,attribute_3) select attribute_0, "
+ "attribute_1, attribute_2, accuracy insert into outputStream;");
try {
SiddhiAppRuntime siddhiAppRuntime1 = siddhiManager
.createSiddhiAppRuntime(trainingStream1 + trainingQuery1);
// should be successful even though both the apps are using the same model name with different feature
// values
SiddhiAppRuntime siddhiAppRuntime2 = siddhiManager
.createSiddhiAppRuntime(trainingStrream2 + trainingQuery2);
} catch (Exception e) {
logger.error(e.getCause().getMessage());
AssertJUnit.fail("Model is visible across Siddhi Apps which is wrong!");
}
}
開發者ID:wso2-extensions,項目名稱:siddhi-gpl-execution-streamingml,代碼行數:33,代碼來源:HoeffdingClassifierUpdaterStreamProcessorExtensionTestCase.java
示例13: testUpdateUpdateRegressionLearningStreamProcessorExtension12
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void testUpdateUpdateRegressionLearningStreamProcessorExtension12() throws InterruptedException {
logger.info("UpdateUpdateRegressionLearningStreamProcessorExtension TestCase - model is visible only "
+ "within the SiddhiApp");
SiddhiManager siddhiManager = new SiddhiManager();
String trainingStream1 = "@App:name('AMRulesRegressorTestApp1') \n"
+ "define stream StreamTrain (attribute_0 double, "
+ "attribute_1 double, attribute_2 double, attribute_3 double, attribute_4 double );";
String trainingQuery1 = ("@info(name = 'query-train') "
+ "from StreamTrain#streamingml:updateAMRulesRegressor('ml', "
+ "attribute_0, attribute_1, attribute_2, attribute_3, attribute_4) \n"
+ "insert all events into trainOutputStream;\n");
String trainingStrream2 = "@App:name('AMRulesRegressorTestApp2') define stream StreamTrain "
+ "(attribute_0 double, attribute_1 double, attribute_2 double,attribute_3 double );";
String trainingQuery2 = ("@info(name = 'query-train') "
+ "from StreamTrain#streamingml:updateAMRulesRegressor('ml', "
+ "attribute_0, attribute_1 , attribute_2 ,attribute_3) "
+ "insert all events into trainOutputStream;\n");
try {
SiddhiAppRuntime siddhiAppRuntime1 = siddhiManager
.createSiddhiAppRuntime(trainingStream1 + trainingQuery1);
// should be successful even though both the apps are using the same model name with different feature
// values
SiddhiAppRuntime siddhiAppRuntime2 = siddhiManager
.createSiddhiAppRuntime(trainingStrream2 + trainingQuery2);
} catch (Exception e) {
logger.error(e.getCause().getMessage());
AssertJUnit.fail("Model is visible across Siddhi Apps which is wrong!");
}
}
開發者ID:wso2-extensions,項目名稱:siddhi-gpl-execution-streamingml,代碼行數:33,代碼來源:AdaptiveModelRulesRegressorUpdaterStreamProcessorExtensionTestcase.java
示例14: jsonSinkMapperTestCase1
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void jsonSinkMapperTestCase1() throws InterruptedException {
log.info("JsonSinkMapperTestCase 1");
InMemoryBroker.Subscriber subscriberWSO2 = new InMemoryBroker.Subscriber() {
@Override
public void onMessage(Object msg) {
String jsonString;
switch (wso2Count.incrementAndGet()) {
case 1:
jsonString = "{\"event\":{\"symbol\":\"WSO2\",\"price\":55.6,\"volume\":100}}";
AssertJUnit.assertEquals(jsonString , msg);
break;
case 2:
jsonString = "{\"event\":{\"symbol\":\"WSO2\",\"price\":57.678,\"volume\":100}}";
AssertJUnit.assertEquals(jsonString, msg);
break;
case 3:
jsonString = "{\"event\":{\"symbol\":\"WSO2\",\"price\":50.0,\"volume\":100}}";
AssertJUnit.assertEquals(jsonString , msg);
break;
case 4:
jsonString = "{\"event\":{\"symbol\":\"WSO2#$%\",\"price\":50.0,\"volume\":100}}";
AssertJUnit.assertEquals(jsonString , msg);
break;
case 5:
jsonString = "[{\"event\":{\"symbol\":\"WSO2\",\"price\":55.6,\"volume\":100}}," +
"{\"event\":{\"symbol\":\"IBM\",\"price\":32.6,\"volume\":160}}]";
AssertJUnit.assertEquals(jsonString , msg);
break;
default:
AssertJUnit.fail();
}
}
@Override
public String getTopic() {
return "WSO2";
}
};
//subscribe to "inMemory" broker per topic
InMemoryBroker.subscribe(subscriberWSO2);
String streams = "" +
"@App:name('TestSiddhiApp')" +
"define stream FooStream (symbol string, price float, volume long); " +
"@sink(type='inMemory', topic='WSO2', @map(type='json')) " +
"define stream BarStream (symbol string, price float, volume long); ";
String query = "" +
"from FooStream " +
"select * " +
"insert into BarStream; ";
SiddhiManager siddhiManager = new SiddhiManager();
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
InputHandler stockStream = siddhiAppRuntime.getInputHandler("FooStream");
siddhiAppRuntime.start();
Event wso2Event = new Event();
Event ibmEvent = new Event();
Object[] wso2Data = {"WSO2", 55.6f, 100L};
Object[] ibmData = {"IBM", 32.6f, 160L};
wso2Event.setData(wso2Data);
ibmEvent.setData(ibmData);
stockStream.send(new Object[]{"WSO2", 55.6f, 100L});
stockStream.send(new Object[]{"WSO2", 57.678f, 100L});
stockStream.send(new Object[]{"WSO2", 50f, 100L});
stockStream.send(new Object[]{"WSO2#$%", 50f, 100L});
stockStream.send(new Event[]{wso2Event, ibmEvent});
SiddhiTestHelper.waitForEvents(waitTime, 5, wso2Count, timeout);
//assert event count
AssertJUnit.assertEquals(5, wso2Count.get());
siddhiAppRuntime.shutdown();
//unsubscribe from "inMemory" broker per topic
InMemoryBroker.unsubscribe(subscriberWSO2);
}
示例15: jsonSinkMapperTestCase2
import org.testng.AssertJUnit; //導入方法依賴的package包/類
@Test
public void jsonSinkMapperTestCase2() throws InterruptedException {
log.info("JsonSinkMapperTestCase 2");
InMemoryBroker.Subscriber subscriberWSO2 = new InMemoryBroker.Subscriber() {
@Override
public void onMessage(Object msg) {
String jsonString;
switch (wso2Count.incrementAndGet()) {
case 1:
jsonString = "{\"event\":{\"symbol\":\"WSO2\",\"price\":55.6,\"volume\":\"undefined\"}}";
AssertJUnit.assertEquals(jsonString, msg);
break;
case 2:
jsonString = "{\"event\":{\"symbol\":\"WSO2\",\"price\":\"undefined\",\"volume\":100}}";
AssertJUnit.assertEquals(jsonString, msg);
break;
case 3:
jsonString = "{\"event\":{\"symbol\":\"undefined\",\"price\":55.6,\"volume\":100}}";
AssertJUnit.assertEquals(jsonString, msg);
break;
default:
AssertJUnit.fail();
}
}
@Override
public String getTopic() {
return "WSO2";
}
};
//subscribe to "inMemory" broker per topic
InMemoryBroker.subscribe(subscriberWSO2);
String streams = "" +
"@App:name('TestSiddhiApp')" +
"define stream FooStream (symbol string, price float, volume long); " +
"@sink(type='inMemory', topic='WSO2', @map(type='json')) " +
"define stream BarStream (symbol string, price float, volume long); ";
String query = "" +
"from FooStream " +
"select * " +
"insert into BarStream; ";
SiddhiManager siddhiManager = new SiddhiManager();
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
InputHandler stockStream = siddhiAppRuntime.getInputHandler("FooStream");
siddhiAppRuntime.start();
stockStream.send(new Object[]{"WSO2", 55.6f, null});
stockStream.send(new Object[]{"WSO2", null, 100L});
stockStream.send(new Object[]{null, 55.6f, 100L});
SiddhiTestHelper.waitForEvents(waitTime, 3, wso2Count, timeout);
//assert event count
AssertJUnit.assertEquals(3, wso2Count.get());
siddhiAppRuntime.shutdown();
//unsubscribe from "inMemory" broker per topic
InMemoryBroker.unsubscribe(subscriberWSO2);
}