You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by fi...@apache.org on 2005/02/16 02:07:39 UTC

svn commit: r153980 [5/8] - in incubator/jackrabbit/site: ./ apidocs/org/apache/jackrabbit/core/ apidocs/org/apache/jackrabbit/core/state/mem/ apidocs/org/apache/jackrabbit/core/state/obj/ apidocs/org/apache/jackrabbit/core/state/xml/ apidocs/org/apache/jackrabbit/core/version/ apidocs/org/apache/jackrabbit/core/xml/ xref-test/ xref-test/org/apache/jackrabbit/init/ xref-test/org/apache/jackrabbit/test/ xref-test/org/apache/jackrabbit/test/api/ xref-test/org/apache/jackrabbit/test/api/version/ xref/org/apache/jackrabbit/core/

Added: incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/NodeTestData.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/NodeTestData.html?view=auto&rev=153980
==============================================================================
--- incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/NodeTestData.html (added)
+++ incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/NodeTestData.html Tue Feb 15 17:07:29 2005
@@ -0,0 +1,117 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /><title>NodeTestData xref</title>
+<link type="text/css" rel="stylesheet" href="../../../../stylesheet.css" />
+</head>
+<body>
+<pre>
+
+<a name="1" href="#1">1</a>   <em class="comment">/*</em>
+<a name="2" href="#2">2</a>   <em class="comment"> * Copyright 2004-2005 The Apache Software Foundation or its licensors,</em>
+<a name="3" href="#3">3</a>   <em class="comment"> *                     as applicable.</em>
+<a name="4" href="#4">4</a>   <em class="comment"> *</em>
+<a name="5" href="#5">5</a>   <em class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</em>
+<a name="6" href="#6">6</a>   <em class="comment"> * you may not use this file except in compliance with the License.</em>
+<a name="7" href="#7">7</a>   <em class="comment"> * You may obtain a copy of the License at</em>
+<a name="8" href="#8">8</a>   <em class="comment"> *</em>
+<a name="9" href="#9">9</a>   <em class="comment"> *      <a href="http://www.apache.org/licenses/LICENSE-2.0" target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.0</a></em>
+<a name="10" href="#10">10</a>  <em class="comment"> *</em>
+<a name="11" href="#11">11</a>  <em class="comment"> * Unless required by applicable law or agreed to in writing, software</em>
+<a name="12" href="#12">12</a>  <em class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</em>
+<a name="13" href="#13">13</a>  <em class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</em>
+<a name="14" href="#14">14</a>  <em class="comment"> * See the License for the specific language governing permissions and</em>
+<a name="15" href="#15">15</a>  <em class="comment"> * limitations under the License.</em>
+<a name="16" href="#16">16</a>  <em class="comment"> */</em>
+<a name="17" href="#17">17</a>  <strong>package</strong> <a href="../../../../org/apache/jackrabbit/init/package-summary.html">org.apache.jackrabbit.init</a>;
+<a name="18" href="#18">18</a>  
+<a name="19" href="#19">19</a>  <strong>import</strong> javax.jcr.RepositoryException;
+<a name="20" href="#20">20</a>  <strong>import</strong> javax.jcr.Node;
+<a name="21" href="#21">21</a>  <strong>import</strong> java.util.StringTokenizer;
+<a name="22" href="#22">22</a>  <strong>import</strong> java.util.Calendar;
+<a name="23" href="#23">23</a>  <strong>import</strong> java.io.ByteArrayOutputStream;
+<a name="24" href="#24">24</a>  <strong>import</strong> java.io.OutputStreamWriter;
+<a name="25" href="#25">25</a>  <strong>import</strong> java.io.IOException;
+<a name="26" href="#26">26</a>  <strong>import</strong> java.io.ByteArrayInputStream;
+<a name="27" href="#27">27</a>  
+<a name="28" href="#28">28</a>  <strong>import</strong> org.apache.jackrabbit.test.AbstractJCRTest;
+<a name="29" href="#29">29</a>  
+<a name="30" href="#30">30</a>  <em>/**<em>*</em></em>
+<a name="31" href="#31">31</a>  <em> * Sets up test data required for level 1 node test cases.</em>
+<a name="32" href="#32">32</a>  <em> */</em>
+<a name="33" href="#33">33</a>  <strong>public</strong> <strong>class</strong> <a href="../../../../org/apache/jackrabbit/init/NodeTestData.html">NodeTestData</a> <strong>extends</strong> <a href="../../../../org/apache/jackrabbit/test/AbstractJCRTest.html">AbstractJCRTest</a> {
+<a name="34" href="#34">34</a>  
+<a name="35" href="#35">35</a>      <em>/**<em>* Path pointing to the test root */</em></em>
+<a name="36" href="#36">36</a>      <strong>private</strong> <strong>static</strong> <strong>final</strong> String TEST_DATA_PATH = <span class="string">"testdata/node"</span>;
+<a name="37" href="#37">37</a>  
+<a name="38" href="#38">38</a>      <em>/**<em>* Resolved QName for nt:resource */</em></em>
+<a name="39" href="#39">39</a>      <strong>private</strong> String ntResource;
+<a name="40" href="#40">40</a>  
+<a name="41" href="#41">41</a>      <em>/**<em>* Resolved QName for jcr:encoding */</em></em>
+<a name="42" href="#42">42</a>      <strong>private</strong> String jcrEncoding;
+<a name="43" href="#43">43</a>  
+<a name="44" href="#44">44</a>      <em>/**<em>* Resolved QName for jcr:mimeType */</em></em>
+<a name="45" href="#45">45</a>      <strong>private</strong> String jcrMimeType;
+<a name="46" href="#46">46</a>  
+<a name="47" href="#47">47</a>      <em>/**<em>* Resolved QName for jcr:data */</em></em>
+<a name="48" href="#48">48</a>      <strong>private</strong> String jcrData;
+<a name="49" href="#49">49</a>  
+<a name="50" href="#50">50</a>      <em>/**<em>* Resolved QName for jcr:lastModified */</em></em>
+<a name="51" href="#51">51</a>      <strong>private</strong> String jcrLastModified;
+<a name="52" href="#52">52</a>  
+<a name="53" href="#53">53</a>      <em>/**<em>*</em></em>
+<a name="54" href="#54">54</a>  <em>     * Sets up the fixture for this test.</em>
+<a name="55" href="#55">55</a>  <em>     */</em>
+<a name="56" href="#56">56</a>      <strong>protected</strong> <strong>void</strong> setUp() throws Exception {
+<a name="57" href="#57">57</a>          <strong>super</strong>.setUp();
+<a name="58" href="#58">58</a>          ntResource = superuser.getNamespacePrefix(NS_NT_URI) + <span class="string">":resource"</span>;
+<a name="59" href="#59">59</a>          jcrEncoding = superuser.getNamespacePrefix(NS_JCR_URI) + <span class="string">":encoding"</span>;
+<a name="60" href="#60">60</a>          jcrMimeType = superuser.getNamespacePrefix(NS_JCR_URI) + <span class="string">":mimeType"</span>;
+<a name="61" href="#61">61</a>          jcrData = superuser.getNamespacePrefix(NS_JCR_URI) + <span class="string">":data"</span>;
+<a name="62" href="#62">62</a>          jcrLastModified = superuser.getNamespacePrefix(NS_JCR_URI) + <span class="string">":lastModified"</span>;
+<a name="63" href="#63">63</a>      }
+<a name="64" href="#64">64</a>  
+<a name="65" href="#65">65</a>      <em>/**<em>*</em></em>
+<a name="66" href="#66">66</a>  <em>     * Creates two nodes under {@link #TEST_DATA_PATH}: one of type</em>
+<a name="67" href="#67">67</a>  <em>     * nt:resource and a second node referencing the first.</em>
+<a name="68" href="#68">68</a>  <em>     */</em>
+<a name="69" href="#69">69</a>      <strong>public</strong> <strong>void</strong> testFillInSearchData() throws RepositoryException, IOException {
+<a name="70" href="#70">70</a>          <strong>if</strong> (superuser.getRootNode().hasNode(TEST_DATA_PATH)) {
+<a name="71" href="#71">71</a>              <em class="comment">// delete previous data</em>
+<a name="72" href="#72">72</a>              superuser.getRootNode().getNode(TEST_DATA_PATH).remove();
+<a name="73" href="#73">73</a>              superuser.save();
+<a name="74" href="#74">74</a>          }
+<a name="75" href="#75">75</a>          <em class="comment">// create nodes to testPath</em>
+<a name="76" href="#76">76</a>          StringTokenizer names = <strong>new</strong> StringTokenizer(TEST_DATA_PATH, <span class="string">"/"</span>);
+<a name="77" href="#77">77</a>          Node dataRoot = superuser.getRootNode();
+<a name="78" href="#78">78</a>          <strong>while</strong> (names.hasMoreTokens()) {
+<a name="79" href="#79">79</a>              String name = names.nextToken();
+<a name="80" href="#80">80</a>              <strong>if</strong> (!dataRoot.hasNode(name)) {
+<a name="81" href="#81">81</a>                  dataRoot = dataRoot.addNode(name, testNodeType);
+<a name="82" href="#82">82</a>              } <strong>else</strong> {
+<a name="83" href="#83">83</a>                  dataRoot = dataRoot.getNode(name);
+<a name="84" href="#84">84</a>              }
+<a name="85" href="#85">85</a>          }
+<a name="86" href="#86">86</a>  
+<a name="87" href="#87">87</a>          Node resource = dataRoot.addNode(<span class="string">"myResource"</span>, ntResource);
+<a name="88" href="#88">88</a>          resource.setProperty(jcrEncoding, <span class="string">"ISO-8859-1"</span>);
+<a name="89" href="#89">89</a>          resource.setProperty(jcrMimeType, <span class="string">"text/plain"</span>);
+<a name="90" href="#90">90</a>          ByteArrayOutputStream data = <strong>new</strong> ByteArrayOutputStream();
+<a name="91" href="#91">91</a>          OutputStreamWriter writer = <strong>new</strong> OutputStreamWriter(data, <span class="string">"ISO-8859-1"</span>);
+<a name="92" href="#92">92</a>          writer.write(<span class="string">"Hello world."</span>);
+<a name="93" href="#93">93</a>          writer.close();
+<a name="94" href="#94">94</a>          resource.setProperty(jcrData, <strong>new</strong> ByteArrayInputStream(data.toByteArray()));
+<a name="95" href="#95">95</a>          resource.setProperty(jcrLastModified, Calendar.getInstance());
+<a name="96" href="#96">96</a>          log.println(<span class="string">"Adding node: "</span> + resource.getPath());
+<a name="97" href="#97">97</a>  
+<a name="98" href="#98">98</a>          Node resReference = dataRoot.addNode(<span class="string">"reference"</span>);
+<a name="99" href="#99">99</a>          resReference.setProperty(<span class="string">"ref"</span>, resource);
+<a name="100" href="#100">100</a>         log.println(<span class="string">"Adding node: "</span> + resReference.getPath());
+<a name="101" href="#101">101</a> 
+<a name="102" href="#102">102</a>         superuser.save();
+<a name="103" href="#103">103</a>     }
+<a name="104" href="#104">104</a> }
+</pre>
+<hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
+</html>
+

