01: /*
02: * User: Michael Rettig
03: * Date: Sep 15, 2002
04: * Time: 10:51:00 PM
05: */
06: package net.sourceforge.jaxor.parser.tests;
07:
08: import junit.framework.TestCase;
09: import net.sourceforge.jaxor.parser.GeneratorConfig;
10: import org.jdom.Document;
11: import org.jdom.Element;
12: import org.jdom.output.XMLOutputter;
13: import org.xml.sax.InputSource;
14:
15: import java.io.StringReader;
16: import java.io.StringWriter;
17:
18: public class GeneratorConfigTest extends TestCase {
19:
20: public void testParsing() throws Exception {
21: Document doc = new Document(createGenerator());
22: GeneratorConfig config = new GeneratorConfig();
23: StringWriter writer = new StringWriter();
24: XMLOutputter output = new XMLOutputter();
25: output.output(doc, writer);
26: config.parse(new InputSource(
27: new StringReader(writer.toString())));
28: assertEquals(1, config.getGenerator().getAttributes().size());
29: }
30:
31: private Element createGenerator() {
32: Element el = new Element("generator");
33: el.addContent(createElement("extends",
34: "net.sourceforge.FakeEntity"));
35: el.addContent(createElement("implements",
36: "net.sourceforge.BaseInterface"));
37: el.addContent(EntityParserTest.createAttribute());
38: return el;
39: }
40:
41: private Element createElement(String element, String s) {
42: Element el = new Element(element);
43: el.setAttribute("name", s);
44: return el;
45: }
46: }
|