1 13 14 package se.anatom.ejbca.webdist; 15 16 import junit.framework.TestCase; 17 import junit.framework.TestSuite; 18 19 import com.meterware.httpunit.GetMethodWebRequest; 20 import com.meterware.httpunit.HttpUnitOptions; 21 import com.meterware.httpunit.WebConversation; 22 import com.meterware.httpunit.WebRequest; 23 import com.meterware.httpunit.WebResponse; 24 25 27 public class WebdistHttpTest extends TestCase { 28 29 public static void main( String args[] ) { 30 junit.textui.TestRunner.run( suite() ); 31 } 32 33 34 public static TestSuite suite() { 35 return new TestSuite( WebdistHttpTest.class ); 36 } 37 38 39 public WebdistHttpTest( String name ) { 40 super( name ); 41 } 42 43 public void testJspCompile() throws Exception { 44 String httpReqPath = "http://127.0.0.1:8080/ejbca"; 46 String resourceName = "publicweb/webdist"; 47 String resourceName1 = "publicweb/webdist/cacert.jsp"; 48 String resourceName2 = "publicweb/webdist/cacrl.jsp"; 49 String resourceName3 = "publicweb/webdist/revoked.jsp"; 50 String resourceName4 = "publicweb/webdist/listcerts.jsp"; 51 String resourceName5 = "publicweb/webdist/certdist.jsp"; 52 53 HttpUnitOptions.setExceptionsThrownOnErrorStatus(false); 55 WebConversation wc = new WebConversation(); 56 WebRequest request = new GetMethodWebRequest( httpReqPath + '/' + resourceName ); 57 WebResponse response = wc.getResponse( request ); 58 assertEquals( "Response code", 200, response.getResponseCode() ); 59 request = new GetMethodWebRequest( httpReqPath + '/' + resourceName1 ); 60 response = wc.getResponse( request ); 61 assertEquals( "Response code", 200, response.getResponseCode() ); 62 request = new GetMethodWebRequest( httpReqPath + '/' + resourceName2 ); 63 response = wc.getResponse( request ); 64 assertEquals( "Response code", 200, response.getResponseCode() ); 65 request = new GetMethodWebRequest( httpReqPath + '/' + resourceName3 ); 66 response = wc.getResponse( request ); 67 assertEquals( "Response code", 200, response.getResponseCode() ); 68 request = new GetMethodWebRequest( httpReqPath + '/' + resourceName4 ); 69 response = wc.getResponse( request ); 70 assertEquals( "Response code", 200, response.getResponseCode() ); 71 request = new GetMethodWebRequest( httpReqPath + '/' + resourceName5 ); 72 response = wc.getResponse( request ); 73 assertEquals( "Response code", 404, response.getResponseCode() ); 75 } 76 77 78 } 79 | Popular Tags |