Author: olga
Date: Fri May 30 13:30:33 2008
New Revision: 661840

URL: http://svn.apache.org/viewvc?rev=661840&view=rev
Log:
PIG-243: fix for windows unit tests

Modified:
    incubator/pig/trunk/CHANGES.txt
    incubator/pig/trunk/src/org/apache/pig/builtin/PigStorage.java
    incubator/pig/trunk/src/org/apache/pig/builtin/TextLoader.java
    incubator/pig/trunk/test/org/apache/pig/test/TestAlgebraicEval.java
    incubator/pig/trunk/test/org/apache/pig/test/TestBinaryStorage.java
    incubator/pig/trunk/test/org/apache/pig/test/TestBuiltin.java
    incubator/pig/trunk/test/org/apache/pig/test/TestCombiner.java
    incubator/pig/trunk/test/org/apache/pig/test/TestCompressedFiles.java
    incubator/pig/trunk/test/org/apache/pig/test/TestEvalPipeline.java
    incubator/pig/trunk/test/org/apache/pig/test/TestFilterOpNumeric.java
    incubator/pig/trunk/test/org/apache/pig/test/TestFilterOpString.java
    incubator/pig/trunk/test/org/apache/pig/test/TestInfixArithmetic.java
    incubator/pig/trunk/test/org/apache/pig/test/TestLargeFile.java
    incubator/pig/trunk/test/org/apache/pig/test/TestMapReduce.java
    
incubator/pig/trunk/test/org/apache/pig/test/TestMapReduceResultRecycling.java
    incubator/pig/trunk/test/org/apache/pig/test/TestOrderBy.java
    incubator/pig/trunk/test/org/apache/pig/test/TestParamSubPreproc.java
    incubator/pig/trunk/test/org/apache/pig/test/TestPi.java
    incubator/pig/trunk/test/org/apache/pig/test/TestPigContext.java
    incubator/pig/trunk/test/org/apache/pig/test/TestPigFile.java
    incubator/pig/trunk/test/org/apache/pig/test/TestPigScriptParser.java
    incubator/pig/trunk/test/org/apache/pig/test/TestPigSplit.java
    incubator/pig/trunk/test/org/apache/pig/test/TestReversibleLoadStore.java
    incubator/pig/trunk/test/org/apache/pig/test/TestStore.java
    incubator/pig/trunk/test/org/apache/pig/test/TestStreaming.java
    incubator/pig/trunk/test/org/apache/pig/test/Util.java

Modified: incubator/pig/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/CHANGES.txt?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/CHANGES.txt (original)
+++ incubator/pig/trunk/CHANGES.txt Fri May 30 13:30:33 2008
@@ -306,3 +306,5 @@
 
     PIG-85: memory optimization
 
+    PIG-243: Fixing unit tests on windows
+

Modified: incubator/pig/trunk/src/org/apache/pig/builtin/PigStorage.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/builtin/PigStorage.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/builtin/PigStorage.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/builtin/PigStorage.java Fri May 30 
13:30:33 2008
@@ -59,6 +59,8 @@
         }
         String line;
         if((line = in.readLine(utf8, recordDel)) != null) {            
+            if (line.length()>0 && line.charAt(line.length()-1)=='\r')
+                line = line.substring(0, line.length()-1);
             return new Tuple(line, fieldDel);
         }
         return null;

Modified: incubator/pig/trunk/src/org/apache/pig/builtin/TextLoader.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/builtin/TextLoader.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/builtin/TextLoader.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/builtin/TextLoader.java Fri May 30 
13:30:33 2008
@@ -49,6 +49,9 @@
             return null;
         String line;
         if ((line = in.readLine(utf8, (byte)'\n')) != null) {
+            if (line.length()>0 && line.charAt(line.length()-1)=='\r')
+                line = line.substring(0, line.length()-1);
+
             Tuple t = new Tuple(1);
             t.setField(0, new DataAtom(line));
             return t;

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestAlgebraicEval.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestAlgebraicEval.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestAlgebraicEval.java 
(original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestAlgebraicEval.java Fri May 
30 13:30:33 2008
@@ -40,7 +40,7 @@
         ps.close();
         StringBuilder query = new StringBuilder();
         query.append("myid =  foreach (group (load 'file:");
-        query.append(tmpFile);
+        query.append(Util.encodeEscape(tmpFile.toString()));
         query.append("') all) generate COUNT($1);");
         if (log.isDebugEnabled()) {
             log.debug(query.toString());
@@ -63,7 +63,7 @@
         ps.close();
         StringBuilder query = new StringBuilder();
         query.append("myid = foreach (group (load 'file:");
-        query.append(tmpFile);
+        query.append(Util.encodeEscape(tmpFile.toString()));
         query.append("') all) generate group, COUNT($1) ;");
         if (log.isDebugEnabled()) {
             log.debug(query.toString());
@@ -86,7 +86,7 @@
         ps.close();
         StringBuilder query = new StringBuilder();
         query.append("myid = foreach (group (load 'file:");
-        query.append(tmpFile);
+        query.append(Util.encodeEscape(tmpFile.toString()));
         query.append("') all) generate COUNT($1), group ;");
         if (log.isDebugEnabled()) {
             log.debug(query.toString());
@@ -111,7 +111,7 @@
             ps.println(i%10 + ":" + i);
         }
         ps.close();
-        String query = "myid = foreach (group (load 'file:" + tmpFile + "' 
using " + PigStorage.class.getName() + "(':')) by $0) generate group, 
COUNT($1.$1) ;";
+        String query = "myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':')) by $0) generate group, COUNT($1.$1) ;";
         System.out.println(query);
         pigServer.registerQuery(query);
         Iterator it = pigServer.openIterator("myid");
@@ -137,7 +137,7 @@
             ps.println(i%10 + ":" + i);
         }
         ps.close();
-        String query = "myid = foreach (group (load 'file:" + tmpFile + "' 
using " + PigStorage.class.getName() + "(':')) by $0) generate group, 
COUNT($1.$1), COUNT($1.$0) ;";
+        String query = "myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':')) by $0) generate group, COUNT($1.$1), COUNT($1.$0) ;";
         System.out.println(query);
         pigServer.registerQuery(query);
         Iterator it = pigServer.openIterator("myid");

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestBinaryStorage.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestBinaryStorage.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestBinaryStorage.java 
(original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestBinaryStorage.java Fri May 
30 13:30:33 2008
@@ -78,7 +78,7 @@
                                 simpleEchoStreamingCommand + "` " +
                                 "input(stdin using BinaryStorage()) " +
                                 "output(stdout using BinaryStorage());");
