[dna-commits] DNA SVN: r932 - trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Fri May 22 09:33:13 EDT 2009


Author: spagop
Date: 2009-05-22 09:33:13 -0400 (Fri, 22 May 2009)
New Revision: 932

Modified:
   trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNConnectorTestUtil.java
Log:
changes made to support workspace features and enhanced tests

Modified: 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	2009-05-22 13:32:37 UTC (rev 931)
+++ trunk/extensions/dna-connector-svn/src/test/java/org/jboss/dna/connector/svn/SVNConnectorTestUtil.java	2009-05-22 13:33:13 UTC (rev 932)
@@ -25,8 +25,12 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
 import org.jboss.dna.common.util.FileUtil;
+import org.tmatesoft.svn.core.SVNDirEntry;
 import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNNodeKind;
 import org.tmatesoft.svn.core.SVNURL;
 import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
 import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
@@ -41,17 +45,64 @@
  */
 public class SVNConnectorTestUtil {
 
+    @SuppressWarnings("unchecked")
     public static void main( String[] args ) throws Exception {
         try {
-            System.out.println("hello ......");
+            System.out.println("My repos. ......");
             String svnUrl = SVNConnectorTestUtil.createURL("src/test/resources/dummy_svn_repos", "target/copy_of dummy_svn_repos");
             String username = "sp";
             String password = "";
-            SVNRepository repos = createRepository(svnUrl, username, password);
-            System.out.println("Repository Root: " + repos.getRepositoryRoot(true));
-            System.out.println("Repository UUID: " + repos.getRepositoryUUID(true));
-            System.out.println("hello ......");
+            System.out.println(svnUrl);
+            SVNRepository trunkWorkspace = createRepository(svnUrl +"/trunk", username, password);
+            System.out.println("Repository location: " + trunkWorkspace.getLocation().toString());
+            System.out.println("Repository Root: " + trunkWorkspace.getRepositoryRoot(true));
+            System.out.println("Repository UUID: " + trunkWorkspace.getRepositoryUUID(true));
+            /**
+             * Returns the repository location to which this object is set. 
+             * It may be the location that was used to create this object
+             * (see {@link SVNRepositoryFactory#create(SVNURL)}), or the recent 
+             * one the object was set to.
+             */
+            System.out.println("location: " + trunkWorkspace.getLocation().getPath());
+            System.out.println("decoded location: " + trunkWorkspace.getLocation().toDecodedString());
+            System.out.println("last seg: " + getRepositoryWorspaceName(trunkWorkspace));
+            
+            final Collection<SVNDirEntry> dirEntries = trunkWorkspace.getDir("",
+                                                                            -1,
+                                                                            null,
+                                                                            (Collection<SVNDirEntry>)null);
+            for (SVNDirEntry dirEntry : dirEntries) {
+             System.out.println("name: " + dirEntry.getName());   
+            }
+            
+////            
+//            SVNNodeKind nodeKind = trunkWorkspace.checkPath( "/" ,  -1 );
+//            if ( nodeKind == SVNNodeKind.NONE ) {
+//                System.err.println( "There is no entry in the workspace "+ trunkWorkspace );
+//                System.exit( 1 );
+//            } else if ( nodeKind == SVNNodeKind.FILE ) {
+//                System.err.println( "The entry at '" + trunkWorkspace + "' is a file while a directory was expected." );
+//                System.exit( 1 );
+//            } else {
+//            listEntries(trunkWorkspace, "/root");
+////            long latestRevision = trunkWorkspace.getLatestRevision( );
+////            System.out.println( "workspace latest revision: " + latestRevision );
+//            
+//////            SVNNodeKind kind = trunkWorkspace.checkPath("/", -1);
+////            if(kind == SVNNodeKind.NONE) {
+////                System.out.println("none");
+////            } else if(kind == SVNNodeKind.UNKNOWN) {
+////                System.out.println("unknown");
+////            } else if(kind == SVNNodeKind.FILE) {
+////                System.out.println("file");
+////            } else if(kind == SVNNodeKind.DIR) {
+//                System.out.println("dir");
+////                listEntries(trunkWorkspace,"root");
+//            }
+
+
         } catch (SVNException e) {
+            e.printStackTrace();
         }
     }
 
@@ -80,8 +131,9 @@
         repository.setAuthenticationManager(authManager);
         return repository;
     }
-    
-    public static String createURL(String src, String dst) throws IOException {
+
+    public static String createURL( String src,
+                                    String dst ) throws IOException {
         // First we need to find the absolute path. Note that Maven always runs the tests from the project's directory,
         // so use new File to create an instance at the current location ...
         File mySrc = new File(src);
@@ -95,8 +147,29 @@
         String url = myDst.getCanonicalFile().toURL().toString();
         return url.replaceFirst("file:/", "file://localhost/");
     }
+    
+    @SuppressWarnings("unchecked")
+    public static void listEntries( SVNRepository workspace, String path ) throws SVNException {
+        Collection<SVNDirEntry> entries = workspace.getDir( path, -1 , null , (Collection) null );
+        Iterator<SVNDirEntry> iterator = entries.iterator( );
+        while ( iterator.hasNext( ) ) {
+            SVNDirEntry entry = iterator.next( );
+            System.out.println( "/" + (path.equals( "" ) ? "" : path + "/" ) + entry.getName( ) + 
+                               " ( author: '" + entry.getAuthor( ) + "'; revision: " + entry.getRevision( ) + 
+                               "; date: " + entry.getDate( ) + ")" );
+            if ( entry.getKind() == SVNNodeKind.DIR ) {
+                listEntries( workspace, ( path.equals( "" ) ) ? entry.getName( ) : path + "/" + entry.getName( ) );
+            }
+        }
+    }
+
+    public static String getRepositoryWorspaceName(SVNRepository repository) {
+        String[] segments = repository.getLocation().getPath().split("/");
+        return segments[segments.length - 1];
+    }
+
     private SVNConnectorTestUtil() {
         // prevent constructor
     }
 
-}
\ No newline at end of file
+}




More information about the dna-commits mailing list