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.ByteArrayInputStream ; 13 import java.io.IOException ; 14 import java.util.Iterator ; 15 16 21 public class ImportSysViewTest extends BaseTest{ 22 23 private String sysView = "<sv:node xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" " + 24 "xmlns:jcr=\"http://www.jcp.org/jcr/1.0\" " + 25 "xmlns:pt=\"http://www.jcp.org/jcr/pt/1.0\" " + 26 "xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" " + 27 "xmlns:exo=\"http://www.exoplatform.com/jcr/exo/1.0\" " + 28 "xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" sv:name=\"sv:root\">" + 29 "<sv:property sv:name=\"jcr:primaryType\" sv:type=\"pt:string\">nt:default</sv:property>" + 30 "<sv:node sv:name=\"childNode\">" + 31 "<sv:property sv:name=\"jcr:created\" sv:type=\"pt:date\">2004-08-18T15:17:00.856+01:00</sv:property>" + 32 "<sv:property sv:name=\"jcr:lastModified\" sv:type=\"pt:date\">2004-08-18T15:17:00.856+01:00</sv:property>" + 33 "<sv:property sv:name=\"jcr:primaryType\" sv:type=\"pt:string\">nt:folder</sv:property>" + 34 "<sv:node sv:name=\"childNode3\">" + 35 "<sv:property sv:name=\"jcr:created\" sv:type=\"pt:date\">2004-08-18T15:17:00.856+01:00</sv:property>" + 36 "<sv:property sv:name=\"jcr:lastModified\" sv:type=\"pt:date\">2004-08-18T15:17:00.856+01:00</sv:property>" + 37 "<sv:property sv:name=\"jcr:primaryType\" sv:type=\"pt:string\">nt:file</sv:property>" + 38 "<sv:node sv:name=\"jcr:content\">" + 39 "<sv:property sv:name=\"jcr:primaryType\" sv:type=\"pt:string\">nt:content</sv:property>" + 40 "<sv:property sv:name=\"jcr:uuid\" sv:type=\"pt:string\">1092835020617</sv:property>" + 41 "<sv:property sv:name=\"exo:content\" sv:type=\"pt:binary\">dGhpcyBpcyB0aGUgYmluYXJ5IGNvbnRlbnQ=</sv:property>" + 42 "</sv:node>" + 43 "</sv:node>" + 44 "<sv:node sv:name=\"childNode2\">" + 45 "<sv:property sv:name=\"jcr:created\" sv:type=\"pt:date\">2004-08-18T15:17:00.856+01:00</sv:property>" + 46 "<sv:property sv:name=\"jcr:lastModified\" sv:type=\"pt:date\">2004-08-18T15:17:00.856+01:00</sv:property>" + 47 "<sv:property sv:name=\"jcr:primaryType\" sv:type=\"pt:string\">nt:file</sv:property>" + 48 "<sv:node sv:name=\"jcr:content\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"pt:string\">nt:content</sv:property>" + 49 "<sv:property sv:name=\"jcr:uuid\" sv:type=\"pt:string\">1092835020616</sv:property>" + 50 "<sv:property sv:name=\"exo:content\" sv:type=\"pt:string\">this is the content</sv:property>" + 51 "</sv:node>" + 52 "</sv:node>" + 53 "</sv:node>" + 54 "</sv:node>"; 55 56 public void testImportSysView() throws RepositoryException, InvalidSerializedDataException, 57 ConstraintViolationException, IOException , ItemExistsException { 58 ticket.importXML("/", new ByteArrayInputStream (sysView.getBytes())); 59 60 Node root = ticket.getRootNode(); 61 NodeIterator iterator = root.getNodes(); 62 assertEquals(1, iterator.getSize()); 63 64 iterator = root.getNode("childNode").getNodes(); 65 assertEquals(2, iterator.getSize()); 66 67 Property property = root.getProperty("childNode/childNode3/jcr:content/exo:content"); 68 assertEquals("this is the binary content", property.getString()); 69 70 property = root.getProperty("childNode/childNode2/jcr:content/exo:content"); 71 assertEquals("this is the content", property.getString()); 72 } 73 74 } 75 | Popular Tags |