-        pigServer.registerQuery("IP = load 'file:" + input + "' using " + 
+        pigServer.registerQuery("IP = load 'file:" + 
Util.encodeEscape(input.toString()) + "' using " + 
                                 "BinaryStorage() split by 'file';");
         pigServer.registerQuery("OP = stream IP through CMD;");
 
@@ -97,6 +97,7 @@
                                                 outputData, 0, outputLen) == 
0);
         
         // Cleanup
+        out.close();
         pigServer.deleteFile(output);
     }
 

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestBuiltin.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestBuiltin.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestBuiltin.java (original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestBuiltin.java Fri May 30 
13:30:33 2008
@@ -472,7 +472,7 @@
        writer.close();
        
        pig.registerFunction("myTr",ShellBagEvalFunc.class.getName() + "('tr o 
0')");
-       pig.registerQuery("a = load 'file:" + tempFile + "';");
+       pig.registerQuery("a = load 'file:" + 
Util.encodeEscape(tempFile.toString()) + "';");
        pig.registerQuery("b = foreach a generate myTr(*);");
        Iterator<Tuple> iter = pig.openIterator("b");
                
@@ -503,7 +503,7 @@
        
        pig.registerFunction("tr1",ShellBagEvalFunc.class.getName() + "('tr o 
A')");
        pig.registerFunction("tr2",ShellBagEvalFunc.class.getName() + "('tr o 
B')");
-       pig.registerQuery("a = load 'file:" + tempFile + "';");
+       pig.registerQuery("a = load 'file:" + 
Util.encodeEscape(tempFile.toString()) + "';");
        pig.registerQuery("b = foreach a generate tr1(*),tr2(*);");
        Iterator<Tuple> iter = pig.openIterator("b");
        

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestCombiner.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestCombiner.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestCombiner.java (original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestCombiner.java Fri May 30 
13:30:33 2008
@@ -39,7 +39,7 @@
         }
         ps.close();
         pig.registerQuery(loadAlias + " = load 'file:"
-                + inputFile + "' using "
+                + Util.encodeEscape(inputFile.toString()) + "' using "
                 + PigStorage.class.getName() + "(',');");
     }
 

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestCompressedFiles.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestCompressedFiles.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestCompressedFiles.java 
(original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestCompressedFiles.java Fri 
May 30 13:30:33 2008
@@ -76,7 +76,7 @@
         // FIXME : this should be tested in all modes
         if(execType == ExecType.LOCAL)
             return;
-        pigServer.registerQuery("A = foreach (cogroup (load 'file:"+gzFile+"') 
by $1, (load 'file:"+datFile + "') by $1) generate flatten( " + 
DIFF.class.getName() + "($1.$1,$2.$1)) ;");
+        pigServer.registerQuery("A = foreach (cogroup (load 
'file:"+Util.encodeEscape(gzFile.toString())+"') by $1, (load 
'file:"+Util.encodeEscape(datFile.toString()) + "') by $1) generate flatten( " 
+ DIFF.class.getName() + "($1.$1,$2.$1)) ;");
         Iterator it = pigServer.openIterator("A");
         boolean success = true;
         while(it.hasNext()) {

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestEvalPipeline.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestEvalPipeline.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestEvalPipeline.java 
(original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestEvalPipeline.java Fri May 
30 13:30:33 2008
@@ -72,7 +72,7 @@
        @Test
        public void testFunctionInsideFunction() throws Throwable {
                File f1 = createFile(new String[]{"a:1","b:1","a:1"});
-               pigServer.registerQuery("a = load 'file:" + f1 + "' using " + 
PigStorage.class.getName() + "(':');");
+               pigServer.registerQuery("a = load 'file:" + 
Util.encodeEscape(f1.toString()) + "' using " + PigStorage.class.getName() + 
"(':');");
                pigServer.registerQuery("b = foreach a generate '1'-'1'/'1';");
                Iterator<Tuple> iter  = pigServer.openIterator("b");
                
@@ -87,8 +87,8 @@
                File f1 = createFile(new String[]{"a:1","b:1","a:1"});
                File f2 = createFile(new String[]{"b","b","a"});
                
-               pigServer.registerQuery("a = load 'file:" + f1 + "' using " + 
PigStorage.class.getName() + "(':');");
-               pigServer.registerQuery("b = load 'file:" + f2 + "';");
+               pigServer.registerQuery("a = load 'file:" + 
Util.encodeEscape(f1.toString()) + "' using " + PigStorage.class.getName() + 
"(':');");
+               pigServer.registerQuery("b = load 'file:" + 
Util.encodeEscape(f2.toString()) + "';");
                pigServer.registerQuery("c = cogroup a by $0, b by $0;");       
        
                pigServer.registerQuery("d = foreach c generate 
flatten($1),flatten($2);");
                
@@ -109,7 +109,7 @@
                pw.println("a");
                pw.println("a");
                pw.close();
-               pigServer.registerQuery("a = foreach (load 'file:" + f + "') 
generate '1', flatten(" + MyBagFunction.class.getName() + "(*));");
+               pigServer.registerQuery("a = foreach (load 'file:" + 
Util.encodeEscape(f.toString()) + "') generate '1', flatten(" + 
MyBagFunction.class.getName() + "(*));");
                pigServer.registerQuery("b = foreach a generate $0, 
flatten($1);");
                Iterator<Tuple> iter = pigServer.openIterator("a");
                int count = 0;
@@ -145,7 +145,7 @@
                f.store(b, new BinStorage(), pigServer.getPigContext());
                
                
-               pigServer.registerQuery("a = load '" + fileName + "' using 
BinStorage();");
+               pigServer.registerQuery("a = load '" + 
Util.encodeEscape(fileName.toString()) + "' using BinStorage();");
                pigServer.registerQuery("b = foreach a generate 
$0#'apple',flatten($1#'orange');");
                Iterator<Tuple> iter = pigServer.openIterator("b");
                t = iter.next();
@@ -235,8 +235,8 @@
                expectedResults.put("world", 1);
                expectedResults.put("conference", 1);
                
-               pigServer.registerQuery("newsArticles = LOAD 'file:" + newsFile 
+ "' USING " + TextLoader.class.getName() + "();");
-           pigServer.registerQuery("queryLog = LOAD 'file:" + queryLogFile + 
"';");
+               pigServer.registerQuery("newsArticles = LOAD 'file:" + 
Util.encodeEscape(newsFile.toString()) + "' USING " + 
TextLoader.class.getName() + "();");
+               pigServer.registerQuery("queryLog = LOAD 'file:" + 
Util.encodeEscape(queryLogFile.toString()) + "';");
 
            pigServer.registerQuery("titleNGrams = FOREACH newsArticles 
GENERATE flatten(" + TitleNGrams.class.getName() + "(*));");
            pigServer.registerQuery("cogrouped = COGROUP titleNGrams BY $0 
INNER, queryLog BY $0 INNER;");
@@ -270,7 +270,7 @@
         ps.close(); 
                
         String tmpOutputFile = FileLocalizer.getTemporaryPath(null, 
pigServer.getPigContext()).toString();
-               pigServer.registerQuery("A = LOAD 'file:" + tmpFile + "';");
+               pigServer.registerQuery("A = LOAD 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "';");
                if (eliminateDuplicates){
                        pigServer.registerQuery("B = DISTINCT (FOREACH A 
GENERATE $0) PARALLEL 10;");
                }else{
@@ -278,7 +278,7 @@
                }
                pigServer.store("B", tmpOutputFile);
                
-               pigServer.registerQuery("A = load '" + tmpOutputFile + "';");
+               pigServer.registerQuery("A = load '" + 
Util.encodeEscape(tmpOutputFile.toString()) + "';");
                Iterator<Tuple> iter = pigServer.openIterator("A");
                int last = -1;
                while (iter.hasNext()){

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestFilterOpNumeric.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestFilterOpNumeric.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestFilterOpNumeric.java 
(original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestFilterOpNumeric.java Fri 
May 30 13:30:33 2008
@@ -52,7 +52,7 @@
             }
         }
         ps.close();
-        pigServer.registerQuery("A=load 'file:" + tmpFile + "' using 
"+PigStorage.class.getName() +"(':');");
+        pigServer.registerQuery("A=load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using "+PigStorage.class.getName() 
+"(':');");
         String query = "A = filter A by $0 == $1;";
         log.info(query);
         pigServer.registerQuery(query);
@@ -82,7 +82,7 @@
             }
         }
         ps.close();
-        pigServer.registerQuery("A=load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':');");
+        pigServer.registerQuery("A=load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':');");
         String query = "A = filter A by $0 != $1;";
         log.info(query);
         pigServer.registerQuery(query);
@@ -108,7 +108,7 @@
             }
         }
         ps.close();
-        pigServer.registerQuery("A=load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':');");
+        pigServer.registerQuery("A=load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':');");
         String query = "A = filter A by $0 > $1;";
 
         log.info(query);
@@ -131,7 +131,7 @@
             ps.println(i + "\t" + i + "\t1");            
         }
         ps.close();
-        pigServer.registerQuery("A=load 'file:" + tmpFile + "';");
+        pigServer.registerQuery("A=load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "';");
         String query = "A = foreach A generate ($1 >= '"+ 
LOOP_COUNT+"'-'10'?'1':'0');";
         log.info(query);
         pigServer.registerQuery(query);
@@ -159,7 +159,7 @@
             ps.println(i + "\t" + i + "\t1");            
         }
         ps.close();
-        pigServer.registerQuery("A=load 'file:" + tmpFile + "';");
+        pigServer.registerQuery("A=load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "';");
         String query = "A = foreach A generate ($0 < '10'?($1 >= '5' ? '2': 
'1') : '0');";
         log.info(query);
         pigServer.registerQuery(query);
@@ -190,7 +190,7 @@
             }
         }
         ps.close();
-        pigServer.registerQuery("A=load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':');");
+        pigServer.registerQuery("A=load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':');");
         String query = "A = filter A by $0 < $1;";
 
         log.info(query);
@@ -220,7 +220,7 @@
             }
         }
         ps.close();
-        pigServer.registerQuery("A=load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':');");
+        pigServer.registerQuery("A=load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':');");
         String query = "A = filter A by $0 >= $1;";
 
         log.info(query);
@@ -249,7 +249,7 @@
             }
         }
         ps.close();
-        pigServer.registerQuery("A=load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':');");
+        pigServer.registerQuery("A=load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':');");
         String query = "A = filter A by $0 <= $1;";
 
         log.info(query);

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestFilterOpString.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestFilterOpString.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestFilterOpString.java 
(original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestFilterOpString.java Fri 
May 30 13:30:33 2008
@@ -52,7 +52,7 @@
             }
         }
         ps.close();
-        pigServer.registerQuery("A=load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':');");
+        pigServer.registerQuery("A=load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':');");
         String query = "A = filter A by $0 eq $1;";
 
         log.info(query);
@@ -79,7 +79,7 @@
             }
         }
         ps.close();
