01: package org.ontoware.aifbcommons.xml;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05:
06: import org.dom4j.Document;
07: import org.dom4j.DocumentHelper;
08: import org.junit.Assert;
09: import org.junit.Test;
10:
11: public class DocumentComposerTest {
12:
13: @Test
14: public void testComposing() {
15: Document master = DocumentHelper.createDocument();
16: master.addElement("master").addElement("replace").addAttribute(
17: "key", "a");
18: Document a = DocumentHelper.createDocument();
19: a.addElement("aaa").addElement("bbb")
20: .addAttribute("ccc", "ddd");
21:
22: Map<String, Document> mapping = new HashMap<String, Document>();
23: mapping.put("a", a);
24:
25: Document composed = DocumentComposer.compose(master, mapping);
26:
27: Assert.assertTrue(composed.selectNodes("//bbb") != null);
28: Assert.assertEquals(1, composed.selectNodes("//bbb").size());
29:
30: }
31:
32: }
|