commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jke...@apache.org
Subject svn commit: r278863 - in /jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation: FileValidatorTest.java UrlValidatorTest.java
Date Mon, 05 Sep 2005 21:51:50 GMT
Author: jkeyes
Date: Mon Sep  5 14:51:40 2005
New Revision: 278863

URL: http://svn.apache.org/viewcvs?rev=278863&view=rev
Log:
- add tests for UrlValidator
- fix FileValidator hidden file test

Modified:
    jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/FileValidatorTest.java
    jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/UrlValidatorTest.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=278863&r1=278862&r2=278863&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:51:40 2005
@@ -121,7 +121,7 @@
         // make file hidden on Windows
         attribute("H");
 
-        final Object[] array = new Object[] { ".hidden", "src" };
+        final Object[] array = new Object[] { "src/test/data/.hidden.txt", "src" };
         final List list = Arrays.asList(array);
         final FileValidator validator = FileValidator.getExistingFileInstance();
         validator.setHidden(true);

Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/UrlValidatorTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/UrlValidatorTest.java?rev=278863&r1=278862&r2=278863&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/UrlValidatorTest.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/validation/UrlValidatorTest.java
Mon Sep  5 14:51:40 2005
@@ -37,19 +37,49 @@
         assertEquals(new URL("file:///etc"), i.next());
         assertFalse(i.hasNext());
     }
-    
-    public void testBadProtocol() {
-        final Object[] array = new Object[] { "http://www.apache.org/", "file:///etc"};
+
+    public void testMalformedURL() throws InvalidArgumentException, MalformedURLException
{
+        final Object[] array = new Object[] { "www.apache.org"};
         final List list = Arrays.asList(array);
-        final UrlValidator validator = new UrlValidator();
-        validator.setProtocol("http");
+        final Validator validator = new UrlValidator();
 
-        try{
+        try {
             validator.validate(list);
-            fail("Expected InvalidArgumentException");
         }
         catch(InvalidArgumentException e){
-            assertEquals("file:///etc",e.getMessage());
+            assertEquals("Cannot understand url: www.apache.org",e.getMessage());
+        }
+        
+    }
+
+    public void testBadProtocol() {
+        {
+            final Object[] array = new Object[] { "http://www.apache.org/", "file:///etc"};
+            final List list = Arrays.asList(array);
+            final UrlValidator validator = new UrlValidator();
+            validator.setProtocol("http");
+    
+            assertEquals("incorrect protocol", "http", validator.getProtocol());
+            try{
+                validator.validate(list);
+                fail("Expected InvalidArgumentException");
+            }
+            catch(InvalidArgumentException e){
+                assertEquals("file:///etc",e.getMessage());
+            }
+        }
+        {
+            final Object[] array = new Object[] { "http://www.apache.org/", "file:///etc"};
+            final List list = Arrays.asList(array);
+            final UrlValidator validator = new UrlValidator("http");
+    
+            try{
+                validator.validate(list);
+                fail("Expected InvalidArgumentException");
+            }
+            catch(InvalidArgumentException e){
+                assertEquals("file:///etc",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