-        pigServer.registerQuery("A=load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':');");
+        pigServer.registerQuery("A=load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':');");
         String query = "A = filter A by $0 neq $1;";
 
         log.info(query);
@@ -106,7 +106,7 @@
             }
         }
         ps.close();
-        pigServer.registerQuery("A=load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':');");
+        pigServer.registerQuery("A=load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':');");
         String query = "A = filter A by $0 gt $1;";
 
         log.info(query);
@@ -138,7 +138,7 @@
         }
         ps.close();
         
-        pigServer.registerQuery("A=load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':');");
+        pigServer.registerQuery("A=load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':');");
         String query = "A = filter A by $0 gte $1;";
 
         log.info(query);
@@ -166,7 +166,7 @@
         }
         ps.close();
         
-        pigServer.registerQuery("A=load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':');");
+        pigServer.registerQuery("A=load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':');");
         String query = "A = filter A by $0 lt $1;";
 
         log.info(query);
@@ -196,7 +196,7 @@
         }
         ps.close();
         
-        pigServer.registerQuery("A=load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':');");
+        pigServer.registerQuery("A=load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':');");
         String query = "A = filter A by $0 lte $1;";
 
         log.info(query);

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestInfixArithmetic.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestInfixArithmetic.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestInfixArithmetic.java 
(original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestInfixArithmetic.java Fri 
May 30 13:30:33 2008
@@ -58,7 +58,7 @@
             ps.println(i + ":" + i);
         }
         ps.close();
