1 /* Reattore HTTP Server 2 3 Copyright (C) 2002 Michael Hope <michaelh@juju.net.nz> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 $Id: TestFileInterceptor.java,v 1.5 2003/01/23 02:29:24 michaelh Exp $ 20 */ 21 22 package test.juju.reattore.core.intercept.impl; 23 24 import junit.framework.*; 25 import juju.reattore.server.intercept.impl.*; 26 import juju.reattore.protocol.http.*; 27 28 /*** PENDING: Redundant comment. 29 */ 30 public class TestFileInterceptor 31 extends TestCase { 32 33 private static String getBaseDir() { 34 return "/Users/michaelh/projects/reattore" + "/tests"; 35 } 36 37 private FileInterceptor create(String dir) { 38 return new juju.reattore.server.intercept.impl.FileInterceptor(dir); 39 } 40 41 /*** Tests that the correct file is served. */ 42 public void testGetFile() { 43 FileInterceptor ic = create(getBaseDir()); 44 MockHttpResponse resp = new MockHttpResponse(); 45 MockHttpRequest req = new MockHttpRequest("GET", 46 "test/juju/reattore/core/intercept/impl/TestFile1.txt"); 47 boolean ret = ic.process(req, resp); 48 49 assertTrue(ret); 50 assertEquals(HttpResponse.SC_OK, resp.getStatus()); 51 } 52 53 /*** Tests that 404 Not Found is returned when the file doesn't exist. 54 */ 55 public void testGetFileNegative() { 56 FileInterceptor ic = create(getBaseDir()); 57 MockHttpResponse resp = new MockHttpResponse(); 58 MockHttpRequest req = new MockHttpRequest("GET", "NotThere.txt"); 59 60 boolean ret = ic.process(req, resp); 61 62 assertEquals(false, ret); 63 assertEquals(HttpResponse.SC_NOT_FOUND, resp.getStatus()); 64 } 65 66 /*** @see TestSuite */ 67 public static Test suite() { 68 return new TestSuite(TestFileInterceptor.class); 69 } 70 }

This page was automatically generated by Maven