KickJava   Java API By Example, From Geeks To Geeks.

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


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.ByteArrayInputStream JavaDoc;
13 import java.io.IOException JavaDoc;
14 import java.util.Iterator JavaDoc;
15
16 /**
17  * Created y the eXo platform team
18  * User: Benjamin Mestrallet
19  * Date: 17 ao�t 2004
20  */

21 public class ImportSysViewTest extends BaseTest{
22
23   private String JavaDoc 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 JavaDoc, ItemExistsException {
58     ticket.importXML("/", new ByteArrayInputStream JavaDoc(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