You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Nicole Luneburg <Ni...@lisasoft.com> on 2009/01/23 05:14:16 UTC

Viewing Test Results

Hi all,

I'm running cactus 1.8.0, jboss 4.2.3.
I am able to run my test however all tests fail.

For simplicity I just had one test class and one test method:

package myapp.ejb.service;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import junit.framework.Assert;

import org.apache.cactus.ServletTestCase;
import org.apache.cactus.WebRequest;
import org.apache.cactus.client.authentication.FormAuthentication;
import org.apache.log4j.Logger;

public class UserTest extends ServletTestCase {

                private static final Logger log = Logger.getLogger(UserTest.class);

                public UserTest(final String name) {
                                System.out.println("inside constructor");
                                log.info("inside constructor");
                                super(name);
                }

                public void begin(WebRequest theRequest) {
                    System.out.println("inside begin()");
                    log.info("inside begin()");
                }

                public void setUp() throws Exception {
                                System.out.println("inside setUp() ");
                                log.info("inside setUp() ");

                                super.setUp();
                }

                protected void tearDown() throws Exception {
                                System.out.println("inside tearDown() ");
                                log.info("inside tearDown() ");

                                super.tearDown();
                }

                public void testGetUserString() {
                                System.out.println("inside testGetUserString()");
                                log.info("inside testGetUserString()");

                                Assert.assertTrue(true);
                }
}

When I run my ant test target I get the following output (extract):

cactus.test:
     [echo] Cargo gets JBoss for running the tests...
   [cactus] -----------------------------------------------------------------
   [cactus] Parsed JBoss version = [4.2.3]
   [cactus] Running tests against JBoss 4.2.3 @ http://localhost:8080
   [cactus] -----------------------------------------------------------------
   [cactus] Deploying [.//cactus/myapp-cactified.ear] to [C:\DOCUME~1\myname\LOCALS~1\Temp\cargo\conf/deploy]...
   [cactus] JBoss 4.2.3 starting...
Server [Apache-Coyote/1.1] started
   [cactus] Running myapp.ejb.service.UserTest
   [cactus] JBoss 4.2.3 started on port [8080]
   [cactus] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.375 sec
   [cactus] Test myapp.ejb.service.UserTest FAILED
   [cactus] JBoss 4.2.3 is stopping...

BUILD SUCCESSFUL
Total time: 1 minute 52 seconds

As you can see it fails even though I'm not really "testing" anything.
In the cactus sample ejb3 project, running the test target generated a jboss42x directory in the target directory.
This directory contained files like:

TEST-org.apache.cactus.sample.ejb3.TestConverterEJB.xml

That look like test results.

So I have two questions:

1) How do I see the output of my log4j log.info or System.out.println statements?
2) If I can't see the output of my statements anywhere, is the only way to see the results in greater detail through generating xml files such as the one shown above?
3) I have almost an identical ant test target as the one that does generate those xml files, but they aren't generating :(

--------------- In relation to question 3, my ant test target is:

<target name="cactus.test" depends="cactus.cactifyear">
      <echo>Cargo gets JBoss for running the tests...</echo>
      <mkdir dir="${reports.dir}" />

      <cactus earfile="${cactified.archive.name}" printsummary="yes">
            <classpath>
                  <path refid="cactus.classpath" />
                  <pathelement location="${cactus.dir}/classes" />
            </classpath>
            <containerset>
                  <cargo containerId="${jboss.container.id}" output="${cactus.logs.dir}/output.log" log="${cactus.logs.dir}/cargo.log" home="${cactus.jboss.dir}">
                        <configuration>
                              <property name="cargo.servlet.port" value="${cargo.servlet.port}" />
                              <property name="cargo.logging" value="${cargo.logging}" />
                              <deployable type="ear" file="${cactified.archive.name}" />
                        </configuration>
                  </cargo>
            </containerset>

            <formatter type="${cactus.formatter.type}" />
            <batchtest todir="${reports.dir}">
                  <fileset dir="${project.test.dir}">
                        <include name="**/*Test.java" />
                  </fileset>
            </batchtest>
      </cactus>
