private void runAssertionInvalid(RegressionEnvironment env, String typename, Object incorrectUnderlying, String message) { EventSender sender = env.eventService().getEventSender(typename); try { sender.sendEvent(incorrectUnderlying); fail(); } catch (EPException ex) { SupportMessageAssertUtil.assertMessage(ex, message); } } }
public void run(RegressionEnvironment env) { String stmtText = "@name('s0') select type?,dyn[1]?,nested.nes2?,map('a')? from MyEventWithXPath"; env.compileDeploy(stmtText).addListener("s0"); EPAssertionUtil.assertEqualsAnyOrder(new Object[]{ new EventPropertyDescriptor("type?", Node.class, null, false, false, false, false, false), new EventPropertyDescriptor("dyn[1]?", Node.class, null, false, false, false, false, false), new EventPropertyDescriptor("nested.nes2?", Node.class, null, false, false, false, false, false), new EventPropertyDescriptor("map('a')?", Node.class, null, false, false, false, false, false), }, env.statement("s0").getEventType().getPropertyDescriptors()); SupportEventTypeAssertionUtil.assertConsistency(env.statement("s0").getEventType()); EventSender sender = env.eventService().getEventSender("MyEventWithXPath"); Document root = SupportXML.sendEvent(sender, SCHEMA_XML); EventBean theEvent = env.listener("s0").assertOneGetNewAndReset(); assertSame(root.getDocumentElement().getChildNodes().item(0), theEvent.get("type?")); assertSame(root.getDocumentElement().getChildNodes().item(4), theEvent.get("dyn[1]?")); assertSame(root.getDocumentElement().getChildNodes().item(6).getChildNodes().item(1), theEvent.get("nested.nes2?")); assertSame(root.getDocumentElement().getChildNodes().item(8), theEvent.get("map('a')?")); SupportEventTypeAssertionUtil.assertConsistency(theEvent); env.undeployAll(); } }
public void run(RegressionEnvironment env) { String stmtText = "@name('s0') select type?,dyn[1]?,nested.nes2?,map('a')? from MyEventWithPrefix"; env.compileDeploy(stmtText).addListener("s0"); EPAssertionUtil.assertEqualsAnyOrder(new Object[]{ new EventPropertyDescriptor("type?", Node.class, null, false, false, false, false, false), new EventPropertyDescriptor("dyn[1]?", Node.class, null, false, false, false, false, false), new EventPropertyDescriptor("nested.nes2?", Node.class, null, false, false, false, false, false), new EventPropertyDescriptor("map('a')?", Node.class, null, false, false, false, false, false), }, env.statement("s0").getEventType().getPropertyDescriptors()); SupportEventTypeAssertionUtil.assertConsistency(env.statement("s0").getEventType()); EventSender sender = env.eventService().getEventSender("MyEventWithPrefix"); Document root = SupportXML.sendEvent(sender, SCHEMA_XML); EventBean theEvent = env.listener("s0").assertOneGetNewAndReset(); assertSame(root.getDocumentElement().getChildNodes().item(0), theEvent.get("type?")); assertSame(root.getDocumentElement().getChildNodes().item(4), theEvent.get("dyn[1]?")); assertSame(root.getDocumentElement().getChildNodes().item(6).getChildNodes().item(1), theEvent.get("nested.nes2?")); assertSame(root.getDocumentElement().getChildNodes().item(8), theEvent.get("map('a')?")); SupportEventTypeAssertionUtil.assertConsistency(theEvent); env.undeployAll(); } }
EventSender sender = env.eventService().getEventSender("SensorEvent"); sender.sendEvent(doc);
private void runAssertionSuccess(RegressionEnvironment env, String typename, Object... correctUnderlyings) { String stmtText = "@name('s0') select * from " + typename; env.compileDeploy(stmtText).addListener("s0"); EventSender sender = env.eventService().getEventSender(typename); for (Object underlying : correctUnderlyings) { sender.sendEvent(underlying); assertSame(underlying, env.listener("s0").assertOneGetNewAndReset().getUnderlying()); } env.undeployAll(); }
env.compileDeploy("@name('s2') select SupportStaticMethodLib.sleep(100) from XMLType").statement("s2").addListener(listenerThree); EventSender senderOne = env.eventService().getEventSender("MyMap"); EventSender senderTwo = env.eventService().getEventSender("SupportBean"); EventSender senderThree = env.eventService().getEventSender("XMLType");
public void run(RegressionEnvironment env) { String epl = "create schema TypeOne(col1 int);\n"; epl += "create schema TypeTwo(col2 int);\n"; epl += "create schema TypeTrigger(trigger int);\n"; epl += "create window WinOne#keepall as TypeOne;\n"; epl += "create window WinTwo#keepall as TypeTwo;\n"; epl += "@name('insert-window-one') insert into WinOne(col1) select intPrimitive from SupportBean;\n"; epl += "@name('insert-otherstream') on TypeTrigger insert into OtherStream select col1 from WinOne;\n"; epl += "@name('insert-window-two') on TypeTrigger insert into WinTwo(col2) select col1 from WinOne;\n"; epl += "@name('s0') on OtherStream select col2 from WinTwo;\n"; env.compileDeployWBusPublicType(epl, new RegressionPath()).addListener("s0"); // populate WinOne env.sendEventBean(new SupportBean("E1", 9)); // fire trigger if (EventRepresentationChoice.getEngineDefault(env.getConfiguration()).isObjectArrayEvent()) { env.eventService().getEventSender("TypeTrigger").sendEvent(new Object[0]); } else { env.eventService().getEventSender("TypeTrigger").sendEvent(new HashMap()); } assertEquals(9, env.listener("s0").assertOneGetNewAndReset().get("col2")); env.undeployAll(); } }
env.eventService().getEventSender("ABC"); fail(); } catch (EventTypeException ex) { env.eventService().getEventSender("ABC"); fail("Event type named 'ABC' could not be found"); } catch (EventTypeException ex) {
EventSender sender = env.eventService().getEventSender("EventABC"); sender.sendEvent(doc); EventSender senderTwo = env.eventService().getEventSender("BEvent"); senderTwo.sendEvent(getDocument("<xxxx><b><c>text</c></b></xxxx>")); // allowed, not checking
private static void runAssertionStatementNameExists(RegressionEnvironment env, String typeName, Object[] events) { env.compileDeploy("@Name('MyStatement') select * from " + typeName); env.compileDeploy("@name('flow') create dataflow MyDataFlowOne " + "create schema AllObject java.lang.Object," + "EPStatementSource -> thedata<AllObject> {" + " statementDeploymentId : '" + env.deploymentId("MyStatement") + "'," + " statementName : 'MyStatement'," + "} " + "DefaultSupportCaptureOp(thedata) {}"); DefaultSupportCaptureOp<Object> captureOp = new DefaultSupportCaptureOp<Object>(2); EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions() .operatorProvider(new DefaultSupportGraphOpProvider(captureOp)); EPDataFlowInstance df = env.runtime().getDataFlowService().instantiate(env.deploymentId("flow"), "MyDataFlowOne", options); df.start(); EventSender sender = env.eventService().getEventSender(typeName); for (Object event : events) { sender.sendEvent(event); } try { captureOp.get(1, TimeUnit.SECONDS); } catch (Throwable t) { throw new RuntimeException(t); } EPAssertionUtil.assertEqualsExactOrder(events, captureOp.getCurrent()); df.cancel(); env.undeployAll(); }
SupportEventTypeAssertionUtil.assertConsistency(env.statement("s0").getEventType()); EventSender sender = env.eventService().getEventSender("TestNested2"); sender.sendEvent(SupportXML.getDocument("<nested2><prop3>2</prop3><prop3></prop3><prop3>4</prop3></nested2>")); EventBean theEvent = env.iterator("s0").next();