Re: problem getting test results

Paulo R C Siqueira <[email protected]>
Newsgroups gmane.comp.jakarta.cactus.user
Message-ID <[email protected]>
The source is the same for the ServletRedirector and for the ServletRedirectorSecure, except that for the ServletRedirectorSecure I uncomment the two commentted lines in the beginHome mehod.

public class Test extends ServletTestCase {
  public Test( String name ) {
    super( name );
  }
  public void beginHome( WebRequest theRequest ) {
    theRequest.setURL( "localhost", "/teste","/Home.do", null, null );
// theRequest.setRedirectorName( "ServletRedirectorSecure" );
// theRequest.setAuthentication(new FormAuthentication("test","123"));
  }
  public void testHome() {
    assertTrue( "Forcing assertion failure", false );
  }
}

The web.xml too is the same for both the ServletRedirector and the ServletRedirectorSecure, except that I remove the lines for declarative security when using the ServletRedirector:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                            http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
     <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <!-- Declarative security configuration -->
  <security-constraint>
   <web-resource-collection>
     <web-resource-name>Unprotected Resources</web-resource-name>
     <url-pattern>/Logout.do</url-pattern>
     <url-pattern>/images/*</url-pattern>
  </web-resource-collection>
    </security-constraint>
    <security-constraint>
      <web-resource-collection>
        <web-resource-name>All Pages</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>FORM</auth-method>
    <form-login-config>
        <form-login-page>/Login.do</form-login-page>
        <form-error-page>/LoginError.do</form-error-page>
    </form-login-config>
  </login-config>
  <security-role>
    <role-name>test</role-name>
  </security-role>
</web-app>

There is nothing specific to Cactus in the deployment descriptor. I use the following Ant target to add the Cactus configuration to the web.xml file:

<target name="cactus">
  <cactifywar srcfile="${dist.war}" destfile="${dist.dir}/test${war.name}">
    <classes dir="${build.test.classes.dir}" includes="**/*.class"/>
    <servletredirector/>
    <servletredirector name="ServletRedirectorSecure"
        mapping="/ServletRedirectorSecure"/>
  </cactifywar>
  <!-- Replace the base app jar with the test version. -->
  <move file="${dist.dir}/test${war.name}" tofile="${dist.war}"/>
</target>

Thank You :)

Kazuhito SUGURI <[email protected]> escreveu: Hi Paulo,

In article <[email protected]>,
Fri, 3 Mar 2006 11:08:46 -0300 (ART),
Paulo R C Siqueira  wrote: 
gangrelbr1> It is frustrating... but with ServletRedirector instead of
gangrelbr1> ServletRedirectorSecure it works.
gangrelbr1> This means I will need to run my tests with testing authentication?
gangrelbr1> Or is there something that could be done to solve this problem?

I'm not understanding why authentication makes the problem.
Could you please post following items for further analysis?
- source codes of the test case and web.xml that are using ServletRedirectorSecure
- source codes of the test case and web.xml that are using ServletRedirector

Regards,
----
Kazuhito SUGURI

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]




_________________________________
Paulo "gangrel-br" R C Siqueira
Sun Certified Programmer for the Java 2 Platform 1.4
Mogi das Cruzes - SP - Brazil
Contact: (11) 8149-5046
		
---------------------------------
 Yahoo! Search
 Dê uma espiadinha e saiba tudo sobre o Big Brother Brasil.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.