1   /*
2    * db2sa: DB2 Syntax Assistant
3    * Copyright (C) Andres Gomez Casanova
4    *
5    * This file is part of db2sa.
6    *
7    * db2sa is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU Lesser General Public License as published by
9    * the Free Software Foundation; either version 3 of the License, or
10   * (at your option) any later version.
11   *
12   * db2sa is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public License
18   * along with this library; if not, see <http://www.gnu.org/licenses/>.
19   *
20   * Contact:
21   * a n g o c a  at  y a h o o  dot  c o m
22   * Cra. 45 No 61 - 31, Bogota, Colombia.
23   *
24   * Author:   $LastChangedBy: angoca $:
25   * Date:     $LastChangedDate: 2009-07-26 04:15:54 +0200 (Sun, 26 Jul 2009) $:
26   * Revision: $LastChangedRevision: 460 $:
27   * URL:      $HeadURL: https://db2sa.svn.sourceforge.net/svnroot/db2sa/branches/db2sa_beta/source-code/src/test/java/name/angoca/db2sa/core/syntax/graph/GraphConstructorTest.java $:
28   */
29  package name.angoca.db2sa.core.syntax.graph;
30  
31  import java.io.StringBufferInputStream;
32  
33  import name.angoca.db2sa.Configurator;
34  import name.angoca.db2sa.Constants;
35  import name.angoca.db2sa.core.syntax.graph.exception.DuplicateNodeException;
36  import name.angoca.db2sa.core.syntax.graph.exception.EndingNodeNotDefinedException;
37  import name.angoca.db2sa.core.syntax.graph.exception.GrammarFileException;
38  import name.angoca.db2sa.core.syntax.graph.exception.InvalidGraphException;
39  import name.angoca.db2sa.core.syntax.graph.exception.StartingNodeNotDefinedException;
40  
41  import org.junit.AfterClass;
42  import org.junit.Assert;
43  import org.junit.Before;
44  import org.junit.Test;
45  import org.xml.sax.InputSource;
46  
47  /**
48   * Tests for the graph constructor.<br/>
49   * <b>Control Version</b><br />
50   * <ul>
51   * <li>0.0.1 Class creation.</li>
52   * <li>0.1.0 More tests and corrections for the existing ones.</li>
53   * <li>0.1.1 final.</li>
54   * <li>0.2.0 SetUp and TeadDown.</li>
55   * <li>1.0.0 Moved to version 1.</li>
56   * </ul>
57   * 
58   * @author Andres Gomez Casanova <a
59   *         href="mailto:a n g o c a at y a h o o dot c o m">(AngocA)</a>
60   * @version 1.0.0 2009-07-19
61   */
62  @SuppressWarnings("deprecation")
63  public final class GraphConstructorTest {
64      /**
65       * Default constructor.
66       */
67      public GraphConstructorTest() {
68          // Nothing.
69      }
70  
71      /**
72       * Clears the configuration file name property before each test.
73       * 
74       */
75      @Before
76      public final void setUp() {
77          System.clearProperty(Constants.DB2SA_CONF_XML);
78      }
79  
80      /**
81       * Clears the configuration file name property at the end of the test.
82       * 
83       */
84      @AfterClass
85      public static void tearDownAfterClass() {
86          System.clearProperty(Constants.DB2SA_CONF_XML);
87      }
88  
89      /**
90       * Tests that a simple graph can be constructed.
91       * 
92       * @throws InvalidGraphException
93       *             Never.
94       */
95      @Test
96      public final void testBuild() throws InvalidGraphException {
97          String xml = ""; //$NON-NLS-1$
98          xml += "<grammar>"; //$NON-NLS-1$
99          xml += " <tokens>"; //$NON-NLS-1$
100         // Starting Node.
101         xml += "  <token>"; //$NON-NLS-1$
102         xml += "   <id>STARTING_TOKEN</id>"; //$NON-NLS-1$
103         xml += "   <name>STARTING_TOKEN</name>"; //$NON-NLS-1$
104         xml += "   <reserved />"; //$NON-NLS-1$
105         xml += "   <children>"; //$NON-NLS-1$
106         xml += "    <idNode>create</idNode>"; //$NON-NLS-1$
107         xml += "   </children>"; //$NON-NLS-1$
108         xml += "  </token>"; //$NON-NLS-1$
109         // create Node.
110         xml += "  <token>"; //$NON-NLS-1$
111         xml += "   <id>create</id>"; //$NON-NLS-1$
112         xml += "   <name>create</name>"; //$NON-NLS-1$
113         xml += "   <reserved/>"; //$NON-NLS-1$
114         xml += "   <children>"; //$NON-NLS-1$
115         xml += "    <idNode>ENDING_TOKEN</idNode>"; //$NON-NLS-1$
116         xml += "   </children>"; //$NON-NLS-1$
117         xml += "  </token>"; //$NON-NLS-1$
118         // Ending Node.
119         xml += "  <token>"; //$NON-NLS-1$
120         xml += "   <id>ENDING_TOKEN</id>"; //$NON-NLS-1$
121         xml += "   <name>ENDING_TOKEN</name>"; //$NON-NLS-1$
122         xml += "   <reserved/>"; //$NON-NLS-1$
123         xml += "  </token>"; //$NON-NLS-1$
124         xml += " </tokens>"; //$NON-NLS-1$
125         xml += "</grammar>"; //$NON-NLS-1$
126 
127         final InputSource content = new InputSource(
128                 new StringBufferInputStream(xml));
129         final StartingToken actual = GraphConstructor.build(content);
130 
131         final StartingToken expected = new StartingToken();
132         // FIXME aquí tiene que ser un ending node, pero no ve la diferencia
133 
134         final GraphToken create = new GraphToken("create", true); //$NON-NLS-1$
135         final GraphToken help = new GraphToken("?", true); //$NON-NLS-1$
136         final GraphToken about = new GraphToken("about", true); //$NON-NLS-1$
137 
138         final EndingToken end = new EndingToken();
139         expected.addWay(create);
140         expected.addWay(help);
141         expected.addWay(about);
142 
143         create.addWay(end);
144         help.addWay(end);
145         about.addWay(end);
146 
147         Assert.assertEquals("Simple graph", expected, actual); //$NON-NLS-1$
148     }
149 
150     /**
151      * Tests a grammar that has an ending node.
152      * 
153      * @throws InvalidGraphException
154      *             Never.
155      */
156     @Test(expected = EndingNodeNotDefinedException.class)
157     public final void testBuildNoEndingNode() throws InvalidGraphException {
158         String xml = ""; //$NON-NLS-1$
159         xml += "<grammar>"; //$NON-NLS-1$
160         xml += " <tokens>"; //$NON-NLS-1$
161         // Starting Node.
162         xml += "  <token>"; //$NON-NLS-1$
163         xml += "   <id>STARTING_TOKEN</id>"; //$NON-NLS-1$
164         xml += "   <name>STARTING_TOKEN</name>"; //$NON-NLS-1$
165         xml += "   <reserved />"; //$NON-NLS-1$
166         xml += "  </token>"; //$NON-NLS-1$
167         xml += " </tokens>"; //$NON-NLS-1$
168         xml += "</grammar>"; //$NON-NLS-1$
169 
170         final InputSource content = new InputSource(
171                 new StringBufferInputStream(xml));
172         GraphConstructor.build(content);
173     }
174 
175     /**
176      * Tests a grammar that has a duplicated node.
177      * 
178      * @throws InvalidGraphException
179      *             Never.
180      */
181     @Test(expected = DuplicateNodeException.class)
182     public final void testBuildDuplicatedNode() throws InvalidGraphException {
183         String xml = ""; //$NON-NLS-1$
184         xml += "<grammar>"; //$NON-NLS-1$
185         xml += " <tokens>"; //$NON-NLS-1$
186         // Starting Node.
187         xml += "  <token>"; //$NON-NLS-1$
188         xml += "   <id>STARTING_TOKEN</id>"; //$NON-NLS-1$
189         xml += "   <name>STARTING_TOKEN</name>"; //$NON-NLS-1$
190         xml += "   <reserved />"; //$NON-NLS-1$
191         xml += "   <children>"; //$NON-NLS-1$
192         xml += "    <idNode>ENDING_TOKEN</idNode>"; //$NON-NLS-1$
193         xml += "   </children>"; //$NON-NLS-1$
194         xml += "  </token>"; //$NON-NLS-1$
195         // Ending Node.
196         xml += "  <token>"; //$NON-NLS-1$
197         xml += "   <id>ENDING_TOKEN</id>"; //$NON-NLS-1$
198         xml += "   <name>ENDING_TOKEN</name>"; //$NON-NLS-1$
199         xml += "   <reserved/>"; //$NON-NLS-1$
200         xml += "  </token>"; //$NON-NLS-1$
201         // Duplicated Ending node.
202         xml += "  <token>"; //$NON-NLS-1$
203         xml += "   <id>ENDING_TOKEN</id>"; //$NON-NLS-1$
204         xml += "   <name>ENDING_TOKEN</name>"; //$NON-NLS-1$
205         xml += "   <reserved/>"; //$NON-NLS-1$
206         xml += "  </token>"; //$NON-NLS-1$
207         xml += " </tokens>"; //$NON-NLS-1$
208         xml += "</grammar>"; //$NON-NLS-1$
209 
210         final InputSource content = new InputSource(
211                 new StringBufferInputStream(xml));
212         GraphConstructor.build(content);
213     }
214 
215     /**
216      * Tests a grammar that has defined all the nodes that are children.
217      * 
218      * @throws InvalidGraphException
219      *             Never.
220      */
221     @Test(expected = RuntimeException.class)
222     public final void testBuildNotAllChildren() throws InvalidGraphException {
223         String xml = ""; //$NON-NLS-1$
224         xml += "<grammar>"; //$NON-NLS-1$
225         xml += " <tokens>"; //$NON-NLS-1$
226         // Starting Node.
227         xml += "  <token>"; //$NON-NLS-1$
228         xml += "   <id>STARTING_TOKEN</id>"; //$NON-NLS-1$
229         xml += "   <name>STARTING_TOKEN</name>"; //$NON-NLS-1$
230         xml += "   <reserved />"; //$NON-NLS-1$
231         xml += "   <children>"; //$NON-NLS-1$
232         xml += "    <idNode>ENDING_TOKEN</idNode>"; //$NON-NLS-1$
233         xml += "   </children>"; //$NON-NLS-1$
234         xml += "  </token>"; //$NON-NLS-1$
235         xml += " </tokens>"; //$NON-NLS-1$
236         xml += "</grammar>"; //$NON-NLS-1$
237 
238         final InputSource content = new InputSource(
239                 new StringBufferInputStream(xml));
240         GraphConstructor.build(content);
241     }
242 
243     /**
244      * Tests a grammar that has an empty file.
245      * 
246      * @throws InvalidGraphException
247      *             Never.
248      */
249     @Test(expected = GrammarFileException.class)
250     public final void testBuildEmptyFile() throws InvalidGraphException {
251         final String xml = ""; //$NON-NLS-1$
252 
253         final InputSource content = new InputSource(
254                 new StringBufferInputStream(xml));
255         GraphConstructor.build(content);
256     }
257 
258     /**
259      * Tests a grammar that has a file with an unknown structure.
260      * 
261      * @throws InvalidGraphException
262      *             Never.
263      */
264     @Test(expected = GrammarFileException.class)
265     public final void testBuildUnknownStructure() throws InvalidGraphException {
266         final String xml = "This can be a test file"; //$NON-NLS-1$
267 
268         final InputSource content = new InputSource(
269                 new StringBufferInputStream(xml));
270         GraphConstructor.build(content);
271     }
272 
273     /**
274      * Tests a grammar that has an invalid structure.
275      * 
276      * @throws InvalidGraphException
277      *             Never.
278      */
279     @Test(expected = GrammarFileException.class)
280     public final void testBuildInvalidStructure() throws InvalidGraphException {
281         String xml = ""; //$NON-NLS-1$
282         xml += "<grammar>"; //$NON-NLS-1$
283         xml += " <tokens>"; //$NON-NLS-1$
284         xml += "  <token>"; //$NON-NLS-1$
285         xml += "   <id>STARTING_TOKEN</id>"; //$NON-NLS-1$
286 
287         final InputSource content = new InputSource(
288                 new StringBufferInputStream(xml));
289         GraphConstructor.build(content);
290     }
291 
292     /**
293      * Tests a grammar that has no nodes.
294      * 
295      * @throws InvalidGraphException
296      *             Never.
297      */
298     @Test(expected = StartingNodeNotDefinedException.class)
299     public final void testBuildNoNodes() throws InvalidGraphException {
300         String xml = ""; //$NON-NLS-1$
301         xml += "<grammar>"; //$NON-NLS-1$
302         xml += " <tokens>"; //$NON-NLS-1$
303         xml += " </tokens>"; //$NON-NLS-1$
304         xml += "</grammar>"; //$NON-NLS-1$
305 
306         final InputSource content = new InputSource(
307                 new StringBufferInputStream(xml));
308         GraphConstructor.build(content);
309     }
310 
311     /**
312      * Tests a grammar that does not have starting node.
313      * 
314      * @throws InvalidGraphException
315      *             Never.
316      */
317     @Test(expected = StartingNodeNotDefinedException.class)
318     public final void testBuildStartingNode() throws InvalidGraphException {
319         String xml = ""; //$NON-NLS-1$
320         xml += "<grammar>"; //$NON-NLS-1$
321         xml += " <tokens>"; //$NON-NLS-1$
322         // create Node.
323         xml += "  <token>"; //$NON-NLS-1$
324         xml += "   <id>create</id>"; //$NON-NLS-1$
325         xml += "   <name>create</name>"; //$NON-NLS-1$
326         xml += "   <reserved/>"; //$NON-NLS-1$
327         xml += "   <children>"; //$NON-NLS-1$
328         xml += "    <idNode>ENDING_TOKEN</idNode>"; //$NON-NLS-1$
329         xml += "   </children>"; //$NON-NLS-1$
330         xml += "  </token>"; //$NON-NLS-1$
331         // Ending Node.
332         xml += "  <token>"; //$NON-NLS-1$
333         xml += "   <id>ENDING_TOKEN</id>"; //$NON-NLS-1$
334         xml += "   <name>ENDING_TOKEN</name>"; //$NON-NLS-1$
335         xml += "   <reserved/>"; //$NON-NLS-1$
336         xml += "  </token>"; //$NON-NLS-1$
337         xml += " </tokens>"; //$NON-NLS-1$
338         xml += "</grammar>"; //$NON-NLS-1$
339 
340         final InputSource content = new InputSource(
341                 new StringBufferInputStream(xml));
342         GraphConstructor.build(content);
343     }
344 
345     /**
346      * Tests a grammar that has a node without the name tag.
347      * 
348      * @throws InvalidGraphException
349      *             Never.
350      */
351     @Test(expected = RuntimeException.class)
352     public final void testBuildNoName() throws InvalidGraphException {
353         String xml = ""; //$NON-NLS-1$
354         xml += "<grammar>"; //$NON-NLS-1$
355         xml += " <tokens>"; //$NON-NLS-1$
356         // Starting Node.
357         xml += "  <token>"; //$NON-NLS-1$
358         xml += "   <id>STARTING_TOKEN</id>"; //$NON-NLS-1$
359         xml += "   <name>STARTING_TOKEN</name>"; //$NON-NLS-1$
360         xml += "   <reserved />"; //$NON-NLS-1$
361         xml += "   <children>"; //$NON-NLS-1$
362         xml += "    <idNode>create</idNode>"; //$NON-NLS-1$
363         xml += "   </children>"; //$NON-NLS-1$
364         xml += "  </token>"; //$NON-NLS-1$
365         // create Node.
366         xml += "  <token>"; //$NON-NLS-1$
367         xml += "   <id>create</id>"; //$NON-NLS-1$
368         xml += "   <reserved/>"; //$NON-NLS-1$
369         xml += "   <children>"; //$NON-NLS-1$
370         xml += "    <idNode>ENDING_TOKEN</idNode>"; //$NON-NLS-1$
371         xml += "   </children>"; //$NON-NLS-1$
372         xml += "  </token>"; //$NON-NLS-1$
373         // Ending Node.
374         xml += "  <token>"; //$NON-NLS-1$
375         xml += "   <id>ENDING_TOKEN</id>"; //$NON-NLS-1$
376         xml += "   <name>ENDING_TOKEN</name>"; //$NON-NLS-1$
377         xml += "   <reserved/>"; //$NON-NLS-1$
378         xml += "  </token>"; //$NON-NLS-1$
379         xml += " </tokens>"; //$NON-NLS-1$
380         xml += "</grammar>"; //$NON-NLS-1$
381 
382         final InputSource content = new InputSource(
383                 new StringBufferInputStream(xml));
384         GraphConstructor.build(content);
385     }
386 
387     /**
388      * Tests a grammar that has a node without the id tag.
389      * 
390      * @throws InvalidGraphException
391      *             Never.
392      */
393     @Test(expected = RuntimeException.class)
394     public final void testBuildNoId() throws InvalidGraphException {
395         String xml = ""; //$NON-NLS-1$
396         xml += "<grammar>"; //$NON-NLS-1$
397         xml += " <tokens>"; //$NON-NLS-1$
398         // Starting Node.
399         xml += "  <token>"; //$NON-NLS-1$
400         xml += "   <id>STARTING_TOKEN</id>"; //$NON-NLS-1$
401         xml += "   <name>STARTING_TOKEN</name>"; //$NON-NLS-1$
402         xml += "   <reserved />"; //$NON-NLS-1$
403         xml += "   <children>"; //$NON-NLS-1$
404         xml += "    <idNode>create</idNode>"; //$NON-NLS-1$
405         xml += "   </children>"; //$NON-NLS-1$
406         xml += "  </token>"; //$NON-NLS-1$
407         // create Node.
408         xml += "  <token>"; //$NON-NLS-1$
409         xml += "   <name>create</name>"; //$NON-NLS-1$
410         xml += "   <reserved/>"; //$NON-NLS-1$
411         xml += "   <children>"; //$NON-NLS-1$
412         xml += "    <idNode>ENDING_TOKEN</idNode>"; //$NON-NLS-1$
413         xml += "   </children>"; //$NON-NLS-1$
414         xml += "  </token>"; //$NON-NLS-1$
415         // Ending Node.
416         xml += "  <token>"; //$NON-NLS-1$
417         xml += "   <id>ENDING_TOKEN</id>"; //$NON-NLS-1$
418         xml += "   <name>ENDING_TOKEN</name>"; //$NON-NLS-1$
419         xml += "   <reserved/>"; //$NON-NLS-1$
420         xml += "  </token>"; //$NON-NLS-1$
421         xml += " </tokens>"; //$NON-NLS-1$
422         xml += "</grammar>"; //$NON-NLS-1$
423 
424         final InputSource content = new InputSource(
425                 new StringBufferInputStream(xml));
426         GraphConstructor.build(content);
427     }
428 
429     /**
430      * Tests a grammar that has the starting node is not connected to the ending
431      * node.
432      * 
433      * @throws InvalidGraphException
434      *             Never.
435      */
436     @Test
437     public final void testBuildNotConnectedGraph() throws InvalidGraphException {
438         String xml = ""; //$NON-NLS-1$
439         xml += "<grammar>"; //$NON-NLS-1$
440         xml += " <tokens>"; //$NON-NLS-1$
441         // Starting Node.
442         xml += "  <token>"; //$NON-NLS-1$
443         xml += "   <id>STARTING_TOKEN</id>"; //$NON-NLS-1$
444         xml += "   <name>STARTING_TOKEN</name>"; //$NON-NLS-1$
445         xml += "   <reserved />"; //$NON-NLS-1$
446         xml += "  </token>"; //$NON-NLS-1$
447         // Ending Node.
448         xml += "  <token>"; //$NON-NLS-1$
449         xml += "   <id>ENDING_TOKEN</id>"; //$NON-NLS-1$
450         xml += "   <name>ENDING_TOKEN</name>"; //$NON-NLS-1$
451         xml += "   <reserved/>"; //$NON-NLS-1$
452         xml += "  </token>"; //$NON-NLS-1$
453         xml += " </tokens>"; //$NON-NLS-1$
454         xml += "</grammar>"; //$NON-NLS-1$
455 
456         final InputSource content = new InputSource(
457                 new StringBufferInputStream(xml));
458         GraphConstructor.build(content);
459         // FIXME
460         // fail("Not implemented");
461     }
462 
463     /**
464      * Tests if the application throw an exception when the about token is not
465      * defined. TODO
466      * 
467      * @throws InvalidGraphException
468      *             Never.
469      */
470     @Test(expected = RuntimeException.class)
471     public final void testBuildNoAboutToken() throws InvalidGraphException {
472         // Deletes the property, loading other configuration file.
473         System.setProperty(Constants.DB2SA_CONF_XML,
474                 "db2sa_conf-test-NoAboutToken.xml"); //$NON-NLS-1$
475         Configurator.destroyInstance();
476 
477         String xml = ""; //$NON-NLS-1$
478         xml += "<grammar>"; //$NON-NLS-1$
479         xml += " <tokens>"; //$NON-NLS-1$
480         // Starting Node.
481         xml += "  <token>"; //$NON-NLS-1$
482         xml += "   <id>STARTING_TOKEN</id>"; //$NON-NLS-1$
483         xml += "   <name>STARTING_TOKEN</name>"; //$NON-NLS-1$
484         xml += "   <reserved />"; //$NON-NLS-1$
485         xml += "   <children>"; //$NON-NLS-1$
486         xml += "    <idNode>create</idNode>"; //$NON-NLS-1$
487         xml += "   </children>"; //$NON-NLS-1$
488         xml += "  </token>"; //$NON-NLS-1$
489         // create Node.
490         xml += "  <token>"; //$NON-NLS-1$
491         xml += "   <id>create</id>"; //$NON-NLS-1$
492         xml += "   <name>create</name>"; //$NON-NLS-1$
493         xml += "   <reserved/>"; //$NON-NLS-1$
494         xml += "   <children>"; //$NON-NLS-1$
495         xml += "    <idNode>ENDING_TOKEN</idNode>"; //$NON-NLS-1$
496         xml += "   </children>"; //$NON-NLS-1$
497         xml += "  </token>"; //$NON-NLS-1$
498         // Ending Node.
499         xml += "  <token>"; //$NON-NLS-1$
500         xml += "   <id>ENDING_TOKEN</id>"; //$NON-NLS-1$
501         xml += "   <name>ENDING_TOKEN</name>"; //$NON-NLS-1$
502         xml += "   <reserved/>"; //$NON-NLS-1$
503         xml += "  </token>"; //$NON-NLS-1$
504         xml += " </tokens>"; //$NON-NLS-1$
505         xml += "</grammar>"; //$NON-NLS-1$
506 
507         final InputSource content = new InputSource(
508                 new StringBufferInputStream(xml));
509         final StartingToken actual = GraphConstructor.build(content);
510         actual.toString();
511         // FIXME
512     }
513 
514     /**
515      * Tests if the application throw an exception when the help token is not
516      * defined. TODO
517      * 
518      * @throws InvalidGraphException
519      *             Never.
520      */
521     @Test(expected = RuntimeException.class)
522     public final void testBuildNoHelpToken() throws InvalidGraphException {
523         // Deletes the property, loading other configuration file.
524         System.setProperty(Constants.DB2SA_CONF_XML,
525                 "db2sa_conf-test-NoHelpToken.xml"); //$NON-NLS-1$
526         Configurator.destroyInstance();
527 
528         String xml = ""; //$NON-NLS-1$
529         xml += "<grammar>"; //$NON-NLS-1$
530         xml += " <tokens>"; //$NON-NLS-1$
531         // Starting Node.
532         xml += "  <token>"; //$NON-NLS-1$
533         xml += "   <id>STARTING_TOKEN</id>"; //$NON-NLS-1$
534         xml += "   <name>STARTING_TOKEN</name>"; //$NON-NLS-1$
535         xml += "   <reserved />"; //$NON-NLS-1$
536         xml += "   <children>"; //$NON-NLS-1$
537         xml += "    <idNode>create</idNode>"; //$NON-NLS-1$
538         xml += "   </children>"; //$NON-NLS-1$
539         xml += "  </token>"; //$NON-NLS-1$
540         // create Node.
541         xml += "  <token>"; //$NON-NLS-1$
542         xml += "   <id>create</id>"; //$NON-NLS-1$
543         xml += "   <name>create</name>"; //$NON-NLS-1$
544         xml += "   <reserved/>"; //$NON-NLS-1$
545         xml += "   <children>"; //$NON-NLS-1$
546         xml += "    <idNode>ENDING_TOKEN</idNode>"; //$NON-NLS-1$
547         xml += "   </children>"; //$NON-NLS-1$
548         xml += "  </token>"; //$NON-NLS-1$
549         // Ending Node.
550         xml += "  <token>"; //$NON-NLS-1$
551         xml += "   <id>ENDING_TOKEN</id>"; //$NON-NLS-1$
552         xml += "   <name>ENDING_TOKEN</name>"; //$NON-NLS-1$
553         xml += "   <reserved/>"; //$NON-NLS-1$
554         xml += "  </token>"; //$NON-NLS-1$
555         xml += " </tokens>"; //$NON-NLS-1$
556         xml += "</grammar>"; //$NON-NLS-1$
557 
558         final InputSource content = new InputSource(
559                 new StringBufferInputStream(xml));
560         final StartingToken actual = GraphConstructor.build(content);
561         actual.toString();
562         // FIXME
563     }
564 }