/* *************************************************************************************** * Copyright (C) 2006 EsperTech, Inc. All rights reserved. * * http://www.espertech.com/esper * * http://www.espertech.com * * ---------------------------------------------------------------------------------- * * The software in this package is published under the terms of the GPL license * * a copy of which has been included with this distribution in the license.txt file. * *************************************************************************************** */ package com.espertech.esper.regression.nwtable; import com.espertech.esper.client.Configuration; import com.espertech.esper.client.EPServiceProviderManager; import com.espertech.esper.client.EPStatement; import com.espertech.esper.client.scopetest.EPAssertionUtil; import com.espertech.esper.core.service.EPServiceProviderSPI; import com.espertech.esper.metrics.instrumentation.InstrumentationHelper; import com.espertech.esper.supportregression.bean.SupportBean; import com.espertech.esper.supportregression.client.SupportConfigFactory; import junit.framework.TestCase; public class TestNamedWindowIndex extends TestCase { private EPServiceProviderSPI epService; public void setUp() { Configuration config = SupportConfigFactory.getConfiguration(); epService = (EPServiceProviderSPI) EPServiceProviderManager.getDefaultProvider(config); epService.initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.startTest(epService, this.getClass(), getName());} } protected void tearDown() throws Exception { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.endTest();} } public void testUniqueIndexUniqueView() { epService.getEPAdministrator().getConfiguration().addEventType("SupportBean", SupportBean.class); EPStatement stmtWindow = epService.getEPAdministrator().createEPL("create window MyWindowOne#unique(theString) as SupportBean"); epService.getEPAdministrator().createEPL("insert into MyWindowOne select * from SupportBean"); epService.getEPAdministrator().createEPL("create unique index I1 on MyWindowOne(theString)"); epService.getEPRuntime().sendEvent(new SupportBean("E0", 1)); epService.getEPRuntime().sendEvent(new SupportBean("E2", 2)); epService.getEPRuntime().sendEvent(new SupportBean("E2", 3)); epService.getEPRuntime().sendEvent(new SupportBean("E1", 4)); epService.getEPRuntime().sendEvent(new SupportBean("E0", 5)); EPAssertionUtil.assertPropsPerRowAnyOrder(stmtWindow.iterator(), "theString,intPrimitive".split(","), new Object[][]{{"E0", 5}, {"E1", 4}, {"E2", 3}}); } }