db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r828206 - in /db/jdo/trunk/api2: src/java/javax/jdo/ test/java/javax/jdo/ test/resources/enhancer-test-dir/ test/resources/enhancer-test-dir/enhancer-test-subdir/
Date Wed, 21 Oct 2009 20:47:31 GMT
Author: clr
Date: Wed Oct 21 20:47:31 2009
New Revision: 828206

URL: http://svn.apache.org/viewvc?rev=828206&view=rev
Log:
JDO-641 Fixed directory option for Enhancer

Added:
    db/jdo/trunk/api2/test/resources/enhancer-test-dir/
    db/jdo/trunk/api2/test/resources/enhancer-test-dir/enhancer-test-subdir/
    db/jdo/trunk/api2/test/resources/enhancer-test-dir/enhancer-test-subdir/file4.jdo   (with
props)
    db/jdo/trunk/api2/test/resources/enhancer-test-dir/enhancer-test-subdir/file5.class
    db/jdo/trunk/api2/test/resources/enhancer-test-dir/enhancer-test-subdir/file6.jar
    db/jdo/trunk/api2/test/resources/enhancer-test-dir/file1.jdo   (with props)
    db/jdo/trunk/api2/test/resources/enhancer-test-dir/file2.class
    db/jdo/trunk/api2/test/resources/enhancer-test-dir/file3.jar
Modified:
    db/jdo/trunk/api2/src/java/javax/jdo/Enhancer.java
    db/jdo/trunk/api2/test/java/javax/jdo/EnhancerTest.java

Modified: db/jdo/trunk/api2/src/java/javax/jdo/Enhancer.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/src/java/javax/jdo/Enhancer.java?rev=828206&r1=828205&r2=828206&view=diff
==============================================================================
--- db/jdo/trunk/api2/src/java/javax/jdo/Enhancer.java (original)
+++ db/jdo/trunk/api2/src/java/javax/jdo/Enhancer.java Wed Oct 21 20:47:31 2009
@@ -335,12 +335,17 @@
                 classFileNames.add(fileName);
                 addVerboseMessage("MSG_EnhancerClassFileName", fileName); //NOI18N
             } else {
-                // assume a directory if no suffix
-                File directory = new File(fileName);
-                if (directory.isDirectory() && search) {
-                    String[] files = directory.list();
+                // assume a directory if no recognized suffix
+                File directoryFile = new File(fileName);
+                if (directoryFile.isDirectory() && search) {
+                    String directoryPath = directoryFile.getAbsolutePath();
+                    String[] files = directoryFile.list();
+                    String[] pathName = new String[1];
                     if (files != null) {
-                        parseFiles(files, recurse, recurse);
+                        for (String file: files) {
+                            pathName[0] = directoryPath + '/' + file;
+                            parseFiles(pathName, recurse, recurse);
+                        }
                     }
                 }
             }

Modified: db/jdo/trunk/api2/test/java/javax/jdo/EnhancerTest.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/test/java/javax/jdo/EnhancerTest.java?rev=828206&r1=828205&r2=828206&view=diff
==============================================================================
--- db/jdo/trunk/api2/test/java/javax/jdo/EnhancerTest.java (original)
+++ db/jdo/trunk/api2/test/java/javax/jdo/EnhancerTest.java Wed Oct 21 20:47:31 2009
@@ -241,6 +241,37 @@
         assertEquals("Wrong return value ", 3, result.getExitValue());
     }
 