Propchange: incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/NodeTestData.html
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/TestAll.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/TestAll.html?view=diff&r1=153979&r2=153980
==============================================================================
--- incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/TestAll.html (original)
+++ incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/TestAll.html Tue Feb 15 17:07:29 2005
@@ -47,10 +47,11 @@
 <a name="38" href="#38">38</a>          TestSuite suite = <strong>new</strong> TestSuite(<span class="string">"Setup data for tests"</span>);
 <a name="39" href="#39">39</a>  
 <a name="40" href="#40">40</a>          suite.addTestSuite(QueryTestData.<strong>class</strong>);
-<a name="41" href="#41">41</a>  
-<a name="42" href="#42">42</a>          <strong>return</strong> suite;
-<a name="43" href="#43">43</a>      }
-<a name="44" href="#44">44</a>  }
+<a name="41" href="#41">41</a>          suite.addTestSuite(NodeTestData.<strong>class</strong>);
+<a name="42" href="#42">42</a>  
+<a name="43" href="#43">43</a>          <strong>return</strong> suite;
+<a name="44" href="#44">44</a>      }
+<a name="45" href="#45">45</a>  }
 </pre>
 <hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
 </html>

Modified: incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/package-frame.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/package-frame.html?view=diff&r1=153979&r2=153980
==============================================================================
--- incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/package-frame.html (original)
+++ incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/package-frame.html Tue Feb 15 17:07:29 2005
@@ -18,6 +18,10 @@
       <ul>
         
           <li>
+            <a href="NodeTestData.html" target="classFrame">NodeTestData</a>
+          </li>
+        
+          <li>
             <a href="QueryTestData.html" target="classFrame">QueryTestData</a>
           </li>
         

Modified: incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/package-summary.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/package-summary.html?view=diff&r1=153979&r2=153980
==============================================================================
--- incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/package-summary.html (original)
+++ incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/init/package-summary.html Tue Feb 15 17:07:29 2005
@@ -59,6 +59,12 @@
           
             <tr>
               <td>
+                <a href="NodeTestData.html" target="classFrame">NodeTestData</a>
+              </td>
+            </tr>
+          
+            <tr>
+              <td>
                 <a href="QueryTestData.html" target="classFrame">QueryTestData</a>
               </td>
             </tr>

