jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From senthil kumar <senthil_...@yahoo.com>
Subject Re: Failed to get the test results at [http://localhost:80/test/ServletRedirector]
Date Fri, 06 Jan 2006 00:07:15 GMT
Hi Kazuhito,

Sorry for my delayed reply. I was on vacation. Still I
couldn't resolve my problem. Still I am getting the
same error.
I went thru your settings I did the same way as you
specified but still I am getting the same problem. In
my case here is what I am doing.

Tomcat server used in my application is 4.1, this
should be fine right?


1. Directory structure.

./webapps

  ./myapplication
    ./web-inf
    ./web-inf/lib/ (all my application java classes
are here not test cases)

  ./mytestapplication (this has all test classes of my
application java file)
    ./web-inf
    ./web-inf/classes/(all my test case classes are in
here)
    ./web-inf/aspectjrt-1.2.1.jar
    ./web-inf/cactus-1.7.1.jar
    ./web-inf/commons-httpclient-2.0.2.jar
    ./web-inf/junit.jar
    ./web-inf/commons-logging-1.0.4.jar
    ./web-inf/web.xml
    ./web-inf/cactus.properties (properties file as
mentioned in the document)	

2. my web.xml has the following things

<web-app>
    <display-name>Cactus Server</display-name>
    <!-- security filter -->
        <filter>
            <filter-name>securityFilter</filter-name>
           
<filter-class>com.myapp.datahub.common.security.SecurityFilter</filter-class>
        </filter>
    
        <filter-mapping>
            <filter-name>securityFilter</filter-name>
    	<url-pattern>/*</url-pattern>
        </filter-mapping>
    <!-- security filter -->
 
    <!-- Startup services>
	Startup servlet loads the classes that are named
startup-class
	in the z order of the names, and constructs all the
initial params as Properties class
	and calls each one of them. with name of the Startup
servlet and root path and all the arguments

	Note: Startup classes are loaded in the Z-ORDER of
the param-names, meaning first it loades
		startup-class-z, startup-class-y, startup-class-x

	Startup services -->
    <servlet>
        <servlet-name>CactusServer</servlet-name>
       
<servlet-class>com.myapp.datahub.appserver.common.StartupServlet</servlet-class>
       	        <init-param>
	            <param-name>startup-class-z</param-name>
	           
<param-value>com.myapp.datahub.appserver.tomcat.DBCheckStartup</param-value>
	        </init-param>
	        <init-param>
	            <param-name>retryFreq</param-name>
	            <param-value>3</param-value>
	        </init-param>
		<init-param>
		    <param-name>startup-class-y</param-name>
		   
<param-value>com.myapp.datahub.appserver.tomcat.DAOBinder</param-value>
		</init-param>
		<init-param>
		    <param-name>fileName</param-name>
		   
<param-value>conf/daobinding.properties</param-value>
		</init-param>
		<init-param>
		    <param-name>startup-class-x</param-name>
		   
<param-value>com.myapp.datahub.appserver.tomcat.PublishSoapServices</param-value>
		</init-param>
		<init-param>
		    <param-name>configFile</param-name>
		    <param-value>/WEB-INF/services.xml</param-value>
		</init-param>
	       	<load-on-startup>2</load-on-startup>
    </servlet>
    
    <!-- the glue servlet for publishing soap
services-->
    <servlet>
	<servlet-name>ServletRedirector</servlet-name>

<servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
    </servlet>
    <servlet>
   	<servlet-name>ServletTestRunner</servlet-name>
   
<servlet-class>org.apache.cactus.server.runner.ServletTestRunner</servlet-class>
    </servlet>
    <servlet>
       	<servlet-name>SimpleServlet</servlet-name>
       
<servlet-class>com.myapp.datahub.base.SimpleServlet</servlet-class>
    </servlet>
    <servlet>
       
<servlet-name>ServletRedirectorSecure</servlet-name>
       
<servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
    </servlet>


<!--
All session-config, mime-mapping, welcome-file-list,
error-page, taglib,
resource-ref, security-constraint, login-config,
security-role,
env-entry, and ejb-ref elements should follow this
fragment.
-->
    <!-- Define the Servlet Mapping -->

    <servlet-mapping>
        <servlet-name>SimpleServlet</servlet-name>
        <url-pattern>/SimpleServlet</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>ServletRedirector</servlet-name>
        <url-pattern>/ServletRedirector</url-pattern>
    </servlet-mapping>
    	
    <servlet-mapping>
        <servlet-name>ServletTestRunner</servlet-name>
        <url-pattern>/ServletTestRunner</url-pattern>
    </servlet-mapping>
    
    <servlet-mapping>
       
<servlet-name>ServletRedirectorSecure</servlet-name>
       
<url-pattern>/ServletRedirectorSecure</url-pattern>
    </servlet-mapping>

   <resource-ref>
        <res-ref-name>jdbc/kopernik</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
   </resource-ref>
   
   <security-constraint>
          <web-resource-collection>
           
<web-resource-name>Servlets</web-resource-name>
            <description>Protect the Cactus redirector
servlet.</description>
            <url-pattern>/*</url-pattern>
          </web-resource-collection>
          <auth-constraint>
               <role-name>UnitTester</role-name>
          </auth-constraint>
   </security-constraint>
  
   <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>DS_NTRealm</realm-name>
   </login-config>

   <security-role>
        <role-name>UnitTester</role-name>
   </security-role>
</web-app>

3. My test class

   public class HierarchyHelperTest extends TestCase {

    private JTestCase _jtestcase = null;

    public HierarchyHelperTest(String testName) {
        super(testName);
        testData = new
myappTestData("HierarchyHelperTest");
    }

    protected void setUp() throws Exception {
    }
    
    public void beginBasicAuthentication(WebRequest
theRequest)
    {
       
theRequest.setRedirectorName("ServletRedirectorSecure");
        theRequest.setAuthentication(new
BasicAuthentication("DOMAINNAME\\username",
"password"));
        System.out.println("beginBasicAuthentication
===== context Path " + userName);
        System.out.println("beginBasicAuthentication
===== end");
    }

    protected void tearDown() throws Exception {
    }

    public static Test suite() {
        ServletTestSuite suite = new
ServletTestSuite();
        suite.addTestSuite(HierarchyHelperTest.class);
        return suite;
    }

    /**
     * Test of getHVersionGID method, of class
com.myapp.datahub.hierarchy.ejb.HierarchyHelper.
     */
    public void testGetHVersionGID() throws
UnsupportedLanguage,
               
AccessViolation,HierarchyNotFound,AccessViolation,HierarchyServiceSysException,
Exception {
        System.out.println("testGetHVersionGID");
        // TODO add your test code below by replacing
the default call to fail.
        HierarchyHelper helper = new
HierarchyHelper();
        String value =
(String)testData.getTestCaseParameter("testGetHVersionGID",
"var1");
        TestCaseInstance testCase =
testData.getTestCase("testGetHVersionGID");
        boolean resultValue =
testData.assertTestData(testCase ,
"testGetHVersionGID", new String(Integer.toString     
  (helper.getHVersionGID(value))));
        assertTrue("testGetHVersionGID failed",
resultValue);
    }
   }

   My SimpleServlet Test case (This works fine) this
