1 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 ; 16 import java.io.FileReader ; 17 18 21 public class InsertTest extends TestCase { 22 23 ExternalDatabase db; 24 25 public InsertTest(String methodName) { 26 super(methodName); 27 try { 28 db = ExternalDatabase.openDatabase("ozonedb:remote://localhost:3333"); 29 O3DocumentHelper.configure(db); 30 } catch (Exception 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 file = new File ("../../build.xml"); 43 long start = System.currentTimeMillis(); 44 doc = O3DocumentHelper.parse(new FileReader (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 e) { 50 e.printStackTrace(); 51 fail(e.toString()); 52 } 53 } 54 } 55 | Popular Tags |