+    public void testDir() {
+        // invoke enhancer with directory and not recurse
+        InvocationResult result = invokeEnhancer("-v " + basedir + "/target/test-classes/enhancer-test-dir");
+        String outputString = result.getOutputString();
+        String errorString = result.getErrorString();
+        assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+        assertTrue("Expected directory enhancer-test-dir in message from out:\n" + outputString
+ " with err:\n" + errorString, outputString.contains("enhancer-test-dir"));
+        assertTrue("Expected file file1.jdo in message from out:\n" + outputString + " with
err:\n" + errorString, outputString.contains("file1.jdo"));
+        assertTrue("Expected file file2.class in message from out:\n" + outputString + "
with err:\n" + errorString, outputString.contains("file2.class"));
+        assertTrue("Expected file file3.jar in message from out:\n" + outputString + " with
err:\n" + errorString, outputString.contains("file3.jar"));
+        assertFalse("Expected no directory enhancer-test-subdir in message from out:\n" +
outputString + " with err:\n" + errorString, outputString.contains("enhancer-test-subdir"));
+        assertTrue("Expected 3 files to be enhanced in message from out:\n" + outputString
+ " with err:\n" + errorString, outputString.contains("3"));
+    }
+
+    public void testDirRecurse() {
+        // invoke enhancer with directory and recurse
+        InvocationResult result = invokeEnhancer("-v -r " + basedir + "/target/test-classes/enhancer-test-dir");
+        String outputString = result.getOutputString();
+        String errorString = result.getErrorString();
+        assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue());
+        assertTrue("Expected directory enhancer-test-dir in message from out:\n" + outputString
+ " with err:\n" + errorString, outputString.contains("enhancer-test-dir"));
+        assertTrue("Expected directory enhancer-test-subdir in message from out:\n" + outputString
+ " with err:\n" + errorString, outputString.contains("enhancer-test-subdir"));
+        assertTrue("Expected file file1.jdo in message from out:\n" + outputString + " with
err:\n" + errorString, outputString.contains("file1.jdo"));
+        assertTrue("Expected file file2.class in message from out:\n" + outputString + "
with err:\n" + errorString, outputString.contains("file2.class"));
+        assertTrue("Expected file file3.jar in message from out:\n" + outputString + " with
err:\n" + errorString, outputString.contains("file3.jar"));
+        assertTrue("Expected file file4.jdo in message from out:\n" + outputString + " with
err:\n" + errorString, outputString.contains("file4.jdo"));
+        assertTrue("Expected file file5.class in message from out:\n" + outputString + "
with err:\n" + errorString, outputString.contains("file5.class"));
+        assertTrue("Expected file file6.jar in message from out:\n" + outputString + " with
err:\n" + errorString, outputString.contains("file6.jar"));
+        assertTrue("Expected 6 files to be enhanced in message from out:\n" + outputString
+ " with err:\n" + errorString, outputString.contains("6"));
+    }
+
     private InvocationResult invokeEnhancer(String string) {
         InvocationResult result = new InvocationResult();
         try {

Added: db/jdo/trunk/api2/test/resources/enhancer-test-dir/enhancer-test-subdir/file4.jdo
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/test/resources/enhancer-test-dir/enhancer-test-subdir/file4.jdo?rev=828206&view=auto
==============================================================================
    (empty)

Propchange: db/jdo/trunk/api2/test/resources/enhancer-test-dir/enhancer-test-subdir/file4.jdo
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: db/jdo/trunk/api2/test/resources/enhancer-test-dir/enhancer-test-subdir/file5.class
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/test/resources/enhancer-test-dir/enhancer-test-subdir/file5.class?rev=828206&view=auto
==============================================================================
    (empty)

Added: db/jdo/trunk/api2/test/resources/enhancer-test-dir/enhancer-test-subdir/file6.jar
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/test/resources/enhancer-test-dir/enhancer-test-subdir/file6.jar?rev=828206&view=auto
==============================================================================
    (empty)

Added: db/jdo/trunk/api2/test/resources/enhancer-test-dir/file1.jdo
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/test/resources/enhancer-test-dir/file1.jdo?rev=828206&view=auto
==============================================================================
    (empty)

Propchange: db/jdo/trunk/api2/test/resources/enhancer-test-dir/file1.jdo
------------------------------------------------------------------------------
    svn:eol-style = LF

Added: db/jdo/trunk/api2/test/resources/enhancer-test-dir/file2.class
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/test/resources/enhancer-test-dir/file2.class?rev=828206&view=auto
==============================================================================
    (empty)

Added: db/jdo/trunk/api2/test/resources/enhancer-test-dir/file3.jar
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/test/resources/enhancer-test-dir/file3.jar?rev=828206&view=auto
==============================================================================
    (empty)



Mime
View raw message