[dna-commits] DNA SVN: r569 - in trunk/extensions: dna-connector-svn and 23 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Wed Oct 22 17:20:34 EDT 2008


Author: spagop
Date: 2008-10-22 17:20:33 -0400 (Wed, 22 Oct 2008)
New Revision: 569

Added:
   trunk/extensions/dna-connector-svn/
   trunk/extensions/dna-connector-svn/pom.xml
   trunk/extensions/dna-connector-svn/src/
   trunk/extensions/dna-connector-svn/src/main/
   trunk/extensions/dna-connector-svn/src/main/java/
   trunk/extensions/dna-connector-svn/src/main/java/org/
   trunk/extensions/dna-connector-svn/src/main/java/org/jboss/
   trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/
   trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/
   trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/
   trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNProtocol.java
   trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnection.java
   trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnectorI18n.java
   trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryLexicon.java
   trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositorySource.java
   trunk/extensions/dna-connector-svn/src/main/resources/
   trunk/extensions/dna-connector-svn/src/main/resources/org/
   trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/
   trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/
   trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/
   trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/svn/
   trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/svn/SVNConnectorI18n.properties
   trunk/extensions/dna-connector-svn/src/test/
   trunk/extensions/dna-connector-svn/src/test/java/
   trunk/extensions/dna-connector-svn/src/test/java/org/
   trunk/extensions/dna-connector-svn/src/test/java/org/jboss/
   trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/
   trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/
   trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/
   trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNConnectorTestUtil.java
   trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositoryConnectionTest.java
   trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositorySourceTest.java
   trunk/extensions/dna-connector-svn/src/test/resources/
   trunk/extensions/dna-connector-svn/src/test/resources/nodeA/
   trunk/extensions/dna-connector-svn/src/test/resources/nodeA/itemA1
   trunk/extensions/dna-connector-svn/src/test/resources/nodeA/itemA2
Log:
first snapshot for svn-connector

Added: trunk/extensions/dna-connector-svn/pom.xml
===================================================================
--- trunk/extensions/dna-connector-svn/pom.xml	                        (rev 0)
+++ trunk/extensions/dna-connector-svn/pom.xml	2008-10-22 21:20:33 UTC (rev 569)
@@ -0,0 +1,100 @@
+<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.jboss.dna</groupId>
+		<artifactId>dna</artifactId>
+		<version>0.3-SNAPSHOT</version>
+		<relativePath>../..</relativePath>
+	</parent>
+
+	<groupId>org.jboss.dna.connector.svn</groupId>
+	<artifactId>dna-connector-svn</artifactId>
+	<packaging>jar</packaging>
+	<name>JBoss DNA Connector to SVN</name>
+	<description>
+		JBoss DNA Connector that accesses an in-process SVN instance.
+	</description>
+	<url>http://labs.jboss.org/dna</url>
+	<!--
+		Define the dependencies.  Note that all version and scopes default to those 
+		defined in the dependencyManagement section of the parent pom.
+	-->
+	<dependencies>
+		<!-- 
+			Common
+		-->
+		<dependency>
+			<groupId>org.jboss.dna</groupId>
+			<artifactId>dna-common</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.jboss.dna</groupId>
+			<artifactId>dna-graph</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.jboss.dna</groupId>
+			<artifactId>dna-common</artifactId>
+			<version>${pom.version}</version>
+			<type>test-jar</type>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.jboss.dna</groupId>
+			<artifactId>dna-graph</artifactId>
+			<version>${pom.version}</version>
+			<type>test-jar</type>
+			<scope>test</scope>
+		</dependency>
+		<!-- 
+			SVNKit
+		-->
+		<dependency>
+			<groupId>org.tmatesoft.svnkit</groupId>
+			<artifactId>svnkit</artifactId>
+			<version>1.2.0.4949</version>
+		</dependency>
+		<!-- 
+			Testing (note the scope)
+		-->
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-all</artifactId>
+		</dependency>
+		<!-- 
+			Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for testing) 
+		-->
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-log4j12</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+		</dependency>
+		<!-- 
+			Java Concurrency in Practice annotations
+		-->
+		<dependency>
+			<groupId>net.jcip</groupId>
+			<artifactId>jcip-annotations</artifactId>
+		</dependency>
+	</dependencies>
+	<reporting>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-report-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</reporting>
+</project>

Added: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNProtocol.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNProtocol.java	                        (rev 0)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNProtocol.java	2008-10-22 21:20:33 UTC (rev 569)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.svn;
+
+/**
+ * @author Serge Pagop
+ */
+public enum SVNProtocol {
+    FILE("file"),
+    SVN("svn"),
+    SVN_SSH("svn+ssh"),
+    HTTP("http"),
+    HTTPS("https");
+
+    SVNProtocol( String value ) {
+        this.value = value;
+    }
+
+    private final String value;
+
+    public String value() {
+        return value;
+    }
+}

