[ictk-cvs] ictk/test/ictk/boardgame/chess/net/ics/fics/event parserTests.xml,NONE,1.1 templateParser
chess library in java, PGN, FEN, ICS
Brought to you by:
jvarsoke
Update of /cvsroot/ictk/ictk/test/ictk/boardgame/chess/net/ics/fics/event In directory sc8-pr-cvs1:/tmp/cvs-serv24797/test/ictk/boardgame/chess/net/ics/fics/event Modified Files: AllTests.java Added Files: parserTests.xml templateParser.xsl unitTest.dtd Removed Files: FICSBoardUpdateStyle12ParserTest.java FICSChannelParserTest.java FICSGameCreatedParserTest.java FICSGameNotificationParserTest.java FICSKibitzParserTest.java FICSMoveListParserTest.java FICSPlayerConnectionParserTest.java FICSPlayerNotificationParserTest.java FICSSeekAdParserTest.java FICSSeekAdReadableParserTest.java FICSSeekClearParserTest.java FICSSeekRemoveParserTest.java FICSShoutParserTest.java FICSTellParserTest.java makeTest.pl testTemplate.txt Log Message: replaced all fics/event/Tests with xslt generated test files. --- NEW FILE: parserTests.xml --- <?xml version="1.0" encoding="utf-8" standalone="no"?> <!-- * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net * Copyright (C) 2002 J. Varsoke <jva...@gh...> * All rights reserved. * * $Id: parserTests.xml,v 1.1 2003/08/26 20:16:01 jvarsoke Exp $ * * This file is part of ICTK. * * ICTK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ICTK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ICTK; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <!DOCTYPE ictkml SYSTEM "unitTest.dtd" [ ]> <unitTest> <!-- kibitz ............................................................--> <unit id="kibitz" class="Kibitz" event="Kibitz" > <test name="Message0" iochunk="0" > <code format="java"> assertTrue(evt.getPlayer().equals("Handle")); assertFalse(evt.getAccountType().is(ICSAccountType.UNREGISTERED)); assertTrue(evt.getRating().get() == 1902); assertTrue(evt.getBoardNumber() == 7); assertTrue(evt.getMessage().equals("hey")); </code> </test> </unit> <!-- channel ...........................................................--> <unit id="channel" class="Channel" event="Channel" > <test name="Message0" iochunk="0" > <code format="java"> assertTrue("Gorgonian".equals(evt.getPlayer())); assertTrue(evt.getChannel() == 50); assertTrue("da".equals(evt.getMessage())); </code> </test> <test name="Message1" iochunk="1" > <code format="java"> assertTrue(evt.getAccountType().is(ICSAccountType.CHESS_ADVISOR)); </code> </test> <test name="Message3" iochunk="3" > <code format="java"> assertTrue(evt.getAccountType().is(ICSAccountType.ADMIN)); assertTrue(evt.getAccountType().is(ICSAccountType.SERVICE_REP)); assertTrue(evt.getAccountType().is(ICSAccountType.CHESS_ADVISOR)); assertTrue(evt.getAccountType().is(ICSAccountType.TOURNAMENT_MANAGER)); assertTrue(evt.getChannel() == 49); </code> </test> </unit> <!-- shout .............................................................--> <unit id="shout" class="Shout" event="Channel" > </unit> <!-- tell ..............................................................--> <unit id="tell" class="Tell" event="Tell" > <test name="Message0" iochunk="0" > <code format="java"> assertTrue(evt.getPlayer().equals("Handle")); assertTrue(evt.getMessage().equals("Hey")); assertFalse(evt.isFake()); assertTrue(evt.getEventType() == ICSEvent.TELL_EVENT); assertFalse(evt.getMessage().equals("hey")); </code> </test> <test name="Message1" iochunk="1" > <code format="java"> assertTrue(evt.getPlayer().equals("Handle")); assertTrue(evt.getAccountType().is(ICSAccountType.COMPUTER)); assertTrue(evt.getMessage().equals("Hey")); assertFalse(evt.isFake()); assertTrue(evt.getEventType() == ICSEvent.TELL_EVENT); assertFalse(evt.getMessage().equals("hey")); </code> </test> </unit> <!-- player connection..................................................--> <unit id="pin" class="PlayerConnection" event="PlayerConnection" > </unit> <!-- player notification................................................--> <unit id="pnot" class="PlayerNotification" event="PlayerConnection" > </unit> <!-- game created ......................................................--> <unit id="gin" class="GameCreated" event="GameCreated" > </unit> <!-- game notification..................................................--> <unit id="gnot" class="GameNotification" event="GameNotification" > </unit> <!-- game result .......................................................--> <unit id="game_result" class="GameResult" event="GameResult" > </unit> <!-- seek ad ...........................................................--> <unit id="seekad" class="SeekAd" event="SeekAd" > </unit> <!-- seek ad readable ..................................................--> <unit id="seekadreadable" class="SeekAdReadable" event="SeekAd" > </unit> <!-- seek clear ........................................................--> <unit id="seek_clear" class="SeekClear" event="SeekClear" > </unit> <!-- seek remove .......................................................--> <unit id="seek_remove" class="SeekRemove" event="SeekRemove" > </unit> <!-- board update style 12 .............................................--> <unit id="style12" class="BoardUpdateStyle12" event="BoardUpdate" > </unit> <!-- move list .........................................................--> <unit id="movelist" class="MoveList" event="MoveList" > </unit> <!-- <unit id="tell" class="Tell" event="Tell" > <test name="Message0" iochunk="0" > <code format="java"> </code> </test> </unit> --> </unitTest> --- NEW FILE: templateParser.xsl --- <?xml version="1.0"?> <!-- * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net * Copyright (C) 2002 J. Varsoke <jva...@gh...> * All rights reserved. * * $Id: templateParser.xsl,v 1.1 2003/08/26 20:16:01 jvarsoke Exp $ * * This file is part of ICTK. * * ICTK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ICTK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ICTK; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:redirect="http://xml.apache.org/xalan/redirect" xmlns:java="java" extension-element-prefixes="redirect" > <xsl:output method="text" omit-xml-declaration="yes"/> <xsl:template match="unitTest"> <xsl:apply-templates select="unit"/> </xsl:template> <!-- main event --> <xsl:template match="unit"> <xsl:variable name="parserclassname" select="concat('FICS', @class, 'Parser')" /> <xsl:variable name="classname" select="concat($parserclassname, 'Test')" /> <xsl:variable name="filename" select="concat($classname, '.java')" /> <!-- show the filename so we can capture in a log and delete later --> <xsl:value-of select="$filename"/><xsl:text> </xsl:text> <redirect:write select="$filename">/* /* * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net * Copyright (C) 2003 J. Varsoke <jva...@gh...> * All rights reserved. * * This file is part of ICTK. * * ICTK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ICTK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ICTK; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package ictk.boardgame.chess.net.ics.fics.event; import ictk.boardgame.chess.net.ics.event.*; import ictk.boardgame.chess.net.ics.*; import ictk.util.Log; import java.util.regex.*; import java.io.IOException; import junit.framework.*; public class <xsl:value-of select="$classname"/> extends ParserTest { ICS<xsl:value-of select="@event"/>Event evt; public <xsl:value-of select="$classname"/> () throws IOException { super("ictk.boardgame.chess.net.ics.fics.event"); } public void setUp () { parser = <xsl:value-of select="$parserclassname"/>.getInstance(); //debug = true; } public void tearDown () { evt = null; parser = null; } <xsl:apply-templates select="test"/> //inherited/////////////////////////////////////////////////////////// public void testParseAll () { //debug=true; if (debug) { Log.addMask(ICSEventParser.DEBUG); parser.setDebug(true); } try { super.testParseAll(); } finally { Log.removeMask(ICSEventParser.DEBUG); debug = false; } } ////////////////////////////////////////////////////////////////////// public void testNative () { //debug=true; if (debug) { Log.addMask(ICSEventParser.DEBUG); parser.setDebug(true); } try { super.testNative(); } finally { Log.removeMask(ICSEventParser.DEBUG); debug = false; } } } </redirect:write> </xsl:template> <xsl:template match="test"> ////////////////////////////////////////////////////////////////////// public void test<xsl:value-of select="@name"/> () { //debug = true; if (debug) { Log.addMask(ICSEventParser.DEBUG); parser.setDebug(true); } try { evt = (ICS<xsl:value-of select="../@event"/>Event) <!-- -->parser.createICSEvent(mesg[<xsl:value-of select="@iochunk"/>]); assertTrue(evt != null); //begin test <xsl:apply-templates select="code" mode="test"/> //end test } finally { Log.removeMask(ICSEventParser.DEBUG); debug = false; } } </xsl:template> <xsl:template match="code" mode="test"> <xsl:if test="@format='java'"> <xsl:value-of select="."/> </xsl:if> </xsl:template> </xsl:stylesheet> --- NEW FILE: unitTest.dtd --- <?xml version="1.0" encoding="utf-8"?> <!-- * ICTK - Internet Chess ToolKit * More information is available at http://ictk.sourceforge.net * Copyright (C) 2002 J. Varsoke <jva...@gh...> * All rights reserved. * * $Id: unitTest.dtd,v 1.1 2003/08/26 20:16:01 jvarsoke Exp $ * * This file is part of ICTK. * * ICTK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ICTK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ICTK; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> <!ELEMENT unitTest (unit*)> <!ATTLIST unitTest xmlns:unittest CDATA "http://ictk.sourceforge.net/test/unittest" > <!ELEMENT unit (description?, test*)> <!ATTLIST unit id ID #REQUIRED class NMTOKEN #REQUIRED event NMTOKEN #IMPLIED type NMTOKEN #IMPLIED > <!ELEMENT description (#PCDATA)*> <!ATTLIST description xml:space (default | preserve) 'preserve' > <!ELEMENT test (description?, code?)> <!ATTLIST test name NMTOKEN #REQUIRED iochunk NMTOKEN #IMPLIED > <!ELEMENT code (#PCDATA)> <!ATTLIST code format NOTATION (java) #REQUIRED xml:space (default | preserve) 'preserve' > <!NOTATION java SYSTEM "http://java.sun.com"> <!-- ? --> Index: AllTests.java =================================================================== RCS file: /cvsroot/ictk/ictk/test/ictk/boardgame/chess/net/ics/fics/event/AllTests.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AllTests.java 24 Aug 2003 01:48:44 -0000 1.3 --- AllTests.java 26 Aug 2003 20:16:01 -0000 1.4 *************** *** 45,53 **** suite.addTest(new TestSuite(FICSPlayerNotificationParserTest.class)); suite.addTest(new TestSuite(FICSSeekAdParserTest.class)); - /* suite.addTest(new TestSuite(FICSSeekAdReadableParserTest.class)); suite.addTest(new TestSuite(FICSSeekClearParserTest.class)); suite.addTest(new TestSuite(FICSSeekRemoveParserTest.class)); - */ suite.addTest(new TestSuite(FICSShoutParserTest.class)); suite.addTest(new TestSuite(FICSTellParserTest.class)); --- 45,51 ---- --- FICSBoardUpdateStyle12ParserTest.java DELETED --- --- FICSChannelParserTest.java DELETED --- --- FICSGameCreatedParserTest.java DELETED --- --- FICSGameNotificationParserTest.java DELETED --- --- FICSKibitzParserTest.java DELETED --- --- FICSMoveListParserTest.java DELETED --- --- FICSPlayerConnectionParserTest.java DELETED --- --- FICSPlayerNotificationParserTest.java DELETED --- --- FICSSeekAdParserTest.java DELETED --- --- FICSSeekAdReadableParserTest.java DELETED --- --- FICSSeekClearParserTest.java DELETED --- --- FICSSeekRemoveParserTest.java DELETED --- --- FICSShoutParserTest.java DELETED --- --- FICSTellParserTest.java DELETED --- --- makeTest.pl DELETED --- --- testTemplate.txt DELETED --- |