1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package nl.hippo.client.webdav.binding.content;
17
18 import java.io.ByteArrayOutputStream;
19 import java.io.IOException;
20 import java.io.InputStream;
21
22 import junit.framework.TestCase;
23 import nl.hippo.client.api.ClientException;
24 import nl.hippo.client.webdav.binding.content.DocumentCollectionImpl;
25
26 import org.jibx.runtime.BindingDirectory;
27 import org.jibx.runtime.IBindingFactory;
28 import org.jibx.runtime.IMarshallingContext;
29 import org.jibx.runtime.IUnmarshallingContext;
30
31
32
33 public class SearchResultBindingTest extends TestCase {
34
35 private InputStream in;
36
37
38 public void setUp() {
39 in = SearchResultBindingTest.class.getResourceAsStream("resources/searchresult.xml");
40 }
41
42
43 /**
44 * Unmarshal the sample document from a file, then marshal it back out to
45 * a Stream
46 * @throws ClientException
47 * @throws IOException
48 */
49 public void test() throws Exception {
50
51
52
53
54 IBindingFactory bfact = BindingDirectory.getFactory(DocumentCollectionImpl.class);
55
56
57 IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
58 DocumentCollectionImpl searchResult = (DocumentCollectionImpl) uctx.unmarshalDocument(in, null);
59
60
61
62
63
64 IMarshallingContext mctx = bfact.createMarshallingContext();
65 mctx.setIndent(2);
66
67 ByteArrayOutputStream out = new ByteArrayOutputStream();
68 mctx.marshalDocument(searchResult, "UTF-8", null, out);
69
70
71
72
73 }
74 }