1 7 package com.inversoft.junit.examples; 8 9 10 import java.io.File ; 11 import java.io.InputStream ; 12 13 import com.inversoft.junit.Request; 14 import com.inversoft.junit.Response; 15 import com.inversoft.junit.WebTestCase; 16 import com.inversoft.junit.internal.http.MockHttpServletRequest; 17 18 19 22 public class SimpleLocalTest extends WebTestCase { 23 24 27 public SimpleLocalTest(String name) { 28 super(name); 29 setLocal(true); 30 } 31 32 35 public void beginFoo(Request request) { 36 System.out.println("Inside beginFoo"); 37 } 38 39 42 public void testFoo() { 43 System.out.println("Inside testFoo"); 44 } 45 46 49 public void endFoo(Response response) { 50 System.out.println("Inside endFoo"); 51 } 52 53 56 public void beginFailure(Request request) { 57 System.out.println("Inside beginFailure"); 58 } 59 60 63 public void testFailure() { 64 System.out.println("Inside testFailure"); 65 fail("Failure"); 66 } 67 68 71 public void endFailure(Response response) { 72 System.out.println("SHOULD NOT BE HERE!!! - Inside endFailure"); 73 } 74 75 78 public void beginRequestSetup(Request request) { 79 request.addParameter("test", "test"); 80 assertTrue("The request variable of WebTestCase should be null", 81 this.request == null); 82 } 83 84 87 public void testRequestSetup() { 88 assertTrue("The request should be a Mock", 89 super.request instanceof MockHttpServletRequest); 90 assertTrue("The request should have a parameter", 91 super.request.getParameter("test").equals("test")); 92 } 93 94 97 public void testContextResource() { 98 99 File file = new File ("."); 100 System.out.println("The current directory: " + file.getAbsolutePath()); 101 102 InputStream is = context.getResourceAsStream("src/com/inversoft/junit/examples/junit.properties"); 103 assertTrue("InputStream should not be null", is != null); 104 } 105 } 106 | Popular Tags |