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-@year@ by SMB GmbH. All rights reserved.
06: //
07: package test.xmldb.levelzero;
08:
09: import test.xmldb.*;
10: import junit.framework.*;
11:
12: import org.xmldb.api.modules.TransactionService;
13:
14: import org.w3c.dom.Node;
15: import org.w3c.dom.NodeList;
16: import org.w3c.dom.Document;
17: import org.w3c.dom.Element;
18: import org.w3c.dom.Text;
19:
20: import org.xmldb.api.modules.XMLResource;
21:
22: /**
23: * @author Per Nyfelt
24: */
25: public class TransactionalDOMTest extends XMLDBTestCase implements
26: LevelZeroTestConstants {
27:
28: /** Creates new TransactionalDOMTest */
29: public TransactionalDOMTest(String name) {
30: super (name);
31: }
32:
33: /**
34: * test the transaction capabilities, this is optional for Core Level 1
35: */
36: public void testTransaction() {
37: try {
38: Document document1 = null;
39: Document document2 = null;
40:
41: String id1 = "LevelZeroTest";
42: String id2 = "LevelZeroTest2";
43: transactionalInsertDOMDocument(id1, document1, id2,
44: document2);
45:
46: } catch (Exception e) {
47: fail(e.getMessage());
48: }
49: }
50:
51: // Transaction support is optional for level 0 compliance
52: private void transactionalInsertDOMDocument(String id1,
53: Document document1, String id2, Document document2)
54: throws Exception {
55:
56: TransactionService transaction = (TransactionService) col
57: .getService("TransactionService", "1.0");
58:
59: transaction.begin();
60:
61: XMLResource resource1 = (XMLResource) col.createResource(id1,
62: XMLResource.RESOURCE_TYPE);
63:
64: resource1.setContentAsDOM(document1);
65: col.storeResource(resource1);
66:
67: XMLResource resource2 = (XMLResource) col.createResource(id2,
68: XMLResource.RESOURCE_TYPE);
69:
70: resource2.setContentAsDOM(document2);
71: col.storeResource(resource2);
72:
73: transaction.commit();
74:
75: }
76: }
|