1 package test.xmldb.levelzero; 8 9 import org.w3c.dom.Document ; 10 import org.xmldb.api.modules.TransactionService; 11 import org.xmldb.api.modules.XMLResource; 12 import test.xmldb.XMLDBTestCase; 13 14 17 public class TransactionalDOMTest extends XMLDBTestCase implements LevelZeroTestConstants { 18 19 20 public TransactionalDOMTest(String name) { 21 super(name); 22 } 23 24 27 public void testTransaction() { 28 try { 29 Document document1 = null; 30 Document document2 = null; 31 32 String id1 = "LevelZeroTest"; 33 String id2 = "LevelZeroTest2"; 34 transactionalInsertDOMDocument(id1, document1, id2, document2); 35 36 } catch (Exception e) { 37 fail( e.getMessage( ) ); 38 } 39 } 40 41 private void transactionalInsertDOMDocument(String id1, Document document1, 43 String id2, Document document2) throws Exception { 44 45 TransactionService transaction = 46 (TransactionService) col.getService("TransactionService", "1.0"); 47 48 transaction.begin(); 49 50 XMLResource resource1 = 51 (XMLResource) col.createResource(id1, XMLResource.RESOURCE_TYPE); 52 53 resource1.setContentAsDOM(document1); 54 col.storeResource(resource1); 55 56 XMLResource resource2 = 57 (XMLResource) col.createResource(id2, XMLResource.RESOURCE_TYPE); 58 59 resource2.setContentAsDOM(document2); 60 col.storeResource(resource2); 61 62 transaction.commit(); 63 64 } 65 } 66 | Popular Tags |