Hey Shawn,
You know what's funny (depending on ho you look at it I guess!) ? It is that
you have reinvented some mechanism already there in Cactus ... It seems you
missed on big part of Cactus ... which is the methodology and tools to
automate running Cactus tests ... (see
http://jakarta.apache.org/commons/cactus/ant.html and
http://jakarta.apache.org/commons/cactus/ant.html) !
In other words, the Ant task that you have implemented has already been
implemented within Cactus (with other tasks), it is called the
'runservertask' and works in the following way :
<runservertests testURL="http://localhost:8080"
startTarget="start_tomcat_32"
stopTarget="stop_tomcat_32"
testTarget="tests"/>
What it does is, instead of sleeping (which I don't like because it takes
time and it is not deterministic), it tries to HTTP connect to the URL
mentionned in thte 'testURL' attribute until it succeeds. When it does, it
calls the Ant target specified by the 'startTarget' attribute, then executes
the Ant target specified by the 'testTarget' attribute (you would put the
junit task to start the Cactus tests in that target - look at the sample Ant
script in <cactusinstalldir>/samples/build) and then call the target defined
by the 'stopTarget' attribute .... that's all ! And it's generic ...
Have a look and tell me what you think.
Thanks
-Vincent
----- Original Message -----
From: "Storoe, Shawn" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, July 26, 2001 4:37 PM
Subject: RE: Help with log4j and cactus
> Yes, I will do that.
> However, I looked over the scripts and I see that you are starting
> weblogic in a fork, but how do you determine that it has started and is
> ready for the test.
> I am currently sleeping for 60 seconds to make sure that bluestone is
> started up. And I start the task in a seperate thread. I did the
> same with weblogic 6.0 as well.
> This will actually work for all app servers and you do not need a
> seperate ant task to start it up. It may make it easier for you to get
> people to set up cactus for different servers.
> The task that I wrote looks like this.
> <target name="sleepstartbluestone" description="Sleep while the
> application server starts">
> <taskdef name="sleepstart" classname="com.divine.ant.SleepStart"/>
> <!-- in miliseconds -->
> <!-- Not a standard ant task. It is in com.divine.ant -->
> <sleepstart millis="60000" tasktostart="startbluestone"/>
> </target>
> This calls a seperate task in a different thread and sleeps for a set
> amount of time before returning. The time should be set to a value that
> you know will allow the other task to be started.
> My other task is just executing a bat file so that I have more
> flexability to start and stop the server(s). And they are are easier to
> write for the other develeopers. Not a java program and usually written
> by the vendor.
> Here is my Bluestone task.
> <target name="startbluestone">
> <exec executable="startBSserverCC.bat">
> </exec>
> </target>
> I do it in a similiar fashion for weblogic and TomCat.
> I switched to this way since I kept having a problem with the weblogic
> task hanging on weblogic 6.0 and no matter what I did, it would not
> return.
> And I had to sleep anyways and or loop while running a test to make sure
> that the server was started.
> Here is the ant task that I wrote. Very simple. However, I also have a
> version that listens for a specific output so that we are sure that it
> has started and not just by sleeping. But I like this way better.
> package com.divine.ant;
> import java.io.*;
> import java.util.*;
> import org.apache.tools.ant.*;
> import org.apache.tools.ant.taskdefs.*;
> /**
> * This is an ANT task that is able to sleep for a specified
> * period of time.
> *
> */
> public class SleepStart extends Task implements Runnable{
> private long millis = -1L;
> private static String tasktostart = null;
> private static Project tempProject = null;
> /**
> * Set the length of time to sleep in milliseconds.
> *
> * <sleep millis="10000"/>
> *
> */
> public void setMillis(long value) {
> millis = value;
> }
> public void setTasktostart(String taskname){
> tasktostart = taskname;
> System.out.println("We are here " + taskname);
> }
> public void run() {
> String temp = tasktostart;
> try {
> System.out.println("In thread");
> System.out.println("Starting [" + temp + "] in seperate
> thread.");
> System.out.println("SleepStart [" +
> this.tempProject.getName() + "]");
> this.tempProject.executeTarget(temp);
> Thread.sleep(1000);
> System.out.println("SleepStart is finished with [" + temp + "]");
> } catch (InterruptedException e) {
> e.printStackTrace();
> }
> }
> public void execute() throws BuildException {
> tempProject = this.getProject();
> if (millis < 0 ) {
> throw new BuildException("You need to specify a positive
> length of " +
> "time to sleep in milliseconds.");
> }
> try {
> new Thread(new SleepStart()).start();
> log("Sleeping for [" + millis/1000 + "]");
> int i = 1;
> while (i < millis/1000)
> {
> i++;
> log("Sleeping for second[" + i + "]");
> Thread.currentThread().sleep(1000);
> }
> } catch (Exception e) {
> e.printStackTrace();
> throw new BuildException(e);
> }
> }
> }
> So, based on my longwinded answer to your question. Is this what you
> are looking for. If so, I will package it up and send it to you. If
> you want me to use ant tasks to start up bluestone, I can write those as
> well, but it will take me a few days to test. I think that bluestone
> sent me some.
> I just prefer not to use them since it is more work to se up the
> classpath and such.
> Thanks
> Shawn
>
> -----Original Message-----
> From: Vincent Massol
> Sent: Thu 7/26/2001 10:00 AM
> To: [EMAIL PROTECTED]
> Cc:
> Subject: Re: Help with log4j and cactus
>
>
>
> Hi Shawn,
>
> If you look in the <cactusinstalldir>/sample/build directory,
> you'll find
> several file named "build-tests-<servername>-<version>.xml".
> These are Ant
> scripts that are used to start/stop/deploy the cactus tests in
> the
> application server in order to automate running the tests. In
> order to help
> Cactus users we'd like to provide as much of these as possible.
> We currently
> have Tomcat, Resin, Orion, WebLogic 5.x, ... bu we don't have
> Bluestone !
> :-)
>
> Helping us with Bluestone scripts would be fantastic !
>
> Of course, I understand you may not currently have enough time
> to do that.
> That's fine, don't worry ! I'm asking just in case ... :-)
>
> Thanks
> -Vincent
>
> ----- Original Message -----
> From: "Storoe, Shawn" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, July 25, 2001 3:46 PM
> Subject: RE: Help with log4j and cactus
>
>
> > Hi Vincent,
> >
> > Thanks. That seemed to do the trick. Let me know what you
> are looking
> > for with the bluestone stuff and I will get it to you.
> >
> > Meaning, what do you mean by ant script working for BlueStone?
> Are you
> > looking for configuration directions?
> >
> > Shawn
> >
> >
> > -----Original Message-----
> > From: Vincent Massol
> > Sent: Wed 7/25/2001 3:59 AM
> > To: [EMAIL PROTECTED]
> > Cc:
> > Subject: Re: Help with log4j and cactus
> >
> >
> >
> > Hi Shawn,
> >
> > It seems to be a known issue that we have with Cactus 1.1
> which
> > should be
> > easy to correct. What happens in is that log4j is initialized
> in
> > the Cactus
> > redirector (i.e. in the JVM of your application server),
> meaning
> > that if
> > Bluestone itself is using Log4j, it will probably close it's
> > existing
> > appenders and thus any call to log from Bluestone will result
> in
> > the error
> > displayed in it's console. Maybe the same happens in the other
> > way.
> >
> > What I suggest is to try to modify your Cactus Log4j
> > configuration (files
> > log_server.properties and log_client.properties). Currently it
> > should be
> > something like (for log_server.properties) :
> >
> > ----
> > # Properties for configuring Log4j
> > # This is the configuring for logging on the server side
> >
> > log4j.appender.cactus = org.apache.log4j.FileAppender
> > log4j.appender.cactus.File = cactus_server.log
> > log4j.appender.cactus.Append = false
> > log4j.appender.cactus.layout = org.apache.log4j.PatternLayout
> > log4j.appender.cactus.layout.ConversionPattern = %r [%t] %-5p
> > %c{2} %x - %m
> > %n
> >
> > log4j.rootCategory = DEBUG, cactus
> > ---
> >
> > Change it to be :
> >
> > ---
> > # Properties for configuring Log4j
> > # This is the configuring for logging on the server side
> >
> > log4j.appender.cactus = org.apache.log4j.FileAppender
> > log4j.appender.cactus.File = cactus_server.log
> > log4j.appender.cactus.Append = false
> > log4j.appender.cactus.layout = org.apache.log4j.PatternLayout
> > log4j.appender.cactus.layout.ConversionPattern = %r [%t] %-5p
> > %c{2} %x - %m
> > %n
> >
> > log4j.category.org.apache.commons.cactus = DEBUG, cactus
> > ---
> >
> > So that only the classes in package org.apache.commons.cactus
> > will use the
> > "cactus" appender.
> >
> > Now the problem of initialization may still remain. Can you
> give
> > it a try
> > and tell me how it goes ? I'll send a patch for the
> > initialization code if
> > it is still a problem.
> > Thanks
> >
> > Note 1: It will be corrected in the next version of Cactus.
> The
> > above
> > mentionned correction has already been done in Cactus in CVS.
> >
> > Sorry about that.
> >
> > Note 2: Once you have the Ant script working for Bluestone, I
> > would be very
> > interested if you could contribute it so that we can add it to
> > our list of
> > "supported" application servers. Thanks
> >
> > -Vincent
> >
> >
> >
> > ----- Original Message -----
> > From: "Storoe, Shawn" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Tuesday, July 24, 2001 11:07 PM
> > Subject: Help with log4j and cactus
> >
> >
> > > I am currently working on a project that is using the
> > following
> > > products.
> > >
> > > Bluestone application server.
> > >
> > > Ant Scripts to run cactus and junit tests.
> > >
> > > Up to this point, I have not had any problem logging from
> out
> > > application. However once I started extending
> ServletTestCase
> > instead
> > > of TestCase, I started to get errors as follows from both
> the
> > ant
> > > scripts and the Bluestone server console.
> > >
> > > I have searched everywhere on the web and cannot find any
> > pointers or
> > > hints to get around this problem.
> > >
> > > Does anyone have any ideas?
> > >
> > >
> > > Ant Scripts:
> > >
> > > [junit] log4j:WARN Not allowed to write to a closed
> > appender.
> > > [junit] log4j:ERROR Attempted to append to closed
> appender
> > named
> > > [TEMP1].
> > > [junit] log4j:WARN Not allowed to write to a closed
> > appender.
> > > [junit] log4j:ERROR Attempted to append to closed
> appender
> > named
> > > [TEMP1].
> > > [junit] log4j:WARN Not allowed to write to a closed
> > appender.
> > > [junit] log4j:ERROR Attempted to append to closed
> appender
> > named
> > > [TEMP1].
> > > [junit] log4j:WARN Not allowed to write to a closed
> > appender.
> > > [junit] log4j:ERROR Attempted to append to closed
> appender
> > named
> > > [TEMP1].
> > > [junit] log4j:WARN Not allowed to write to a closed
> > appender.
> > > [junit] log4j:ERROR Attempted to append to closed
> appender
> > named
> > > [TEMP1].
> > > [junit] log4j:WARN Not allowed to write to a closed
> > appender.
> > > [junit] log4j:ERROR Attempted to append to closed
> appender
> > named
> > > [TEMP1].
> > > [junit] log4j:WARN Not allowed to write to a closed
> > appender.
> > > [junit] log4j:ERROR Attempted to append to closed
> appender
> > named
> > > [TEMP1].
> > > [junit] log4j:WARN Not allowed to write to a closed
> > appender.
> > > [junit] log4j:ERROR Attempted to append to closed
> appender
> > named
> > > [TEMP1].
> > >
> > > Bluestone server console.
> > >
> > > log4j:WARN Not allowed to write to a closed appender.
> > > log4j:ERROR Attempted to append to closed appender named
> > [TEMP].
> > > log4j:WARN Not allowed to write to a closed appender.
> > > log4j:ERROR Attempted to append to closed appender named
> > [TEMP].
> > > log4j:WARN Not allowed to write to a closed appender.
> > > log4j:ERROR Attempted to append to closed appender named
> > [TEMP].
> > > log4j:WARN Not allowed to write to a closed appender.
> > > log4j:ERROR Attempted to append to closed appender named
> > [TEMP].
> > > log4j:WARN Not allowed to write to a closed appender.
> > > log4j:ERROR Attempted to append to closed appender named
> > [TEMP].
> > >
> > >
> > > All of the log4j logging appears to work fine if I am not in
> > the
> > > ServletTestCase?
> > >
> > > Thanks
> > >
> > > Shawn Storoe
> > >
> >
> >
> >
> >
>
>
>
>