You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by vm...@apache.org on 2004/02/13 15:12:49 UTC
cvs commit: jakarta-cactus/scratchpad/cactus2/samples/servlet/conf aspectwerkz.xml
vmassol 2004/02/13 06:12:49
Added: scratchpad/cactus2/integration/maven plugin.jelly .cvsignore
build.properties.sample project.xml
project.properties plugin.properties
scratchpad/cactus2/samples/servlet project.properties
maven.xml project.xml .cvsignore
scratchpad/cactus2/framework/src/main/org/apache/cactus/framework
TestListenerAspect.java
scratchpad/cactus2/framework maven.xml project.xml
.cvsignore project.properties
scratchpad/cactus2 default-project.xml LICENSE.cactus
.cvsignore
scratchpad/cactus2/framework/conf aspectwerkz.xml
scratchpad/cactus2/samples/servlet/src/main/org/apache/cactus/sample/servlet
SampleServlet.java SampleBodyTag.java
SampleServletConfig.java SampleTag.java
scratchpad/cactus2/samples/servlet/src/test-cactus/org/apache/cactus/sample/servlet
TestSampleServletAspectWerkz.java
scratchpad/cactus2/samples/servlet/src/webapp/WEB-INF
web.xml
scratchpad/cactus2/samples/servlet/conf aspectwerkz.xml
Log:
very first cut at cactus 2...
Revision Changes Path
1.1 jakarta-cactus/scratchpad/cactus2/integration/maven/plugin.jelly
Index: plugin.jelly
===================================================================
<?xml version="1.0"?>
<!--
=============================================================================
Cactus2 plugin for Maven.
=============================================================================
-->
<project
xmlns:j="jelly:core"
xmlns:doc="doc"
xmlns:util="jelly:util"
xmlns:ant="jelly:ant"
xmlns:define="jelly:define"
xmlns:x="jelly:xml">
<!--
========================================================================
Default goal.
========================================================================
-->
<goal name="cactus2" prereqs="cactus2:test-war"
description="Runs the Cactus tests"/>
<!--
========================================================================
Initializations.
========================================================================
-->
<goal name="cactus2:init">
<j:set var="tmp" value="${maven.cactus.src.dir}"/>
${pom.getPluginContext('maven-aspectwerkz-plugin').setVariable('maven.aspectwerkz.src.dir', tmp)}
<j:set var="tmp" value="${maven.cactus.build.dest}"/>
${pom.getPluginContext('maven-aspectwerkz-plugin').setVariable('maven.aspectwerkz.build.dest', tmp)}
</goal>
<!--
========================================================================
Compile the Cactus tests
========================================================================
-->
<goal name="cactus2:compile" prereqs="cactus2:init,aspectwerkz:weave"
description="Compile the Cactus tests"/>
<!--
========================================================================
Run Cactus tests
========================================================================
-->
<goal name="cactus2:test-war" prereqs="cactus2:compile,war:war"
description="Runs the Cactus tests">
<taskdef name="junit"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
<ant:junit printSummary="true" fork="true" dir="${maven.build.dir}">
<ant:sysproperty key="aspectwerkz.definition.file" value="${basedir}/conf/aspectwerkz.xml"/>
<ant:formatter type="plain" usefile="false"/>
<ant:classpath>
<ant:path refid="maven.dependency.classpath"/>
<ant:pathelement location="${maven.build.dest}"/>
<ant:pathelement location="${plugin.getDependencyPath('aspectwerkz:aspectwerkz')}"/>
<ant:pathelement location="${plugin.getDependencyPath('dom4j:dom4j')}"/>
<ant:pathelement location="${plugin.getDependencyPath('trove:trove')}"/>
<ant:pathelement location="${plugin.getDependencyPath('bcel:bcel')}"/>
<ant:pathelement location="${plugin.getDependencyPath('jrexx:jrexx')}"/>
</ant:classpath>
<ant:test name="org.apache.cactus.sample.servlet.TestSampleServletAspectWerkz"/>
</ant:junit>
</goal>
</project>
1.1 jakarta-cactus/scratchpad/cactus2/integration/maven/.cvsignore
Index: .cvsignore
===================================================================
target
maven.log
velocity.log
build.properties
.classpath
.project
1.1 jakarta-cactus/scratchpad/cactus2/integration/maven/build.properties.sample
Index: build.properties.sample
===================================================================
# -----------------------------------------------------------------------------
# Environment-dependent properties. Create a copy of this file and
# name if build.properties. Then edit the file and tune it to match your
# environment.
#
# $Id: build.properties.sample,v 1.1 2003/11/08 16:46:45 vmassol Exp $
# -----------------------------------------------------------------------------
# Properties required to upload the Cactus plugin web site
maven.username = vmassol
maven.ssh.executable = tortoiseplink
maven.scp.executable = pscp
# (optional). Properties to use if you're behind a firewall
#maven.proxy.host =
#maven.proxy.port =
#maven.proxy.username =
#maven.proxy.password =
1.1 jakarta-cactus/scratchpad/cactus2/integration/maven/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- Note: We cannot inherit from a base project.xml as this project.xml is
required at runtime by this plugin. Any reference to a base project.xml
will not be resolved at runtime as this base project.xml will not
exist. -->
<project>
<pomVersion>3</pomVersion>
<name>Maven Cactus2 plugin</name>
<groupId>cactus</groupId>
<id>cactus2-maven</id>
<currentVersion>2.0-SNAPSHOT</currentVersion>
<organization>
<name>Apache Software Foundation</name>
<url>http://jakarta.apache.org/</url>
<logo>http://jakarta.apache.org/cactus/images/jakarta-logo.gif</logo>
</organization>
<inceptionYear>2003</inceptionYear>
<package>org.apache.cactus.integration.maven</package>
<logo>http://jakarta.apache.org/cactus/images/logocactus.gif</logo>
<description>Maven plugin for Cactus2</description>
<shortDescription>Maven plugin for Cactus2</shortDescription>
<url>http://jakarta.apache.org/cactus/${pom.currentVersion}/integration/maven/</url>
<issueTrackingUrl>http://nagoya.apache.org/bugzilla/</issueTrackingUrl>
<siteAddress>cvs.apache.org</siteAddress>
<siteDirectory>/www/jakarta.apache.org/cactus/${pom.currentVersion}/integration/maven/</siteDirectory>
<distributionDirectory>/www/www.apache.org/dist/jakarta/cactus/</distributionDirectory>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-cactus2/integration/maven/</connection>
<url>http://cvs.apache.org/viewcvs/jakarta-cactus2/integration/maven</url>
</repository>
<versions>
<version>
<id>2.0</id>
<name>2.0</name>
<tag>HEAD</tag>
</version>
</versions>
<mailingLists>
<mailingList>
<name>Cactus User List</name>
<subscribe>cactus-user-subscribe@jakarta.apache.org</subscribe>
<unsubscribe>cactus-user-unsubscribe@jakarta.apache.org</unsubscribe>
<archive>http://www.mail-archive.com/cactus-user@jakarta.apache.org/</archive>
</mailingList>
<mailingList>
<name>Cactus Developer List</name>
<subscribe>cactus-dev-subscribe@jakarta.apache.org</subscribe>
<unsubscribe>cactus-dev-unsubscribe@jakarta.apache.org</unsubscribe>
<archive>http://www.mail-archive.com/cactus-dev@jakarta.apache.org/</archive>
</mailingList>
</mailingLists>
<developers>
<developer>
<name>Vincent Massol</name>
<id>vmassol</id>
<email>vmassol@pivolis.com</email>
<organization>Pivolis</organization>
</developer>
<developer>
<name>Jari Worsley</name>
<id>jariw</id>
<email>jariw@hyperlink-interactive.co.uk</email>
<organization></organization>
</developer>
<developer>
<name>Nicholas Lesiecki</name>
<id>ndlesiecki</id>
<email>ndlesiecki@yahoo.com</email>
<organization></organization>
</developer>
<developer>
<name>Julien Ruaux</name>
<id>jruaux</id>
<email>jruaux@octo.com</email>
<organization>Octo Technology</organization>
</developer>
<developer>
<name>Christopher Lenz</name>
<id>cmlenz</id>
<email>cmlenz@gmx.de</email>
<organization></organization>
</developer>
</developers>
<contributors>
<contributor>
<name>Eric Pugh</name>
<email>EPugh@upstate.com</email>
</contributor>
<contributor>
<name>Michael Gaffney</name>
<email>michael.gaffney@panacya.com</email>
</contributor>
</contributors>
<dependencies>
<dependency>
<groupId>aspectwerkz</groupId>
<artifactId>aspectwerkz</artifactId>
<version>0.9.RC2.dev.20040125</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>trove</groupId>
<artifactId>trove</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>bcel</groupId>
<artifactId>bcel</artifactId>
<version>5.1</version>
</dependency>
<dependency>
<groupId>jrexx</groupId>
<artifactId>jrexx</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main</sourceDirectory>
<resources>
<resource>
<directory>src/plugin-resources</directory>
<targetPath>plugin-resources</targetPath>
</resource>
<resource>
<directory>.</directory>
<includes>
<include>plugin.jelly</include>
<include>plugin.properties</include>
<include>project.properties</include>
<include>project.xml</include>
</includes>
</resource>
</resources>
</build>
<reports>
<report>maven-changes-plugin</report>
<report>maven-changelog-plugin</report>
<report>maven-file-activity-plugin</report>
<report>maven-developer-activity-plugin</report>
<report>maven-file-activity-plugin</report>
<report>maven-license-plugin</report>
<report>maven-linkcheck-plugin</report>
</reports>
</project>
1.1 jakarta-cactus/scratchpad/cactus2/integration/maven/project.properties
Index: project.properties
===================================================================
# -----------------------------------------------------------------------------
# Default properties for the Maven build. You can override these properties
# either by defining a build.properties file with the overriden properties
# or by passing them on the command line as system parameters (-D).
#
# $Id: project.properties,v 1.1 2004/02/13 14:12:48 vmassol Exp $
# -----------------------------------------------------------------------------
# Display Cactus version on web site
maven.xdoc.date = left
maven.xdoc.version = ${pom.currentVersion}
# Location of license file
maven.license.licenseFile = ${basedir}/../../LICENSE.cactus
# Web site colors
maven.ui.body.background = #fff
maven.ui.body.foreground = #000
maven.ui.section.background = #036
maven.ui.section.foreground = #fff
maven.ui.subsection.background = #888
maven.ui.subsection.foreground = #fff
maven.ui.table.header.background = #bbb
maven.ui.table.header.foreground = #fff
maven.ui.table.row.odd.background = #ddd
maven.ui.table.row.odd.foreground = #000
maven.ui.table.row.even.background = #efefef
maven.ui.table.row.even.foreground = #000
maven.ui.banner.background = #fff
maven.ui.banner.foreground = #000
maven.ui.banner.border.top = #369
maven.ui.banner.border.bottom = #003
maven.ui.source.background = #fff
maven.ui.source.foreground = #000
maven.ui.source.border.right = #888
maven.ui.source.border.left = #888
maven.ui.source.border.top = #888
maven.ui.source.border.bottom = #888
maven.ui.navcol.background = #eee
maven.ui.navcol.background.ns4 = #fff
maven.ui.navcol.foreground = #000
maven.ui.navcol.foreground.ns4 = #555
maven.ui.navcol.border.top = #fff
maven.ui.navcol.border.right = #aaa
maven.ui.navcol.border.bottom = #aaa
maven.ui.breadcrumbs.background = #ddd
maven.ui.breadcrumbs.foreground = #000
maven.ui.breadcrumbs.border.top = #fff
maven.ui.breadcrumbs.border.bottom = #aaa
maven.ui.href.link = blue
maven.ui.href.link.active = #f30
maven.ui.href.link.selfref = #555
# For the changes plugin to link issue with Bugzilla
maven.changes.issue.template = %URL%/show_bug.cgi?id=%ISSUE%
1.1 jakarta-cactus/scratchpad/cactus2/integration/maven/plugin.properties
Index: plugin.properties
===================================================================
# -------------------------------------------------------------------
# Default properties for the Cactus2 plugin
# -------------------------------------------------------------------
maven.cactus.src.dir = ${basedir}/src/test-cactus
maven.cactus.build.dest = ${maven.build.dir}/cactus/classes
1.1 jakarta-cactus/scratchpad/cactus2/samples/servlet/project.properties
Index: project.properties
===================================================================
# -----------------------------------------------------------------------------
# Default properties for the Maven build. You can override these properties
# either by defining a build.properties file with the overriden properties
# or by passing them on the command line as system parameters (-D).
#
# $Id: project.properties,v 1.1 2004/02/13 14:12:49 vmassol Exp $
# -----------------------------------------------------------------------------
# Aspectwerkz plugin configuration
maven.aspectwerkz.verbose = true
# Display Cactus version on web site
maven.xdoc.date = left
maven.xdoc.version = ${pom.currentVersion}
# Location of license file
maven.license.licenseFile = ${basedir}/../../LICENSE.cactus
# Web site colors
maven.ui.body.background = #fff
maven.ui.body.foreground = #000
maven.ui.section.background = #036
maven.ui.section.foreground = #fff
maven.ui.subsection.background = #888
maven.ui.subsection.foreground = #fff
maven.ui.table.header.background = #bbb
maven.ui.table.header.foreground = #fff
maven.ui.table.row.odd.background = #ddd
maven.ui.table.row.odd.foreground = #000
maven.ui.table.row.even.background = #efefef
maven.ui.table.row.even.foreground = #000
maven.ui.banner.background = #fff
maven.ui.banner.foreground = #000
maven.ui.banner.border.top = #369
maven.ui.banner.border.bottom = #003
maven.ui.source.background = #fff
maven.ui.source.foreground = #000
maven.ui.source.border.right = #888
maven.ui.source.border.left = #888
maven.ui.source.border.top = #888
maven.ui.source.border.bottom = #888
maven.ui.navcol.background = #eee
maven.ui.navcol.background.ns4 = #fff
maven.ui.navcol.foreground = #000
maven.ui.navcol.foreground.ns4 = #555
maven.ui.navcol.border.top = #fff
maven.ui.navcol.border.right = #aaa
maven.ui.navcol.border.bottom = #aaa
maven.ui.breadcrumbs.background = #ddd
maven.ui.breadcrumbs.foreground = #000
maven.ui.breadcrumbs.border.top = #fff
maven.ui.breadcrumbs.border.bottom = #aaa
maven.ui.href.link = blue
maven.ui.href.link.active = #f30
maven.ui.href.link.selfref = #555
# For the changes plugin to link issue with Bugzilla
maven.changes.issue.template = %URL%/show_bug.cgi?id=%ISSUE%
1.1 jakarta-cactus/scratchpad/cactus2/samples/servlet/maven.xml
Index: maven.xml
===================================================================
<project
xmlns:j="jelly:core"
xmlns:maven="jelly:maven">
<goal name="dist" prereqs="clean,cactus2:test-war"/>
</project>
1.1 jakarta-cactus/scratchpad/cactus2/samples/servlet/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<extend>${basedir}/../../default-project.xml</extend>
<id>cactus2-samples-servlet</id>
<name>Cactus2 Servlet Sample</name>
<package>org.apache.cactus.samples.servlet</package>
<description>Sample Servlet for Cactus2</description>
<shortDescription>Sample Servlet for Cactus2</shortDescription>
<url>http://jakarta.apache.org/cactus/${pom.currentVersion}/samples/servlet/</url>
<siteDirectory>/www/jakarta.apache.org/cactus/${pom.currentVersion}/samples/servlet/</siteDirectory>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-cactus2/samples/servlet/</connection>
<url>http://cvs.apache.org/viewcvs/jakarta-cactus2/samples/servlet</url>
</repository>
<dependencies>
<dependency>
<groupId>cactus</groupId>
<artifactId>cactus2-framework</artifactId>
<version>${pom.currentVersion}</version>
<properties>
<aspectwerkz.library>true</aspectwerkz.library>
</properties>
</dependency>
<dependency>
<groupId>servletapi</groupId>
<artifactId>servletapi</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>httpunit</groupId>
<artifactId>httpunit</artifactId>
<version>1.5.4</version>
</dependency>
</dependencies>
</project>
1.1 jakarta-cactus/scratchpad/cactus2/samples/servlet/.cvsignore
Index: .cvsignore
===================================================================
target
maven.log
velocity.log
build.properties
.classpath
.project
1.1 jakarta-cactus/scratchpad/cactus2/framework/src/main/org/apache/cactus/framework/TestListenerAspect.java
Index: TestListenerAspect.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Cactus" and "Apache Software
* Foundation" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.cactus.framework;
import org.codehaus.aspectwerkz.attribdef.Pointcut;
import org.codehaus.aspectwerkz.attribdef.aspect.Aspect;
import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
/**
* Intercepts client side JUnit tests and sets up the test listener socket
* if not set.
*/
public class TestListenerAspect extends Aspect
{
/**
* @Execution * *..TestCase+.test*()
*/
Pointcut interceptClientTest;
/**
* Has the test listener socket been set up?
*/
private boolean isSetup = false;
/**
* @Around interceptClientTest
*/
public synchronized Object setupListener(JoinPoint joinPoint)
throws Throwable
{
if (!this.isSetup)
{
System.out.println("Setting up test listener socket");
this.isSetup = true;
}
return joinPoint.proceed();
}
}
1.1 jakarta-cactus/scratchpad/cactus2/framework/maven.xml
Index: maven.xml
===================================================================
<project
xmlns:j="jelly:core"
xmlns:maven="jelly:maven">
<goal name="dist" prereqs="clean,aspectwerkz:aspectc,jar:install"/>
</project>
1.1 jakarta-cactus/scratchpad/cactus2/framework/project.xml
Index: project.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<extend>${basedir}/../default-project.xml</extend>
<id>cactus2-framework</id>
<name>Cactus2 Framework</name>
<package>org.apache.cactus.framework</package>
<description>Cactus2 Framework</description>
<shortDescription>Cactus2 Framework</shortDescription>
<url>http://jakarta.apache.org/cactus/${pom.currentVersion}/framework/</url>
<siteDirectory>/www/jakarta.apache.org/cactus/${pom.currentVersion}/framework/</siteDirectory>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-cactus2/framework/</connection>
<url>http://cvs.apache.org/viewcvs/jakarta-cactus2/framework</url>
</repository>
</project>
1.1 jakarta-cactus/scratchpad/cactus2/framework/.cvsignore
Index: .cvsignore
===================================================================
target
maven.log
velocity.log
build.properties
.classpath
.project
1.1 jakarta-cactus/scratchpad/cactus2/framework/project.properties
Index: project.properties
===================================================================
# -----------------------------------------------------------------------------
# Default properties for the Maven build. You can override these properties
# either by defining a build.properties file with the overriden properties
# or by passing them on the command line as system parameters (-D).
#
# $Id: project.properties,v 1.1 2004/02/13 14:12:49 vmassol Exp $
# -----------------------------------------------------------------------------
# Aspectwerkz plugin configuration
maven.aspectwerkz.verbose = true
maven.aspectwerkz.aspectc.build.dir = ${maven.build.dest}
# Display Cactus version on web site
maven.xdoc.date = left
maven.xdoc.version = ${pom.currentVersion}
# Location of license file
maven.license.licenseFile = ${basedir}/../LICENSE.cactus
# Web site colors
maven.ui.body.background = #fff
maven.ui.body.foreground = #000
maven.ui.section.background = #036
maven.ui.section.foreground = #fff
maven.ui.subsection.background = #888
maven.ui.subsection.foreground = #fff
maven.ui.table.header.background = #bbb
maven.ui.table.header.foreground = #fff
maven.ui.table.row.odd.background = #ddd
maven.ui.table.row.odd.foreground = #000
maven.ui.table.row.even.background = #efefef
maven.ui.table.row.even.foreground = #000
maven.ui.banner.background = #fff
maven.ui.banner.foreground = #000
maven.ui.banner.border.top = #369
maven.ui.banner.border.bottom = #003
maven.ui.source.background = #fff
maven.ui.source.foreground = #000
maven.ui.source.border.right = #888
maven.ui.source.border.left = #888
maven.ui.source.border.top = #888
maven.ui.source.border.bottom = #888
maven.ui.navcol.background = #eee
maven.ui.navcol.background.ns4 = #fff
maven.ui.navcol.foreground = #000
maven.ui.navcol.foreground.ns4 = #555
maven.ui.navcol.border.top = #fff
maven.ui.navcol.border.right = #aaa
maven.ui.navcol.border.bottom = #aaa
maven.ui.breadcrumbs.background = #ddd
maven.ui.breadcrumbs.foreground = #000
maven.ui.breadcrumbs.border.top = #fff
maven.ui.breadcrumbs.border.bottom = #aaa
maven.ui.href.link = blue
maven.ui.href.link.active = #f30
maven.ui.href.link.selfref = #555
# For the changes plugin to link issue with Bugzilla
maven.changes.issue.template = %URL%/show_bug.cgi?id=%ISSUE%
1.1 jakarta-cactus/scratchpad/cactus2/default-project.xml
Index: default-project.xml
===================================================================
<?xml version="1.0"?>
<project>
<pomVersion>3</pomVersion>
<name>Jakarta Cactus2</name>
<groupId>cactus</groupId>
<id>jakarta-cactus2</id>
<currentVersion>2.0-SNAPSHOT</currentVersion>
<organization>
<name>Apache Software Foundation</name>
<url>http://jakarta.apache.org/</url>
<logo>http://jakarta.apache.org/cactus/images/jakarta-logo.gif</logo>
</organization>
<inceptionYear>2003</inceptionYear>
<package>org.apache.cactus</package>
<logo>http://jakarta.apache.org/cactus/images/logocactus.gif</logo>
<shortDescription>Cactus is a simple test framework for unit testing server-side java code.</shortDescription>
<description>
Cactus is a simple test framework for unit testing server-side java code
(Servlets, EJBs, Tag Libs, Filters, ...). The intent of Cactus is to
lower the cost of writing tests for server-side code. It uses JUnit and
extends it.
</description>
<url>http://jakarta.apache.org/cactus/${pom.currentVersion}/</url>
<issueTrackingUrl>http://nagoya.apache.org/bugzilla/</issueTrackingUrl>
<siteAddress>cvs.apache.org</siteAddress>
<siteDirectory>/www/jakarta.apache.org/cactus/${pom.currentVersion}</siteDirectory>
<distributionDirectory>/www/www.apache.org/dist/jakarta/cactus/</distributionDirectory>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-cactus2</connection>
<url>http://cvs.apache.org/viewcvs/jakarta-cactus2/</url>
</repository>
<versions>
<version>
<id>2.0</id>
<name>2.0</name>
<tag>HEAD</tag>
</version>
</versions>
<mailingLists>
<mailingList>
<name>Cactus User List</name>
<subscribe>cactus-user-subscribe@jakarta.apache.org</subscribe>
<unsubscribe>cactus-user-unsubscribe@jakarta.apache.org</unsubscribe>
<archive>http://www.mail-archive.com/cactus-user@jakarta.apache.org/</archive>
</mailingList>
<mailingList>
<name>Cactus Developer List</name>
<subscribe>cactus-dev-subscribe@jakarta.apache.org</subscribe>
<unsubscribe>cactus-dev-unsubscribe@jakarta.apache.org</unsubscribe>
<archive>http://www.mail-archive.com/cactus-dev@jakarta.apache.org/</archive>
</mailingList>
</mailingLists>
<developers>
<developer>
<name>Vincent Massol</name>
<id>vmassol</id>
<email>vmassol@pivolis.com</email>
<organization>Pivolis</organization>
</developer>
<developer>
<name>Jari Worsley</name>
<id>jariw</id>
<email>jariw@hyperlink-interactive.co.uk</email>
<organization></organization>
</developer>
<developer>
<name>Nicholas Lesiecki</name>
<id>ndlesiecki</id>
<email>ndlesiecki@yahoo.com</email>
<organization></organization>
</developer>
<developer>
<name>Julien Ruaux</name>
<id>jruaux</id>
<email>jruaux@octo.com</email>
<organization>Octo Technology</organization>
</developer>
<developer>
<name>Christopher Lenz</name>
<id>cmlenz</id>
<email>cmlenz@gmx.de</email>
<organization></organization>
</developer>
</developers>
<contributors>
<contributor>
<name>Eric Pugh</name>
<email>EPugh@upstate.com</email>
</contributor>
<contributor>
<name>Michael Gaffney</name>
<email>michael.gaffney@panacya.com</email>
</contributor>
</contributors>
<dependencies>
<dependency>
<groupId>aspectwerkz</groupId>
<artifactId>aspectwerkz-core</artifactId>
<version>0.9.RC2.dev.20040125</version>
</dependency>
<dependency>
<groupId>aspectwerkz</groupId>
<artifactId>aspectwerkz</artifactId>
<version>0.9.RC2.dev.20040125</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main</sourceDirectory>
<unitTestSourceDirectory>src/test</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/Test*.java</include>
</includes>
<excludes>
<exclude>**/Test*All.java</exclude>
</excludes>
</unitTest>
</build>
<reports>
<report>maven-changes-plugin</report>
<report>maven-changelog-plugin</report>
<report>maven-file-activity-plugin</report>
<report>maven-developer-activity-plugin</report>
<report>maven-file-activity-plugin</report>
<report>maven-license-plugin</report>
<report>maven-linkcheck-plugin</report>
</reports>
</project>
1.1 jakarta-cactus/scratchpad/cactus2/LICENSE.cactus
Index: LICENSE.cactus
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Cactus" and "Apache Software
* Foundation" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
1.1 jakarta-cactus/scratchpad/cactus2/.cvsignore
Index: .cvsignore
===================================================================
target
maven.log
velocity.log
build.properties
.classpath
.project
.checkstyle
1.1 jakarta-cactus/scratchpad/cactus2/framework/conf/aspectwerkz.xml
Index: aspectwerkz.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE aspectwerkz PUBLIC "-//AspectWerkz//DTD//EN" "http://aspectwerkz.codehaus.org/dtd/aspectwerkz.dtd">
<aspectwerkz>
<system>
<package name="org.apache.cactus.framework">
<use-aspect class="TestListenerAspect"/>
</package>
</system>
</aspectwerkz>
1.1 jakarta-cactus/scratchpad/cactus2/samples/servlet/src/main/org/apache/cactus/sample/servlet/SampleServlet.java
Index: SampleServlet.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Cactus" and "Apache Software
* Foundation" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.cactus.sample.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Hashtable;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* Sample servlet that implement some very simple business logic. The goal is
* to provide functional tests for Cactus, so we focus on providing as many
* different test cases as possible rather than implementing a meaningful
* business logic.
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
* @version $Id: SampleServlet.java,v 1.1 2004/02/13 14:12:49 vmassol Exp $
*/
public class SampleServlet extends HttpServlet
{
/**
* Entry point for the servlet when a GET request is received. This will
* be used to verify that we can test for the servlet output stream in
* Cactus test cases.
*
* @param theRequest the HTTP request
* @param theResponse the HTTP response
*
* @exception IOException on failure
*/
public void doGet(HttpServletRequest theRequest,
HttpServletResponse theResponse) throws IOException
{
PrintWriter pw = theResponse.getWriter();
theResponse.setContentType("text/html");
pw.print("<html><head/><body>");
pw.print("A GET request");
pw.print("</body></html>");
}
/**
* Return the method used to send data from the client (POST or GET). This
* will be used to verify that we can simulate POST or GET methods from
* Cactus. This simulates a method which would test the method to
* implement it's business logic.
*
* @param theRequest the HTTP request
* @return the method used to post data
*/
public String checkMethod(HttpServletRequest theRequest)
{
return theRequest.getMethod();
}
/**
* Set some variable in the HTTP session. It verifies that a session object
* has automatically been created by Cactus prior to calling this method.
*
* @param theRequest the HTTP request
*/
public void setSessionVariable(HttpServletRequest theRequest)
{
HttpSession session = theRequest.getSession(false);
session.setAttribute("name_setSessionVariable",
"value_setSessionVariable");
}
/**
* Set some attribute in the request.
*
* @param theRequest the HTTP request
*/
public void setRequestAttribute(HttpServletRequest theRequest)
{
theRequest.setAttribute("name_setRequestAttribute",
"value_setRequestAttribute");
}
/**
* Get some parameters from the HTTP request.
*
* @param theRequest the HTTP request
* @return a hashtable containing some parameters
*/
public Hashtable getRequestParameters(HttpServletRequest theRequest)
{
Hashtable params = new Hashtable();
params.put("param1", theRequest.getParameter("param1"));
params.put("param2", theRequest.getParameter("param2"));
return params;
}
/**
* Get a header from the request.
*
* @return a test request header
* @param theRequest the HTTP request
*/
public String getRequestHeader(HttpServletRequest theRequest)
{
return theRequest.getHeader("testheader");
}
/**
* @return the cookies sent in the HTTP request
*
* @param theRequest the HTTP request
*/
public Hashtable getRequestCookies(HttpServletRequest theRequest)
{
Hashtable allCookies = new Hashtable();
Cookie[] cookies = theRequest.getCookies();
if (cookies != null)
{
for (int i = 0; i < cookies.length; i++)
{
Cookie cookie = cookies[i];
allCookies.put(cookie.getName(), cookie.getValue());
}
}
return allCookies;
}
/**
* Set a header in the HTTP response. This is to verify that Cactus tests
* can assert the returned headers.
*
* @param theResponse the HTTP response
*/
public void setResponseHeader(HttpServletResponse theResponse)
{
theResponse.setHeader("responseheader", "this is a response header");
}
/**
* Set a cookie for sending back to the client. This is to verify that
* it is possible with Cactus to assert the cookies returned to the client
*
* @param theResponse the HTTP response
*/
public void setResponseCookie(HttpServletResponse theResponse)
{
Cookie cookie = new Cookie("responsecookie",
"this is a response cookie");
cookie.setDomain("jakarta.apache.org");
theResponse.addCookie(cookie);
}
/**
* Use a <code>RequestDispatcher</code> to forward to a JSP page. This is
* to verify that Cactus supports asserting the result, even in the case
* of forwarding to another page.
*
* @param theRequest the HTTP request
* @param theResponse the HTTP response
* @param theConfig the servlet config object
*
* @exception IOException on failure
* @exception ServletException on failure
*/
public void doForward(HttpServletRequest theRequest,
HttpServletResponse theResponse, ServletConfig theConfig)
throws IOException, ServletException
{
RequestDispatcher rd =
theConfig.getServletContext().getRequestDispatcher(
"/test/test.jsp");
rd.forward(theRequest, theResponse);
}
/**
* Use a <code>RequestDispatcher</code> to include a JSP page. This is
* to verify that Cactus supports asserting the result, even in the case
* of including another page.
*
* @param theRequest the HTTP request
* @param theResponse the HTTP response
* @param theConfig the servlet config object
*
* @exception IOException on failure
* @exception ServletException on failure
*/
public void doInclude(HttpServletRequest theRequest,
HttpServletResponse theResponse, ServletConfig theConfig)
throws IOException, ServletException
{
RequestDispatcher rd =
theConfig.getServletContext().getRequestDispatcher(
"/test/test.jsp");
rd.include(theRequest, theResponse);
}
}
1.1 jakarta-cactus/scratchpad/cactus2/samples/servlet/src/main/org/apache/cactus/sample/servlet/SampleBodyTag.java
Index: SampleBodyTag.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Cactus" and "Apache Software
* Foundation" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.cactus.sample.servlet;
import java.io.IOException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyTagSupport;
/**
* Sample tag that interacts with its body. The tag acts as a filter for its
* body. "Target" and "Replacement" Strings are defined by the tag's attributes
* and each "occurrence" of the target is replaced by the "replacement".
*
* @author <a href="mailto:nick@eblox.com">Nicholas Lesiecki</a>
*
* @version $Id: SampleBodyTag.java,v 1.1 2004/02/13 14:12:49 vmassol Exp $
*/
public class SampleBodyTag extends BodyTagSupport
{
/**
* The substring to be replaced in the body.
*/
private String target;
/**
* The substring that will replace the target in the body.
*/
private String replacement;
/**
* Sets the substring to be replaced in the body.
*
* @param theTarget the substring to be replaced in the body
*/
public void setTarget(String theTarget)
{
this.target = theTarget;
}
/**
* Sets the substring that will replace the target in the body.
*
* @param theReplacement the replacement string
*/
public void setReplacement(String theReplacement)
{
this.replacement = theReplacement;
}
/**
* @see BodyTagSupport#doAfterBody()
*/
public int doAfterBody() throws JspTagException
{
String contentString = this.bodyContent.getString();
StringBuffer contentBuffer = new StringBuffer(contentString);
int beginIndex = -1;
int targetLength = this.target.length();
// while instances of target still exist
while ((beginIndex = contentString.indexOf(this.target)) > -1)
{
int endIndex = beginIndex + targetLength;
contentBuffer.replace(beginIndex, endIndex, this.replacement);
contentString = contentBuffer.toString();
}
// write out the changed body
JspWriter pageWriter = this.bodyContent.getEnclosingWriter();
try
{
pageWriter.write(contentString);
}
catch (IOException e)
{
throw new JspTagException(e.getMessage());
}
return SKIP_BODY;
}
/**
* @see BodyTagSupport#release()
*/
public void release()
{
this.target = null;
this.replacement = null;
}
}
1.1 jakarta-cactus/scratchpad/cactus2/samples/servlet/src/main/org/apache/cactus/sample/servlet/SampleServletConfig.java
Index: SampleServletConfig.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Cactus" and "Apache Software
* Foundation" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.cactus.sample.servlet;
import javax.servlet.http.HttpServlet;
/**
* Sample servlet to show how to unit test a servlet that makes calls to
* <code>getServletConfig()</code>, <code>getServletContext()</code>,
* <code>log()</code>, ... (i.e. methods inherited from
* <code>GenericServlet</code>).
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
* @version $Id: SampleServletConfig.java,v 1.1 2004/02/13 14:12:49 vmassol Exp $
*/
public class SampleServletConfig extends HttpServlet
{
/**
* Simulate a method that calls <code>getServletConfig()</code>.
*
* @return some data retrieved from the servlet configuration.
*/
public String getConfigData()
{
return getServletConfig().getInitParameter("param1");
}
}
1.1 jakarta-cactus/scratchpad/cactus2/samples/servlet/src/main/org/apache/cactus/sample/servlet/SampleTag.java
Index: SampleTag.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Cactus" and "Apache Software
* Foundation" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.cactus.sample.servlet;
import java.io.IOException;
import java.util.Enumeration;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;
/**
* Sample tag that implements simple tag logic.
*
* @author <a href="mailto:nick@eblox.com">Nicholas Lesiecki</a>
*
* @version $Id: SampleTag.java,v 1.1 2004/02/13 14:12:49 vmassol Exp $
*/
public class SampleTag extends TagSupport
{
/**
* Determines whether the tag's body should be shown.
*/
private boolean showBody;
/**
* Determines whether page should continue after the tag.
*/
private boolean stopPage;
/**
* Determines whether the tag's body should be shown.
*
* @param isBodyShown a String equaling 'true' will be taken as
* <code>true</code>. Anything else will be
* taken as <code>false</code>.
*/
public void setShowBody(String isBodyShown)
{
this.showBody = "true".equals(isBodyShown.toLowerCase());
}
/**
* Determines whether page should stop after the tag.
*
* @param isPageStopped a String equaling 'true' will be taken as
* <code>true</code>. Anything else will be
* taken as <code>false</code>.
*/
public void setStopPage(String isPageStopped)
{
this.stopPage = "true".equals(isPageStopped);
}
/**
* Prints the names and values of everything in page scope to the response,
* along with the body (if showBody is set to <code>true</code>).
*
* @return the return code
* @exception JspTagException on failure
*/
public int doStartTag() throws JspTagException
{
Enumeration names = pageContext.getAttributeNamesInScope(
PageContext.PAGE_SCOPE);
JspWriter out = pageContext.getOut();
try
{
out.println("The following attributes exist in page scope: <BR>");
while (names.hasMoreElements())
{
String name = (String) names.nextElement();
Object attribute = pageContext.getAttribute(name);
out.println(name + " = " + attribute + " <BR>");
}
if (this.showBody)
{
out.println("Body Content Follows: <BR>");
return EVAL_BODY_INCLUDE;
}
}
catch (IOException e)
{
throw new JspTagException(e.getMessage());
}
return SKIP_BODY;
}
/**
* Does two things:
* <ul>
* <li>Stops the page if the corresponding attribute has been set</li>
* <li>Prints a message another tag encloses this one.</li>
* </ul>
*
* @return the return code
* @exception JspTagException on failure
*/
public int doEndTag() throws JspTagException
{
//get the parent if any
Tag parent = this.getParent();
if (parent != null)
{
try
{
JspWriter out = this.pageContext.getOut();
out.println("This tag has a parent. <BR>");
}
catch (IOException e)
{
throw new JspTagException(e.getMessage());
}
}
if (this.stopPage)
{
return Tag.SKIP_PAGE;
}
return Tag.EVAL_PAGE;
}
}
1.1 jakarta-cactus/scratchpad/cactus2/samples/servlet/src/test-cactus/org/apache/cactus/sample/servlet/TestSampleServletAspectWerkz.java
Index: TestSampleServletAspectWerkz.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Cactus" and "Apache Software
* Foundation" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.cactus.sample.servlet;
import java.util.Hashtable;
import javax.servlet.http.HttpServletRequest;
import org.codehaus.aspectwerkz.attribdef.Pointcut;
import org.codehaus.aspectwerkz.attribdef.aspect.Aspect;
import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
import org.codehaus.aspectwerkz.joinpoint.MethodJoinPoint;
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
import junit.framework.TestCase;
public class TestSampleServletAspectWerkz extends TestCase
{
/**
* Intercepts Servlet's doXXX calls and instead redirect the flow of
* execution to the {@link SampleServlet#getRequestParameters} method to
* unit test.
*/
public static class GetRequestParametersTestAdvice extends Aspect
{
/**
* @Execution * *..SampleServlet.do*(..)
*/
Pointcut interceptServlet;
/**
* @Around interceptServlet
*/
public Object catchGetRequestParameters(JoinPoint joinPoint)
throws Throwable
{
MethodJoinPoint jp = (MethodJoinPoint) joinPoint;
SampleServlet servlet = (SampleServlet) jp.getTargetInstance();
Hashtable params = servlet.getRequestParameters(
(HttpServletRequest) jp.getParameters()[0]);
assertNotNull(params.get("param1"));
assertNotNull(params.get("param2"));
assertEquals("value1", params.get("param1"));
assertEquals("value2", params.get("param2"));
return null;
}
}
/**
* Test {@link SampleServlet#getRequestParameters} by calling the server
* side using HttpUnit. On the server side, our aspect will kick in and
* the {@link GetRequestParametersTestAdvice#testGetRequestParameters(JoinPoint)} test method will
* be called to unit test our method.
*/
public void testGetRequestParameters() throws Exception
{
WebConversation conversation = new WebConversation();
WebRequest request = new GetMethodWebRequest(
"http://localhost:8080/test/SampleServlet?param1=value1¶m2=value2");
WebResponse response = conversation.getResponse(request);
}
}
1.1 jakarta-cactus/scratchpad/cactus2/samples/servlet/src/webapp/WEB-INF/web.xml
Index: web.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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>
<servlet>
<servlet-name>ServletSample</servlet-name>
<servlet-class>org.apache.cactus.sample.servlet.SampleServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletSample</servlet-name>
<url-pattern>/servletsample</url-pattern>
</servlet-mapping>
</web-app>
1.1 jakarta-cactus/scratchpad/cactus2/samples/servlet/conf/aspectwerkz.xml
Index: aspectwerkz.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE aspectwerkz PUBLIC "-//AspectWerkz//DTD//EN" "http://aspectwerkz.codehaus.org/dtd/aspectwerkz.dtd">
<aspectwerkz>
<system>
<package name="org.apache.cactus.sample.servlet">
<use-aspect class="TestSampleServletAspectWerkz$GetRequestParametersTestAdvice"/>
</package>
<package name="org.apache.cactus.framework">
<use-aspect class="TestListenerAspect"/>
</package>
</system>
</aspectwerkz>
---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org