jefft       2003/05/31 05:42:39

  Modified:    src/test/org/apache/cocoon/environment/commandline/test
                        CommandLineContextTestCase.java
  Log:
  Update CommandLineContext to reflect that getResource() on a nonexistent
  resource should return null, as per servlet docs.
  
  Revision  Changes    Path
  1.5       +12 -6     
cocoon-2.1/src/test/org/apache/cocoon/environment/commandline/test/CommandLineContextTestCase.java
  
  Index: CommandLineContextTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/test/org/apache/cocoon/environment/commandline/test/CommandLineContextTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CommandLineContextTestCase.java   12 May 2003 13:26:18 -0000      1.4
  +++ CommandLineContextTestCase.java   31 May 2003 12:42:39 -0000      1.5
  @@ -130,6 +130,7 @@
        */
       public void setUp() throws Exception {
           commandLineContextDir = System.getProperty("java.io.tmpdir", "/tmp");
  +        new File(commandLineContextDir, "foo"+File.separator+"bar").mkdirs();
           commandLineContext = new CommandLineContext(commandLineContextDir);
           commandLineContext.enableLogging( new ConsoleLogger() );
       }
  @@ -141,7 +142,10 @@
        * @exception  Exception  Description of Exception
        * @since
        */
  -    public void tearDown() throws Exception { }
  +    public void tearDown() throws Exception {
  +        new File(commandLineContextDir, "foo"+File.separator+"bar").delete();
  +        new File(commandLineContextDir, "foo").delete();
  +    }
   
   
       /**
  @@ -156,15 +160,17 @@
                   new String[]{"", commandLineContextDir},
                   new String[]{"/", commandLineContextDir},
                   new String[]{"foo", commandLineContextDir + File.separator + "foo"},
  -                new String[]{"foo/bar", commandLineContextDir + File.separator + 
"foo/bar"}
  +                new String[]{"foo/bar", commandLineContextDir + File.separator + 
"foo/bar"},
  +                new String[]{"foo/bar/nonexistent", null}
                   };
           for (int i = 0; i < test_values.length; i++) {
               String tests[] = (String[]) test_values[i];
               String test = tests[0];
  -            File expected_file = new File(tests[1]);
  -            URL expected = expected_file.toURL();
  -
               URL result = commandLineContext.getResource(test);
  +            URL expected = null;
  +            if (result != null) {
  +                expected = new File(tests[1]).toURL();
  +            }
               String message = "Test " +
                       "'" + test + "'";
               assertEquals(message, expected, result);
  
  
  

Reply via email to