class file is also located in the same place

   public class SimpleServlet extends HttpServlet {

      public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
      throws ServletException, IOException {
            HierarchyHelper helper = new
HierarchyHelper();
            String user = "DOMAINNAME\\username";
            try{
                int versionId =
helper.getHVersionGID("en-US");
            }catch(Exception e){
            }
            System.out.println("Value of versionId
=====>>>>");
        }
    }

4. Under my tomcat directory structure

<tomcat-users>
  <role rolename="DSEditors"  />
  <role rolename="UnitTester"  />
  <rolemap>
  	<role name="DSEditors" group="DOMAINNAME\userName"
/>
	<role name="UnitTester" />
  </rolemap>
  <user name="DOMAINNAME\userName" password="password"
roles="UnitTester"/>
</tomcat-users>

5. I didn't create a WAR file for my test application
just I kept my testclasses as class files itself.

6. Here is the Error:

Failed to get the test results at
[http://wkstn04:80/test/ServletRedirector]

org.apache.cactus.util.ChainedRuntimeException: Failed
to get the test results at
[http://wkstn04:80/test/ServletRedirector]
at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody0(DefaultHttpClient.java:92)
at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody1$advice(DefaultHttpClient.java:288)
at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest(DefaultHttpClient.java)
at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runWebTest(HttpProtocolHandler.java:159)
at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody0(HttpProtocolHandler.java:80)
at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody1$advice(HttpProtocolHandler.java:288)
at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest(HttpProtocolHandler.java)
at
org.apache.cactus.internal.client.ClientTestCaseCaller.runTest(ClientTestCaseCaller.java:144)
at
org.apache.cactus.internal.AbstractCactusTestCase.runBareClient(AbstractCactusTestCase.java:215)
at
org.apache.cactus.internal.AbstractCactusTestCase.runBare(AbstractCactusTestCase.java:133)
at
org.apache.cactus.internal.AbstractTestSuite.runTest(AbstractTestSuite.java:259)
at
org.apache.cactus.internal.AbstractTestSuite.run_aroundBody0(AbstractTestSuite.java:250)
at
org.apache.cactus.internal.AbstractTestSuite.run_aroundBody1$advice(AbstractTestSuite.java:217)
at
org.apache.cactus.internal.AbstractTestSuite.run(AbstractTestSuite.java)
at
org.apache.cactus.internal.AbstractTestSuite.runTest(AbstractTestSuite.java:259)
at
org.apache.cactus.internal.AbstractTestSuite.run_aroundBody0(AbstractTestSuite.java:250)
at
org.apache.cactus.internal.AbstractTestSuite.run_aroundBody1$advice(AbstractTestSuite.java:217)
at
org.apache.cactus.internal.AbstractTestSuite.run(AbstractTestSuite.java)
at
org.apache.cactus.server.runner.ServletTestRunner.run(ServletTestRunner.java:308)
at
org.apache.cactus.server.runner.ServletTestRunner.doGet_aroundBody0(ServletTestRunner.java:186)
at
org.apache.cactus.server.runner.ServletTestRunner.doGet_aroundBody1$advice(ServletTestRunner.java:217)
at
org.apache.cactus.server.runner.ServletTestRunner.doGet(ServletTestRunner.java)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at
com.stratify.datahub.common.security.SecurityFilter.doFilter(SecurityFilter.java:67)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:528)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:392)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
at java.lang.Thread.run(Unknown Source)
org.apache.cactus.internal.client.ParsingException:
Not a valid response [401 Unauthorized]
at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.callGetResult(DefaultHttpClient.java:211)
at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody0(DefaultHttpClient.java:87)
at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest_aroundBody1$advice(DefaultHttpClient.java:288)
at
org.apache.cactus.internal.client.connector.http.DefaultHttpClient.doTest(DefaultHttpClient.java)
at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runWebTest(HttpProtocolHandler.java:159)
at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody0(HttpProtocolHandler.java:80)
at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest_aroundBody1$advice(HttpProtocolHandler.java:288)
at
org.apache.cactus.internal.client.connector.http.HttpProtocolHandler.runTest(HttpProtocolHandler.java)
at
org.apache.cactus.internal.client.ClientTestCaseCaller.runTest(ClientTestCaseCaller.java:144)
at
org.apache.cactus.internal.AbstractCactusTestCase.runBareClient(AbstractCactusTestCase.java:215)
at
org.apache.cactus.internal.AbstractCactusTestCase.runBare(AbstractCactusTestCase.java:133)
at
org.apache.cactus.internal.AbstractTestSuite.runTest(AbstractTestSuite.java:259)
at
org.apache.cactus.internal.AbstractTestSuite.run_aroundBody0(AbstractTestSuite.java:250)
at
org.apache.cactus.internal.AbstractTestSuite.run_aroundBody1$advice(AbstractTestSuite.java:217)
at
org.apache.cactus.internal.AbstractTestSuite.run(AbstractTestSuite.java)
at
org.apache.cactus.internal.AbstractTestSuite.runTest(AbstractTestSuite.java:259)
at
org.apache.cactus.internal.AbstractTestSuite.run_aroundBody0(AbstractTestSuite.java:250)
at
org.apache.cactus.internal.AbstractTestSuite.run_aroundBody1$advice(AbstractTestSuite.java:217)
at
org.apache.cactus.internal.AbstractTestSuite.run(AbstractTestSuite.java)
at
org.apache.cactus.server.runner.ServletTestRunner.run(ServletTestRunner.java:308)
at
org.apache.cactus.server.runner.ServletTestRunner.doGet_aroundBody0(ServletTestRunner.java:186)
at
org.apache.cactus.server.runner.ServletTestRunner.doGet_aroundBody1$advice(ServletTestRunner.java:217)
at
org.apache.cactus.server.runner.ServletTestRunner.doGet(ServletTestRunner.java)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at
com.stratify.datahub.common.security.SecurityFilter.doFilter(SecurityFilter.java:67)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:528)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:392)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
at java.lang.Thread.run(Unknown Source)


