KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > jcr > api > serialization > ImportDocViewTest


1 /*
2  * Copyright 2001-2003 The eXo platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  */

5
6 package org.exoplatform.services.jcr.api.serialization;
7
8
9 import javax.jcr.*;
10 import javax.jcr.nodetype.ConstraintViolationException;
11 import org.exoplatform.services.jcr.BaseTest;
12 import java.io.IOException JavaDoc;
13 import java.io.ByteArrayInputStream JavaDoc;
14
15 /**
16  * Created y the eXo platform team
17  * User: Benjamin Mestrallet
18  * Date: 18 ao�t 2004
19  */

20 public class ImportDocViewTest extends BaseTest{
21
22   private String JavaDoc docView = "<root xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" " +
23       "xmlns:jcr=\"http://www.jcp.org/jcr/1.0\" " +
24       "xmlns:pt=\"http://www.jcp.org/jcr/pt/1.0\" " +
25       "xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" " +
26       "xmlns:exo=\"http://www.exoplatform.com/jcr/exo/1.0\" " +
27       "xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" " +
28       "jcr:primaryType=\"nt:default\">" +
29         "<childNode jcr:created=\"2004-08-18T20:07:42.626+01:00\" jcr:primaryType=\"nt:folder\" jcr:lastModified=\"2004-08-18T20:07:42.626+01:00\">" +
30           "<childNode3 jcr:created=\"2004-08-18T20:07:42.636+01:00\" jcr:primaryType=\"nt:file\" jcr:lastModified=\"2004-08-18T20:07:42.636+01:00\">" +
31             "<jcr:content exo:content=\"dGhpcyBpcyB0aGUgYmluYXJ5IGNvbnRlbnQ=\" jcr:primaryType=\"nt:content\" jcr:uuid=\"1092852462407\">" +
32             "</jcr:content>" +
33           "</childNode3>" +
34           "<childNode2 jcr:created=\"2004-08-18T20:07:42.636+01:00\" jcr:primaryType=\"nt:file\" jcr:lastModified=\"2004-08-18T20:07:42.636+01:00\">" +
35             "<jcr:content exo:content=\"this is the content\" jcr:primaryType=\"nt:content\" jcr:uuid=\"1092852462406\">" +
36             "</jcr:content>" +
37           "</childNode2>" +
38         "</childNode>" +
39       "</root>";
40
41   public void testImportDocView() throws RepositoryException, InvalidSerializedDataException,
42       ConstraintViolationException, IOException JavaDoc, ItemExistsException {
43     ticket.importXML("/", new ByteArrayInputStream JavaDoc(docView.getBytes()));
44
45     Node root = ticket.getRootNode();
46     NodeIterator iterator = root.getNodes();
47     assertEquals(1, iterator.getSize());
48
49     iterator = root.getNode("childNode").getNodes();
50     assertEquals(2, iterator.getSize());
51
52     Property property = root.getProperty("childNode/childNode2/jcr:content/exo:content");
53     assertEquals("this is the content", property.getString());
54
55 // property = root.getProperty("childNode/childNode3/jcr:content/exo:content");
56
// assertEquals("this is the binary content", property.getString());
57
}
58
59
60 }
61
Popular Tags