-        String query = "A = foreach (load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':')) generate $0, $0 + $1, $1;";
+        String query = "A = foreach (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':')) generate $0, $0 + $1, $1;";
         log.info(query);
         pig.registerQuery(query);
         Iterator it = pig.openIterator("A");
@@ -79,7 +79,7 @@
             ps.println(i + ":" + i);
         }
         ps.close();
-        String query = "A = foreach (load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':')) generate $0, $0 - $1, $1 ;";
+        String query = "A = foreach (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':')) generate $0, $0 - $1, $1 ;";
         log.info(query);
         pig.registerQuery(query);
         Iterator it = pig.openIterator("A");
@@ -99,7 +99,7 @@
             ps.println(i + ":" + i);
         }
         ps.close();
-        String query = "A = foreach (load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':')) generate $0, $0 * $1, $1 ;";
+        String query = "A = foreach (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':')) generate $0, $0 * $1, $1 ;";
         log.info(query);
         pig.registerQuery(query);
         Iterator it = pig.openIterator("A");
@@ -120,7 +120,7 @@
             ps.println(i + ":" + i);
         }
         ps.close();
-        String query = "A =  foreach (load 'file:" + tmpFile + "' using " + 
PigStorage.class.getName() + "(':')) generate $0, $0 / $1, $1;";
+        String query = "A =  foreach (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "' using " + PigStorage.class.getName() 
+ "(':')) generate $0, $0 / $1, $1;";
         log.info(query);
         pig.registerQuery(query);
         Iterator it = pig.openIterator("A");

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestLargeFile.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestLargeFile.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestLargeFile.java (original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestLargeFile.java Fri May 30 
13:30:33 2008
@@ -113,9 +113,9 @@
        @Test
        public void testLargeFile () throws Exception {
                System.out.println("Running testLargeFile...");
-               pig.registerQuery("A = load " + fileName + ";");
+               pig.registerQuery("A = load " + 
Util.encodeEscape(fileName.toString()) + ";");
                pig.registerQuery("A = group A by $0;");
-               pig.store("A", tmpFile1, "BinStorage()");
+               pig.store("A", Util.encodeEscape(tmpFile1.toString()), 
"BinStorage()");
 //             pig.store("A", tmpFile1);
                pig.registerQuery("B = foreach A generate group, COUNT($1);");
                
@@ -137,7 +137,7 @@
        public void testOrder () throws Exception {
                System.out.println("Running testOrder...");
                int N = 0, Nplus1 = 0;
-               pig.registerQuery("A = load " + fileName + ";");
+               pig.registerQuery("A = load " + 
Util.encodeEscape(fileName.toString()) + ";");
                pig.registerQuery("B = order A by $0;");
                
                Iterator <Tuple> B = pig.openIterator("B");
@@ -164,7 +164,7 @@
        @Test
        public void testDistinct () throws Exception {
                System.out.println("Running testDistinct...");
-               pig.registerQuery("A = load " + fileName + ";");
+               pig.registerQuery("A = load " + 
Util.encodeEscape(fileName.toString()) + ";");
                pig.registerQuery("B = distinct A;");
                
                Iterator <Tuple> B = pig.openIterator("B");

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestMapReduce.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestMapReduce.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestMapReduce.java (original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestMapReduce.java Fri May 30 
13:30:33 2008
@@ -72,7 +72,7 @@
             ps.println(i);
         }
         ps.close();
-        String query = "foreach (group (load 'file:" + tmpFile + "') all) 
generate " + COUNT.class.getName() + "($1) ;";
+        String query = "foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "') all) generate " + 
COUNT.class.getName() + "($1) ;";
         System.out.println(query);
         pig.registerQuery("asdf_id = " + query);
         Iterator it = pig.openIterator("asdf_id");
@@ -138,7 +138,7 @@
             ps.println(i+"\t"+i);
         }
         ps.close();
-        String query = "foreach (load 'file:"+tmpFile+"') generate $0,$1;";
+        String query = "foreach (load 
'file:"+Util.encodeEscape(tmpFile.toString())+"') generate $0,$1;";
         System.out.println(query);
         pig.registerQuery("asdf_id = " + query);
         try {
@@ -164,7 +164,7 @@
             ps.println(i);
         }
         ps.close();
-        String query = "foreach (group (load 'file:"+tmpFile+"' using " + 
MyStorage.class.getName() + "()) by " + MyGroup.class.getName() + "('all')) 
generate flatten(" + MyApply.class.getName() + "($1)) ;";
+        String query = "foreach (group (load 
'file:"+Util.encodeEscape(tmpFile.toString())+"' using " + 
MyStorage.class.getName() + "()) by " + MyGroup.class.getName() + "('all')) 
generate flatten(" + MyApply.class.getName() + "($1)) ;";
         System.out.println(query);
         pig.registerQuery("asdf_id = " + query);
         Iterator it = pig.openIterator("asdf_id");
@@ -189,7 +189,7 @@
         }
         ps.close();
         pig.registerFunction("foo", MyApply.class.getName()+"('foo')");
-        String query = "foreach (group (load 'file:"+tmpFile+"' using " + 
MyStorage.class.getName() + "()) by " + MyGroup.class.getName() + "('all')) 
generate flatten(foo($1)) ;";
+        String query = "foreach (group (load 
'file:"+Util.encodeEscape(tmpFile.toString())+"' using " + 
MyStorage.class.getName() + "()) by " + MyGroup.class.getName() + "('all')) 
generate flatten(foo($1)) ;";
         System.out.println(query);
         pig.registerQuery("asdf_id = " + query);
         Iterator it = pig.openIterator("asdf_id");

Modified: 
incubator/pig/trunk/test/org/apache/pig/test/TestMapReduceResultRecycling.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestMapReduceResultRecycling.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- 
incubator/pig/trunk/test/org/apache/pig/test/TestMapReduceResultRecycling.java 
(original)
+++ 
incubator/pig/trunk/test/org/apache/pig/test/TestMapReduceResultRecycling.java 
Fri May 30 13:30:33 2008
@@ -14,7 +14,7 @@
     public void testPlanRecycling() throws Throwable {
         File tmpFile = this.createTempFile();
         {            
-            String query = "a = load 'file:" + tmpFile + "'; " ;
+            String query = "a = load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "'; " ;
             System.out.println(query);
             pigServer.registerQuery(query);
             pigServer.explain("a", System.out) ;

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestOrderBy.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestOrderBy.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestOrderBy.java (original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestOrderBy.java Fri May 30 
13:30:33 2008
@@ -74,111 +74,111 @@
 
     @Test
     public void testTopLevelOrderBy_Star_NoUsing() throws Exception {
-        verify("myid = order (load 'file:" + tmpFile + "') BY *;", false);
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "') BY *;", false);
     }
 
     @Test
     public void testTopLevelOrderBy_Col1_NoUsing() throws Exception {
-        verify("myid = order (load 'file:" + tmpFile + "') BY $1;", false);
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "') BY $1;", false);
     }
 
     @Test
     public void testTopLevelOrderBy_Col2_NoUsing() throws Exception {
-        verify("myid = order (load 'file:" + tmpFile + "') BY $2;", true);
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "') BY $2;", true);
     }
 
     @Test
     public void testTopLevelOrderBy_Col21_NoUsing() throws Exception {
-        verify("myid = order (load 'file:" + tmpFile + "') BY $2, $1;", true);
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) + "') BY $2, $1;", true);
     }
 
     @Test
     public void testTopLevelOrderBy_Star_Using() throws Exception {
-        verify("myid = order (load 'file:" + tmpFile +
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') BY * USING org.apache.pig.test.OrdAsc;", false);
-        verify("myid = order (load 'file:" + tmpFile +
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') BY * USING org.apache.pig.test.OrdDesc;", true);
-        verify("myid = order (load 'file:" + tmpFile +
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') BY * USING org.apache.pig.test.OrdDescNumeric;", true);
     }
 
     @Test
     public void testTopLevelOrderBy_Col1_Using() throws Exception {
-        verify("myid = order (load 'file:" + tmpFile +
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') BY $1 USING org.apache.pig.test.OrdAsc;", false);
-        verify("myid = order (load 'file:" + tmpFile +
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') BY $1 USING org.apache.pig.test.OrdDesc;", true);
-        verify("myid = order (load 'file:" + tmpFile +
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') BY $1 USING org.apache.pig.test.OrdDescNumeric;", true);
     }
 
     @Test
     public void testTopLevelOrderBy_Col2_Using() throws Exception {
-        verify("myid = order (load 'file:" + tmpFile +
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') BY $2 USING org.apache.pig.test.OrdAsc;", true);
-        verify("myid = order (load 'file:" + tmpFile +
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') BY $2 USING org.apache.pig.test.OrdDesc;", false);
-        verify("myid = order (load 'file:" + tmpFile +
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') BY $2 USING org.apache.pig.test.OrdDescNumeric;", false);
     }
 
     @Test
     public void testTopLevelOrderBy_Col21_Using() throws Exception {
         // col2/col1 ascending - 
-        verify("myid = order (load 'file:" + tmpFile +
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') BY $2, $1 USING org.apache.pig.test.OrdAsc;", true);
-        verify("myid = order (load 'file:" + tmpFile +
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') BY $2, $1 USING org.apache.pig.test.OrdDesc;", false);
-        verify("myid = order (load 'file:" + tmpFile +
+        verify("myid = order (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') BY $2, $1 USING org.apache.pig.test.OrdDescNumeric;", false);
     }
 
     @Test
     public void testNestedOrderBy_Star_NoUsing() throws Exception {
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') by $0) { D = ORDER $1 BY *; generate flatten(D); };", false);
     }
 
     @Test
     public void testNestedOrderBy_Col1_NoUsing() throws Exception {
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') by $0) { D = ORDER $1 BY $1; generate flatten(D); };", false);
     }
 
     @Test
     public void testNestedOrderBy_Col2_NoUsing() throws Exception {
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') by $0) { D = ORDER $1 BY $2; generate flatten(D); };", true);
     }
 
     @Test
     public void testNestedOrderBy_Col21_NoUsing() throws Exception {
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') by $0) { D = ORDER $1 BY $2, $1; generate flatten(D); };", 
true);
     }
 
     @Test
     public void testNestedOrderBy_Star_Using() throws Exception {
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') by $0) { D = ORDER $1 BY * USING " + 
             "org.apache.pig.test.OrdAsc; generate flatten(D); };", false);
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') by $0) { D = ORDER $1 BY * USING " + 
             "org.apache.pig.test.OrdDesc; generate flatten(D); };", true);
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') by $0) { D = ORDER $1 BY * USING " + 
             "org.apache.pig.test.OrdDescNumeric; generate flatten(D); };", 
true);
     }
 
     @Test
     public void testNestedOrderBy_Col1_Using() throws Exception {
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') by $0) { D = ORDER $1 BY $1 USING " + 
             "org.apache.pig.test.OrdAsc; generate flatten(D); };", false);
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
             "') by $0) { D = ORDER $1 BY $1 USING " + 
             "org.apache.pig.test.OrdDesc; generate flatten(D); };", true);
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
                 "') by $0) { D = ORDER $1 BY $1 USING " + 
                 "org.apache.pig.test.OrdDescNumeric; generate flatten(D); };",
                 true);
@@ -186,13 +186,13 @@
 
     @Test
     public void testNestedOrderBy_Col2_Using() throws Exception {
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
                 "') by $0) { D = ORDER $1 BY $2 USING " +
                 "org.apache.pig.test.OrdAsc; generate flatten(D); };", true);
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
                 "') by $0) { D = ORDER $1 BY $2 USING " +
                 "org.apache.pig.test.OrdDesc; generate flatten(D); };", false);
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
                 "') by $0) { D = ORDER $1 BY $2 USING " +
                 "org.apache.pig.test.OrdDescNumeric; generate flatten(D); };",
                 false);
@@ -201,13 +201,13 @@
     @Test
     public void testNestedOrderBy_Col21_Using() throws Exception {
         // col2/col1 ascending - 
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
                 "') by $0) { D = ORDER $1 BY $2, $1 USING " +
                 "org.apache.pig.test.OrdAsc; generate flatten(D); };", true);
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
                 "') by $0) { D = ORDER $1 BY $2, $1 USING " +
                 "org.apache.pig.test.OrdDesc; generate flatten(D); };", false);
-        verify("myid = foreach (group (load 'file:" + tmpFile +
+        verify("myid = foreach (group (load 'file:" + 
Util.encodeEscape(tmpFile.toString()) +
                 "') by $0) { D = ORDER $1 BY $2, $1 USING " +
                 "org.apache.pig.test.OrdDescNumeric; generate flatten(D); };",
                 false);

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestParamSubPreproc.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestParamSubPreproc.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestParamSubPreproc.java 
(original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestParamSubPreproc.java Fri 
May 30 13:30:33 2008
@@ -1198,6 +1198,9 @@
 
             String[] arg = {"date=`perl -e 'print \"20080228\n20070101\"' | 
head -n 1`"};
             String[] argFiles = null;
+            if 
(System.getProperty("os.name").toUpperCase().startsWith("WINDOWS"))
+                arg[0] = "date=`perl -e 'print \\\"20080228\n20070101\\\"' | 
head -n 1`";
+
             ps.genSubstitutedFile(pigIStream , pigOStream , arg , argFiles);
 
             FileInputStream pigResultStream = new FileInputStream(basedir + 
"/output1.pig");

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestPi.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestPi.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestPi.java (original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestPi.java Fri May 30 
13:30:33 2008
@@ -122,12 +122,12 @@
        @Test
        public void testPi () throws Exception {
                
-               pig.registerQuery("A = load " + fileName + " using 
PigStorage(':');");
+               pig.registerQuery("A = load " + 
Util.encodeEscape(fileName.toString()) + " using PigStorage(':');");
                pig.registerQuery("B = foreach A generate $0 - '0.5' as d1, $1 
- '0.5' as d2;");
                pig.registerQuery("C = foreach B generate $0 * $0 as m1, $1 * 
$1 as m2;");
                pig.registerQuery("D = foreach C generate $0 + $1 as s1;");
                pig.registerQuery("D = foreach D generate $0, ARITY($0);");
-               pig.store("D", tmpFile1);
+               pig.store("D", Util.encodeEscape(tmpFile1.toString()));
 
                pig.registerQuery("E = filter D by $0 <= '0.25';");
 

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestPigContext.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestPigContext.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestPigContext.java (original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestPigContext.java Fri May 30 
13:30:33 2008
@@ -82,7 +82,7 @@
 
     private List<String> getCommands() {
         List<String> commands = new ArrayList<String>();
-        commands.add("my_input = LOAD '" + input.getAbsolutePath() + "' USING 
PigStorage();");
+        commands.add("my_input = LOAD '" + 
Util.encodeEscape(input.getAbsolutePath().toString()) + "' USING 
PigStorage();");
         commands.add("words = FOREACH my_input GENERATE 
FLATTEN(TOKENIZE(*));");
         commands.add("grouped = GROUP words BY $0;");
         commands.add("counts = FOREACH grouped GENERATE group, COUNT(words);");

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestPigFile.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestPigFile.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestPigFile.java (original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestPigFile.java Fri May 30 
13:30:33 2008
@@ -81,12 +81,12 @@
         
         log.info("Running Store...");
         String initialdata = File.createTempFile("pig-tmp", 
"").getAbsolutePath();
-        PigFile store = new PigFile(initialdata);
+        PigFile store = new PigFile(Util.encodeEscape(initialdata.toString()));
         store.store(bag, new PigStorage(), pigContext);
         log.info("Done.");
 
         log.info("Running Load...");
-        PigFile load = new PigFile(initialdata);
+        PigFile load = new PigFile(Util.encodeEscape(initialdata.toString()));
         DataBag loaded = load.load(new PigStorage(), pigContext);
         log.info("Done.");
 
@@ -191,7 +191,7 @@
             ps.println(i);
         }
         ps.close();
-        pig.registerQuery("a = load 'file:" + tmpFile+"';");
+        pig.registerQuery("a = load 'file:" + 
Util.encodeEscape(tmpFile.toString())+"';");
         pig.store("a", "/tmp/abc/xyz");
         
         tmpFile.delete();

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestPigScriptParser.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestPigScriptParser.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestPigScriptParser.java 
(original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestPigScriptParser.java Fri 
May 30 13:30:33 2008
@@ -34,7 +34,7 @@
         // Start the real parsing job
         {
                // Initial statement
-               String query = String.format("A = LOAD '%s' ;", tempFile) ;
+               String query = String.format("A = LOAD '%s' ;", 
Util.encodeEscape(tempFile)) ;
                ByteArrayInputStream in = new 
ByteArrayInputStream(query.getBytes()); 
                QueryParser parser = new QueryParser(in, pigContext, "scope", 
aliases, opTable) ;
                LogicalPlan lp = parser.Parse() ; 

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestPigSplit.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestPigSplit.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestPigSplit.java (original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestPigSplit.java Fri May 30 
13:30:33 2008
@@ -35,7 +35,7 @@
                pw.println("0\ta");
                pw.close();
                
-               pigServer.registerQuery("a = load 'file:" + f + "';");
+               pigServer.registerQuery("a = load 'file:" + 
Util.encodeEscape(f.toString()) + "';");
                for (int i=0; i< 500; i++){
                        pigServer.registerQuery("a = filter a by $0 == '1';");
                }
@@ -55,7 +55,7 @@
         pw.println("12");
         pw.println("42");
         pw.close();
-        pigServer.registerQuery("a = load 'file:" + f + "' as (value);");
+        pigServer.registerQuery("a = load 'file:" + 
Util.encodeEscape(f.toString()) + "' as (value);");
         pigServer.registerQuery("split a into b if value < 20, c if value > 
10;");
         pigServer.registerQuery("b1 = order b by value;");
         pigServer.registerQuery("c1 = order c by value;");

Modified: 
incubator/pig/trunk/test/org/apache/pig/test/TestReversibleLoadStore.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestReversibleLoadStore.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestReversibleLoadStore.java 
(original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestReversibleLoadStore.java 
Fri May 30 13:30:33 2008
@@ -32,7 +32,7 @@
         File tmpFile = createTempFile() ;
         
         PigServer pig = new PigServer(ExecType.LOCAL);
-        pig.registerQuery("A = LOAD 'file:" + tmpFile.getAbsolutePath() + "' 
USING "
+        pig.registerQuery("A = LOAD 'file:" + 
Util.encodeEscape(tmpFile.getAbsolutePath().toString()) + "' USING "
                         + DummyLoadFunc.class.getName() + "();");
 
         String file1 = "/tmp/testPigOutput" ;
@@ -68,7 +68,7 @@
         File tmpFile = createTempFile() ;
         
         PigServer pig = new PigServer(ExecType.LOCAL);
-        pig.registerQuery("A = LOAD 'file:" + tmpFile.getAbsolutePath() + "' 
USING "
+        pig.registerQuery("A = LOAD 'file:" + 
Util.encodeEscape(tmpFile.getAbsolutePath().toString()) + "' USING "
                         + DummyLoadStoreFunc.class.getName() + "();");
 
         String file1 = "/tmp/testPigOutput" ;

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestStore.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestStore.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestStore.java (original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestStore.java Fri May 30 
13:30:33 2008
@@ -37,11 +37,11 @@
        String tmpFile1, tmpFile2;
 
        public void testSingleStore() throws Exception{
-               pigServer.registerQuery("A = load " + fileName + ";");
+               pigServer.registerQuery("A = load " + 
Util.encodeEscape(fileName.toString()) + ";");
                
-               pigServer.store("A", tmpFile1);
+               pigServer.store("A", Util.encodeEscape(tmpFile1.toString()));
                
-               pigServer.registerQuery("B = load " + tmpFile1 + ";");
+               pigServer.registerQuery("B = load " + 
Util.encodeEscape(tmpFile1.toString()) + ";");
                Iterator<Tuple> iter  = pigServer.openIterator("B");
                
                int i =0;
@@ -54,13 +54,13 @@
        }
        
        public void testMultipleStore() throws Exception{
-               pigServer.registerQuery("A = load " + fileName + ";");
+               pigServer.registerQuery("A = load " + 
Util.encodeEscape(fileName.toString()) + ";");
                
-               pigServer.store("A", tmpFile1);
+               pigServer.store("A", Util.encodeEscape(tmpFile1.toString()));
                
                pigServer.registerQuery("B = foreach (group A by $0) generate 
$0, SUM($1);");
-               pigServer.store("B", tmpFile2);
-               pigServer.registerQuery("C = load " + tmpFile2 + ";");
+               pigServer.store("B", Util.encodeEscape(tmpFile2.toString()));
+               pigServer.registerQuery("C = load " + 
Util.encodeEscape(tmpFile2.toString()) + ";");
                Iterator<Tuple> iter  = pigServer.openIterator("C");
                
                int i =0;
@@ -75,13 +75,13 @@
        }
        
        public void testStoreWithMultipleMRJobs() throws Exception{
-               pigServer.registerQuery("A = load " + fileName + ";");          
+               pigServer.registerQuery("A = load " + 
Util.encodeEscape(fileName.toString()) + ";");
                pigServer.registerQuery("B = foreach (group A by $0) generate 
$0, SUM($1);");
                pigServer.registerQuery("C = foreach (group B by $0) generate 
$0, SUM($1);");
                pigServer.registerQuery("D = foreach (group C by $0) generate 
$0, SUM($1);");
 
-               pigServer.store("D", tmpFile2);
-               pigServer.registerQuery("E = load " + tmpFile2 + ";");
+               pigServer.store("D", Util.encodeEscape(tmpFile2.toString()));
+               pigServer.registerQuery("E = load " + 
Util.encodeEscape(tmpFile2.toString()) + ";");
                Iterator<Tuple> iter  = pigServer.openIterator("E");
                
                int i =0;

Modified: incubator/pig/trunk/test/org/apache/pig/test/TestStreaming.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestStreaming.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/TestStreaming.java (original)
+++ incubator/pig/trunk/test/org/apache/pig/test/TestStreaming.java Fri May 30 
13:30:33 2008
@@ -32,8 +32,13 @@
 
 public class TestStreaming extends PigExecTestCase {
 
-       private static final String simpleEchoStreamingCommand = 
-               "perl -ne 'chomp $_; print \"$_\n\"'";
+       private static final String simpleEchoStreamingCommand;
+        static {
+            if 
(System.getProperty("os.name").toUpperCase().startsWith("WINDOWS"))
+                simpleEchoStreamingCommand = "perl -ne 'print \\\"$_\\\"'";
+            else
+                simpleEchoStreamingCommand = "perl -ne 'print \"$_\"'";
+        }
 
     private Tuple[] setupExpectedResults(String[] firstField, int[] 
secondField) {
                Assert.assertEquals(firstField.length, secondField.length);
@@ -63,7 +68,7 @@
                        setupExpectedResults(expectedFirstFields, 
expectedSecondFields);
 
                // Pig query to run
-               pigServer.registerQuery("IP = load 'file:" + input + "' using " 
+ 
+               pigServer.registerQuery("IP = load 'file:" + 
Util.encodeEscape(input.toString()) + "' using " + 
                                                PigStorage.class.getName() + 
"(',');");
                pigServer.registerQuery("FILTERED_DATA = filter IP by $1 > 
'3';");
         pigServer.registerQuery("S1 = stream FILTERED_DATA through `" +
@@ -90,7 +95,7 @@
                        setupExpectedResults(expectedFirstFields, 
expectedSecondFields);
 
                // Pig query to run
-               pigServer.registerQuery("IP = load 'file:" + input + "' using " 
+ 
+               pigServer.registerQuery("IP = load 'file:" + 
Util.encodeEscape(input.toString()) + "' using " + 
                                                PigStorage.class.getName() + 
"(',');");
                pigServer.registerQuery("FILTERED_DATA = filter IP by $1 > 
'3';");
                pigServer.registerQuery("STREAMED_DATA = stream FILTERED_DATA 
through `" +
@@ -116,7 +121,7 @@
                        setupExpectedResults(expectedFirstFields, 
expectedSecondFields);
 
                // Pig query to run
-               pigServer.registerQuery("IP = load 'file:" + input + "' using " 
+ 
+               pigServer.registerQuery("IP = load 'file:" + 
Util.encodeEscape(input.toString()) + "' using " + 
                                                PigStorage.class.getName() + 
"(',');");
                pigServer.registerQuery("FILTERED_DATA = filter IP by $1 > 
'3';");
                pigServer.registerQuery("GROUPED_DATA = group FILTERED_DATA by 
$0;");
@@ -159,7 +164,7 @@
                        setupExpectedResults(expectedFirstFields, 
expectedSecondFields);
 
                // Pig query to run
-               pigServer.registerQuery("IP = load 'file:" + input + "' using " 
+ 
+               pigServer.registerQuery("IP = load 'file:" + 
Util.encodeEscape(input.toString()) + "' using " + 
                                                PigStorage.class.getName() + 
"(',');");
                pigServer.registerQuery("FILTERED_DATA = filter IP by $1 > 
'3';");
         pigServer.registerQuery("S1 = stream FILTERED_DATA through `" +
@@ -223,7 +228,7 @@
                 "ship ('" + command2 + "') " +
                 "input('bar' using " + PigStorage.class.getName() + "(',')) " +
                 "stderr();"); 
-        pigServer.registerQuery("IP = load 'file:" + input + "' using " + 
+        pigServer.registerQuery("IP = load 'file:" + 
Util.encodeEscape(input.toString()) + "' using " + 
                                 PigStorage.class.getName() + "(',');");
         pigServer.registerQuery("FILTERED_DATA = filter IP by $1 > '3';");
         pigServer.registerQuery("STREAMED_DATA = stream FILTERED_DATA " +
@@ -296,7 +301,7 @@
                 "cache ('" + c2 + "#script2.pl') " +
                 "input('bar' using " + PigStorage.class.getName() + "(',')) " +
                 "stderr();"); 
-        pigServer.registerQuery("IP = load 'file:" + input + "' using " + 
+        pigServer.registerQuery("IP = load 'file:" + 
Util.encodeEscape(input.toString()) + "' using " + 
                                 PigStorage.class.getName() + "(',');");
         pigServer.registerQuery("FILTERED_DATA = filter IP by $1 > '3';");
         pigServer.registerQuery("STREAMED_DATA = stream FILTERED_DATA " +
@@ -359,7 +364,7 @@
                        "output('foo' using " + PigStorage.class.getName() + 
"(','), " +
                        "'bar' using " + PigStorage.class.getName() + "(',')) " 
+
                        "stderr();"); 
-        pigServer.registerQuery("IP = load 'file:" + input + "' using " + 
+        pigServer.registerQuery("IP = load 'file:" + 
Util.encodeEscape(input.toString()) + "' using " + 
                                 PigStorage.class.getName() + "(',');");
         pigServer.registerQuery("FILTERED_DATA = filter IP by $1 > '3';");
         pigServer.registerQuery("OP = stream FILTERED_DATA through CMD;");
@@ -424,7 +429,7 @@
                 "output('bar', " +
                 "'foobar' using " + PigStorage.class.getName() + "(',')) " +
                 "stderr();"); 
-        pigServer.registerQuery("IP = load 'file:" + input + "' using " + 
+        pigServer.registerQuery("IP = load 'file:" + 
Util.encodeEscape(input.toString()) + "' using " + 
                                 PigStorage.class.getName() + "(',');");
         pigServer.registerQuery("FILTERED_DATA = filter IP by $1 > '3';");
         pigServer.registerQuery("OP = stream FILTERED_DATA through CMD;");
@@ -468,7 +473,7 @@
         // Pig query to run
         pigServer.registerQuery("define CMD `" + simpleEchoStreamingCommand + 
                                 " | " + simpleEchoStreamingCommand + "`;");
-        pigServer.registerQuery("IP = load 'file:" + input + "' using " + 
+        pigServer.registerQuery("IP = load 'file:" + 
Util.encodeEscape(input.toString()) + "' using " + 
                                 PigStorage.class.getName() + "(',');");
         pigServer.registerQuery("OP = stream IP through CMD;");
         
@@ -502,7 +507,7 @@
         // Pig query to run
         pigServer.registerQuery("define CMD `"+ simpleEchoStreamingCommand + 
                                 "` input(stdin using PigDump);");
-        pigServer.registerQuery("IP = load 'file:" + input + "' using " + 
+        pigServer.registerQuery("IP = load 'file:" + 
Util.encodeEscape(input.toString()) + "' using " + 
                                 PigStorage.class.getName() + "(',') " +
                                 "split by 'file';");
         pigServer.registerQuery("FILTERED_DATA = filter IP by $1 > '3';");

Modified: incubator/pig/trunk/test/org/apache/pig/test/Util.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/Util.java?rev=661840&r1=661839&r2=661840&view=diff
==============================================================================
--- incubator/pig/trunk/test/org/apache/pig/test/Util.java (original)
+++ incubator/pig/trunk/test/org/apache/pig/test/Util.java Fri May 30 13:30:33 
2008
@@ -21,6 +21,7 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Iterator;
+import static java.util.regex.Matcher.quoteReplacement;
 
 import org.apache.pig.data.*;
 import org.junit.Assert;
@@ -128,4 +129,17 @@
         System.out.println("---End----") ;
     }
 
+       /**
+     * Helper method to replace all occurrences of "\" with "\\" in a 
+     * string. This is useful to fix the file path string on Windows
+     * where "\" is used as the path separator.
+     * 
+     * @param str Any string
+     * @return The resulting string
+     */
+       public static String encodeEscape(String str) {
+           String regex = "\\\\";
+           String replacement = quoteReplacement("\\\\");
+           return str.replaceAll(regex, replacement);
+}
 }


Reply via email to