01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Library License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-2001 by SMB GmbH. All rights reserved.
06: //
07: // $Id: Obj2XMLTest.java,v 1.3 2002/04/06 15:43:51 per_nyfelt Exp $
08:
09: package test.openxml;
10:
11: import javax.xml.parsers.DocumentBuilder;
12: import javax.xml.parsers.DocumentBuilderFactory;
13:
14: import junit.framework.Test;
15: import junit.framework.TestSuite;
16: import org.apache.xml.serialize.OutputFormat;
17: import org.apache.xml.serialize.XMLSerializer;
18: import org.w3c.dom.Document;
19: import org.w3c.dom.Node;
20: import org.xml.sax.ContentHandler;
21: import org.xml.sax.helpers.DefaultHandler;
22:
23: /**
24: * @author <a href="http://www.softwarebuero.de/">SMB</a>
25: * @version $Revision: 1.3 $Date: 2002/04/06 15:43:51 $
26: */
27: public class Obj2XMLTest extends OpenXmlTestCase {
28:
29: static DocumentBuilderFactory builderFactory = new org.apache.xerces.jaxp.DocumentBuilderFactoryImpl();
30:
31: public static Test suite() {
32: TestSuite suite = new TestSuite();
33: suite.addTestSuite(Obj2XMLTest.class);
34: return suite;
35: }
36:
37: public Obj2XMLTest(String name) {
38: super (name);
39: }
40:
41: public void testSAX() throws Exception {
42: Data data = (Data) db.createObject(DataImpl.class.getName());
43: data.setup();
44: ContentHandler handler = new DefaultHandler();
45: db.xmlForObject(data, handler);
46: //XMLSerializer serializer = new XMLSerializer(System.out, new OutputFormat("xml", "UTF-8", true));
47: //db.xmlForObject(data, serializer.asContentHandler());
48: }
49:
50: public void testDOM() throws Exception {
51: Data data = (Data) db.createObject(DataImpl.class.getName());
52: data.setup();
53:
54: DocumentBuilder documentBuilder = builderFactory
55: .newDocumentBuilder();
56: Document doc = documentBuilder.newDocument();
57:
58: Node node = db.xmlForObject(data, doc);
59: assertNotNull(node);
60: }
61:
62: }
|