KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > ozoneDB > xml > dom4j > InsertTest


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-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: InsertTest.java,v 1.2 2003/05/05 07:16:37 per_nyfelt Exp $
8
package test.ozoneDB.xml.dom4j;
9
10 import junit.framework.TestCase;
11 import org.dom4j.Document;
12 import org.ozoneDB.ExternalDatabase;
13 import org.ozoneDB.xml.dom4j.O3DocumentHelper;
14
15 import java.io.File JavaDoc;
16 import java.io.FileReader JavaDoc;
17
18 /**
19  * $Id: InsertTest.java,v 1.2 2003/05/05 07:16:37 per_nyfelt Exp $
20  */

21 public class InsertTest extends TestCase {
22
23     ExternalDatabase db;
24
25     public InsertTest(String JavaDoc methodName) {
26         super(methodName);
27         try {
28             db = ExternalDatabase.openDatabase("ozonedb:remote://localhost:3333");
29             O3DocumentHelper.configure(db);
30         } catch (Exception JavaDoc e) {
31             e.printStackTrace();
32             fail(e.toString());
33         }
34     }
35
36     public void testInsert() {
37         try {
38             Document doc = O3DocumentHelper.fetchDocument("build.xml");
39             if (doc != null) {
40                 O3DocumentHelper.deleteDocument(doc);
41             }
42             File JavaDoc file = new File JavaDoc("../../build.xml");
43             long start = System.currentTimeMillis();
44             doc = O3DocumentHelper.parse(new FileReader JavaDoc(file), "build.xml");
45             long end = System.currentTimeMillis();
46                         System.out.println("Inserted document " + doc.asXML());
47             System.out.println("parsing took " + (end - start) / 1000 + " seconds");
48             db.close();
49         } catch (Exception JavaDoc e) {
50             e.printStackTrace();
51             fail(e.toString());
52         }
53     }
54 }
55
Popular Tags