KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > openxml > Obj2XMLTest


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-2001 by SMB GmbH. All rights reserved.
6
//
7
// $Id: Obj2XMLTest.java,v 1.1 2003/11/02 17:29:30 per_nyfelt Exp $
8

9 package test.openxml;
10
11 import javax.xml.parsers.DocumentBuilder JavaDoc;
12 import javax.xml.parsers.DocumentBuilderFactory JavaDoc;
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 JavaDoc;
19 import org.w3c.dom.Node JavaDoc;
20 import org.xml.sax.ContentHandler JavaDoc;
21 import org.xml.sax.helpers.DefaultHandler JavaDoc;
22
23
24 /**
25  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
26  * @version $Revision: 1.1 $Date: 2003/11/02 17:29:30 $
27  */

28 public class Obj2XMLTest extends OpenXmlTestCase {
29
30     static DocumentBuilderFactory JavaDoc builderFactory = new org.apache.xerces.jaxp.DocumentBuilderFactoryImpl();
31
32     public static Test suite() {
33         TestSuite suite = new TestSuite();
34         suite.addTestSuite(Obj2XMLTest.class);
35         return suite;
36     }
37
38     public Obj2XMLTest(String JavaDoc name) {
39         super(name);
40     }
41
42
43     public void testSAX() throws Exception JavaDoc {
44         Data data = (Data) db.createObject(DataImpl.class.getName());
45         data.setup();
46         ContentHandler JavaDoc handler = new DefaultHandler JavaDoc();
47         db.xmlForObject(data, handler);
48         //XMLSerializer serializer = new XMLSerializer(System.out, new OutputFormat("xml", "UTF-8", true));
49
//db.xmlForObject(data, serializer.asContentHandler());
50
}
51
52
53     public void testDOM() throws Exception JavaDoc {
54         Data data = (Data) db.createObject(DataImpl.class.getName());
55         data.setup();
56
57         DocumentBuilder JavaDoc documentBuilder = builderFactory.newDocumentBuilder();
58         Document JavaDoc doc = documentBuilder.newDocument();
59
60         Node JavaDoc node = db.xmlForObject(data, doc);
61         assertNotNull(node);
62     }
63
64 }
65
Popular Tags