1 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 ; 13 import java.io.ByteArrayInputStream ; 14 15 20 public class ImportDocViewTest extends BaseTest{ 21 22 private String 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 , ItemExistsException { 43 ticket.importXML("/", new ByteArrayInputStream (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 } 58 59 60 } 61 | Popular Tags |