</target>

--------------

I hope what I am asking here makes sense.

Thanks!
Nic

________________________________
The contents of this email are confidential and may be subject to legal or professional privilege and copyright. No representation is made that this email is free of viruses or other defects. If you have received this communication in error, you may not copy or distribute any part of it or otherwise disclose its contents to anyone. Please advise the sender of your incorrect receipt of this correspondence.

RE: Viewing Test Results

Posted by Nicole Luneburg <Ni...@lisasoft.com>.
Anyone know what I'm doing wrong? ..

-----Original Message-----
Sent: Tuesday, 27 January 2009 11:47 AM

Hi,

Thanks for the welcome and the response!

Ok so before I modified my assert, I took it out to see what happens.
My class looking like:

package myapp.ejb.service;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.apache.cactus.ServletTestCase;
import org.apache.cactus.WebRequest;
import org.apache.cactus.client.authentication.FormAuthentication;
import org.apache.log4j.Logger;

public class UserTest extends ServletTestCase {

                private static final Logger log = Logger.getLogger(UserTest.class);

                public UserTest(final String name) {
                                super(name);
                }

                public void begin(WebRequest theRequest) {
                    System.out.println("inside begin()");

                          theRequest.setRedirectorName("ServletRedirectorSecure");
                        theRequest.setAuthentication(new FormAuthentication("test", "test"));
                }

                public void setUp() throws Exception {
                                log.info("inside setUp() ");
                }

                protected void tearDown() throws Exception {
                                log.info("inside tearDown() ");
                }

                public void testGetUserString() {
                                log.info("inside testGetUserString()");
                }
}

So points are:

1) This test fails.
2) This test is successful if I take out the WebRequest operations in the begin(...) method. Why?
3) I'm not sure if I mentioned in my last email ... the xml files are not generating at all even though I followed the example app so I cannot see any output there :(:

Nicole


The contents of this email are confidential and may be subject to legal or professional privilege and copyright. No representation is made that this email is free of viruses or other defects. If you have received this communication in error, you may not copy or distribute any part of it or otherwise disclose its contents to anyone. Please advise the sender of your incorrect receipt of this correspondence.

---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-user-help@jakarta.apache.org


The contents of this email are confidential and may be subject to legal or professional privilege and copyright. No representation is made that this email is free of viruses or other defects. If you have received this communication in error, you may not copy or distribute any part of it or otherwise disclose its contents to anyone. Please advise the sender of your incorrect receipt of this correspondence.

---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-user-help@jakarta.apache.org


RE: Viewing Test Results

Posted by Nicole Luneburg <Ni...@lisasoft.com>.
Hi,

Thanks for the welcome and the response!

Ok so before I modified my assert, I took it out to see what happens.
My class looking like:

package myapp.ejb.service;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.apache.cactus.ServletTestCase;
import org.apache.cactus.WebRequest;
import org.apache.cactus.client.authentication.FormAuthentication;
import org.apache.log4j.Logger;

public class UserTest extends ServletTestCase {

                private static final Logger log = Logger.getLogger(UserTest.class);

                public UserTest(final String name) {
                                super(name);
                }

                public void begin(WebRequest theRequest) {
                    System.out.println("inside begin()");

                          theRequest.setRedirectorName("ServletRedirectorSecure");
                        theRequest.setAuthentication(new FormAuthentication("test", "test"));
                }

                public void setUp() throws Exception {
                                log.info("inside setUp() ");
                }

                protected void tearDown() throws Exception {
                                log.info("inside tearDown() ");
                }

                public void testGetUserString() {
                                log.info("inside testGetUserString()");
                }
}

So points are:

1) This test fails.
2) This test is successful if I take out the WebRequest operations in the begin(...) method. Why?
3) I'm not sure if I mentioned in my last email ... the xml files are not generating at all even though I followed the example app so I cannot see any output there :(:

Nicole