Modified: incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/test/AbstractJCRTest.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/test/AbstractJCRTest.html?view=diff&r1=153979&r2=153980
==============================================================================
--- incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/test/AbstractJCRTest.html (original)
+++ incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/test/AbstractJCRTest.html Tue Feb 15 17:07:29 2005
@@ -242,89 +242,93 @@
 <a name="233" href="#233">233</a>         }
 <a name="234" href="#234">234</a> 
 <a name="235" href="#235">235</a>         <strong>if</strong> (isReadOnly) {
-<a name="236" href="#236">236</a>             <strong>if</strong> (!superuser.getRootNode().hasNode(testPath)) {
-<a name="237" href="#237">237</a>                 fail(<span class="string">"Workspace does not contain test data at: "</span> + testRoot);
-<a name="238" href="#238">238</a>             }
-<a name="239" href="#239">239</a>             testRootNode = superuser.getRootNode().getNode(testPath);
-<a name="240" href="#240">240</a>         } <strong>else</strong> {
-<a name="241" href="#241">241</a>             Node root = superuser.getRootNode();
-<a name="242" href="#242">242</a>             <strong>if</strong> (root.hasNode(testPath)) {
-<a name="243" href="#243">243</a>                 <em class="comment">// clean test root</em>
-<a name="244" href="#244">244</a>                 testRootNode = root.getNode(testPath);
-<a name="245" href="#245">245</a>                 <strong>for</strong> (NodeIterator children = testRootNode.getNodes(); children.hasNext();) {
-<a name="246" href="#246">246</a>                     children.nextNode().remove();
-<a name="247" href="#247">247</a>                 }
-<a name="248" href="#248">248</a>             } <strong>else</strong> {
-<a name="249" href="#249">249</a>                 <em class="comment">// create nodes to testPath</em>
-<a name="250" href="#250">250</a>                 StringTokenizer names = <strong>new</strong> StringTokenizer(testPath, <span class="string">"/"</span>);
-<a name="251" href="#251">251</a>                 Node currentNode = root;
-<a name="252" href="#252">252</a>                 <strong>while</strong> (names.hasMoreTokens()) {
-<a name="253" href="#253">253</a>                     currentNode = currentNode.addNode(names.nextToken(), testNodeType);
-<a name="254" href="#254">254</a>                 }
-<a name="255" href="#255">255</a>                 testRootNode = currentNode;
-<a name="256" href="#256">256</a>             }
-<a name="257" href="#257">257</a>             root.save();
-<a name="258" href="#258">258</a>         }
-<a name="259" href="#259">259</a>     }
-<a name="260" href="#260">260</a> 
-<a name="261" href="#261">261</a>     <strong>protected</strong> <strong>void</strong> tearDown() throws Exception {
-<a name="262" href="#262">262</a>         <strong>if</strong> (superuser != <strong>null</strong>) {
-<a name="263" href="#263">263</a>             <strong>try</strong> {
-<a name="264" href="#264">264</a>                 <strong>if</strong> (!isReadOnly) {
-<a name="265" href="#265">265</a>                     <em class="comment">// do a 'rollback'</em>
-<a name="266" href="#266">266</a>                     superuser.refresh(false);
-<a name="267" href="#267">267</a>                     Node root = superuser.getRootNode();
-<a name="268" href="#268">268</a>                     <strong>if</strong> (root.hasNode(testPath)) {
-<a name="269" href="#269">269</a>                         <em class="comment">// clean test root</em>
-<a name="270" href="#270">270</a>                         testRootNode = root.getNode(testPath);
-<a name="271" href="#271">271</a>                         <strong>for</strong> (NodeIterator children = testRootNode.getNodes(); children.hasNext();) {
-<a name="272" href="#272">272</a>                             children.nextNode().remove();
-<a name="273" href="#273">273</a>                         }
-<a name="274" href="#274">274</a>                         root.save();
-<a name="275" href="#275">275</a>                     }
-<a name="276" href="#276">276</a>                 }
-<a name="277" href="#277">277</a>             } <strong>finally</strong> {
-<a name="278" href="#278">278</a>                 superuser.logout();
-<a name="279" href="#279">279</a>             }
-<a name="280" href="#280">280</a>         }
-<a name="281" href="#281">281</a>     }
-<a name="282" href="#282">282</a> 
-<a name="283" href="#283">283</a>     <strong>protected</strong> String getProperty(String name) throws RepositoryException {
-<a name="284" href="#284">284</a>         String testCaseName = getName();
-<a name="285" href="#285">285</a>         String testClassName = getClass().getName();
-<a name="286" href="#286">286</a>         String testPackName = <span class="string">""</span>;
-<a name="287" href="#287">287</a>         <strong>int</strong> idx;
-<a name="288" href="#288">288</a>         <strong>if</strong> ((idx = testClassName.lastIndexOf('.')) > -1) {
-<a name="289" href="#289">289</a>             testPackName = testClassName.substring(testClassName.lastIndexOf('.', idx - 1) + 1, idx);
-<a name="290" href="#290">290</a>             testClassName = testClassName.substring(idx + 1);
-<a name="291" href="#291">291</a>         }
-<a name="292" href="#292">292</a> 
-<a name="293" href="#293">293</a>         <em class="comment">// 1) test case specific property first</em>
-<a name="294" href="#294">294</a>         String value = helper.getProperty(RepositoryStub.PROP_PREFIX + <span class="string">"."</span>
-<a name="295" href="#295">295</a>                 + testClassName + <span class="string">"."</span> + testCaseName + <span class="string">"."</span> + name);
-<a name="296" href="#296">296</a>         <strong>if</strong> (value != <strong>null</strong>) {
-<a name="297" href="#297">297</a>             <strong>return</strong> value;
-<a name="298" href="#298">298</a>         }
-<a name="299" href="#299">299</a> 
-<a name="300" href="#300">300</a>         <em class="comment">// 2) check test class property</em>
-<a name="301" href="#301">301</a>         value = helper.getProperty(RepositoryStub.PROP_PREFIX + <span class="string">"."</span>
-<a name="302" href="#302">302</a>                 + testClassName + <span class="string">"."</span> + name);
-<a name="303" href="#303">303</a>         <strong>if</strong> (value != <strong>null</strong>) {
-<a name="304" href="#304">304</a>             <strong>return</strong> value;
-<a name="305" href="#305">305</a>         }
-<a name="306" href="#306">306</a> 
-<a name="307" href="#307">307</a>         <em class="comment">// 3) check package property</em>
-<a name="308" href="#308">308</a>         value = helper.getProperty(RepositoryStub.PROP_PREFIX + <span class="string">"."</span>
-<a name="309" href="#309">309</a>                 + testPackName + <span class="string">"."</span> + name);
-<a name="310" href="#310">310</a>         <strong>if</strong> (value != <strong>null</strong>) {
-<a name="311" href="#311">311</a>             <strong>return</strong> value;
-<a name="312" href="#312">312</a>         }
-<a name="313" href="#313">313</a> 
-<a name="314" href="#314">314</a>         <em class="comment">// finally try global property</em>
-<a name="315" href="#315">315</a>         <strong>return</strong> helper.getProperty(RepositoryStub.PROP_PREFIX + <span class="string">"."</span> + name);
-<a name="316" href="#316">316</a>     }
+<a name="236" href="#236">236</a>             <strong>if</strong> (testPath.length() == 0) {
+<a name="237" href="#237">237</a>                 <em class="comment">// test root is the root node</em>
+<a name="238" href="#238">238</a>                 testRootNode = superuser.getRootNode();
+<a name="239" href="#239">239</a>             } <strong>else</strong> <strong>if</strong> (!superuser.getRootNode().hasNode(testPath)) {
+<a name="240" href="#240">240</a>                 fail(<span class="string">"Workspace does not contain test data at: "</span> + testRoot);
+<a name="241" href="#241">241</a>             } <strong>else</strong> {
+<a name="242" href="#242">242</a>                 testRootNode = superuser.getRootNode().getNode(testPath);
+<a name="243" href="#243">243</a>             }
+<a name="244" href="#244">244</a>         } <strong>else</strong> {
+<a name="245" href="#245">245</a>             Node root = superuser.getRootNode();
+<a name="246" href="#246">246</a>             <strong>if</strong> (root.hasNode(testPath)) {
+<a name="247" href="#247">247</a>                 <em class="comment">// clean test root</em>
+<a name="248" href="#248">248</a>                 testRootNode = root.getNode(testPath);
+<a name="249" href="#249">249</a>                 <strong>for</strong> (NodeIterator children = testRootNode.getNodes(); children.hasNext();) {
+<a name="250" href="#250">250</a>                     children.nextNode().remove();
+<a name="251" href="#251">251</a>                 }
+<a name="252" href="#252">252</a>             } <strong>else</strong> {
+<a name="253" href="#253">253</a>                 <em class="comment">// create nodes to testPath</em>
+<a name="254" href="#254">254</a>                 StringTokenizer names = <strong>new</strong> StringTokenizer(testPath, <span class="string">"/"</span>);
+<a name="255" href="#255">255</a>                 Node currentNode = root;
+<a name="256" href="#256">256</a>                 <strong>while</strong> (names.hasMoreTokens()) {
+<a name="257" href="#257">257</a>                     currentNode = currentNode.addNode(names.nextToken(), testNodeType);
+<a name="258" href="#258">258</a>                 }
+<a name="259" href="#259">259</a>                 testRootNode = currentNode;
+<a name="260" href="#260">260</a>             }
+<a name="261" href="#261">261</a>             root.save();
+<a name="262" href="#262">262</a>         }
+<a name="263" href="#263">263</a>     }
+<a name="264" href="#264">264</a> 
+<a name="265" href="#265">265</a>     <strong>protected</strong> <strong>void</strong> tearDown() throws Exception {
+<a name="266" href="#266">266</a>         <strong>if</strong> (superuser != <strong>null</strong>) {
+<a name="267" href="#267">267</a>             <strong>try</strong> {
+<a name="268" href="#268">268</a>                 <strong>if</strong> (!isReadOnly) {
+<a name="269" href="#269">269</a>                     <em class="comment">// do a 'rollback'</em>
+<a name="270" href="#270">270</a>                     superuser.refresh(false);
+<a name="271" href="#271">271</a>                     Node root = superuser.getRootNode();
+<a name="272" href="#272">272</a>                     <strong>if</strong> (root.hasNode(testPath)) {
+<a name="273" href="#273">273</a>                         <em class="comment">// clean test root</em>
+<a name="274" href="#274">274</a>                         testRootNode = root.getNode(testPath);
+<a name="275" href="#275">275</a>                         <strong>for</strong> (NodeIterator children = testRootNode.getNodes(); children.hasNext();) {
+<a name="276" href="#276">276</a>                             children.nextNode().remove();
+<a name="277" href="#277">277</a>                         }
+<a name="278" href="#278">278</a>                         root.save();
+<a name="279" href="#279">279</a>                     }
+<a name="280" href="#280">280</a>                 }
+<a name="281" href="#281">281</a>             } <strong>finally</strong> {
+<a name="282" href="#282">282</a>                 superuser.logout();
+<a name="283" href="#283">283</a>             }
+<a name="284" href="#284">284</a>         }
+<a name="285" href="#285">285</a>     }
+<a name="286" href="#286">286</a> 
+<a name="287" href="#287">287</a>     <strong>protected</strong> String getProperty(String name) throws RepositoryException {
+<a name="288" href="#288">288</a>         String testCaseName = getName();
+<a name="289" href="#289">289</a>         String testClassName = getClass().getName();
+<a name="290" href="#290">290</a>         String testPackName = <span class="string">""</span>;
+<a name="291" href="#291">291</a>         <strong>int</strong> idx;
+<a name="292" href="#292">292</a>         <strong>if</strong> ((idx = testClassName.lastIndexOf('.')) > -1) {
+<a name="293" href="#293">293</a>             testPackName = testClassName.substring(testClassName.lastIndexOf('.', idx - 1) + 1, idx);
+<a name="294" href="#294">294</a>             testClassName = testClassName.substring(idx + 1);
+<a name="295" href="#295">295</a>         }
+<a name="296" href="#296">296</a> 
+<a name="297" href="#297">297</a>         <em class="comment">// 1) test case specific property first</em>
+<a name="298" href="#298">298</a>         String value = helper.getProperty(RepositoryStub.PROP_PREFIX + <span class="string">"."</span>
+<a name="299" href="#299">299</a>                 + testClassName + <span class="string">"."</span> + testCaseName + <span class="string">"."</span> + name);
+<a name="300" href="#300">300</a>         <strong>if</strong> (value != <strong>null</strong>) {
+<a name="301" href="#301">301</a>             <strong>return</strong> value;
+<a name="302" href="#302">302</a>         }
+<a name="303" href="#303">303</a> 
+<a name="304" href="#304">304</a>         <em class="comment">// 2) check test class property</em>
+<a name="305" href="#305">305</a>         value = helper.getProperty(RepositoryStub.PROP_PREFIX + <span class="string">"."</span>
+<a name="306" href="#306">306</a>                 + testClassName + <span class="string">"."</span> + name);
+<a name="307" href="#307">307</a>         <strong>if</strong> (value != <strong>null</strong>) {
+<a name="308" href="#308">308</a>             <strong>return</strong> value;
+<a name="309" href="#309">309</a>         }
+<a name="310" href="#310">310</a> 
+<a name="311" href="#311">311</a>         <em class="comment">// 3) check package property</em>
+<a name="312" href="#312">312</a>         value = helper.getProperty(RepositoryStub.PROP_PREFIX + <span class="string">"."</span>
+<a name="313" href="#313">313</a>                 + testPackName + <span class="string">"."</span> + name);
+<a name="314" href="#314">314</a>         <strong>if</strong> (value != <strong>null</strong>) {
+<a name="315" href="#315">315</a>             <strong>return</strong> value;
+<a name="316" href="#316">316</a>         }
 <a name="317" href="#317">317</a> 
-<a name="318" href="#318">318</a> }
+<a name="318" href="#318">318</a>         <em class="comment">// finally try global property</em>
+<a name="319" href="#319">319</a>         <strong>return</strong> helper.getProperty(RepositoryStub.PROP_PREFIX + <span class="string">"."</span> + name);
+<a name="320" href="#320">320</a>     }
+<a name="321" href="#321">321</a> 
+<a name="322" href="#322">322</a> }
 </pre>
 <hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
 </html>

