[[[
[in subversion/bindings/java/javahl/]
* src/org/tigris/subversion/javahl/tests/BasicTests.java
* src/org/tigris/subversion/javahl/tests/SVNTests.java
  Modified JUnit tests to remove hard-coded assumption about .svn folder name
  so that the SVN_ASP_DOT_NET_HACK environment variable is properly handled on
  Windows.  The test suite now checks the environment variable and sets the internal
  use of the directory name accordingly.
  
  Patch by: markphip

]]]
Index: subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/tests/BasicTests.java
===================================================================
--- subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/tests/BasicTests.java	(revision 16850)
+++ subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/tests/BasicTests.java	(working copy)
@@ -531,21 +531,21 @@
         OneTest thisTest = new OneTest();
 
         // create a lock file in A/B
-        File adminLock = new File(thisTest.getWorkingCopy(),"A/B/.svn/lock");
+        File adminLock = new File(thisTest.getWorkingCopy(),"A/B/" + SVNTests.SVN_DIRNAME() + "/lock");
         PrintWriter pw = new PrintWriter(new FileOutputStream(adminLock));
         pw.print("stop looking!");
         pw.close();
         thisTest.getWc().setItemIsLocked("A/B", true);
 
         // create a lock file in A/D/G
-        adminLock = new File(thisTest.getWorkingCopy(),"A/D/G/.svn/lock");
+        adminLock = new File(thisTest.getWorkingCopy(),"A/D/G/" + SVNTests.SVN_DIRNAME() + "/lock");
         pw = new PrintWriter(new FileOutputStream(adminLock));
         pw.print("stop looking!");
         pw.close();
         thisTest.getWc().setItemIsLocked("A/D/G", true);
 
         // create a lock file in A/C
-        adminLock = new File(thisTest.getWorkingCopy(),"A/C/.svn/lock");
+        adminLock = new File(thisTest.getWorkingCopy(),"A/C/" + SVNTests.SVN_DIRNAME() + "/lock");
         pw = new PrintWriter(new FileOutputStream(adminLock));
         pw.print("stop looking!");
         pw.close();
Index: subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/tests/SVNTests.java
===================================================================
--- subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/tests/SVNTests.java	(revision 16850)
+++ subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/tests/SVNTests.java	(working copy)
@@ -21,13 +21,16 @@
 import junit.framework.TestSuite;
 import org.tigris.subversion.javahl.*;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Properties;
 /**
  * common base class for the javahl binding tests
  */
@@ -113,6 +116,12 @@
     protected static String rootUrl;
 
     /**
+     * contains the name of the SVN working copy directory - either
+     * ".svn" or "_svn".
+     */
+    private static String dirName;
+
+    /**
      * retrieve the root directory and the root url from the command line
      * arguments
      * @param args  command line arguments
@@ -361,6 +370,95 @@
     }
 
     /**
+     * get the name of the SVN working copy directory.
+     * @return the name of the SVN working copy directory.
+     */
+    public static String SVN_DIRNAME(){
+        if (dirName == null) {
+            // svn only supports this feature on Windows
+            if (isOsWindows())
+                dirName = getEnvironmentVariable("SVN_ASP_DOT_NET_HACK");
+            // If the environment variable was present, then use _svn
+            // as the directory name, otherwise the default of .svn
+            if (dirName != null)
+                dirName = "_svn";
+            else
+                dirName = ".svn";
+        }
+        return dirName;
+    }
+
+    /**
+     * get the value of a specific environment variable.
+     * @param var   the environment variable to retrieve
+     * @return the value of the environment variable
+     * @throws Throwable
+     */
+    public static String getEnvironmentVariable(String var) {
+        try {
+            // pre-Java 1.5 this throws an Error.  On Java 1.5 it
+            // returns the environment variable
+           return System.getenv(var);
+        } catch(Error e) {
+            try {
+                // This means we are on 1.4.  Get all variables into
+                // a Properties object and get the variable from that
+                return getEnvVars().getProperty(var);
+            } catch (Throwable e1) {
+                return null;
+            }
+        }
+    }
+
+    /**
+     * get all of the environment variables in a Properties object.
+     * @return all of the environment variables
+     * @throws Throwable
+     */
+    public static Properties getEnvVars() throws Throwable {
+        Process p = null;
+        Properties envVars = new Properties();
+        Runtime r = Runtime.getRuntime();
+        if (isOsWindows()) {
+            if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) 
+                p = r.exec( "command.com /c set" );
+            else
+                p = r.exec( "cmd.exe /c set" );
+        } else {
+            p = r.exec( "env" );
+        }
+        if (p != null) {
+	        BufferedReader br = new BufferedReader(
+	                new InputStreamReader(p.getInputStream()));
+	        String line;
+	        while( (line = br.readLine()) != null ) {
+				int idx = line.indexOf( '=' );
+				String key = line.substring( 0, idx );
+				String value = line.substring( idx+1 );
+				envVars.setProperty( key, value );
+	        }
+        }
+        return envVars;
+	}
+
+	/**
+	 * Answer whether running on Windows OS.
+	 * (Actual code extracted from org.apache.commons.lang.SystemUtils.IS_OS_WINDOWS)
+	 * (For such one simple method it does make sense to introduce dependency on whole commons-lang.jar)
+	 * @return
+	 */
+	public static boolean isOsWindows()
+	{
+        try {
+            return System.getProperty("os.name").startsWith("Windows");
+        } catch (SecurityException ex) {
+            // we are not allowed to look at this property
+            return false;
+        }
+	}
+
+
+    /**
      * internal class which implements the OutputInterface to write the data
      * to a file.
      */
