/* *************************************************************************************** * 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.db; import com.espertech.esper.client.*; import com.espertech.esper.client.scopetest.SupportUpdateListener; import com.espertech.esper.metrics.instrumentation.InstrumentationHelper; import com.espertech.esper.supportregression.bean.*; import com.espertech.esper.supportregression.client.SupportConfigFactory; import com.espertech.esper.supportregression.epl.SupportDatabaseService; import junit.framework.TestCase; import java.util.Properties; public class TestDatabaseOuterJoinWCache extends TestCase { private EPServiceProvider epService; private SupportUpdateListener listener; public void setUp() { ConfigurationDBRef configDB = new ConfigurationDBRef(); configDB.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, new Properties()); configDB.setConnectionCatalog("test"); configDB.setExpiryTimeCache(60, 120); Configuration configuration = SupportConfigFactory.getConfiguration(); configuration.getEngineDefaults().getLogging().setEnableQueryPlan(true); configuration.addDatabaseReference("MyDB", configDB); epService = EPServiceProviderManager.getDefaultProvider(configuration); epService.initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.startTest(epService, this.getClass(), getName());} } protected void tearDown() throws Exception { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.endTest();} listener = null; epService.destroy(); } public void testOuterJoinWithCache() { epService.getEPAdministrator().getConfiguration().addEventType("SupportBean", SupportBean.class); String stmtText = "select * from SupportBean as sb " + "left outer join " + "sql:MyDB ['select myint from mytesttable'] as t " + "on sb.intPrimitive = t.myint " + "where myint is null"; EPStatement statement = epService.getEPAdministrator().createEPL(stmtText); listener = new SupportUpdateListener(); statement.addListener(listener); epService.getEPRuntime().sendEvent(new SupportBean("E1", -1)); assertTrue(listener.getAndClearIsInvoked()); epService.getEPRuntime().sendEvent(new SupportBean("E2", 10)); assertFalse(listener.getAndClearIsInvoked()); epService.getEPRuntime().sendEvent(new SupportBean("E1", 1)); assertTrue(listener.getAndClearIsInvoked()); } }