The contents of this email are confidential and may be subject to legal or professional privilege and copyright. No representation is made that this email is free of viruses or other defects. If you have received this communication in error, you may not copy or distribute any part of it or otherwise disclose its contents to anyone. Please advise the sender of your incorrect receipt of this correspondence.

---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-user-help@jakarta.apache.org


Re: Viewing Test Results

Posted by Petar Tahchiev <pa...@gmail.com>.
Hi Nicole,

welcome back ;-).

output.log  contains all the server-side logs. Client-side logs (the begin
and end methods)
should be printed on the command line or in the xml you mentioned.

One problem I see in your testcases is the following:
you use JUnit4 assert methods.

Take a look here:

http://jakarta.apache.org/cactus/writing/howto_testcase_servlet.html

the assert methods are inherited from the Servlet/JSP/FilterTestCase you
extend.

Try to change this and maybe if it fails again let us know what the content
of the xml is.

Thanks

2009/1/23 Nicole Luneburg <Ni...@lisasoft.com>

> Just quickly ...
> I can see my STDOUTs in output.log, but only for:
>
> 1) setup()
> 2) testGetUserString()
>
> In that order.
>
> I need to be able to access begin(WebRequest theRequest) because I need to
> do:
>
>            theRequest.setRedirectorName("ServletRedirectorSecure");
>            theRequest.setAuthentication(new BasicAuthentication("testuser",
> "testpassword"));
>
> what do I need to do?
> I've already gone through the example etc but obviously I must be doing
> something wrong :(
>
> nic
>
> The contents of this email are confidential and may be subject to legal or
> professional privilege and copyright. No representation is made that this
> email is free of viruses or other defects. If you have received this
> communication in error, you may not copy or distribute any part of it or
> otherwise disclose its contents to anyone. Please advise the sender of your
> incorrect receipt of this correspondence.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org
>
>


-- 
Regards, Petar!
Karlovo, Bulgaria.
- - - - - - - -
| Author @ Manning Publications.
| Senior Solution Architect @ Unic
| BGJUG-Bulgarian Java User Group Leader.
| Apache Maven Developer.
| Apache Jakarta PMC member.
| Jakarta Cactus Lead Developer.
| Blogger: http://weblogs.java.net/blog/paranoiabla/
- - - - - - - -
Public PGP Key at:
https://keyserver1.pgp.com/vkd/DownloadKey.event?keyid=0x19658550C3110611
Key Fingerprint: A369 A7EE 61BC 93A3 CDFF  55A5 1965 8550 C311 0611

RE: Viewing Test Results (Att: Petar)

Posted by Nicole Luneburg <Ni...@lisasoft.com>.
Hi Petar,

Sorry to bother you directly with this ...

Remember I was saying I got your example working?
I left it exactly as it is but I just added:

junit.framework.Assert.assertTrue("expected test role in request", super.request.isUserInRole("test"));

and the test fails.
Does this mean the example didn't work? :(

The contents of this email are confidential and may be subject to legal or professional privilege and copyright. No representation is made that this email is free of viruses or other defects. If you have received this communication in error, you may not copy or distribute any part of it or otherwise disclose its contents to anyone. Please advise the sender of your incorrect receipt of this correspondence.

---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-user-help@jakarta.apache.org


RE: Viewing Test Results

Posted by Nicole Luneburg <Ni...@lisasoft.com>.
Just quickly ...
I can see my STDOUTs in output.log, but only for:

1) setup()
2) testGetUserString()

In that order.

I need to be able to access begin(WebRequest theRequest) because I need to do:

            theRequest.setRedirectorName("ServletRedirectorSecure");
            theRequest.setAuthentication(new BasicAuthentication("testuser", "testpassword"));

what do I need to do?
I've already gone through the example etc but obviously I must be doing something wrong :(

nic

The contents of this email are confidential and may be subject to legal or professional privilege and copyright. No representation is made that this email is free of viruses or other defects. If you have received this communication in error, you may not copy or distribute any part of it or otherwise disclose its contents to anyone. Please advise the sender of your incorrect receipt of this correspondence.

---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-user-help@jakarta.apache.org