commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jke...@apache.org
Subject svn commit: r278849 - /jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/FileValidatorTest.java
Date Mon, 05 Sep 2005 21:20:48 GMT
Author: jkeyes
Date: Mon Sep  5 14:20:22 2005
New Revision: 278849

URL: http://svn.apache.org/viewcvs?rev=278849&view=rev
Log:
- replaced tags with spaces

Modified:
    jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/FileValidatorTest.java

Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/FileValidatorTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/FileValidatorTest.java?rev=278849&r1=278848&r2=278849&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/FileValidatorTest.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/FileValidatorTest.java
Mon Sep  5 14:20:22 2005
@@ -16,7 +16,6 @@
 package org.apache.commons.cli2.validation;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Iterator;
@@ -26,14 +25,15 @@
 
 /**
  * JUnit test case for the FileValidator.
- *
+ * 
  * @author Rob Oxspring
  * @author John Keyes
  */
 public class FileValidatorTest extends TestCase {
 
     public void testValidate() throws InvalidArgumentException {
-        final Object[] array = new Object[] { "src", "project.xml", "veryunlikelyfilename"};
+        final Object[] array = new Object[] { "src", "project.xml",
+                "veryunlikelyfilename" };
         final List list = Arrays.asList(array);
         final FileValidator validator = new FileValidator();
 
@@ -47,30 +47,31 @@
     }
 
     public void testValidate_Directory() {
-        final Object[] array = new Object[] { "src", "project.xml"};
+        final Object[] array = new Object[] { "src", "project.xml" };
         final List list = Arrays.asList(array);
-        final FileValidator validator = FileValidator.getExistingDirectoryInstance();
+        final FileValidator validator = FileValidator
+                .getExistingDirectoryInstance();
 
         assertTrue("is a directory validator", validator.isDirectory());
         assertFalse("is not a file validator", validator.isFile());
         assertTrue("is an existing file validator", validator.isExisting());
         assertFalse("is not a hidden file validator", validator.isHidden());
 
-        try{
+        try {
             validator.validate(list);
             fail("InvalidArgumentException");
-        }
-        catch(InvalidArgumentException e){
-            assertEquals("project.xml",e.getMessage());
+        } catch (InvalidArgumentException e) {
+            assertEquals("project.xml", e.getMessage());
         }
     }
 
     public void testValidate_ReadableFile() {
-    	// make file readonly
-    	File file = new File("src/test/data/readable.txt");
-    	file.setReadOnly();
+        // make file readonly
+        File file = new File("src/test/data/readable.txt");
+        file.setReadOnly();
 
-        final Object[] array = new Object[] { "src/test/data/readable.txt", "src/test/data/notreadable.txt"};
+        final Object[] array = new Object[] { "src/test/data/readable.txt",
+                "src/test/data/notreadable.txt" };
         final List list = Arrays.asList(array);
         final FileValidator validator = FileValidator.getExistingFileInstance();
         validator.setReadable(true);
@@ -82,21 +83,21 @@
         assertTrue("is a readable file validator", validator.isReadable());
         assertFalse("is not a writable file validator", validator.isWritable());
 
-        try{
+        try {
             validator.validate(list);
             fail("InvalidArgumentException");
-        }
-        catch(InvalidArgumentException e){
-            assertEquals("src/test/data/notreadable.txt",e.getMessage());
+        } catch (InvalidArgumentException e) {
+            assertEquals("src/test/data/notreadable.txt", e.getMessage());
         }
     }
 
     public void testValidate_WritableFile() {
-    	// make file readonly
-    	File file = new File("src/test/data/readable.txt");
-    	file.setReadOnly();
+        // make file readonly
+        File file = new File("src/test/data/readable.txt");
+        file.setReadOnly();
 
-    	final Object[] array = new Object[] { "src/test/data/writable.txt", "src/test/data/readable.txt"};
+        final Object[] array = new Object[] { "src/test/data/writable.txt",
+                "src/test/data/readable.txt" };
         final List list = Arrays.asList(array);
         final FileValidator validator = FileValidator.getExistingFileInstance();
         validator.setWritable(true);
@@ -108,57 +109,57 @@
         assertFalse("is not a readable file validator", validator.isReadable());
         assertTrue("is a writable file validator", validator.isWritable());
 
-        try{
+        try {
             validator.validate(list);
             fail("InvalidArgumentException");
-        }
-        catch(InvalidArgumentException e){
-            assertEquals("src/test/data/readable.txt",e.getMessage());
+        } catch (InvalidArgumentException e) {
+            assertEquals("src/test/data/readable.txt", e.getMessage());
         }
     }
 
     public void testValidate_HiddenFile() throws InvalidArgumentException {
-    	// make file hidden on Windows
-    	attribute("H");
-    	
-		final Object[] array = new Object[] { ".hidden", "src"};
-		final List list = Arrays.asList(array);
-		final FileValidator validator = FileValidator.getExistingFileInstance();
-		validator.setHidden(true);
-		
-		assertFalse("is not a directory validator", validator.isDirectory());
-		assertTrue("is a file validator", validator.isFile());
-		assertTrue("is an existing file validator", validator.isExisting());
-		assertTrue("is a hidden file validator", validator.isHidden());
-	
-		try{
-			validator.validate(list);
-			fail("InvalidArgumentException");
-		}
-		catch(InvalidArgumentException e){
-			assertEquals("src",e.getMessage());
-		}
+        // make file hidden on Windows
+        attribute("H");
+
+        final Object[] array = new Object[] { ".hidden", "src" };
+        final List list = Arrays.asList(array);
+        final FileValidator validator = FileValidator.getExistingFileInstance();
+        validator.setHidden(true);
+
+        assertFalse("is not a directory validator", validator.isDirectory());
+        assertTrue("is a file validator", validator.isFile());
+        assertTrue("is an existing file validator", validator.isExisting());
+        assertTrue("is a hidden file validator", validator.isHidden());
+
+        try {
+            validator.validate(list);
+            fail("InvalidArgumentException");
+        } catch (InvalidArgumentException e) {
+            assertEquals("src", e.getMessage());
+        }
     }
 
     private void attribute(String attr) {
-		final String os = System.getProperty("os.name").toLowerCase();
+        final String os = System.getProperty("os.name").toLowerCase();
 
-		// if the test is run on windows, run the attrib program
-		// to set the hidden attribute
-		if (os.indexOf("windows") != -1) {
-			// windows
-			try {
-				Process proc = Runtime.getRuntime().exec("attrib.exe +" + attr + " src/test/data/.hidden.txt",
null, new File("."));
-			} 
-			catch (IOException e) {
-					System.out.println(e.getMessage());
-				e.printStackTrace();
-			}
-		} 
+        // if the test is run on windows, run the attrib program
+        // to set the hidden attribute
+        if (os.indexOf("windows") != -1) {
+            // windows
+            try {
+                Process proc = Runtime.getRuntime().exec(
+                        "attrib.exe +" + attr + " src/test/data/.hidden.txt",
+                        null, new File("."));
+            } catch (IOException e) {
+                System.out.println(e.getMessage());
+                e.printStackTrace();
+            }
+        }
     }
 
     public void testValidate_Existing() {
-        final Object[] array = new Object[] { "project.xml", "veryunlikelyfilename"};
+        final Object[] array = new Object[] { "project.xml",
+                "veryunlikelyfilename" };
         final List list = Arrays.asList(array);
         final FileValidator validator = FileValidator.getExistingInstance();
 
@@ -167,26 +168,24 @@
         assertTrue("is an existing file validator", validator.isExisting());
         assertFalse("is not a hidden file validator", validator.isHidden());
 
-        try{
+        try {
             validator.validate(list);
             fail("InvalidArgumentException");
-        }
-        catch(InvalidArgumentException e){
-            assertEquals("veryunlikelyfilename",e.getMessage());
+        } catch (InvalidArgumentException e) {
+            assertEquals("veryunlikelyfilename", e.getMessage());
         }
     }
 
     public void testValidate_File() {
-        final Object[] array = new Object[] { "project.xml", "src"};
+        final Object[] array = new Object[] { "project.xml", "src" };
         final List list = Arrays.asList(array);
         final Validator validator = FileValidator.getExistingFileInstance();
 
-        try{
+        try {
             validator.validate(list);
             fail("InvalidArgumentException");
-        }
-        catch(InvalidArgumentException e){
-            assertEquals("src",e.getMessage());
+        } catch (InvalidArgumentException e) {
+            assertEquals("src", e.getMessage());
         }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message