Added: incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/test/api/ItemDefTest.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/test/api/ItemDefTest.html?view=auto&rev=153980
==============================================================================
--- incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/test/api/ItemDefTest.html (added)
+++ incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/test/api/ItemDefTest.html Tue Feb 15 17:07:29 2005
@@ -0,0 +1,165 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /><title>ItemDefTest xref</title>
+<link type="text/css" rel="stylesheet" href="../../../../../stylesheet.css" />
+</head>
+<body>
+<pre>
+
+<a name="1" href="#1">1</a>   <em class="comment">/*</em>
+<a name="2" href="#2">2</a>   <em class="comment"> * Copyright 2004-2005 The Apache Software Foundation or its licensors,</em>
+<a name="3" href="#3">3</a>   <em class="comment"> *                     as applicable.</em>
+<a name="4" href="#4">4</a>   <em class="comment"> *</em>
+<a name="5" href="#5">5</a>   <em class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</em>
+<a name="6" href="#6">6</a>   <em class="comment"> * you may not use this file except in compliance with the License.</em>
+<a name="7" href="#7">7</a>   <em class="comment"> * You may obtain a copy of the License at</em>
+<a name="8" href="#8">8</a>   <em class="comment"> *</em>
+<a name="9" href="#9">9</a>   <em class="comment"> *      <a href="http://www.apache.org/licenses/LICENSE-2.0" target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.0</a></em>
+<a name="10" href="#10">10</a>  <em class="comment"> *</em>
+<a name="11" href="#11">11</a>  <em class="comment"> * Unless required by applicable law or agreed to in writing, software</em>
+<a name="12" href="#12">12</a>  <em class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</em>
+<a name="13" href="#13">13</a>  <em class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</em>
+<a name="14" href="#14">14</a>  <em class="comment"> * See the License for the specific language governing permissions and</em>
+<a name="15" href="#15">15</a>  <em class="comment"> * limitations under the License.</em>
+<a name="16" href="#16">16</a>  <em class="comment"> */</em>
+<a name="17" href="#17">17</a>  <strong>package</strong> <a href="../../../../../org/apache/jackrabbit/test/api/package-summary.html">org.apache.jackrabbit.test.api</a>;
+<a name="18" href="#18">18</a>  
+<a name="19" href="#19">19</a>  <strong>import</strong> org.apache.jackrabbit.test.AbstractJCRTest;
+<a name="20" href="#20">20</a>  <strong>import</strong> org.apache.jackrabbit.test.NotExecutableException;
+<a name="21" href="#21">21</a>  
+<a name="22" href="#22">22</a>  <strong>import</strong> javax.jcr.Session;
+<a name="23" href="#23">23</a>  <strong>import</strong> javax.jcr.RepositoryException;
+<a name="24" href="#24">24</a>  <strong>import</strong> javax.jcr.Node;
+<a name="25" href="#25">25</a>  <strong>import</strong> javax.jcr.NodeIterator;
+<a name="26" href="#26">26</a>  <strong>import</strong> javax.jcr.Property;
+<a name="27" href="#27">27</a>  <strong>import</strong> javax.jcr.PathNotFoundException;
+<a name="28" href="#28">28</a>  <strong>import</strong> javax.jcr.nodetype.NodeType;
+<a name="29" href="#29">29</a>  <strong>import</strong> javax.jcr.nodetype.PropertyDef;
+<a name="30" href="#30">30</a>  <strong>import</strong> javax.jcr.nodetype.NodeDef;
+<a name="31" href="#31">31</a>  
+<a name="32" href="#32">32</a>  <em>/**<em>*</em></em>
+<a name="33" href="#33">33</a>  <em> * This test checks if item definitions with mandatory constraints are</em>
+<a name="34" href="#34">34</a>  <em> * respected.</em>
+<a name="35" href="#35">35</a>  <em> * &lt;p/></em>
+<a name="36" href="#36">36</a>  <em> * If the default workspace does not contain a node with a node type definition</em>
+<a name="37" href="#37">37</a>  <em> * that specifies a mandatory child node a {@link NotExecutableException} is</em>
+<a name="38" href="#38">38</a>  <em> * thrown. If the default workspace does not contain a node with a node type</em>
+<a name="39" href="#39">39</a>  <em> * definition that specifies a mandatory property a {@link NotExecutableException}</em>
+<a name="40" href="#40">40</a>  <em> * is thrown.</em>
+<a name="41" href="#41">41</a>  <em> *</em>
+<a name="42" href="#42">42</a>  <em> * @test</em>
+<a name="43" href="#43">43</a>  <em> * @sources ItemDefTest.java</em>
+<a name="44" href="#44">44</a>  <em> * @executeClass org.apache.jackrabbit.test.api.ItemDefTest</em>
+<a name="45" href="#45">45</a>  <em> * @keywords level1</em>
+<a name="46" href="#46">46</a>  <em> */</em>
+<a name="47" href="#47">47</a>  <strong>public</strong> <strong>class</strong> <a href="../../../../../org/apache/jackrabbit/test/api/ItemDefTest.html">ItemDefTest</a> <strong>extends</strong> <a href="../../../../../org/apache/jackrabbit/test/AbstractJCRTest.html">AbstractJCRTest</a> {
+<a name="48" href="#48">48</a>  
+<a name="49" href="#49">49</a>      <em>/**<em>* If &lt;code>true&lt;/code> indicates that the test found a mandatory node */</em></em>
+<a name="50" href="#50">50</a>      <strong>private</strong> <strong>boolean</strong> foundMandatoryNode = false;
+<a name="51" href="#51">51</a>  
+<a name="52" href="#52">52</a>      <em>/**<em>* If &lt;code>true&lt;/code> indicates that the test found a mandatory property */</em></em>
+<a name="53" href="#53">53</a>      <strong>private</strong> <strong>boolean</strong> foundMandatoryProperty = false;
+<a name="54" href="#54">54</a>  
+<a name="55" href="#55">55</a>      <em>/**<em>*</em></em>
+<a name="56" href="#56">56</a>  <em>     * Sets up the fixture for this test.</em>
+<a name="57" href="#57">57</a>  <em>     */</em>
+<a name="58" href="#58">58</a>      <strong>protected</strong> <strong>void</strong> setUp() throws Exception {
+<a name="59" href="#59">59</a>          isReadOnly = <strong>true</strong>;
+<a name="60" href="#60">60</a>          <strong>super</strong>.setUp();
+<a name="61" href="#61">61</a>      }
+<a name="62" href="#62">62</a>  
+<a name="63" href="#63">63</a>      <em>/**<em>*</em></em>
+<a name="64" href="#64">64</a>  <em>     * Tests if a node's mandatory properties and nodes are legally set. The</em>
+<a name="65" href="#65">65</a>  <em>     * information which properties and nodes are mandatory is taken from the</em>
+<a name="66" href="#66">66</a>  <em>     * node's primary and mixin node types. This test runs recursively through</em>
+<a name="67" href="#67">67</a>  <em>     * the entire repository.</em>
+<a name="68" href="#68">68</a>  <em>     */</em>
+<a name="69" href="#69">69</a>      <strong>public</strong> <strong>void</strong> testIsMandatory() throws RepositoryException, NotExecutableException {
+<a name="70" href="#70">70</a>          <em class="comment">//Session session=superuser;</em>
+<a name="71" href="#71">71</a>          Session session = helper.getReadOnlySession();
+<a name="72" href="#72">72</a>          Node root = session.getRootNode();
+<a name="73" href="#73">73</a>          traverse(root);
+<a name="74" href="#74">74</a>          <strong>if</strong> (!foundMandatoryNode) {
+<a name="75" href="#75">75</a>              <strong>throw</strong> <strong>new</strong> <a href="../../../../../org/apache/jackrabbit/test/NotExecutableException.html">NotExecutableException</a>(<span class="string">"Workspace does not contain any node with a mandatory child node definition"</span>);
+<a name="76" href="#76">76</a>          }
+<a name="77" href="#77">77</a>          <strong>if</strong> (!foundMandatoryProperty) {
+<a name="78" href="#78">78</a>              <strong>throw</strong> <strong>new</strong> <a href="../../../../../org/apache/jackrabbit/test/NotExecutableException.html">NotExecutableException</a>(<span class="string">"Workspace does not contain any node with a mandatory property definition"</span>);
+<a name="79" href="#79">79</a>          }
+<a name="80" href="#80">80</a>      }
+<a name="81" href="#81">81</a>  
+<a name="82" href="#82">82</a>      <em>/**<em>*</em></em>
+<a name="83" href="#83">83</a>  <em>     * Traverses the node hierarchy and applies {@link #checkMandatoryConstraint(javax.jcr.Node, javax.jcr.nodetype.NodeType)}</em>
+<a name="84" href="#84">84</a>  <em>     * to all descendant nodes of &lt;code>parentNode&lt;/code>.</em>
+<a name="85" href="#85">85</a>  <em>     */</em>
+<a name="86" href="#86">86</a>      <strong>private</strong> <strong>void</strong> traverse(Node parentNode)
+<a name="87" href="#87">87</a>              throws RepositoryException {
+<a name="88" href="#88">88</a>  
+<a name="89" href="#89">89</a>          NodeIterator nodes = parentNode.getNodes();
+<a name="90" href="#90">90</a>          <strong>while</strong> (nodes.hasNext()) {
+<a name="91" href="#91">91</a>              Node node = nodes.nextNode();
+<a name="92" href="#92">92</a>  
+<a name="93" href="#93">93</a>              NodeType primeType = node.getPrimaryNodeType();
+<a name="94" href="#94">94</a>              checkMandatoryConstraint(node, primeType);
+<a name="95" href="#95">95</a>  
+<a name="96" href="#96">96</a>              NodeType mixins[] = node.getMixinNodeTypes();
+<a name="97" href="#97">97</a>              <strong>for</strong> (<strong>int</strong> i = 0; i &lt; mixins.length; i++) {
+<a name="98" href="#98">98</a>                  checkMandatoryConstraint(node, mixins[i]);
+<a name="99" href="#99">99</a>              }
+<a name="100" href="#100">100</a> 
+<a name="101" href="#101">101</a>             traverse(node);
+<a name="102" href="#102">102</a>         }
+<a name="103" href="#103">103</a>     }
+<a name="104" href="#104">104</a> 
+<a name="105" href="#105">105</a>     <em>/**<em>*</em></em>
+<a name="106" href="#106">106</a> <em>     * Checks if mandatory node / property definitions are respected.</em>
+<a name="107" href="#107">107</a> <em>     */</em>
+<a name="108" href="#108">108</a>     <strong>private</strong> <strong>void</strong> checkMandatoryConstraint(Node node, NodeType type)
+<a name="109" href="#109">109</a>             throws RepositoryException {
+<a name="110" href="#110">110</a> 
+<a name="111" href="#111">111</a>         <em class="comment">// test if node contains all mandatory properties of current type</em>
+<a name="112" href="#112">112</a>         PropertyDef propDefs[] = type.getPropertyDefs();
+<a name="113" href="#113">113</a>         <strong>for</strong> (<strong>int</strong> i = 0; i &lt; propDefs.length; i++) {
+<a name="114" href="#114">114</a>             PropertyDef propDef = propDefs[i];
+<a name="115" href="#115">115</a> 
+<a name="116" href="#116">116</a>             <strong>if</strong> (propDef.isMandatory()) {
+<a name="117" href="#117">117</a>                 foundMandatoryProperty = <strong>true</strong>;
+<a name="118" href="#118">118</a>                 String name = propDef.getName();
+<a name="119" href="#119">119</a> 
+<a name="120" href="#120">120</a>                 <strong>try</strong> {
+<a name="121" href="#121">121</a>                     Property p = node.getProperty(name);
+<a name="122" href="#122">122</a>                     <strong>if</strong> (propDef.isMultiple()) {
+<a name="123" href="#123">123</a>                         <em class="comment">// empty array fails</em>
+<a name="124" href="#124">124</a>                         assertFalse(<span class="string">"A mandatory and multiple property "</span> +
+<a name="125" href="#125">125</a>                                 <span class="string">"must not be empty."</span>,
+<a name="126" href="#126">126</a>                                 p.getValues().length == 0);
+<a name="127" href="#127">127</a>                     } <strong>else</strong> {
+<a name="128" href="#128">128</a>                         <em class="comment">// empty value fails</em>
+<a name="129" href="#129">129</a>                         assertNotNull(<span class="string">"A mandatory property must have a value"</span>,
+<a name="130" href="#130">130</a>                                 p.getValue());
+<a name="131" href="#131">131</a>                     }
+<a name="132" href="#132">132</a>                 } <strong>catch</strong> (PathNotFoundException e) {
+<a name="133" href="#133">133</a>                     fail(<span class="string">"Mandatory property "</span> + name + <span class="string">" does not exist."</span>);
+<a name="134" href="#134">134</a>                 }
+<a name="135" href="#135">135</a>             }
+<a name="136" href="#136">136</a>         }
+<a name="137" href="#137">137</a> 
+<a name="138" href="#138">138</a>         <em class="comment">// test if node contains all mandatory nodes of current type</em>
+<a name="139" href="#139">139</a>         NodeDef nodeDefs[] = type.getChildNodeDefs();
+<a name="140" href="#140">140</a>         <strong>for</strong> (<strong>int</strong> i = 0; i &lt; nodeDefs.length; i++) {
+<a name="141" href="#141">141</a>             NodeDef nodeDef = nodeDefs[i];
+<a name="142" href="#142">142</a>             <strong>if</strong> (nodeDef.isMandatory()) {
+<a name="143" href="#143">143</a>                 foundMandatoryNode = <strong>true</strong>;
+<a name="144" href="#144">144</a>                 <strong>try</strong> {
+<a name="145" href="#145">145</a>                     node.getNode(nodeDef.getName());
+<a name="146" href="#146">146</a>                 } <strong>catch</strong> (PathNotFoundException e) {
+<a name="147" href="#147">147</a>                     fail(<span class="string">"Mandatory child "</span> + nodeDef.getName() + <span class="string">" for "</span> + node.getPath() + <span class="string">" does not exist."</span>);
+<a name="148" href="#148">148</a>                 }
+<a name="149" href="#149">149</a>             }
+<a name="150" href="#150">150</a>         }
+<a name="151" href="#151">151</a>     }
+<a name="152" href="#152">152</a> }
+</pre>
+<hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
+</html>
+

