Author: gadams
Date: Tue May 22 18:26:15 2012
New Revision: 1341585

URL: http://svn.apache.org/viewvc?rev=1341585&view=rev
Log:
Bugzilla #52144: Fix crash on use of version switch (-v). Submitted by Luis 
Bernardo.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java
    xmlgraphics/fop/trunk/status.xml
    
xmlgraphics/fop/trunk/test/java/org/apache/fop/cli/CommandLineOptionsTestCase.java

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java?rev=1341585&r1=1341584&r2=1341585&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java 
Tue May 22 18:26:15 2012
@@ -357,8 +357,11 @@ public class CommandLineOptions {
             } else if (args[i].equals("-a")) {
                 this.renderingOptions.put(Accessibility.ACCESSIBILITY, 
Boolean.TRUE);
             } else if (args[i].equals("-v")) {
-                /* Currently just print the version */
+                /* verbose mode although users may expect version; currently 
just print the version */
                 printVersion();
+                if (args.length == 1) {
+                    return false;
+                }
             } else if (args[i].equals("-param")) {
                   if (i + 2 < args.length) {
                       String name = args[++i];

Modified: xmlgraphics/fop/trunk/status.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1341585&r1=1341584&r2=1341585&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Tue May 22 18:26:15 2012
@@ -63,6 +63,9 @@
       documents. Example: the fix of marks layering will be such a case when 
it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Config" dev="GA" type="fix" fixes-bug="52144" 
due-to="Luis Bernardo">
+        Fix crash on use of version switch (-v).
+      </action>
       <action context="Renderers" dev="GA" type="fix" fixes-bug="53242" 
due-to="Luis Bernardo">
         Support fractional line widths in AFP renderer, fixing problem with 
SVG line drawing.
       </action>

Modified: 
xmlgraphics/fop/trunk/test/java/org/apache/fop/cli/CommandLineOptionsTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/cli/CommandLineOptionsTestCase.java?rev=1341585&r1=1341584&r2=1341585&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/test/java/org/apache/fop/cli/CommandLineOptionsTestCase.java
 (original)
+++ 
xmlgraphics/fop/trunk/test/java/org/apache/fop/cli/CommandLineOptionsTestCase.java
 Tue May 22 18:26:15 2012
@@ -22,6 +22,8 @@ package org.apache.fop.cli;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import java.io.IOException;
+
 import org.apache.fop.apps.FOPException;
 import org.junit.Before;
 import org.junit.Test;
@@ -49,4 +51,22 @@ public class CommandLineOptionsTestCase 
         assertEquals(clo.getOutputFormat(), "application/X-fop-print");
     }
 
+    @Test
+    public void testVandVersionSwitchs() throws FOPException, IOException {
+        // test -v
+        String cl1 = "-v";
+        String[] cmd1 = cl1.split(" ");
+        CommandLineOptions clo1 = new CommandLineOptions();
+        assertTrue(!clo1.parse(cmd1));
+        // test -version
+        String cl2 = "-version";
+        String[] cmd2 = cl2.split(" ");
+        CommandLineOptions clo2 = new CommandLineOptions();
+        assertTrue(!clo2.parse(cmd2));
+        // test -v + more switches
+        String cl3 = "-v " + commandLine;
+        String[] cmd3 = cl3.split(" ");
+        CommandLineOptions clo3 = new CommandLineOptions();
+        assertTrue(clo3.parse(cmd3));
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to