Search in sources :

Example 6 with Breakpoint

use of org.exist.debugger.model.Breakpoint in project exist by eXist-db.

the class DebuggerTest method testLineBreakpoint.

@Test
public void testLineBreakpoint() throws IOException {
    Debugger debugger = DebuggerImpl.getDebugger();
    try {
        // sending init request
        // jetty.port.jetty
        DebuggingSource source = debugger.init("http://127.0.0.1:" + existWebServer.getPort() + "/exist/xquery/fibo.xql");
        assertNotNull("Debugging source can't be NULL.", source);
        Breakpoint breakpoint = source.newBreakpoint();
        breakpoint.setLineno(24);
        breakpoint.sync();
        source.run();
        List<Location> stack = source.getStackFrames();
        assertEquals(1, stack.size());
        assertEquals(24, stack.get(0).getLineBegin());
        source.stepInto();
        stack = source.getStackFrames();
        assertEquals(3, stack.size());
        assertEquals(8, stack.get(0).getLineBegin());
        source.stop();
    } catch (IOException e) {
        assertNotNull("IO exception: " + e.getMessage(), null);
    } catch (ExceptionTimeout e) {
        assertNotNull("Timeout exception: " + e.getMessage(), null);
    }
}
Also used : Breakpoint(org.exist.debugger.model.Breakpoint) IOException(java.io.IOException) Location(org.exist.debugger.model.Location)

Example 7 with Breakpoint

use of org.exist.debugger.model.Breakpoint in project exist by eXist-db.

the class DebuggerTest method testEvaluation.

@Test
public void testEvaluation() throws IOException {
    Debugger debugger = DebuggerImpl.getDebugger();
    try {
        // sending init request
        // jetty.port.jetty
        DebuggingSource source = debugger.init("http://127.0.0.1:" + existWebServer.getPort() + "/exist/xquery/fibo.xql");
        assertNotNull("Debugging source can't be NULL.", source);
        Breakpoint breakpoint = source.newBreakpoint();
        breakpoint.setLineno(24);
        breakpoint.sync();
        String res = source.evaluate("$dbgp:session");
        assertNull(res);
        res = source.evaluate("let $seq := (98.5, 98.3, 98.9) return count($seq)");
        assertEquals("3", res);
        // xquery engine have problem here, because context not copied correctly
        // res = source.evaluate("f:fibo(2)");
        // System.out.println(res);
        source.run();
        List<Location> stack = source.getStackFrames();
        assertEquals(1, stack.size());
        assertEquals(24, stack.get(0).getLineBegin());
        breakpoint.remove();
        source.stop();
    } catch (IOException e) {
        assertNotNull("IO exception: " + e.getMessage(), null);
    } catch (ExceptionTimeout e) {
        assertNotNull("Timeout exception: " + e.getMessage(), null);
    }
}
Also used : Breakpoint(org.exist.debugger.model.Breakpoint) IOException(java.io.IOException) Location(org.exist.debugger.model.Location)

Aggregations

Breakpoint (org.exist.debugger.model.Breakpoint)7 IOException (java.io.IOException)4 Location (org.exist.debugger.model.Location)4 Init (org.exist.debuggee.dbgp.packets.Init)1 TerminatedException (org.exist.xquery.TerminatedException)1