Propchange: incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/test/api/ItemDefTest.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/test/api/ItemReadMethodsTest.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/test/api/ItemReadMethodsTest.html?view=auto&rev=153980
==============================================================================
--- incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/test/api/ItemReadMethodsTest.html (added)
+++ incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/test/api/ItemReadMethodsTest.html Tue Feb 15 17:07:29 2005
@@ -0,0 +1,203 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /><title>ItemReadMethodsTest xref</title>
+<link type="text/css" rel="stylesheet" href="../../../../../stylesheet.css" />
+</head>
+<body>
+<pre>
+
+<a name="1" href="#1">1</a>   <em class="comment">/*</em>
+<a name="2" href="#2">2</a>   <em class="comment"> * Copyright 2004-2005 The Apache Software Foundation or its licensors,</em>
+<a name="3" href="#3">3</a>   <em class="comment"> *                     as applicable.</em>
+<a name="4" href="#4">4</a>   <em class="comment"> *</em>
+<a name="5" href="#5">5</a>   <em class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</em>
+<a name="6" href="#6">6</a>   <em class="comment"> * you may not use this file except in compliance with the License.</em>
+<a name="7" href="#7">7</a>   <em class="comment"> * You may obtain a copy of the License at</em>
+<a name="8" href="#8">8</a>   <em class="comment"> *</em>
+<a name="9" href="#9">9</a>   <em class="comment"> *      <a href="http://www.apache.org/licenses/LICENSE-2.0" target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.0</a></em>
+<a name="10" href="#10">10</a>  <em class="comment"> *</em>
+<a name="11" href="#11">11</a>  <em class="comment"> * Unless required by applicable law or agreed to in writing, software</em>
+<a name="12" href="#12">12</a>  <em class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</em>
+<a name="13" href="#13">13</a>  <em class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</em>
+<a name="14" href="#14">14</a>  <em class="comment"> * See the License for the specific language governing permissions and</em>
+<a name="15" href="#15">15</a>  <em class="comment"> * limitations under the License.</em>
+<a name="16" href="#16">16</a>  <em class="comment"> */</em>
+<a name="17" href="#17">17</a>  <strong>package</strong> <a href="../../../../../org/apache/jackrabbit/test/api/package-summary.html">org.apache.jackrabbit.test.api</a>;
+<a name="18" href="#18">18</a>  
+<a name="19" href="#19">19</a>  <strong>import</strong> org.apache.jackrabbit.test.AbstractJCRTest;
+<a name="20" href="#20">20</a>  <strong>import</strong> org.apache.jackrabbit.test.NotExecutableException;
+<a name="21" href="#21">21</a>  
+<a name="22" href="#22">22</a>  <strong>import</strong> javax.jcr.Session;
+<a name="23" href="#23">23</a>  <strong>import</strong> javax.jcr.Item;
+<a name="24" href="#24">24</a>  <strong>import</strong> javax.jcr.Property;
+<a name="25" href="#25">25</a>  <strong>import</strong> javax.jcr.NodeIterator;
+<a name="26" href="#26">26</a>  <strong>import</strong> javax.jcr.Node;
+<a name="27" href="#27">27</a>  <strong>import</strong> javax.jcr.PropertyIterator;
+<a name="28" href="#28">28</a>  <strong>import</strong> javax.jcr.RepositoryException;
+<a name="29" href="#29">29</a>  <strong>import</strong> javax.jcr.PathNotFoundException;
+<a name="30" href="#30">30</a>  <strong>import</strong> javax.jcr.ItemNotFoundException;
+<a name="31" href="#31">31</a>  <strong>import</strong> java.util.NoSuchElementException;
+<a name="32" href="#32">32</a>  
+<a name="33" href="#33">33</a>  <em>/**<em>*</em></em>
+<a name="34" href="#34">34</a>  <em> * Tests the 'read' methods specified in the {@link javax.jcr.Item} interface</em>
+<a name="35" href="#35">35</a>  <em> * on a level 1 repository.</em>
+<a name="36" href="#36">36</a>  <em> * &lt;p/></em>
+<a name="37" href="#37">37</a>  <em> * The root node of the default workspace must have at least one child node,</em>
+<a name="38" href="#38">38</a>  <em> * otherwise a {@link org.apache.jackrabbit.test.NotExecutableException} is</em>
+<a name="39" href="#39">39</a>  <em> * thrown.</em>
+<a name="40" href="#40">40</a>  <em> *</em>
+<a name="41" href="#41">41</a>  <em> * @test</em>
+<a name="42" href="#42">42</a>  <em> * @sources ItemReadMethodsTest.java</em>
+<a name="43" href="#43">43</a>  <em> * @executeClass org.apache.jackrabbit.test.api.ItemReadMethodsTest</em>
+<a name="44" href="#44">44</a>  <em> * @keywords level1</em>
+<a name="45" href="#45">45</a>  <em> */</em>
+<a name="46" href="#46">46</a>  <strong>public</strong> <strong>class</strong> <a href="../../../../../org/apache/jackrabbit/test/api/ItemReadMethodsTest.html">ItemReadMethodsTest</a> <strong>extends</strong> <a href="../../../../../org/apache/jackrabbit/test/AbstractJCRTest.html">AbstractJCRTest</a> {
+<a name="47" href="#47">47</a>  
+<a name="48" href="#48">48</a>      <em>/**<em>* Session to access the workspace */</em></em>
+<a name="49" href="#49">49</a>      <strong>private</strong> Session session;
+<a name="50" href="#50">50</a>  
+<a name="51" href="#51">51</a>      <em>/**<em>* The primary test item */</em></em>
+<a name="52" href="#52">52</a>      <strong>private</strong> Item item;
+<a name="53" href="#53">53</a>  
+<a name="54" href="#54">54</a>      <em>/**<em>* A child item of the primary test item */</em></em>
+<a name="55" href="#55">55</a>      <strong>private</strong> Item childItem;
+<a name="56" href="#56">56</a>  
+<a name="57" href="#57">57</a>      <em>/**<em>* A property of the primary test item */</em></em>
+<a name="58" href="#58">58</a>      <strong>private</strong> Property childProperty;
+<a name="59" href="#59">59</a>  
+<a name="60" href="#60">60</a>      <em>/**<em>*</em></em>
+<a name="61" href="#61">61</a>  <em>     * Sets up the fixture for this test.</em>
+<a name="62" href="#62">62</a>  <em>     */</em>
+<a name="63" href="#63">63</a>      <strong>protected</strong> <strong>void</strong> setUp() throws Exception {
+<a name="64" href="#64">64</a>          isReadOnly = <strong>true</strong>;
+<a name="65" href="#65">65</a>          <strong>super</strong>.setUp();
+<a name="66" href="#66">66</a>  
+<a name="67" href="#67">67</a>          session = helper.getReadOnlySession();
+<a name="68" href="#68">68</a>          item = session.getRootNode();
+<a name="69" href="#69">69</a>  
+<a name="70" href="#70">70</a>          NodeIterator nodes = ((Node) item).getNodes();
+<a name="71" href="#71">71</a>          <strong>try</strong> {
+<a name="72" href="#72">72</a>              childItem = nodes.nextNode();
+<a name="73" href="#73">73</a>          } <strong>catch</strong> (NoSuchElementException e) {
+<a name="74" href="#74">74</a>              <strong>throw</strong> <strong>new</strong> <a href="../../../../../org/apache/jackrabbit/test/NotExecutableException.html">NotExecutableException</a>(<span class="string">"Workspace does not have sufficient content to run this test."</span>);
+<a name="75" href="#75">75</a>          }
+<a name="76" href="#76">76</a>  
+<a name="77" href="#77">77</a>          PropertyIterator properties = ((Node) item).getProperties();
+<a name="78" href="#78">78</a>          <strong>try</strong> {
+<a name="79" href="#79">79</a>              childProperty = properties.nextProperty();
+<a name="80" href="#80">80</a>          } <strong>catch</strong> (NoSuchElementException e) {
+<a name="81" href="#81">81</a>              fail(<span class="string">"Any node must have at least one property set: jcr:primaryType"</span>);
+<a name="82" href="#82">82</a>          }
+<a name="83" href="#83">83</a>      }
+<a name="84" href="#84">84</a>  
+<a name="85" href="#85">85</a>      <em>/**<em>*</em></em>
+<a name="86" href="#86">86</a>  <em>     * Tests if getPath() returns the correct path.</em>
+<a name="87" href="#87">87</a>  <em>     */</em>
+<a name="88" href="#88">88</a>      <strong>public</strong> <strong>void</strong> testGetPath() throws RepositoryException {
+<a name="89" href="#89">89</a>          String path = childItem.getPath();
+<a name="90" href="#90">90</a>          String notation = <span class="string">""</span>;
+<a name="91" href="#91">91</a>  
+<a name="92" href="#92">92</a>          <strong>try</strong> {
+<a name="93" href="#93">93</a>              <em class="comment">// check for same named sibling of childItem</em>
+<a name="94" href="#94">94</a>              ((Node) item).getNode(childItem.getName() + <span class="string">"[2]"</span>);
+<a name="95" href="#95">95</a>              notation = <span class="string">"[1]"</span>;
+<a name="96" href="#96">96</a>          } <strong>catch</strong> (PathNotFoundException e) {
+<a name="97" href="#97">97</a>          }
+<a name="98" href="#98">98</a>  
+<a name="99" href="#99">99</a>          <strong>if</strong> (path.indexOf(<span class="string">"["</span>) != -1) {
+<a name="100" href="#100">100</a>             notation = path.substring(path.indexOf(<span class="string">"["</span>));
+<a name="101" href="#101">101</a>         }
+<a name="102" href="#102">102</a>         assertEquals(<span class="string">"getPath returns wrong result"</span>,
+<a name="103" href="#103">103</a>                 <span class="string">"/"</span> + childItem.getName() + notation,
+<a name="104" href="#104">104</a>                 childItem.getPath());
+<a name="105" href="#105">105</a>     }
+<a name="106" href="#106">106</a> 
+<a name="107" href="#107">107</a>     <em>/**<em>*</em></em>
+<a name="108" href="#108">108</a> <em>     * Tests if getName() returns same as last name returned by getPath()</em>
+<a name="109" href="#109">109</a> <em>     */</em>
+<a name="110" href="#110">110</a>     <strong>public</strong> <strong>void</strong> testGetName() throws RepositoryException {
+<a name="111" href="#111">111</a>         assertEquals(<span class="string">"getName() of root must be an empty string"</span>,
+<a name="112" href="#112">112</a>                 <span class="string">""</span>,
+<a name="113" href="#113">113</a>                 item.getName());
+<a name="114" href="#114">114</a> 
+<a name="115" href="#115">115</a>         <em class="comment">// build name from path</em>
+<a name="116" href="#116">116</a>         String path = childItem.getPath();
+<a name="117" href="#117">117</a>         String name = path.substring(path.lastIndexOf(<span class="string">"/"</span>) + 1);
+<a name="118" href="#118">118</a>         <strong>if</strong> (name.indexOf(<span class="string">"["</span>) != -1) {
+<a name="119" href="#119">119</a>             name = name.substring(0, name.indexOf(<span class="string">"["</span>));
+<a name="120" href="#120">120</a>         }
+<a name="121" href="#121">121</a>         assertEquals(<span class="string">"getName() must be the same as the last item in the path"</span>,
+<a name="122" href="#122">122</a>                 name,
+<a name="123" href="#123">123</a>                 childItem.getName());
+<a name="124" href="#124">124</a>     }
+<a name="125" href="#125">125</a> 
+<a name="126" href="#126">126</a>     <em>/**<em>*</em></em>
+<a name="127" href="#127">127</a> <em>     * Tests if getItem(x).getParent() is item itself</em>
+<a name="128" href="#128">128</a> <em>     */</em>
+<a name="129" href="#129">129</a>     <strong>public</strong> <strong>void</strong> testGetParent() throws RepositoryException {
+<a name="130" href="#130">130</a>         assertSame(<span class="string">"getParent() of a child item must be the item itself."</span>,
+<a name="131" href="#131">131</a>                 item, childItem.getParent());
+<a name="132" href="#132">132</a>     }
+<a name="133" href="#133">133</a> 
+<a name="134" href="#134">134</a>     <em>/**<em>*</em></em>
+<a name="135" href="#135">135</a> <em>     * Tests if getParent() of root throws an ItemNotFoundException</em>
+<a name="136" href="#136">136</a> <em>     */</em>
+<a name="137" href="#137">137</a>     <strong>public</strong> <strong>void</strong> testGetParentOfRoot() throws RepositoryException {
+<a name="138" href="#138">138</a>         <strong>try</strong> {
+<a name="139" href="#139">139</a>             item.getParent();
+<a name="140" href="#140">140</a>             fail(<span class="string">"getParent() of root must throw an ItemNotFoundException."</span>);
+<a name="141" href="#141">141</a>         } <strong>catch</strong> (ItemNotFoundException e) {
+<a name="142" href="#142">142</a>             <em class="comment">// success</em>
+<a name="143" href="#143">143</a>         }
+<a name="144" href="#144">144</a>     }
+<a name="145" href="#145">145</a> 
+<a name="146" href="#146">146</a>     <em>/**<em>*</em></em>
+<a name="147" href="#147">147</a> <em>     * Tests if depth of root is 0 and depth of a sub item of root is 1</em>
+<a name="148" href="#148">148</a> <em>     */</em>
+<a name="149" href="#149">149</a>     <strong>public</strong> <strong>void</strong> testGetDepth() throws RepositoryException {
+<a name="150" href="#150">150</a>         assertEquals(<span class="string">"getDepth() of root must be 0"</span>, 0, item.getDepth());
+<a name="151" href="#151">151</a>         assertEquals(<span class="string">"getDepth() of child item of root must be 1"</span>, 1,
+<a name="152" href="#152">152</a>                 childItem.getDepth());
+<a name="153" href="#153">153</a>     }
+<a name="154" href="#154">154</a> 
+<a name="155" href="#155">155</a>     <em>/**<em>*</em></em>
+<a name="156" href="#156">156</a> <em>     * Tests if getSession() is same as through which the Item was acquired</em>
+<a name="157" href="#157">157</a> <em>     */</em>
+<a name="158" href="#158">158</a>     <strong>public</strong> <strong>void</strong> testGetSession() throws RepositoryException {
+<a name="159" href="#159">159</a>         assertSame(<span class="string">"getSession must return the Session through which "</span> +
+<a name="160" href="#160">160</a>                 <span class="string">"the Item was acquired."</span>,
+<a name="161" href="#161">161</a>                 item.getSession(),
+<a name="162" href="#162">162</a>                 session);
+<a name="163" href="#163">163</a>     }
+<a name="164" href="#164">164</a> 
+<a name="165" href="#165">165</a>     <em>/**<em>*</em></em>
+<a name="166" href="#166">166</a> <em>     * Tests if isNode() returns true if the Item is a node and false if it is a</em>
+<a name="167" href="#167">167</a> <em>     * property</em>
+<a name="168" href="#168">168</a> <em>     */</em>
+<a name="169" href="#169">169</a>     <strong>public</strong> <strong>void</strong> testIsNode() {
+<a name="170" href="#170">170</a>         assertTrue(<span class="string">"isNode() must return true if Item is a node."</span>,
+<a name="171" href="#171">171</a>                 childItem.isNode());
+<a name="172" href="#172">172</a>         assertFalse(<span class="string">"isNode() must return false if Item is a property."</span>,
+<a name="173" href="#173">173</a>                 childProperty.isNode());
+<a name="174" href="#174">174</a>     }
+<a name="175" href="#175">175</a> 
+<a name="176" href="#176">176</a>     <em>/**<em>*</em></em>
+<a name="177" href="#177">177</a> <em>     * Tests if isSame() returns true when retrieving an item through different</em>
+<a name="178" href="#178">178</a> <em>     * sessions</em>
+<a name="179" href="#179">179</a> <em>     */</em>
+<a name="180" href="#180">180</a>     <strong>public</strong> <strong>void</strong> testIsSame() throws RepositoryException {
+<a name="181" href="#181">181</a>         assertFalse(<span class="string">"isSame(Item item) must return false for different items."</span>,
+<a name="182" href="#182">182</a>                 item.isSame(childItem));
+<a name="183" href="#183">183</a> 
+<a name="184" href="#184">184</a>         <em class="comment">// access same item (root) through different session</em>
+<a name="185" href="#185">185</a>         Item otherItem = helper.getReadOnlySession().getRootNode();
+<a name="186" href="#186">186</a>         assertTrue(<span class="string">"isSame(Item item) must return true for the same "</span> +
+<a name="187" href="#187">187</a>                 <span class="string">"item retrieved through different sessions."</span>,
+<a name="188" href="#188">188</a>                 item.isSame(otherItem));
+<a name="189" href="#189">189</a>     }
+<a name="190" href="#190">190</a> }
+</pre>
+<hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
+</html>
+

Propchange: incubator/jackrabbit/site/xref-test/org/apache/jackrabbit/test/api/ItemReadMethodsTest.html
------------------------------------------------------------------------------
    svn:eol-style = native