@@ -0,0 +1,1520 @@
+package lux;%0A%0Aimport static lux.query.LuxParserTest.makeSpanNearQuery;%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.io.ByteArrayInputStream;%0A%0Aimport lux.BasicQueryTest.SearchExtractor;%0Aimport lux.xpath.AbstractExpression;%0Aimport lux.xquery.XQuery;%0A%0Aimport org.apache.lucene.search.Query;%0Aimport org.apache.lucene.xmlparser.ParserException;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Apublic class OptimizerTest %7B%0A    %0A    private Evaluator eval;%0A    %0A    @Before%0A    public void setup () %7B%0A        eval = new Evaluator();%0A    %7D%0A%0A    @Test%0A    public void testDeepPath () throws Exception %7B%0A        // this is currently failing%0A        Query expected = makeSpanNearQuery(%22lux_path%22, 0, true, %22PLAY%22, %22ACT%22, %22SCENE%22, %22SPEECH%22, %22LINE%22);%0A        assertQuery (expected, %22string(/PLAY/ACT%5B4%5D/SCENE%5B1%5D/SPEECH%5B1%5D/LINE%5B3%5D)%22);%0A    %7D%0A%0A    private void assertQuery(Query expectedOpt, String query) throws ParserException %7B%0A        // TODO Auto-generated method stub%0A        XCompiler compiler = eval.getCompiler();%0A        compiler.compile(query);%0A        XQuery optimizedQuery = compiler.getLastOptimized();%0A        AbstractExpression optimizedExpression = optimizedQuery.getBody();%0A        SearchExtractor extractor = new SearchExtractor();%0A        optimizedExpression.accept(extractor);%0A        String xmlQueryString = extractor.queries.get(0).toString();%0A        Query opt = eval.getXmlQueryParser().parse(new ByteArrayInputStream(xmlQueryString.getBytes())); %0A        assertEquals (expectedOpt, opt);%0A    %7D%0A%7D%0A

test for suboptimal optimization in a case with a long XPath