protected String defaultLocate(String pathOrSql, StatementContext context) throws Exception { if (defaultLocator == null) { return pathOrSql; } else { return defaultLocator.locate(pathOrSql, context); } }
@Test public void testCachesOriginalQueryWhenNotFound() throws Exception { StatementLocator statementLocator = new ClasspathStatementLocator(); StatementContext statementContext = new TestingStatementContext(new HashMap<String, Object>()) { @Override public Class<?> getSqlObjectType() { return TestClasspathStatementLocator.class; } }; String input = "missing query"; String located = statementLocator.locate(input, statementContext); assertEquals(input, located); // first time just caches it located = statementLocator.locate(input, statementContext); assertEquals(input, located); // second time reads from cache }