Could you please give me your advice what I have to
investigate to resolve this problem asap. I got struck
here... I want to come out of this.. with out
authentication working I was not able to test
anything. 

Thanks a lot for your reply,
Senthil.




--- Kazuhito SUGURI <suguri.kazuhito@lab.ntt.co.jp>
wrote:

> Hi Senthil,
> 
> Have you solved the problem?
> If the problem is still there, let us start from a
> working sample.
> 
> In article
>
<20051220194447.15165.qmail@web51814.mail.yahoo.com>,
> Tue, 20 Dec 2005 11:44:47 -0800 (PST),
> senthil kumar <senthil_cbe@yahoo.com> wrote: 
> senthil_cbe> Thanks for your reply. I set the break
> point in my
> senthil_cbe> beginXXX and Test Suite() methods it
> looks like
> senthil_cbe> beginXXX is not at all called. It gets
> into suite()
> senthil_cbe> method but not beginXX method. Here is
> my begin method
> 
> After some tries, I cannot reproduce your problem.
> 
> Appending are codes I tried:
> 	SampleJUnitTest.java   - extends JUnit's TestCase
> 	SampleServletTest.java - extends Cactus's
> ServletTestCase
> 	AllTests.java          - provide a suite()
> 	web.xml
> 	tomcat-users.xml
> 
> A war-archive should have structure as follows:
> 	./WEB-INF/lib
> 	./WEB-INF/lib/cactus-1.7.1.jar
> 	./WEB-INF/lib/commons-httpclient-2.0.2.jar
> 	./WEB-INF/lib/aspectjrt-1.2.1.jar
> 	./WEB-INF/lib/junit.jar
> 	./WEB-INF/lib/commons-logging-1.0.4.jar
> 	./WEB-INF/classes
> 	./WEB-INF/classes/SampleServletTest.class
> 	./WEB-INF/classes/SampleJUnitTest.class
> 	./WEB-INF/classes/AllTests.class
> 	./WEB-INF/web.xml
> 
> I deployed the war-archive (sample.war) ant
> tomcat-users.xml
> to the Tomcat-5.5.9 on my localhost. All of
> following URLs work fine:
>      
>
http://localhost:8080/sample/ServletTestRunner?suite=AllTests
>      
>
http://localhost:8080/sample/ServletTestRunner?suite=SampleJUnitTest
>      
>
http://localhost:8080/sample/ServletTestRunner?suite=SampleServletTest
> 
> Could you explain what I should do to reproduce your
> problem form the sample?
> 
> Regards,
> ----
> Kazuhito SUGURI
> > import junit.framework.Test;
> import junit.framework.TestCase;
> 
> import org.apache.cactus.ServletTestSuite;
> import org.apache.cactus.WebRequest;
> import
>
org.apache.cactus.client.authentication.BasicAuthentication;
> 
> public class SampleJUnitTest
>     extends TestCase
> {
>     public SampleJUnitTest(String theName)
>     {
>         super(theName);
>     }
> 
>     public void beginSample(WebRequest theRequest)
>     {
>        
>
theRequest.setRedirectorName("ServletRedirectorSecure");
>         theRequest.setAuthentication(new
> BasicAuthentication("testuser",
>                                                     
>         "testpassword"));
>     }
> 
>     public void testSample()
>     {
>         assertTrue(true);
>     }
> 
>     public static Test suite()
>     {
>         ServletTestSuite suite = new
> ServletTestSuite();
>         suite.addTestSuite(SampleJUnitTest.class);
>         return suite;
>     }
> }
> > import junit.framework.Test;
> 
> import org.apache.cactus.ServletTestCase;
> import org.apache.cactus.ServletTestSuite;
> import org.apache.cactus.WebRequest;
> import
>
org.apache.cactus.client.authentication.BasicAuthentication;
> 
> public class SampleServletTest
>     extends ServletTestCase
> {
>     public SampleServletTest(String theName)
>     {
>         super(theName);
>     }
> 
>     public void beginSample(WebRequest theRequest)
>     {
>        
>
theRequest.setRedirectorName("ServletRedirectorSecure");
>         theRequest.setAuthentication(new
> BasicAuthentication("testuser",
>                                                     
>         "testpassword"));
>     }
> 
>     public void testSample()
>     {
>         assertEquals("testuser",
> request.getUserPrincipal().getName());
>     }
> 
>     public static Test suite()
>     {
>         ServletTestSuite suite = new
> ServletTestSuite();
>         suite.addTestSuite(SampleServletTest.class);
>         return suite;
>     }
> }
> > import junit.framework.Test;
> import org.apache.cactus.ServletTestSuite;
> 
> public class AllTests
> {
>     public static Test suite()
>     {
>         ServletTestSuite suite = new
> ServletTestSuite();
>         suite.addTestSuite(SampleJUnitTest.class);
>         suite.addTestSuite(SampleServletTest.class);
>         return suite;
>     }
> }
> > <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems,
> Inc.//DTD Web Application 2.3//EN"
>                         
> "http://java.sun.com/dtd/web-app_2_3.dtd">
> <web-app>
>     <display-name>Sample</display-name>
>     <description>Sample Application</description>
> 
>     <servlet>
>        
> <servlet-name>ServletTestRunner</servlet-name>
>        
>
<servlet-class>org.apache.cactus.server.runner.ServletTestRunner</servlet-class>
>     </servlet>
> 
>     <servlet>
>        
> <servlet-name>ServletRedirector</servlet-name>
>        
>
<servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
>     </servlet>
> 
>     <servlet>
>        
> <servlet-name>ServletRedirectorSecure</servlet-name>
>        
>
<servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
>     </servlet>
> 
>     <servlet-mapping>
>        
> <servlet-name>ServletTestRunner</servlet-name>
>        
> <url-pattern>/ServletTestRunner</url-pattern>
>     </servlet-mapping>
> 
>     <servlet-mapping>
>        
> <servlet-name>ServletRedirector</servlet-name>
>        
> <url-pattern>/ServletRedirector</url-pattern>
>     </servlet-mapping>
> 
>     <servlet-mapping>
>        
> <servlet-name>ServletRedirectorSecure</servlet-name>
>        
> <url-pattern>/ServletRedirectorSecure</url-pattern>
>     </servlet-mapping>
> 
>     <security-constraint>
>         <web-resource-collection>
>             <web-resource-name>Cactus Test
> Redirector</web-resource-name>
>             <url-pattern>/*</url-pattern>
>         </web-resource-collection>
>         <auth-constraint>
>             <role-name>test</role-name>
>         </auth-constraint>
>     </security-constraint>
> 
>     <login-config>
>         <auth-method>BASIC</auth-method>
>         <realm-name>myrealm</realm-name>
>     </login-config>
> 
>     <security-role>
>         <role-name>test</role-name>
>     </security-role>
> </web-app>
> > <?xml version='1.0' encoding='utf-8'?>
> <tomcat-users>
>   <role rolename="test"/>
>   <user username="testuser" password="testpassword"
> roles="test"/>
> </tomcat-users>
> 
> >
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
cactus-user-help@jakarta.apache.org



Mime
View raw message