Added: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnection.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnection.java	                        (rev 0)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnection.java	2008-10-22 21:20:33 UTC (rev 569)
@@ -0,0 +1,181 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.svn;
+
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import javax.transaction.xa.XAResource;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.cache.CachePolicy;
+import org.jboss.dna.graph.commands.GraphCommand;
+import org.jboss.dna.graph.connectors.RepositoryConnection;
+import org.jboss.dna.graph.connectors.RepositorySourceException;
+import org.jboss.dna.graph.connectors.RepositorySourceListener;
+import org.jboss.dna.graph.properties.Name;
+import org.jboss.dna.graph.properties.NameFactory;
+import org.jboss.dna.graph.requests.Request;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.io.SVNRepository;
+
+/**
+ * The repository connection to a SVN Repository instance.
+ * 
+ * @author Serge Pagop
+ */
+public class SVNRepositoryConnection implements RepositoryConnection {
+
+    protected static final RepositorySourceListener NO_OP_LISTENER = new RepositorySourceListener() {
+
+        /**
+         * {@inheritDoc}
+         */
+        public void notify( String sourceName,
+                            Object... events ) {
+            // do nothing
+        }
+    };
+
+    private Name uuidPropertyName;
+    private final String sourceName;
+    private final String uuidPropertyNameString;
+    private final CachePolicy cachePolicy;
+    private final SVNRepository repository;
+    private RepositorySourceListener listener = NO_OP_LISTENER;
+
+    public SVNRepositoryConnection( String sourceName,
+                                    CachePolicy cachePolicy,
+                                    String uuidPropertyName,
+                                    SVNRepository repository ) {
+        assert (sourceName != null);
+        assert (repository != null);
+        assert (uuidPropertyName != null);
+        this.sourceName = sourceName;
+        this.cachePolicy = cachePolicy;
+        this.uuidPropertyNameString = uuidPropertyName;
+        this.repository = repository;
+    }
+
+    SVNRepository getRepository() {
+        return repository;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getSourceName() {
+        return sourceName;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public CachePolicy getDefaultCachePolicy() {
+        return cachePolicy;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public XAResource getXAResource() {
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean ping( long time,
+                         TimeUnit unit ) {
+        try {
+            this.repository.getRepositoryRoot(true);
+        } catch (SVNException e) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setListener( RepositorySourceListener listener ) {
+        this.listener = listener != null ? listener : NO_OP_LISTENER;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.connectors.RepositoryConnection#close()
+     */
+    public void close() {
+        // do not care about.
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.connectors.RepositoryConnection#execute(org.jboss.dna.graph.ExecutionContext,
+     *      org.jboss.dna.graph.commands.GraphCommand[])
+     */
+    public void execute( ExecutionContext context,
+                         GraphCommand... commands ) throws RepositorySourceException {
+        // Now execute the commands ...
+  
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.connectors.RepositoryConnection#execute(org.jboss.dna.graph.ExecutionContext,
+     *      org.jboss.dna.graph.requests.Request)
+     */
+    public void execute( ExecutionContext context,
+                         Request request ) throws RepositorySourceException {
+        // TODO
+    }
+
+    /**
+     * @return listener
+     */
+    protected RepositorySourceListener getListener() {
+        return this.listener;
+    }
+
+    /**
+     * Utility method to calculate (if required) and obtain the name that should be used to store the UUID values for each node.
+     * This method may be called without regard to synchronization, since it should return the same value if it happens to be
+     * called concurrently while not yet initialized.
+     * 
+     * @param context the execution context
+     * @return the name, or null if the UUID should not be stored
+     */
+    protected Name getUuidPropertyName( ExecutionContext context ) {
+        if (uuidPropertyName == null) {
+            NameFactory nameFactory = context.getValueFactories().getNameFactory();
+            uuidPropertyName = nameFactory.create(this.uuidPropertyNameString);
+        }
+        return this.uuidPropertyName;
+    }
+
+    protected UUID generateUuid() {
+        return UUID.randomUUID();
+    }
+
+}

Added: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnectorI18n.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnectorI18n.java	                        (rev 0)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryConnectorI18n.java	2008-10-22 21:20:33 UTC (rev 569)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.svn;
+
+import java.util.Locale;
+import java.util.Set;
+import org.jboss.dna.common.i18n.I18n;
+
+/**
+ * @author Serge Pagop
+ */
+public final class SVNRepositoryConnectorI18n {
+
+    public static I18n connectorName;
+    public static I18n nodeDoesNotExist;
+    public static I18n propertyIsRequired;
+    public static I18n errorSerializingCachePolicyInSource;
+    public static I18n objectFoundInJndiWasNotCache;
+    public static I18n objectFoundInJndiWasNotCacheFactory;
+
+    static {
+        try {
+            I18n.initialize(SVNRepositoryConnectorI18n.class);
+        } catch (final Exception err) {
+            System.err.println(err);
+        }
+    }
+
+    public static Set<Locale> getLocalizationProblemLocales() {
+        return I18n.getLocalizationProblemLocales(SVNRepositoryConnectorI18n.class);
+    }
+
+    public static Set<String> getLocalizationProblems() {
+        return I18n.getLocalizationProblems(SVNRepositoryConnectorI18n.class);
+    }
+
+    public static Set<String> getLocalizationProblems( Locale locale ) {
+        return I18n.getLocalizationProblems(SVNRepositoryConnectorI18n.class, locale);
+    }
+}

Added: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryLexicon.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryLexicon.java	                        (rev 0)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryLexicon.java	2008-10-22 21:20:33 UTC (rev 569)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.svn;
+
+import org.jboss.dna.graph.properties.Name;
+import org.jboss.dna.graph.properties.basic.BasicName;
+
+
+
+public class SVNRepositoryLexicon {
+
+    public static class Namespace {
+        public static final String URI = "http://www.jboss.org/dna/connector/svn";
+        public static final String PREFIX = "dnasvn";
+    }
+
+    public static final Name CHILD_PATH_SEGMENT_LIST = new BasicName(Namespace.URI, "orderedChildNames");
+
+}

Added: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositorySource.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositorySource.java	                        (rev 0)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositorySource.java	2008-10-22 21:20:33 UTC (rev 569)
@@ -0,0 +1,468 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.svn;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.naming.BinaryRefAddr;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.StringRefAddr;
+import javax.naming.spi.ObjectFactory;
+import org.jboss.dna.common.i18n.I18n;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.graph.DnaLexicon;
+import org.jboss.dna.graph.cache.CachePolicy;
+import org.jboss.dna.graph.connectors.RepositoryConnection;
+import org.jboss.dna.graph.connectors.RepositoryContext;
+import org.jboss.dna.graph.connectors.RepositorySource;
+import org.jboss.dna.graph.connectors.RepositorySourceCapabilities;
+import org.jboss.dna.graph.connectors.RepositorySourceException;
+import org.jboss.dna.graph.properties.Property;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNURL;
+import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
+import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
+import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
+import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
+import org.tmatesoft.svn.core.io.SVNRepository;
+import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+/**
+ * A repository source that uses a SVN repository instance to manage the content. This source is capable of using an existing
+ * {@link SVNRepository} instance or creating a new instance. This process is controlled entirely by the JavaBean properties of
+ * the SVNRepositorySource instance. Like other {@link RepositorySource} classes, instances of SVNRepositorySource can be placed
+ * into JNDI and do support the creation of {@link Referenceable JNDI referenceable} objects and resolution of references into
+ * SVNRepositorySource. </p>
+ * 
+ * @author Serge Pagop
+ */
+public class SVNRepositorySource implements RepositorySource, ObjectFactory {
+
+    private static final long serialVersionUID = 1L;
+    /**
+     * The default limit is {@value} for retrying {@link RepositoryConnection connection} calls to the underlying source.
+     */
+    public static final int DEFAULT_RETRY_LIMIT = 0;
+    public static final String DEFAULT_UUID_PROPERTY_NAME = DnaLexicon.UUID.getString();
+
+    protected static final String SOURCE_NAME = "sourceName";
+    protected static final String ROOT_NODE_UUID = "rootNodeUuid";
+    protected static final String DEFAULT_CACHE_POLICY = "defaultCachePolicy";
+    protected static final String UUID_PROPERTY_NAME = "uuidPropertyName";
+    protected static final String SVN_REPOS_JNDI_NAME = "svnReposJndiName";
+    protected static final String SVN_REPOS_FACTORY_JNDI_NAME = "svnReposFactoryJndiName";
+    protected static final String SVN_URL = "svnURL";
+    protected static final String SVN_USERNAME = "svnUsername";
+    protected static final String SVN_PASSWORD = "svnPassword";
+    protected static final String RETRY_LIMIT = "retryLimit";
+
+    private final AtomicInteger retryLimit = new AtomicInteger(DEFAULT_RETRY_LIMIT);
+    private String name;
+    private UUID rootNodeUuid = UUID.randomUUID();
+    private String uuidPropertyName = DEFAULT_UUID_PROPERTY_NAME;
+    private String svnURL;
+    private String svnUsername;
+    private String svnPassword;
+    private CachePolicy defaultCachePolicy;
+
+    private transient Context jndiContext;
+    private transient RepositoryContext repositoryContext;
+    private transient SVNRepository svnRepository;
+
+    /**
+     * Create a repository source instance.
+     */
+    public SVNRepositorySource() {
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.connectors.RepositorySource#initialize(org.jboss.dna.graph.connectors.RepositoryContext)
+     */
+    public void initialize( RepositoryContext context ) throws RepositorySourceException {
+        this.repositoryContext = context;
+    }
+
+    /**
+     * @return repositoryContext
+     */
+    public RepositoryContext getRepositoryContext() {
+        return repositoryContext;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getName() {
+        return this.name;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.connectors.RepositorySource#getRetryLimit()
+     */
+    public int getRetryLimit() {
+        return retryLimit.get();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.connectors.RepositorySource#setRetryLimit(int)
+     */
+    public void setRetryLimit( int limit ) {
+        retryLimit.set(limit < 0 ? 0 : limit);
+    }
+
+    /**
+     * Set the name of this source
+     * 
+     * @param name the name for this source
+     */
+    public synchronized void setName( String name ) {
+        if (this.name == name || this.name != null && this.name.equals(name)) return; // unchanged
+        this.name = name;
+    }
+
+    /**
+     * Get the default cache policy for this source, or null if the global default cache policy should be used
+     * 
+     * @return the default cache policy, or null if this source has no explicit default cache policy
+     */
+    public CachePolicy getDefaultCachePolicy() {
+        return defaultCachePolicy;
+    }
+
+    /**
+     * @param defaultCachePolicy Sets defaultCachePolicy to the specified value.
+     */
+    public synchronized void setDefaultCachePolicy( CachePolicy defaultCachePolicy ) {
+        if (this.defaultCachePolicy == defaultCachePolicy || this.defaultCachePolicy != null
+            && this.defaultCachePolicy.equals(defaultCachePolicy)) return; // unchanged
+        this.defaultCachePolicy = defaultCachePolicy;
+    }
+
+    /**
+     * Get the UUID of the root node for the cache. If the cache exists, this UUID is not used but is instead set to the UUID of
+     * the existing root node.
+     * 
+     * @return the UUID of the root node for the cache.
+     */
+    public String getRootNodeUuid() {
+        return this.rootNodeUuid.toString();
+    }
+
+    /**
+     * Get the UUID of the root node for the cache. If the cache exists, this UUID is not used but is instead set to the UUID of
+     * the existing root node.
+     * 
+     * @return the UUID of the root node for the cache.
+     */
+    public UUID getRootNodeUuidObject() {
+        return this.rootNodeUuid;
+    }
+
+    /**
+     * Set the UUID of the root node in this repository. If the cache exists, this UUID is not used but is instead set to the UUID
+     * of the existing root node.
+     * 
+     * @param rootNodeUuid the UUID of the root node for the cache, or null if the UUID should be randomly generated
+     */
+    public synchronized void setRootNodeUuid( String rootNodeUuid ) {
+        UUID uuid = null;
+        if (rootNodeUuid == null) uuid = UUID.randomUUID();
+        else uuid = UUID.fromString(rootNodeUuid);
+        if (this.rootNodeUuid.equals(uuid)) return; // unchanged
+        this.rootNodeUuid = uuid;
+    }
+
+    /**
+     * Get the {@link Property#getName() property name} where the UUID is stored for each node.
+     * 
+     * @return the name of the UUID property; never null
+     */
+    public String getUuidPropertyName() {
+        return this.uuidPropertyName;
+    }
+
+    /**
+     * Set the {@link Property#getName() property name} where the UUID is stored for each node.
+     * 
+     * @param uuidPropertyName the name of the UUID property, or null if the {@link #DEFAULT_UUID_PROPERTY_NAME default name}
+     *        should be used
+     */
+    public synchronized void setUuidPropertyName( String uuidPropertyName ) {
+        if (uuidPropertyName == null || uuidPropertyName.trim().length() == 0) uuidPropertyName = DEFAULT_UUID_PROPERTY_NAME;
+        if (this.uuidPropertyName.equals(uuidPropertyName)) return; // unchanged
+        this.uuidPropertyName = uuidPropertyName;
+    }
+
+    public String getSVNURL() {
+        return this.svnURL;
+    }
+
+    /**
+     * Set the url for the subversion repository.
+     * 
+     * @param url - the url location.
+     * @throws IllegalArgumentException If svn url is null or empty
+     */
+    public void setSVNURL( String url ) {
+        CheckArg.isNotEmpty(url, "SVNURL");
+        this.svnURL = url;
+    }
+
+    public String getSVNUsername() {
+        return this.svnUsername;
+    }
+
+    /**
+     * @param username
+     */
+    public void setSVNUsername( String username ) {
+        this.svnUsername = username;
+    }
+
+    public String getSVNPassword() {
+        return this.svnPassword;
+    }
+
+    /**
+     * @param password
+     */
+    public void setSVNPassword( String password ) {
+        this.svnPassword = password;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.connectors.RepositorySource#getCapabilities()
+     */
+    public RepositorySourceCapabilities getCapabilities() {
+        return new Capabilities();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.graph.connectors.RepositorySource#getConnection()
+     */
+    public RepositoryConnection getConnection() throws RepositorySourceException {
+        if (getName() == null) {
+            I18n msg = SVNRepositoryConnectorI18n.propertyIsRequired;
+            throw new RepositorySourceException(getName(), msg.text("name"));
+        }
+        if (getUuidPropertyName() == null) {
+            I18n msg = SVNRepositoryConnectorI18n.propertyIsRequired;
+            throw new RepositorySourceException(getUuidPropertyName(), msg.text("uuidPropertyName"));
+        }
+        SVNURL svnURL = null;
+        if (this.svnRepository == null) {
+            try {
+                svnURL = SVNURL.parseURIDecoded(getSVNURL());
+                String usedProtocol = this.getSVNURL().substring(0, this.getSVNURL().lastIndexOf(":"));
+                if (usedProtocol.equals(SVNProtocol.SVN.value()) || usedProtocol.equals(SVNProtocol.SVN_SSH.value())) {
+                    SVNRepositoryFactoryImpl.setup();
+                    this.svnRepository = SVNRepositoryFactory.create(svnURL);
+                    ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(this.getSVNUsername(),
+                                                                                                         this.getSVNPassword());
+                    this.svnRepository.setAuthenticationManager(authManager);
+                }
+                if (usedProtocol.equals(SVNProtocol.HTTP.value()) || usedProtocol.equals(SVNProtocol.HTTPS.value())) {
+                    DAVRepositoryFactory.setup();
+                    this.svnRepository = DAVRepositoryFactory.create(svnURL);
+                    ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(this.getSVNUsername(),
+                                                                                                         this.getSVNPassword());
+                    this.svnRepository.setAuthenticationManager(authManager);
+                }
+                if (usedProtocol.equals(SVNProtocol.FILE.value())) {
+                    FSRepositoryFactory.setup();
+                    this.svnRepository = FSRepositoryFactory.create(svnURL);
+                    ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(this.getSVNUsername(),
+                                                                                                         this.getSVNPassword());
+                    this.svnRepository.setAuthenticationManager(authManager);
+                }
+
+            } catch (SVNException ex) {
+                I18n msg = SVNRepositoryConnectorI18n.propertyIsRequired;
+                throw new RepositorySourceException(getSVNURL(), msg.text(this.getSVNURL()), ex);
+            }
+        }
+        return new SVNRepositoryConnection(this.getName(), this.getDefaultCachePolicy(), this.getUuidPropertyName(),
+                                           this.svnRepository);
+    }
+
+    protected Context getContext() {
+        return this.jndiContext;
+    }
+
+    protected synchronized void setContext( Context context ) {
+        this.jndiContext = context;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean equals( Object obj ) {
+        if (obj == this) return true;
+        if (obj instanceof SVNRepositorySource) {
+            SVNRepositorySource that = (SVNRepositorySource)obj;
+            if (this.getName() == null) {
+                if (that.getName() != null) return false;
+            } else {
+                if (!this.getName().equals(that.getName())) return false;
+            }
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see javax.naming.Referenceable#getReference()
+     */
+    public synchronized Reference getReference() {
+        String className = getClass().getName();
+        String factoryClassName = this.getClass().getName();
+        Reference ref = new Reference(className, factoryClassName, null);
+
+        if (getName() != null) {
+            ref.add(new StringRefAddr(SOURCE_NAME, getName()));
+        }
+        if (getRootNodeUuid() != null) {
+            ref.add(new StringRefAddr(ROOT_NODE_UUID, getRootNodeUuid().toString()));
+        }
+        if (getUuidPropertyName() != null) {
+            ref.add(new StringRefAddr(UUID_PROPERTY_NAME, getUuidPropertyName()));
+        }
+        if (getSVNURL() != null) {
+            ref.add(new StringRefAddr(SVN_URL, getSVNURL()));
+        }
+        if (getSVNUsername() != null) {
+            ref.add(new StringRefAddr(SVN_USERNAME, getSVNUsername()));
+        }
+        if (getSVNPassword() != null) {
+            ref.add(new StringRefAddr(SVN_PASSWORD, getSVNPassword()));
+        }
+        if (getDefaultCachePolicy() != null) {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            CachePolicy policy = getDefaultCachePolicy();
+            try {
+                ObjectOutputStream oos = new ObjectOutputStream(baos);
+                oos.writeObject(policy);
+                ref.add(new BinaryRefAddr(DEFAULT_CACHE_POLICY, baos.toByteArray()));
+            } catch (IOException e) {
+                I18n msg = SVNRepositoryConnectorI18n.errorSerializingCachePolicyInSource;
+                throw new RepositorySourceException(getName(), msg.text(policy.getClass().getName(), getName()), e);
+            }
+        }
+        ref.add(new StringRefAddr(RETRY_LIMIT, Integer.toString(getRetryLimit())));
+        return ref;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context,
+     *      java.util.Hashtable)
+     */
+    public Object getObjectInstance( Object obj,
+                                     Name name,
+                                     Context nameCtx,
+                                     Hashtable<?, ?> environment ) throws Exception {
+        if (obj instanceof Reference) {
+            Map<String, Object> values = new HashMap<String, Object>();
+            Reference ref = (Reference)obj;
+            Enumeration<?> en = ref.getAll();
+            while (en.hasMoreElements()) {
+                RefAddr subref = (RefAddr)en.nextElement();
+                if (subref instanceof StringRefAddr) {
+                    String key = subref.getType();
+                    Object value = subref.getContent();
+                    if (value != null) values.put(key, value.toString());
+                } else if (subref instanceof BinaryRefAddr) {
+                    String key = subref.getType();
+                    Object value = subref.getContent();
+                    if (value instanceof byte[]) {
+                        // Deserialize ...
+                        ByteArrayInputStream bais = new ByteArrayInputStream((byte[])value);
+                        ObjectInputStream ois = new ObjectInputStream(bais);
+                        value = ois.readObject();
+                        values.put(key, value);
+                    }
+                }
+            }
+            String sourceName = (String)values.get(SOURCE_NAME);
+            String rootNodeUuidString = (String)values.get(ROOT_NODE_UUID);
+            String uuidPropertyName = (String)values.get(UUID_PROPERTY_NAME);
+            String svnURL = (String)values.get(SVN_URL);
+            String svnUsername = (String)values.get(SVN_USERNAME);
+            String svnPassword = (String)values.get(SVN_PASSWORD);
+            Object defaultCachePolicy = values.get(DEFAULT_CACHE_POLICY);
+            String retryLimit = (String)values.get(RETRY_LIMIT);
+
+            // Create the source instance ...
+            SVNRepositorySource source = new SVNRepositorySource();
+            if (sourceName != null) source.setName(sourceName);
+            if (rootNodeUuidString != null) source.setRootNodeUuid(rootNodeUuidString);
+            if (uuidPropertyName != null) source.setUuidPropertyName(uuidPropertyName);
+            if (svnURL != null) source.setSVNURL(svnURL);
+            if (svnUsername != null) source.setSVNUsername(svnUsername);
+            if (svnPassword != null) source.setSVNPassword(svnPassword);
+            if (defaultCachePolicy instanceof CachePolicy) {
+                source.setDefaultCachePolicy((CachePolicy)defaultCachePolicy);
+            }
+            if (retryLimit != null) source.setRetryLimit(Integer.parseInt(retryLimit));
+            return source;
+        }
+        return null;
+    }
+
+    protected class Capabilities implements RepositorySourceCapabilities {
+        public boolean supportsSameNameSiblings() {
+            return false;
+        }
+
+        public boolean supportsUpdates() {
+            return true;
+        }
+    }
+}

Added: trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/svn/SVNConnectorI18n.properties
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/svn/SVNConnectorI18n.properties	                        (rev 0)
+++ trunk/extensions/dna-connector-svn/src/main/resources/org/jboss/dna/connector/svn/SVNConnectorI18n.properties	2008-10-22 21:20:33 UTC (rev 569)
@@ -0,0 +1,28 @@
+#
+# JBoss, Home of Professional Open Source.
+# Copyright 2008, Red Hat Middleware LLC, and individual contributors
+# as indicated by the @author tags. See the copyright.txt file in the
+# distribution for a full listing of individual contributors.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+#
+
+connectorName = SVN Connector
+nodeDoesNotExist = Could not find an existing node at {0}
+propertyIsRequired = The {0} property is required but has no value
+errorSerializingCachePolicyInSource = Error serializing a {0} instance owned by the {1} SVNRepositorySource
+objectFoundInJndiWasNotSVNRepository = Object in JNDI at {0} found by SVNRepositorySource {1} was expected to be a typ of org.tmatesoft.svn.core.io.SVNRepository but instead was {2}
+objectFoundInJndiWasNotSVNRepositoryFactory =Object in JNDI at {0} found by SVNRepositorySource {1} was expected to be a typ of org.tmatesoft.svn.core.io.SVNRepositoryFactory but instead was {2}
\ No newline at end of file

Added: trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNConnectorTestUtil.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNConnectorTestUtil.java	                        (rev 0)
+++ trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNConnectorTestUtil.java	2008-10-22 21:20:33 UTC (rev 569)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.svn;
+
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNURL;
+import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
+import org.tmatesoft.svn.core.internal.io.dav.DAVRepository;
+import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
+import org.tmatesoft.svn.core.io.SVNRepository;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
+
+/**
+ * @author Serge Pagop
+ */
+public class SVNConnectorTestUtil {
+
+    /**
+     * Create a {@link SVNRepository} from a http protocol.
+     * 
+     * @param url - the url of the repository.
+     * @param username - username credential.
+     * @param password - password credential
+     * @return {@link DAVRepository}.
+     * @throws SVNException - when error situation.
+     */
+    public static DAVRepository createDAVRepositoryURL( String url,
+                                                        String username,
+                                                        String password ) throws SVNException {
+        DAVRepositoryFactory.setup();
+        // The factory knows how to create a DAVRepository
+        DAVRepository repository = (DAVRepository)DAVRepositoryFactory.create(SVNURL.parseURIDecoded(url));
+        ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(username, password);
+        repository.setAuthenticationManager(authManager);
+        return repository;
+    }
+
+    private SVNConnectorTestUtil() {
+        // prevent constructor
+    }
+
+}

Added: trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositoryConnectionTest.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositoryConnectionTest.java	                        (rev 0)
+++ trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositoryConnectionTest.java	2008-10-22 21:20:33 UTC (rev 569)
@@ -0,0 +1,195 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.svn;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.stub;
+import static org.mockito.Mockito.verify;
+import java.util.concurrent.TimeUnit;
+import org.jboss.dna.graph.DnaLexicon;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.cache.CachePolicy;
+import org.jboss.dna.graph.connectors.BasicExecutionContext;
+import org.jboss.dna.graph.connectors.RepositorySourceListener;
+import org.jboss.dna.graph.properties.Name;
+import org.jboss.dna.graph.properties.NameFactory;
+import org.jboss.dna.graph.properties.PathFactory;
+import org.jboss.dna.graph.properties.PropertyFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoAnnotations.Mock;
+import org.tmatesoft.svn.core.internal.io.dav.DAVRepository;
+
+/**
+ * @author Serge Pagop
+ */
+ at SuppressWarnings( "unused" )
+public class SVNRepositoryConnectionTest {
+    private SVNRepositoryConnection connection;
+    private ExecutionContext context;
+    private PathFactory pathFactory;
+    private NameFactory nameFactory;
+    private PropertyFactory propertyFactory;
+    private DAVRepository davRepository;
+    private String uuidPropertyName;
+    private String sourceName;
+
+    @Mock
+    private CachePolicy policy;
+
+    @Before
+    public void beforeEach() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        context = new BasicExecutionContext();
+        context.getNamespaceRegistry().register(DnaLexicon.Namespace.PREFIX, DnaLexicon.Namespace.URI);
+        pathFactory = context.getValueFactories().getPathFactory();
+        propertyFactory = context.getPropertyFactory();
+        nameFactory = context.getValueFactories().getNameFactory();
+
+        // Create a Repository instance from the http-protocol, that use a anonymous credential.
+        String url = "http://anonsvn.jboss.org/repos/dna/trunk/extensions/dna-connector-svn/src/test/resources";
+        String username = "anonymous";
+        String password = "anonymous";
+        // Set up the appropriate factory for a particular protocol
+        davRepository = SVNConnectorTestUtil.createDAVRepositoryURL(url, username, password);
+        sourceName = "the source name";
+        uuidPropertyName = "dna:uuid";
+        connection = new SVNRepositoryConnection(sourceName, policy, uuidPropertyName, davRepository);
+    }
+
+    @After
+    public void afterEach() {
+
+    }
+
+    @Test( expected = AssertionError.class )
+    public void shouldFailToInstantiateIfSourceNameIsNull() {
+        sourceName = null;
+        connection = new SVNRepositoryConnection(sourceName, policy, uuidPropertyName, davRepository);
+    }
+    
+    @Test( expected = AssertionError.class )
+    public void shouldFailToInstantiateIfRepositoryIsNull() {
+        davRepository = null;
+        connection = new SVNRepositoryConnection(sourceName, policy, uuidPropertyName, davRepository);
+    }
+    
+    
+
+    @Test( expected = AssertionError.class )
+    public void shouldFailToInstantiateIfUuidPropertyNameIsNull() throws Exception {
+        uuidPropertyName = null;
+        connection = new SVNRepositoryConnection(sourceName, policy, uuidPropertyName, davRepository);
+
+    }
+
+    @Test
+    public void shouldInstantiateWithValidSourceAndDAVRepositoryReferences() throws Exception {
+        assertThat(connection, is(notNullValue()));
+    }
+
+    @Test
+    public void shouldDelegateToTheSourceForTheConnectionsSourceName() {
+        assertThat(connection.getSourceName(), is("the source name"));
+    }
+
+    @Test
+    public void shouldDelegateToTheSourceForTheConnectionsDefaultCachePolicy() {
+        assertThat(connection.getDefaultCachePolicy(), is(sameInstance(policy)));
+    }
+
+    @Test
+    public void shouldGetTheSVNRepositoryRootFromTheSVNRepositoryWhenPinged() throws Exception {
+        CachePolicy policy = mock(CachePolicy.class);
+        davRepository = mock(DAVRepository.class);
+        connection = new SVNRepositoryConnection("the source name", policy, SVNRepositorySource.DEFAULT_UUID_PROPERTY_NAME,
+                                                 davRepository);
+        stub(davRepository.getRepositoryRoot(true)).toReturn(null);
+        assertThat(connection.ping(1, TimeUnit.SECONDS), is(true));
+        verify(davRepository).getRepositoryRoot(true);
+    }
+
+    @Test
+    public void shouldHaveNoOpListenerWhenCreated() {
+        assertThat(connection.getListener(), is(sameInstance(SVNRepositoryConnection.NO_OP_LISTENER)));
+    }
+
+    @Test
+    public void shouldUseNoOpListenerWhenSettingListenerToNull() {
+        connection.setListener(null);
+        assertThat(connection.getListener(), is(sameInstance(SVNRepositoryConnection.NO_OP_LISTENER)));
+    }
+
+    @Test
+    public void shouldSetListenerToNonNullValue() {
+        RepositorySourceListener listener = mock(RepositorySourceListener.class);
+        connection.setListener(listener);
+        assertThat(connection.getListener(), is(sameInstance(listener)));
+        connection.setListener(null);
+        assertThat(connection.getListener(), is(sameInstance(SVNRepositoryConnection.NO_OP_LISTENER)));
+    }
+
+    @Test
+    public void shouldGetUuidPropertyNameFromSouceAndShouldNotChangeDuringLifetimeOfConnection() {
+        Name name = connection.getUuidPropertyName(context);
+        assertThat(name.getLocalName(), is("uuid"));
+        assertThat(name.getNamespaceUri(), is(DnaLexicon.Namespace.URI));
+        for (int i = 0; i != 10; ++i) {
+            Name name2 = connection.getUuidPropertyName(context);
+            assertThat(name2, is(sameInstance(name)));
+        }
+    }
+
+    @Test
+    public void shouldGenerateUuid() {
+        for (int i = 0; i != 100; ++i) {
+            assertThat(connection.generateUuid(), is(notNullValue()));
+        }
+    }
+    
+    @Test
+    public void should
+
+    /**
+     * Create a Repository instance from the file-protocol.
+     * 
+     * @return {@link FSRepository} the repository
+     * @throws Exception - in case of a exceptional error during the access.
+     */
+    // @SuppressWarnings( "unused" )
+    // private FSRepository createFSRepositoryFromFileProtocol() throws Exception {
+    // //TODO to be changed
+    // // String url = "file:///Users/sp/SVNRepos/test";
+    // String url = "";
+    // // Set up the appropriate factory for a particular protocol
+    // FSRepositoryFactory.setup();
+    // // The factory knows how to create a DAVRepository
+    // FSRepository fsRepository = (FSRepository)FSRepositoryFactory.create(SVNURL.parseURIDecoded(url));
+    // return fsRepository;
+    // }
+}

Added: trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositorySourceTest.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositorySourceTest.java	                        (rev 0)
+++ trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNRepositorySourceTest.java	2008-10-22 21:20:33 UTC (rev 569)
@@ -0,0 +1,271 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.svn;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Matchers.isNull;
+import static org.mockito.Mockito.mock;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+import org.jboss.dna.graph.cache.BasicCachePolicy;
+import org.jboss.dna.graph.connectors.RepositoryConnection;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * @author Serge Pagop
+ */
+public class SVNRepositorySourceTest {
+
+    private SVNRepositorySource source;
+    private RepositoryConnection connection;
+    private String validName;
+    private String validUuidPropertyName;
+    // private String validFileURL;
+    private String validHttpURL;
+    private String validHttpURLUsername;
+    private String validHttpURLPassword;
+    private UUID validRootNodeUuid;
+
+    @Before
+    public void beforeEach() throws Exception {
+        MockitoAnnotations.initMocks(this);
+        validName = "svn source";
+        validUuidPropertyName = "dna:uuid";
+
+        // For file protocol access
+        // validFileURL = "file:///Users/sp/SVNRepos/test";
+
+        // For http protocol access
+        validHttpURL = "http://anonsvn.jboss.org/repos/dna/trunk/extensions/dna-connector-svn/src/test/resources";
+        validHttpURLUsername = "anonymous";
+        validHttpURLPassword = "anonymous";
+
+        // For https protocol access
+        // For svn protocol access
+        // For svn-ssh protocol access
+
+        validRootNodeUuid = UUID.randomUUID();
+        source = new SVNRepositorySource();
+
+    }
+
+    @After
+    public void afterEach() throws Exception {
+        if (connection != null) {
+            connection.close();
+        }
+    }
+
+    @Test
+    public void shouldReturnNonNullCapabilities() {
+        assertThat(source.getCapabilities(), is(notNullValue()));
+    }
+
+    @Test
+    public void shouldNotSupportSameNameSiblings() {
+        assertThat(source.getCapabilities().supportsSameNameSiblings(), is(false));
+    }
+
+    @Test
+    public void shouldSupportUpdates() {
+        assertThat(source.getCapabilities().supportsUpdates(), is(true));
+    }
+
+    @Test
+    public void shouldHaveNullSourceNameUponConstruction() {
+        assertThat(source.getName(), is(nullValue()));
+    }
+
+    @Test
+    public void shouldAllowSettingName() {
+        source.setName("name you like");
+        assertThat(source.getName(), is("name you like"));
+        source.setName("name you do not like");
+        assertThat(source.getName(), is("name you do not like"));
+    }
+
+    @Test
+    public void shouldAllowSettingNameToNull() {
+        source.setName("something that can change the world");
+        source.setName(null);
+        assertThat(source.getName(), is(isNull()));
+    }
+
+    @Test( expected = IllegalArgumentException.class )
+    public void shouldNotAllowNullSVNUrl() {
+        source.setSVNURL(null);
+    }
+
+    @Test( expected = IllegalArgumentException.class )
+    public void shouldNotAllowEmptySVNUrl() {
+        source.setSVNURL("");
+    }
+
+    @Test
+    public void shouldAllowSettingEmptyCredentialsForAnnonymousAccess() {
+        source.setSVNUsername("");
+        assertThat(source.getSVNUsername(), is(notNullValue()));
+        source.setSVNPassword("");
+        assertThat(source.getSVNPassword(), is(notNullValue()));
+
+    }
+
+    @Test
+    public void shouldHaveDefaultRetryLimit() {
+        assertThat(source.getRetryLimit(), is(SVNRepositorySource.DEFAULT_RETRY_LIMIT));
+    }
+
+    @Test
+    public void shouldSetRetryLimitToZeroWhenSetWithNonPositiveValue() {
+        source.setRetryLimit(0);
+        assertThat(source.getRetryLimit(), is(0));
+        source.setRetryLimit(-1);
+        assertThat(source.getRetryLimit(), is(0));
+        source.setRetryLimit(-100);
+        assertThat(source.getRetryLimit(), is(0));
+    }
+
+    @Test
+    public void shouldAllowRetryLimitToBeSet() {
+        for (int i = 0; i != 100; ++i) {
+            source.setRetryLimit(i);
+            assertThat(source.getRetryLimit(), is(i));
+        }
+    }
+
+    @Test
+    public void shouldCreateJndiReferenceAndRecreatedObjectFromReference() throws Exception {
+        BasicCachePolicy cachePolicy = new BasicCachePolicy();
+        cachePolicy.setTimeToLive(1000L, TimeUnit.MILLISECONDS);
+        convertToAndFromJndiReference(validName,
+                                      validRootNodeUuid,
+                                      validHttpURL,
+                                      validHttpURLUsername,
+                                      validHttpURLPassword,
+                                      validUuidPropertyName,
+                                      cachePolicy,
+                                      100);
+    }
+
+    @Test
+    public void shouldCreateJndiReferenceAndRecreatedObjectFromReferenceWithNullProperties() throws Exception {
+        BasicCachePolicy cachePolicy = new BasicCachePolicy();
+        cachePolicy.setTimeToLive(1000L, TimeUnit.MILLISECONDS);
+        convertToAndFromJndiReference("some source", null, "url1", null, null, null, null, 100);
+        convertToAndFromJndiReference(null, null, "url2", null, null, null, null, 100);
+    }
+
+    private void convertToAndFromJndiReference( String sourceName,
+                                                UUID rootNodeUuid,
+                                                String url,
+                                                String username,
+                                                String password,
+                                                String uuidPropertyName,
+                                                BasicCachePolicy cachePolicy,
+                                                int retryLimit ) throws Exception {
+        source.setRetryLimit(retryLimit);
+        source.setName(sourceName);
+        source.setSVNURL(url);
+        source.setSVNUsername(username);
+        source.setSVNPassword(password);
+        source.setDefaultCachePolicy(cachePolicy);
+        source.setRootNodeUuid(rootNodeUuid != null ? rootNodeUuid.toString() : null);
+        source.setUuidPropertyName(uuidPropertyName);
+
+        Reference ref = source.getReference();
+
+        assertThat(ref.getClassName(), is(SVNRepositorySource.class.getName()));
+        assertThat(ref.getFactoryClassName(), is(SVNRepositorySource.class.getName()));
+
+        Map<String, Object> refAttributes = new HashMap<String, Object>();
+        Enumeration<RefAddr> enumeration = ref.getAll();
+        while (enumeration.hasMoreElements()) {
+            RefAddr addr = enumeration.nextElement();
+            refAttributes.put(addr.getType(), addr.getContent());
+        }
+
+        assertThat((String)refAttributes.remove(SVNRepositorySource.SOURCE_NAME), is(source.getName()));
+        assertThat((String)refAttributes.remove(SVNRepositorySource.ROOT_NODE_UUID), is(source.getRootNodeUuid()));
+        assertThat((String)refAttributes.remove(SVNRepositorySource.UUID_PROPERTY_NAME), is(source.getUuidPropertyName()));
+        assertThat((String)refAttributes.remove(SVNRepositorySource.SVN_URL), is(source.getSVNURL()));
+        assertThat((String)refAttributes.remove(SVNRepositorySource.SVN_USERNAME), is(source.getSVNUsername()));
+        assertThat((String)refAttributes.remove(SVNRepositorySource.SVN_PASSWORD), is(source.getSVNPassword()));
+        assertThat((String)refAttributes.remove(SVNRepositorySource.RETRY_LIMIT), is(Integer.toString(source.getRetryLimit())));
+        refAttributes.remove(SVNRepositorySource.DEFAULT_CACHE_POLICY);
+        assertThat(refAttributes.isEmpty(), is(true));
+
+        // Recreate the object, use a newly constructed source ...
+        ObjectFactory factory = new SVNRepositorySource();
+        Name name = mock(Name.class);
+        Context context = mock(Context.class);
+        Hashtable<?, ?> env = new Hashtable<Object, Object>();
+        SVNRepositorySource recoveredSource = (SVNRepositorySource)factory.getObjectInstance(ref, name, context, env);
+        assertThat(recoveredSource, is(notNullValue()));
+
+        assertThat(recoveredSource.getName(), is(source.getName()));
+        assertThat(recoveredSource.getRootNodeUuid(), is(source.getRootNodeUuid()));
+        assertThat(recoveredSource.getUuidPropertyName(), is(source.getUuidPropertyName()));
+        assertThat(recoveredSource.getSVNURL(), is(source.getSVNURL()));
+        assertThat(recoveredSource.getSVNUsername(), is(source.getSVNUsername()));
+        assertThat(recoveredSource.getSVNPassword(), is(source.getSVNPassword()));
+        assertThat(recoveredSource.getDefaultCachePolicy(), is(source.getDefaultCachePolicy()));
+
+        assertThat(recoveredSource.equals(source), is(true));
+        assertThat(source.equals(recoveredSource), is(true));
+    }
+
+    // Only with local file protocol
+    /*
+    @Test
+    public void shouldCreateFSRepositoryIfProtocolIsOfTypeFile() throws Exception {
+        this.source.setName(validName);
+        this.source.setSVNURL(validFileURL);
+        this.connection = source.getConnection();
+        assertThat(this.connection, is(notNullValue()));
+    }*/
+
+    @Test
+    public void shouldCreateDAVRepositoryIfProtocolIsOfTypeHttp() throws Exception {
+        this.source.setName(validName);
+        this.source.setSVNURL(validHttpURL);
+        this.source.setSVNUsername(validHttpURLUsername);
+        this.source.setSVNPassword(validHttpURLPassword);
+        this.connection = source.getConnection();
+        assertThat(this.connection, is(notNullValue()));
+    }
+
+}

Added: trunk/extensions/dna-connector-svn/src/test/resources/nodeA/itemA1
===================================================================
--- trunk/extensions/dna-connector-svn/src/test/resources/nodeA/itemA1	                        (rev 0)
+++ trunk/extensions/dna-connector-svn/src/test/resources/nodeA/itemA1	2008-10-22 21:20:33 UTC (rev 569)
@@ -0,0 +1 @@
+my is content
\ No newline at end of file

Added: trunk/extensions/dna-connector-svn/src/test/resources/nodeA/itemA2
===================================================================
--- trunk/extensions/dna-connector-svn/src/test/resources/nodeA/itemA2	                        (rev 0)
+++ trunk/extensions/dna-connector-svn/src/test/resources/nodeA/itemA2	2008-10-22 21:20:33 UTC (rev 569)
@@ -0,0 +1 @@
+my content
\ No newline at end of file




More information about the dna-commits mailing list