Author: justin
Date: Mon Mar 15 20:12:49 2010
New Revision: 923417

URL: http://svn.apache.org/viewvc?rev=923417&view=rev
Log:
SLING-1393 - adding davex module and test content loading support

Added:
    sling/trunk/bundles/jcr/davex/
    sling/trunk/bundles/jcr/davex/LICENSE
    sling/trunk/bundles/jcr/davex/NOTICE
    sling/trunk/bundles/jcr/davex/README.txt
    sling/trunk/bundles/jcr/davex/pom.xml
    sling/trunk/bundles/jcr/davex/src/
    sling/trunk/bundles/jcr/davex/src/main/
    sling/trunk/bundles/jcr/davex/src/main/java/
    sling/trunk/bundles/jcr/davex/src/main/java/org/
    sling/trunk/bundles/jcr/davex/src/main/java/org/apache/
    sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/
    sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/
    sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/
    sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/impl/
    
sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/impl/servlets/
    
sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
    sling/trunk/bundles/jcr/davex/src/main/resources/
    sling/trunk/bundles/jcr/davex/src/main/resources/OSGI-INF/
    sling/trunk/bundles/jcr/davex/src/main/resources/OSGI-INF/metatype/
    
sling/trunk/bundles/jcr/davex/src/main/resources/OSGI-INF/metatype/metatype.properties
    
sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/TestContentLoader.java
    
sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/TestContentLoaderImpl.java
    
sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/jcr/StartupTestContentLoader.java
    
sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/DavExIntegrationTest.java
Modified:
    sling/trunk/bundles/jcr/jackrabbit-server/pom.xml
    sling/trunk/launchpad/builder/src/main/bundles/list.xml
    sling/trunk/launchpad/test-services/pom.xml
    sling/trunk/launchpad/testing/pom.xml
    sling/trunk/pom.xml

Added: sling/trunk/bundles/jcr/davex/LICENSE
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/davex/LICENSE?rev=923417&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/davex/LICENSE (added)
+++ sling/trunk/bundles/jcr/davex/LICENSE Mon Mar 15 20:12:49 2010
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

