package com.espertech.esper.regression.epl; import junit.framework.TestCase; import com.espertech.esper.client.Configuration; import com.espertech.esper.client.EPServiceProvider; import com.espertech.esper.client.EPServiceProviderManager; import com.espertech.esper.client.EPStatement; import com.espertech.esper.support.bean.SupportBean; import com.espertech.esper.support.bean.SupportBean_A; import com.espertech.esper.support.bean.SupportBean_B; import com.espertech.esper.support.bean.SupportBean_S0; import com.espertech.esper.support.client.SupportConfigFactory; import com.espertech.esper.support.util.ArrayAssertionUtil; import com.espertech.esper.support.util.SupportUpdateListener; import com.espertech.esper.core.EPServiceProviderSPI; import com.espertech.esper.core.StatementType; import com.espertech.esper.core.EPStatementSPI; import com.espertech.esper.epl.named.NamedWindowProcessor; import java.util.LinkedList; import java.util.List; public class TestNamedWindowSelect extends TestCase { private EPServiceProvider epService; private SupportUpdateListener listenerSelect; public void setUp() { Configuration config = SupportConfigFactory.getConfiguration(); epService = EPServiceProviderManager.getDefaultProvider(config); epService.initialize(); listenerSelect = new SupportUpdateListener(); } public void testStaggeredNamedWindow() throws Exception { epService.getEPAdministrator().getConfiguration().addEventType("Metric", SupportBean.class); epService.getEPAdministrator().getConfiguration().addEventType("Latency", SupportBean_S0.class); String epl = "CREATE WINDOW everestDataWindow.win:time_batch(60 sec) as select * from Metric"; epService.getEPAdministrator().createEPL(epl); epService.getEPAdministrator().createEPL("INSERT INTO everestDataWindow SELECT * FROM Metric"); epl = "on Latency as latency SELECT * FROM everestDataWindow as win WHERE latency.id = win.intPrimitive"; epService.getEPAdministrator().createEPL(epl); Thread sendMetricThread = new Thread() { public void start() { while(true) { try { Thread.sleep(50); } catch (InterruptedException e) { } int randomNum = (int) Math.random() * 100; epService.getEPRuntime().sendEvent(new SupportBean("E1", randomNum)); } } }; sendMetricThread.start(); Thread sendLatencyThread = new Thread() { public void start() { while(true) { try { Thread.sleep(100); } catch (InterruptedException e) { } epService.getEPRuntime().sendEvent(new SupportBean_S0(10)); } } }; sendLatencyThread.start(); Thread.sleep(10 * 60 * 60 * 1000); } }