use of org.wso2.carbon.humantask.core.engine.commands.Fail in project siddhi by wso2.
the class InMemoryTransportTestCase method inMemoryTestCase8.
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void inMemoryTestCase8() throws InterruptedException {
log.info("Test inMemory 8");
String streams = "" + "@app:name('TestSiddhiApp')" + "@source(type='testEventInMemory', topic='Foo', prop1='hi', prop2='test', fail='true', " + " @map(type='testString', @attributes(symbol='trp:symbol'," + " volume='volume',price='trp:price'))) " + "define stream FooStream (symbol string, price string, volume long); " + "define stream BarStream (symbol string, price string, volume long); ";
String query = "" + "from FooStream " + "select * " + "insert into BarStream; ";
SiddhiManager siddhiManager = new SiddhiManager();
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);
}
use of org.wso2.carbon.humantask.core.engine.commands.Fail in project siddhi by wso2.
the class IndexOperator method update.
private void update(IndexedEventHolder storeEvents, InMemoryCompiledUpdateSet compiledUpdateSet, StateEvent overwritingOrAddingEvent, ComplexEventChunk<StreamEvent> foundEventChunk) {
// for cases when indexed attribute is also updated but that not changed
// to reduce number of passes needed to update the events
boolean doDeleteUpdate = false;
boolean fail = false;
for (Map.Entry<Integer, ExpressionExecutor> entry : compiledUpdateSet.getExpressionExecutorMap().entrySet()) {
if (doDeleteUpdate || fail) {
break;
}
if (storeEvents.isAttributeIndexed(entry.getKey())) {
// Todo how much check we need to do before falling back to Delete and then Update
foundEventChunk.reset();
Set<Object> keys = null;
PrimaryKeyReferenceHolder[] primaryKeyReferenceHolders = storeEvents.getPrimaryKeyReferenceHolders();
if (primaryKeyReferenceHolders != null && primaryKeyReferenceHolders.length == 1 && entry.getKey() == primaryKeyReferenceHolders[0].getPrimaryKeyPosition()) {
keys = new HashSet<>(storeEvents.getAllPrimaryKeyValues());
}
while (foundEventChunk.hasNext()) {
StreamEvent streamEvent = foundEventChunk.next();
Object updatingData = entry.getValue().execute(overwritingOrAddingEvent);
Object storeEventData = streamEvent.getOutputData()[entry.getKey()];
if (updatingData != null && storeEventData != null && !updatingData.equals(storeEventData)) {
doDeleteUpdate = true;
if (keys == null || keys.size() == 0) {
break;
} else {
keys.remove(storeEventData);
if (!keys.add(updatingData)) {
log.error("Update failed for event :" + overwritingOrAddingEvent + ", as there is " + "already an event stored with primary key '" + updatingData + "' at '" + queryName + "'");
fail = true;
break;
}
}
}
}
}
}
foundEventChunk.reset();
if (!fail) {
if (doDeleteUpdate) {
collectionExecutor.delete(overwritingOrAddingEvent, storeEvents);
ComplexEventChunk<StreamEvent> toUpdateEventChunk = new ComplexEventChunk<StreamEvent>(false);
while (foundEventChunk.hasNext()) {
StreamEvent streamEvent = foundEventChunk.next();
foundEventChunk.remove();
// to make the chained state back to normal
streamEvent.setNext(null);
for (Map.Entry<Integer, ExpressionExecutor> entry : compiledUpdateSet.getExpressionExecutorMap().entrySet()) {
streamEvent.setOutputData(entry.getValue().execute(overwritingOrAddingEvent), entry.getKey());
}
toUpdateEventChunk.add(streamEvent);
}
storeEvents.add(toUpdateEventChunk);
} else {
while (foundEventChunk.hasNext()) {
StreamEvent streamEvent = foundEventChunk.next();
// to make the chained state back to normal
streamEvent.setNext(null);
for (Map.Entry<Integer, ExpressionExecutor> entry : compiledUpdateSet.getExpressionExecutorMap().entrySet()) {
streamEvent.setOutputData(entry.getValue().execute(overwritingOrAddingEvent), entry.getKey());
}
}
}
}
}
use of org.wso2.carbon.humantask.core.engine.commands.Fail in project wso2-synapse by wso2.
the class SynapseEventSourceTest method renewTest.
public void renewTest() {
Date date = new Date(System.currentTimeMillis() + 3600000 * 2);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
String message = "<wse:Renew xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\">\n" + " <wse:Expires>" + ConverterUtil.convertToString(cal) + "</wse:Expires>\n" + "</wse:Renew>";
try {
MessageContext msgCtx = createMessageContext(message, EventingConstants.WSE_RENEW);
QName qname = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_IDENTIFIER, "wse");
TestUtils.addSOAPHeaderBlock(msgCtx, qname, id);
source.receive(msgCtx);
} catch (Exception ignored) {
}
try {
assertEquals(1, subMan.getSubscriptions().size());
SynapseSubscription s = (SynapseSubscription) subMan.getSubscription(this.id);
assertEquals(SUB_MAN_URL, s.getSubManUrl());
assertEquals(ADDR_URL, s.getAddressUrl());
assertEquals(FILTER_DIALECT, s.getFilterDialect());
assertEquals(FILTER, s.getFilterValue());
assertEquals(date, s.getExpires().getTime());
} catch (EventException e) {
fail("Eventing exception occured while accessing the subscription manager");
}
}
use of org.wso2.carbon.humantask.core.engine.commands.Fail in project wso2-synapse by wso2.
the class SynapseEventSourceTest method createMessageContext.
private MessageContext createMessageContext(String payload, String action) {
try {
SynapseConfiguration synapseConfig = new SynapseConfiguration();
AxisConfiguration axisConfig = new AxisConfiguration();
synapseConfig.setAxisConfiguration(axisConfig);
ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig);
SynapseEnvironment env = new Axis2SynapseEnvironment(cfgCtx, synapseConfig);
axisConfig.addParameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfig);
axisConfig.addParameter(SynapseConstants.SYNAPSE_ENV, env);
MessageContext msgCtx = TestUtils.getAxis2MessageContext(payload, null).getAxis2MessageContext();
msgCtx.setConfigurationContext(cfgCtx);
msgCtx.setTo(new EndpointReference(SUB_MAN_URL));
msgCtx.setWSAAction(action);
return msgCtx;
} catch (Exception e) {
fail();
}
return null;
}
use of org.wso2.carbon.humantask.core.engine.commands.Fail in project wso2-synapse by wso2.
the class SynapseEventSourceTest method unsubscribeTest.
public void unsubscribeTest() {
String message = "<wse:Unsubscribe xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\"/>";
try {
MessageContext msgCtx = createMessageContext(message, EventingConstants.WSE_UNSUBSCRIBE);
QName qname = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_IDENTIFIER, "wse");
TestUtils.addSOAPHeaderBlock(msgCtx, qname, id);
source.receive(msgCtx);
} catch (Exception ignored) {
}
try {
assertEquals(0, subMan.getSubscriptions().size());
} catch (EventException e) {
fail("Eventing exception occured while accessing the subscription manager");
}
}
Aggregations