Added: sling/trunk/bundles/jcr/davex/NOTICE
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/davex/NOTICE?rev=923417&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/davex/NOTICE (added)
+++ sling/trunk/bundles/jcr/davex/NOTICE Mon Mar 15 20:12:49 2010
@@ -0,0 +1,9 @@
+Apache Sling WebDAV
+Copyright 2008-2010 The Apache Software Foundation
+
+Apache Sling is based on source code originally developed 
+by Day Software (http://www.day.com/).
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+

Added: sling/trunk/bundles/jcr/davex/README.txt
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/davex/README.txt?rev=923417&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/davex/README.txt (added)
+++ sling/trunk/bundles/jcr/davex/README.txt Mon Mar 15 20:12:49 2010
@@ -0,0 +1,28 @@
+Apache Sling WebDAV
+
+Bundle to access JCR repositories over WebDAV using Jackrabbit's DavEx 
extensions.
+
+
+Getting Started
+===============
+
+This component uses a Maven 2 (http://maven.apache.org/) build
+environment. It requires a Java 5 JDK (or higher) and Maven 
(http://maven.apache.org/)
+2.0.7 or later. We recommend to use the latest Maven version.
+
+If you have Maven 2 installed, you can compile and
+package the jar using the following command:
+
+    mvn package
+
+See the Maven 2 documentation for other build features.
+
+The latest source code for this component is available in the
+Subversion (http://subversion.tigris.org/) source repository of
+the Apache Software Foundation. If you have Subversion installed,
+you can checkout the latest source using the following command:
+
+    svn checkout http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/davex
+
+See the Subversion documentation for other source control features.
+

Added: sling/trunk/bundles/jcr/davex/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/davex/pom.xml?rev=923417&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/davex/pom.xml (added)
+++ sling/trunk/bundles/jcr/davex/pom.xml Mon Mar 15 20:12:49 2010
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+    <!--
+        Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements. See the NOTICE file distributed
+        with this work for additional information regarding copyright 
ownership. The ASF licenses this file to you under the Apache License,
+        Version 2.0 (the "License"); you may not use this file except in 
compliance with the License. You may obtain a copy of the License
+        at http://www.apache.org/licenses/LICENSE-2.0 Unless required by 
applicable law or agreed to in writing, software distributed under
+        the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY KIND, either express or implied. See the
+        License for the specific language governing permissions and 
limitations under the License.
+    -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>8</version>
+        <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>org.apache.sling.jcr.davex</artifactId>
+    <packaging>bundle</packaging>
+    <version>0.9.0-SNAPSHOT</version>
+
+    <name>Apache Sling DavEx Access to repositories</name>
+    <description>
+        Bundle to access JCR repositories over DavEx
+    </description>
+
+    <scm>
+        
<connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/davex</connection>
+        
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/davex</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/davex</url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Category>sling,jcr</Bundle-Category>
+                        <Private-Package>
+                            org.apache.sling.jcr.davex.impl.*
+                        </Private-Package>
+                        <Import-Package>
+                            <!-- ignore HTTP client methods of webdav -->
+                            !org.apache.commons.httpclient.*,
+
+                            <!-- ignore XML resolver of xerces -->
+                            !org.apache.xml.resolver.*,
+
+                            <!-- don't import any sun stuff -->
+                            !sun.*,
+
+                            <!-- import the rest -->
+                            *
+                        </Import-Package>
+                        <Embed-Dependency>
+                            jackrabbit-jcr-server,
+                            jackrabbit-webdav,
+                            xercesImpl,
+                        </Embed-Dependency>
+                        <Embed-Transitive>true</Embed-Transitive>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <excludePackageNames>
+                        org.apache.sling.jcr.davex.impl
+                    </excludePackageNames>
+                </configuration>
+            </plugin>
+        </plugins>
+    </reporting>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <version>1.0.0</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-jcr-server</artifactId>
+            <version>2.0.0</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+            <version>2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
+        <!-- OSGi Libraries -->
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+    </dependencies>
+</project>

Added: 
sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java?rev=923417&view=auto
==============================================================================
--- 
sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
 (added)
+++ 
sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
 Mon Mar 15 20:12:49 2010
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.sling.jcr.davex.impl.servlets;
+
+import javax.jcr.Repository;
+import javax.servlet.Servlet;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet;
+
+/**
+ * DavEx WebDav servlet which acquires a Repository instance via the OSGi
+ * service registry.
+ *
+ */
+...@component(label = "%dav.name", description = "%dav.description")
+...@service(Servlet.class)
+...@properties( { @Property(name = "alias", value = "/server"),
+        @Property(name = "init.resource-path-prefix", value = "/server"),
+        @Property(name = "init.missing-auth-mapping", value = ""),
+        @Property(name = "service.description", value = "Sling JcrRemoting 
Servlet"),
+        @Property(name = "service.vendor", value = "The Apache Software 
Foundation") })
+public class SlingDavExServlet extends JcrRemotingServlet {
+
+    @Reference
+    private Repository repository;
+
+    @Override
+    protected Repository getRepository() {
+        return repository;
+    }
+
+}

Added: 
sling/trunk/bundles/jcr/davex/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/davex/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=923417&view=auto
==============================================================================
--- 
sling/trunk/bundles/jcr/davex/src/main/resources/OSGI-INF/metatype/metatype.properties
 (added)
+++ 
sling/trunk/bundles/jcr/davex/src/main/resources/OSGI-INF/metatype/metatype.properties
 Mon Mar 15 20:12:49 2010
@@ -0,0 +1,43 @@
+#
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+#
+
+
+#
+# This file contains localization strings for configuration labels and
+# descriptions as used in the metatype.xml descriptor generated by the
+# the SCR plugin
+
+#
+# SlingDavExServlet
+# (This servlet is directly registered with the HttpService besides the
+# SlingMainServlet. Requests to this servlet do not pass by Sling)
+dav.name = Apache Sling DavEx Servlet
+dav.description = The DavEx Servlet allows direct access to the \
+ complete Repository. It is directly accessible in its own URL space and \
+ requests to this servlet do not pass by the Sling Main Servlet and request \
+ processing.
+
+dav.root.name = Root Path
+dav.root.description = The root path at which the DavEx Servlet is \
+ accessible. The default value is "/server".
+
+dav.realm.name = Authentication Realm
+dav.realm.description = The name of the HTTP Basic Authentication Realm \
+ presented to the client to ask for authentication credentials to access the \
+ repository.

Modified: sling/trunk/bundles/jcr/jackrabbit-server/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-server/pom.xml?rev=923417&r1=923416&r2=923417&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-server/pom.xml (original)
+++ sling/trunk/bundles/jcr/jackrabbit-server/pom.xml Mon Mar 15 20:12:49 2010
@@ -167,6 +167,7 @@
                                             
org.apache.sling.jcr.jackrabbit.server.impl.Activator
                                         </Bundle-Activator>
                                         <Export-Package>
+                                            
org.apache.sling.jcr.jackrabbit.server;version=2.0.7,
                                             
org.apache.sling.jcr.jackrabbit.server.security.*;version=2.0.4-incubator,
                                             
org.apache.jackrabbit.core.security.principal;version=2.0.0
                                         </Export-Package>

Added: 
sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/TestContentLoader.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/TestContentLoader.java?rev=923417&view=auto
==============================================================================
--- 
sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/TestContentLoader.java
 (added)
+++ 
sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/TestContentLoader.java
 Mon Mar 15 20:12:49 2010
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.sling.jcr.jackrabbit.server;
+
+import java.io.IOException;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Service interface which defines a method for loading pre-defined test 
content. This has to be part of
+ * the Jackrabbit Server bundle because Jackrabbit's test content loading 
mechanism uses internal APIs.
+ */
+public interface TestContentLoader {
+
+    public void loadTestContent() throws RepositoryException, IOException;
+
+}

Added: 
sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/TestContentLoaderImpl.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/TestContentLoaderImpl.java?rev=923417&view=auto
==============================================================================
--- 
sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/TestContentLoaderImpl.java
 (added)
+++ 
sling/trunk/bundles/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/impl/TestContentLoaderImpl.java
 Mon Mar 15 20:12:49 2010
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.sling.jcr.jackrabbit.server.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.retention.RetentionPolicy;
+
+import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
+import org.apache.jackrabbit.api.JackrabbitWorkspace;
+import org.apache.jackrabbit.core.NodeImpl;
+import org.apache.jackrabbit.core.retention.RetentionPolicyImpl;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.jackrabbit.server.TestContentLoader;
+
+/**
+ * Component which loads the Jackrabbit test content into a Sling-managed JCR
+ * repository. For now, this is a direct copy of code from jackrabbit-core's
+ * JackrabbitRepositoryStub class. Once that class is refactored, we can remove
+ * almost all of this code.
+ *
+ * @scr.component immediate="true" metatype="no"
+ * @scr.service
+ *
+ * @scr.property name="service.description" value="Test Content Loader"
+ * @scr.property name="service.vendor" value="The Apache Software Foundation"
+ *
+ */
+public class TestContentLoaderImpl implements TestContentLoader {
+
+    /** @scr.reference */
+    private SlingRepository repository;
+
+    private String encoding = "UTF-8";
+
+    public void loadTestContent() throws RepositoryException, IOException {
+
+        Session session = repository.loginAdministrative(null);
+        try {
+            loadTestContent(session);
+        } finally {
+            session.logout();
+        }
+    }
+
+    private void loadTestContent(Session session) throws RepositoryException, 
IOException {
+        JackrabbitWorkspace workspace = (JackrabbitWorkspace) 
session.getWorkspace();
+        Collection<String> workspaces = 
Arrays.asList(workspace.getAccessibleWorkspaceNames());
+        if (!workspaces.contains("test")) {
+            workspace.createWorkspace("test");
+        }
+
+        JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager) 
workspace.getNodeTypeManager();
+        if (!manager.hasNodeType("test:versionable")) {
+            InputStream xml = 
getResource("/org/apache/jackrabbit/core/test-nodetypes.xml");
+            try {
+                manager.registerNodeTypes(xml, 
JackrabbitNodeTypeManager.TEXT_XML);
+            } finally {
+                xml.close();
+            }
+        }
+
+        Node data = getOrAddNode(session.getRootNode(), "testdata");
+        addPropertyTestData(getOrAddNode(data, "property"));
+        addQueryTestData(getOrAddNode(data, "query"));
+        addNodeTestData(getOrAddNode(data, "node"));
+        addLifecycleTestData(getOrAddNode(data, "lifecycle"));
+        addExportTestData(getOrAddNode(data, "docViewTest"));
+
+        Node conf = getOrAddNode(session.getRootNode(), "testconf");
+        addRetentionTestData(getOrAddNode(conf, "retentionTest"));
+
+        session.save();
+    }
+
+    private InputStream getResource(String name) {
+        return TestContentLoaderImpl.class.getResourceAsStream(name);
+    }
+
+    private Node getOrAddNode(Node node, String name) throws 
RepositoryException {
+        try {
+            return node.getNode(name);
+        } catch (PathNotFoundException e) {
+            return node.addNode(name);
+        }
+    }
+
+    /**
+     * Creates a boolean, double, long, calendar and a path property at the
+     * given node.
+     */
+    private void addPropertyTestData(Node node) throws RepositoryException {
+        node.setProperty("boolean", true);
+        node.setProperty("double", Math.PI);
+        node.setProperty("long", 90834953485278298l);
+        Calendar c = Calendar.getInstance();
+        c.set(2005, 6, 18, 17, 30);
+        node.setProperty("calendar", c);
+        ValueFactory factory = node.getSession().getValueFactory();
+        node.setProperty("path", factory.createValue("/", PropertyType.PATH));
+        node.setProperty("multi", new String[] { "one", "two", "three" });
+    }
+
+    /**
+     * Creates a node with a RetentionPolicy
+     */
+    private void addRetentionTestData(Node node) throws RepositoryException {
+        RetentionPolicy rp = 
RetentionPolicyImpl.createRetentionPolicy("testRetentionPolicy", 
node.getSession());
+        
node.getSession().getRetentionManager().setRetentionPolicy(node.getPath(), rp);
+    }
+
+    /**
+     * Creates four nodes under the given node. Each node has a String property
+     * named "prop1" with some content set.
+     */
+    private void addQueryTestData(Node node) throws RepositoryException {
+        while (node.hasNode("node1")) {
+            node.getNode("node1").remove();
+        }
+        getOrAddNode(node, "node1").setProperty("prop1", "You can have it 
good, cheap, or fast. Any two.");
+        getOrAddNode(node, "node1").setProperty("prop1", "foo bar");
+        getOrAddNode(node, "node1").setProperty("prop1", "Hello world!");
+        getOrAddNode(node, "node2").setProperty("prop1", "Apache Jackrabbit");
+    }
+
+    /**
+     * Creates three nodes under the given node: one of type nt:resource and 
the
+     * other nodes referencing it.
+     */
+    private void addNodeTestData(Node node) throws RepositoryException, 
IOException {
+        if (node.hasNode("multiReference")) {
+            node.getNode("multiReference").remove();
+        }
+        if (node.hasNode("resReference")) {
+            node.getNode("resReference").remove();
+        }
+        if (node.hasNode("myResource")) {
+            node.getNode("myResource").remove();
+        }
+
+        Node resource = node.addNode("myResource", "nt:resource");
+        // nt:resource not longer referenceable since JCR 2.0
+        resource.addMixin("mix:referenceable");
+        resource.setProperty("jcr:encoding", encoding);
+        resource.setProperty("jcr:mimeType", "text/plain");
+        resource.setProperty("jcr:data", new ByteArrayInputStream("Hello 
w\u00F6rld.".getBytes(encoding)));
+        resource.setProperty("jcr:lastModified", Calendar.getInstance());
+
+        Node resReference = getOrAddNode(node, "reference");
+        resReference.setProperty("ref", resource);
+        // make this node itself referenceable
+        resReference.addMixin("mix:referenceable");
+
+        Node multiReference = node.addNode("multiReference");
+        ValueFactory factory = node.getSession().getValueFactory();
+        multiReference.setProperty("ref", new Value[] { 
factory.createValue(resource),
+                factory.createValue(resReference) });
+    }
+
+    /**
+     * Creates a lifecycle policy node and another node with a lifecycle
+     * referencing that policy.
+     */
+    private void addLifecycleTestData(Node node) throws RepositoryException {
+        Node policy = getOrAddNode(node, "policy");
+        policy.addMixin(NodeType.MIX_REFERENCEABLE);
+        Node transitions = getOrAddNode(policy, "transitions");
+        Node transition = getOrAddNode(transitions, "identity");
+        transition.setProperty("from", "identity");
+        transition.setProperty("to", "identity");
+
+        Node lifecycle = getOrAddNode(node, "node");
+        ((NodeImpl) lifecycle).assignLifecyclePolicy(policy, "identity");
+    }
+
+    private void addExportTestData(Node node) throws RepositoryException, 
IOException {
+        getOrAddNode(node, "invalidXmlName").setProperty("propName", "some 
text");
+
+        // three nodes which should be serialized as xml text in docView export
+        // separated with spaces
+        getOrAddNode(node, "jcr:xmltext").setProperty("jcr:xmlcharacters", "A 
text without any special character.");
+        getOrAddNode(node, "some-element");
+        getOrAddNode(node, "jcr:xmltext").setProperty("jcr:xmlcharacters",
+                " The entity reference characters: <, ', ,&, >,  \" should" + 
" be escaped in xml export. ");
+        getOrAddNode(node, "some-element");
+        getOrAddNode(node, "jcr:xmltext").setProperty("jcr:xmlcharacters", "A 
text without any special character.");
+
+        Node big = getOrAddNode(node, "bigNode");
+        big.setProperty("propName0", 
"SGVsbG8gd8O2cmxkLg==;SGVsbG8gd8O2cmxkLg==".split(";"), PropertyType.BINARY);
+        big.setProperty("propName1", "text 1");
+        big.setProperty("propName2", "multival text 1;multival text 2;multival 
text 3".split(";"));
+        big.setProperty("propName3", "text 1");
+
+        addExportValues(node, "propName");
+        addExportValues(node, "Prop<>prop");
+    }
+
+    /**
+     * create nodes with following properties binary & single binary & multival
+     * notbinary & single notbinary & multival
+     */
+    private void addExportValues(Node node, String name) throws 
RepositoryException, IOException {
+        String prefix = "valid";
+        if (name.indexOf('<') != -1) {
+            prefix = "invalid";
+        }
+        node = getOrAddNode(node, prefix + "Names");
+
+        String[] texts = new String[] { "multival text 1", "multival text 2", 
"multival text 3" };
+        getOrAddNode(node, prefix + "MultiNoBin").setProperty(name, texts);
+
+        Node resource = getOrAddNode(node, prefix + "MultiBin");
+        resource.setProperty("jcr:encoding", encoding);
+        resource.setProperty("jcr:mimeType", "text/plain");
+        String[] values = new String[] { "SGVsbG8gd8O2cmxkLg==", 
"SGVsbG8gd8O2cmxkLg==" };
+        resource.setProperty(name, values, PropertyType.BINARY);
+        resource.setProperty("jcr:lastModified", Calendar.getInstance());
+
+        getOrAddNode(node, prefix + "NoBin").setProperty(name, "text 1");
+
+        resource = getOrAddNode(node, "invalidBin");
+        resource.setProperty("jcr:encoding", encoding);
+        resource.setProperty("jcr:mimeType", "text/plain");
+        byte[] bytes = "Hello w\u00F6rld.".getBytes(encoding);
+        resource.setProperty(name, new ByteArrayInputStream(bytes));
+        resource.setProperty("jcr:lastModified", Calendar.getInstance());
+    }
+
+}

Modified: sling/trunk/launchpad/builder/src/main/bundles/list.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/launchpad/builder/src/main/bundles/list.xml?rev=923417&r1=923416&r2=923417&view=diff
==============================================================================
--- sling/trunk/launchpad/builder/src/main/bundles/list.xml (original)
+++ sling/trunk/launchpad/builder/src/main/bundles/list.xml Mon Mar 15 20:12:49 
2010
@@ -304,5 +304,10 @@
             <artifactId>org.apache.sling.jcr.webdav</artifactId>
             <version>2.0.9-SNAPSHOT</version>
         </bundle>
+        <bundle>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.jcr.davex</artifactId>
+            <version>0.9.0-SNAPSHOT</version>
+        </bundle>
     </startLevel>
 </bundles>

Modified: sling/trunk/launchpad/test-services/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/pom.xml?rev=923417&r1=923416&r2=923417&view=diff
==============================================================================
--- sling/trunk/launchpad/test-services/pom.xml (original)
+++ sling/trunk/launchpad/test-services/pom.xml Mon Mar 15 20:12:49 2010
@@ -76,6 +76,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.jcr.jackrabbit.server</artifactId>
+            <version>2.0.7-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
             <version>2.0.8</version>
         </dependency>

Added: 
sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/jcr/StartupTestContentLoader.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/jcr/StartupTestContentLoader.java?rev=923417&view=auto
==============================================================================
--- 
sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/jcr/StartupTestContentLoader.java
 (added)
+++ 
sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/jcr/StartupTestContentLoader.java
 Mon Mar 15 20:12:49 2010
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.sling.launchpad.testservices.jcr;
+
+import java.io.IOException;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.sling.jcr.jackrabbit.server.TestContentLoader;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * Component which loads the JCR test content on startup.
+ *
+ * @scr.component immediate="true" metatype="no"
+ *
+ * @scr.property name="service.description" value="Test Content Loader"
+ * @scr.property name="service.vendor" value="The Apache Software Foundation"
+ *
+ */
+public class StartupTestContentLoader {
+
+    /** @scr.reference */
+    private TestContentLoader loader;
+
+    // ---------- SCR integration
+
+    protected void activate(ComponentContext context) throws 
RepositoryException, IOException {
+        loader.loadTestContent();
+    }
+
+    protected void deactivate(ComponentContext context) {
+        ;
+    }
+
+}

Modified: sling/trunk/launchpad/testing/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/pom.xml?rev=923417&r1=923416&r2=923417&view=diff
==============================================================================
--- sling/trunk/launchpad/testing/pom.xml (original)
+++ sling/trunk/launchpad/testing/pom.xml Mon Mar 15 20:12:49 2010
@@ -442,6 +442,21 @@
             <scope>test</scope>
         </dependency>
 
+        <dependency>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+            <version>2.0</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-jcr2dav</artifactId>
+            <version>2.0.0</version>
+            <scope>test</scope>
+        </dependency>
+
+
         <!-- Dependencies for the Test Build and Run -->
         <dependency>
             <groupId>org.apache.sling</groupId>

Added: 
sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/DavExIntegrationTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/DavExIntegrationTest.java?rev=923417&view=auto
==============================================================================
--- 
sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/DavExIntegrationTest.java
 (added)
+++ 
sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/DavExIntegrationTest.java
 Mon Mar 15 20:12:49 2010
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.sling.launchpad.webapp.integrationtest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.commons.JcrUtils;
+import org.apache.sling.commons.testing.integration.HttpTestBase;
+
+/**
+ * Test of Davex
+ */
+public class DavExIntegrationTest extends HttpTestBase {
+
+    private Repository repository;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        repository = JcrUtils.getRepository(HTTP_BASE_URL + "/server/");
+    }
+
+    public void testDescriptor() throws Exception {
+        assertEquals("2.0", 
repository.getDescriptor(Repository.SPEC_VERSION_DESC));
+        assertEquals("Jackrabbit", 
repository.getDescriptor(Repository.REP_NAME_DESC));
+    }
+
+    public void testReadNode() throws Exception {
+        final String path = "/DavExNodeTest_1_" + System.currentTimeMillis();
+        final String url = HTTP_BASE_URL + path;
+
+        // add some properties to the node
+        final Map<String, String> props = new HashMap<String, String>();
+        props.put("name1", "value1");
+        props.put("name2", "value2");
+
+        testClient.createNode(url, props);
+
+        Session session = repository.login("default");
+
+        Node node = session.getNode(path);
+
+        assertNotNull(node);
+        assertEquals("value1", node.getProperty("name1").getString());
+        assertEquals("value2", node.getProperty("name2").getString());
+
+        session.logout();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        repository = null;
+    }
+}

Modified: sling/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/pom.xml?rev=923417&r1=923416&r2=923417&view=diff
==============================================================================
--- sling/trunk/pom.xml (original)
+++ sling/trunk/pom.xml Mon Mar 15 20:12:49 2010
@@ -99,6 +99,7 @@
         <module>bundles/jcr/ocm</module>
         <module>bundles/jcr/resource</module>
         <module>bundles/jcr/webdav</module>
+        <module>bundles/jcr/davex</module>
         <module>bundles/jcr/webconsole</module>
         
         <!-- Servlets -->


Reply via email to