protected Fixture newFixture() { fixture = new Fixture(); fixture.listener = fixtureListener; return fixture; }
protected void interpretTables(Parse tables) { try { // Don't create the first fixture again, because creation may do something important. getArgsForTable(tables); // get them again for the new fixture object doTable(tables); } catch (Exception ex) { exception(fixtureName(tables), ex); return; } interpretFollowingTables(tables); }
private void interpretFollowingTables(Parse tables) { // listener.tableFinished(tables); tables = tables.more; while (tables != null) { Parse fixtureName = fixtureName(tables); if (fixtureName != null) { try { Fixture fixture = getLinkedFixtureWithArgs(tables); fixture.doTable(tables); } catch (Throwable e) { exception(fixtureName, e); } } // listener.tableFinished(tables); tables = tables.more; } }
@Override public void doCell(Fixture fixture, Parse cell) throws Exception { String symbolName = cell.text(); if (!Fixture.hasSymbol(symbolName)) fixture.exception(cell, new FitFailureException("No such symbol: " + symbolName)); else { String value = (String) Fixture.getSymbol(symbolName); if (adapter.field != null) { adapter.set(adapter.parse(value)); cell.addToBody(Fixture.gray(" = " + value)); } if (adapter.method != null) { cell.body = value; fixture.check(cell, adapter); } } } }
public void doTables(Parse tables) { summary.put("run date", new Date()); summary.put("run elapsed time", new RunTime()); if (tables != null) { Parse heading = tables.at(0, 0, 0); if (heading != null) { try { Fixture fixture = getLinkedFixtureWithArgs(tables); fixture.listener = listener; fixture.interpretTables(tables); } catch (Throwable e) { // NOSONAR exception(heading, e); interpretFollowingTables(tables); } } } listener.tablesFinished(counts); ClearSymbols(); SemaphoreFixture.ClearSemaphores(); //Semaphores: clear all at end }
private void interpretFollowingTables(Parse tables) { listener.tableFinished(tables); tables = tables.more; while (tables != null) { Parse heading = tables.at(0, 0, 0); if (forcedAbort) ignore(heading); //Semaphores: ignore on failed lock else if (heading != null) { try { Fixture fixture = getLinkedFixtureWithArgs(tables); fixture.doTable(tables); } catch (Throwable e) { // NOSONAR exception(heading, e); } } listener.tableFinished(tables); tables = tables.more; } }
public void doTables(Parse tables) { summary.put("run date", new Date()); summary.put("run elapsed time", new RunTime()); if (tables != null) { Parse fixtureName = fixtureName(tables); if (fixtureName != null) { try { Fixture fixture = getLinkedFixtureWithArgs(tables); fixture.interpretTables(tables); } catch (Exception e) { exception(fixtureName, e); interpretFollowingTables(tables); } } } }
@Override public void doCell(Fixture fixture, Parse cell) { try { //TODO-MdM hmm... somehow this needs to regulated by the fixture. if (fixture instanceof ColumnFixture) ((ColumnFixture) fixture).executeIfNeeded(); Object valueObj = adapter.get(); //...might be validly null String symbolValue = valueObj == null ? "null" : valueObj.toString(); String symbolName = cell.text(); Fixture.setSymbol(symbolName, symbolValue); cell.addToBody(Fixture.gray(" = " + symbolValue)); } catch (Exception e) { fixture.exception(cell, e); } } }
private boolean run(Reader reader, Writer writer) throws IOException, ParseException { listener.beforeTest(testPath); String input = read(reader); Parse tables = new Parse(input); fixture = new Fixture(); fixture.doTables(tables); PrintWriter output = new PrintWriter(writer); tables.print(output); output.flush(); boolean passed = passed(fixture); result = new TestResult(); result.setPath(testPath); result.setPassed(passed); result.setRight(fixture.getCounts().right); result.setWrong(fixture.getCounts().wrong); result.setIgnored(fixture.getCounts().ignores); result.setExceptions(fixture.getCounts().exceptions); listener.afterTest(result); return passed; }
String[] path = symbolName.split("\\."); String[] items = symbolName.split("\\s*,\\s*"); if (items.length > 1 || !Fixture.hasSymbol(path[0])) { String result = null; for (String name : items) { String[] nestedPath = name.split("\\."); if (Fixture.hasSymbol(nestedPath[0])) { String symbolValue = (String) Fixture.getSymbol(nestedPath[0]); if (nestedPath.length > 1) { symbolValue = unmarshallParamValue(nestedPath, symbolValue).toString(); fixture.exception(cell, new FitFailureException("No such symbol: " + symbolName)); Object symbol = Fixture.getSymbol(path[0]); String valueString = ""; Object value = null; if (symbol instanceof String) { valueString = (String) Fixture.getSymbol(path[0]); if (!"null".equals(valueString)) { value = unmarshallParamValue(path, valueString);
private boolean run(Reader reader, Writer writer) throws IOException, ParseException { String input = read(reader); Parse tables = new Parse(input); fixture = new Fixture(); fixture.doTables(tables); PrintWriter output = new PrintWriter(writer); tables.print(output); output.flush(); return passed(fixture); }
protected void exception(Exception e) { tables = new Parse("body", "Unable to parse input. Input ignored.", null, null); fixture.exception(tables, e); }
public void process() { fixture.listener = fixtureListener; try { int size = 1; while ((size = FitProtocol.readSize(socketReader)) != 0) { try { print("processing document of size: " + size + "\n"); String document = FitProtocol.readDocument(socketReader, size); //TODO MDM if the page name was always the first line of the body, it could be printed here. Parse tables = new Parse(document); newFixture().doTables(tables); print("\tresults: " + fixture.counts() + "\n"); counts.tally(fixture.counts); } catch (FitParseException e) { exception(e); } } print("completion signal recieved" + "\n"); } catch (Exception e) { exception(e); } }
public void process() { try { if (input.indexOf("<wiki>") >= 0) { tables = new Parse(input, new String[] { "wiki", "table", "tr", "td" }); fixture.doTables(tables.parts); } else { tables = new Parse(input, new String[] { "table", "tr", "td" }); fixture.doTables(tables); } } catch (Exception e) { exception(e); } tables.print(output); }