Patch 2 from Eric Pugh for Maven 235

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@112819 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
dion
2003-02-03 14:08:02 +00:00
parent 670ec885a8
commit 66116a6418
10 changed files with 112 additions and 110 deletions

View File

@@ -94,10 +94,13 @@
========================================================================
-->
<goal name="cactus:webapp" description="Create the Cactus webapp">
<attainGoal name="war:init"/> <!-- this seems required to setup the plugin context -->
<!-- this seems required to setup the plugin context -->
<attainGoal name="war:init"/>
<j:set var="maven.cactus.prewar.dir" value="${pom.getPluginContext('maven-war-plugin').getVariable('maven.war.build.dir')}"/>
<available file="${maven.cactus.prewar.dir}/${maven.final.name}.war"
<available file="${maven.cactus.prewar.dir}/${pom.artifactId}.war"
property="maven.cactus.prewar.exists"/>
<j:choose>
@@ -105,7 +108,7 @@
<j:when test="${maven.cactus.prewar.exists}">
<!-- Expand the project war -->
<unwar src="${maven.cactus.prewar.dir}/${maven.final.name}.war"
<unwar src="${maven.cactus.prewar.dir}/${pom.artifactId}.war"
dest="${maven.cactus.build.dir}/${pom.artifactId}"/>
<attainGoal name="cactus:webapp-update"/>
@@ -113,14 +116,14 @@
<j:otherwise>
<available file="${maven.cactus.prewar.dir}/${maven.final.name}/WEB-INF"
<available file="${maven.cactus.prewar.dir}/${pom.artifactId}/WEB-INF"
type="dir" property="maven.cactus.prewebapp.exists"/>
<j:choose>
<j:when test="${maven.cactus.prewebapp.exists}">
<copy todir="${maven.cactus.build.dir}/${pom.artifactId}">
<fileset dir="${maven.cactus.prewar.dir}/${maven.final.name}"/>
<fileset dir="${maven.cactus.prewar.dir}/${pom.artifactId}"/>
</copy>
<attainGoal name="cactus:webapp-update"/>
@@ -167,12 +170,20 @@
You need to provide a Cactus'ed web.xml to use.
-->
<j:set var="cactuscheckwebxml" value="${maven.cactus.webxml}X"/>
<j:if test="${cactuscheckwebxml == 'X'}">
<fail message="You must provide in your project.properties a maven.cactus.webxml web.xml file to use."/>
</j:if>
<j:choose>
<j:when test="${cactuscheckwebxml == 'X'}">
<echo message="You should provide in your project.properties a maven.cactus.webxml web.xml file to use. Using default web.xml"/>
<copy toFile="${maven.cactus.build.dir}/${pom.artifactId}/WEB-INF/web.xml" overwrite="true"
file="${plugin.resources}/conf/web.cactus.xml"/>
</j:when>
<j:otherwise>
<copy toFile="${maven.cactus.build.dir}/${pom.artifactId}/WEB-INF/web.xml" overwrite="true"
file="${maven.cactus.webxml}"/>
</j:otherwise>
</j:choose>
<copy toFile="${maven.cactus.build.dir}/${pom.artifactId}/WEB-INF/web.xml" overwrite="true"
file="${maven.cactus.webxml}"/>
</goal>
@@ -326,7 +337,10 @@
<!--
========================================================================
Generate Cactus test report (xdoc format). Run maven xdoc:transform
to then transform into HTML.
to then transform into HTML. By default, the test reports go into the
standard test reports directory. If you have at least one Junit Test
then when you run maven site it will convert them. Otherwise you must
call cactus:generate.
========================================================================
-->
@@ -336,13 +350,13 @@
<mkdir dir="${maven.cactus.test.reportsDirectory}"/>
<!-- Consolidate the reports into a single -->
<junitreport todir="${maven.cactus.test.reportsDirectory}">
<!-- based on junit report plugin -->
<junitreport todir="${maven.build.dir}">
<fileset dir="${maven.cactus.test.reportsDirectory}">
<include name="TEST-*.xml"/>
</fileset>
</junitreport>
<!-- copied from junit report plugin -->
<doc:jsl
input="${maven.build.dir}/TESTS-TestSuites.xml"
output="junit-report.xml"
@@ -351,6 +365,7 @@
outputMode="xml"
prettyPrint="true"
/>
</goal>

View File

@@ -61,7 +61,7 @@ maven.cactus.port = 8080
maven.cactus.junit.usefile = true
# Location of generated raw test reports
maven.cactus.test.reportsDirectory = ${maven.cactus.build.dir}/test-reports
maven.cactus.test.reportsDirectory = ${maven.build.dir}/test-reports
# Define what TestRunner to use. Default is the JUnit text test runner
# (the one used by the <junit> Ant task). Valid values are: text, swing

View File

@@ -1,4 +1,9 @@
# Please specify your path to your container
#maven.cactus.tomcat4x.home = C:/Apps/jakarta-tomcat-4.1.10
maven.cactus.tomcat4x.home = C:/java/tomcat
#maven.cactus.resin2x.home = C:/Apps/resin-2.1.4
# Plase specify what container you are testing with
maven.cactus.container=tomcat-4x

View File

@@ -60,12 +60,12 @@
<!-- build information for the project -->
<build>
<sourceDirectory>src/java</sourceDirectory>
<sourceDirectory>src/java</sourceDirectory>
<unitTestSourceDirectory>src/test</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/Test*.java</include>
<include>**/DummyTest.java</include>
</includes>
</unitTest>

View File

@@ -69,10 +69,9 @@ import javax.servlet.jsp.tagext.BodyTagSupport;
*
* @author <a href="mailto:nick@eblox.com">Nicholas Lesiecki</a>
*
* @version $Id: SampleBodyTag.java,v 1.1 2003/01/24 03:44:46 jvanzyl Exp $
* @version $Id: SampleBodyTag.java,v 1.2 2003/02/03 14:08:02 dion Exp $
*/
public class SampleBodyTag extends BodyTagSupport
{
public class SampleBodyTag extends BodyTagSupport {
/**
* The substring to be replaced in the body.
*/
@@ -88,26 +87,23 @@ public class SampleBodyTag extends BodyTagSupport
*
* @param theTarget the substring to be replaced in the body
*/
public void setTarget(String theTarget)
{
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)
{
public void setReplacement(String theReplacement) {
this.replacement = theReplacement;
}
/**
* @see BodyTagSupport#doAfterBody()
*/
public int doAfterBody() throws JspTagException
{
public int doAfterBody() throws JspTagException {
String contentString = this.bodyContent.getString();
StringBuffer contentBuffer = new StringBuffer(contentString);
@@ -115,8 +111,7 @@ public class SampleBodyTag extends BodyTagSupport
int targetLength = this.target.length();
// while instances of target still exist
while ((beginIndex = contentString.indexOf(this.target)) > -1)
{
while ((beginIndex = contentString.indexOf(this.target)) > -1) {
int endIndex = beginIndex + targetLength;
contentBuffer.replace(beginIndex, endIndex, this.replacement);
@@ -127,12 +122,9 @@ public class SampleBodyTag extends BodyTagSupport
// write out the changed body
JspWriter pageWriter = this.bodyContent.getEnclosingWriter();
try
{
try {
pageWriter.write(contentString);
}
catch (IOException e)
{
} catch (IOException e) {
throw new JspTagException(e.getMessage());
}
@@ -142,8 +134,7 @@ public class SampleBodyTag extends BodyTagSupport
/**
* @see BodyTagSupport#release()
*/
public void release()
{
public void release() {
this.target = null;
this.replacement = null;
}

View File

@@ -76,10 +76,9 @@ import org.apache.maven.cactus.sample.util.GenericResponseWrapper;
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
* @version $Id: SampleFilter.java,v 1.1 2003/01/24 03:44:46 jvanzyl Exp $
* @version $Id: SampleFilter.java,v 1.2 2003/02/03 14:08:02 dion Exp $
*/
public class SampleFilter implements Filter
{
public class SampleFilter implements Filter {
/**
* We need to save the filter config as the Fitler API does not offer
* a means to get the filter config ... except in the <code>init()</code>
@@ -91,11 +90,10 @@ public class SampleFilter implements Filter
* cycle of the filter.
*
* @param theConfig the filter config
*
*
* @exception ServletException on failure
*/
public void init(FilterConfig theConfig) throws ServletException
{
public void init(FilterConfig theConfig) throws ServletException {
this.config = theConfig;
}
@@ -107,14 +105,13 @@ public class SampleFilter implements Filter
* @param theResponse the returned HTTP response
* @param theChain the chain of filters extracted from the definition
* given in <code>web.xml</code> by the container.
*
*
* @exception ServletException on failure
* @exception IOException on failure
*/
public void doFilter(ServletRequest theRequest,
public void doFilter(ServletRequest theRequest,
ServletResponse theResponse, FilterChain theChain) throws IOException,
ServletException
{
ServletException {
OutputStream out = theResponse.getOutputStream();
addHeader(out);
@@ -123,7 +120,7 @@ public class SampleFilter implements Filter
// the response (add the footer). If we did not do this, we would
// get an error saying that the response has already been
// committed.
GenericResponseWrapper wrapper =
GenericResponseWrapper wrapper =
new GenericResponseWrapper((HttpServletResponse) theResponse);
theChain.doFilter(theRequest, wrapper);
@@ -139,15 +136,13 @@ public class SampleFilter implements Filter
* <code>web.xml</code>). Don't write anything if no parameter is defined.
*
* @param theOutputStream the output stream
*
*
* @exception IOException on failure
*/
protected void addHeader(OutputStream theOutputStream) throws IOException
{
protected void addHeader(OutputStream theOutputStream) throws IOException {
String header = this.config.getInitParameter("header");
if (header != null)
{
if (header != null) {
theOutputStream.write(header.getBytes());
}
}
@@ -158,15 +153,13 @@ public class SampleFilter implements Filter
* <code>web.xml</code>). Don't write anything if no parameter is defined.
*
* @param theOutputStream the output stream
*
*
* @exception IOException on failure
*/
protected void addFooter(OutputStream theOutputStream) throws IOException
{
protected void addFooter(OutputStream theOutputStream) throws IOException {
String footer = this.config.getInitParameter("footer");
if (footer != null)
{
if (footer != null) {
theOutputStream.write(footer.getBytes());
}
}
@@ -175,7 +168,6 @@ public class SampleFilter implements Filter
* Filter un-initialisation. Called by the servlet engine during the life
* cycle of the filter.
*/
public void destroy()
{
public void destroy() {
}
}

View File

@@ -60,20 +60,37 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
public class SampleServlet extends HttpServlet
{
public boolean isAuthenticated(HttpServletRequest request)
{
/**
* Sample servlet that implements some very simple business logic. The goal is
* to provide some functional tests for Cactus and examples for Cactus users.
* This servlet simply checks is a user is authenticated
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
* @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
*
* @version $Id: SampleServlet.java,v 1.2 2003/02/03 14:08:02 dion Exp $
*/
public class SampleServlet extends HttpServlet {
/**
*Take a request object and return whether the user is authenticated o not.
*
* @param request the HttpServletRequest object
*
* @return boolean whether the request is by an authenticated user or not
*
*/
public boolean isAuthenticated(HttpServletRequest request) {
HttpSession session = request.getSession(false);
if (session == null)
{
if (session == null) {
return false;
}
String authenticationAttribute =
String authenticationAttribute =
(String) session.getAttribute("authenticated");
return new Boolean(authenticationAttribute).booleanValue();
}
}

View File

@@ -73,12 +73,11 @@ import javax.servlet.ServletOutputStream;
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
* @version $Id: FilterServletOutputStream.java,v 1.1 2003/01/24 03:44:47 jvanzyl Exp $
* @version $Id: FilterServletOutputStream.java,v 1.2 2003/02/03 14:08:02 dion Exp $
*
* @see GenericResponseWrapper
*/
public class FilterServletOutputStream extends ServletOutputStream
{
public class FilterServletOutputStream extends ServletOutputStream {
/**
* The stream where all the data will get written to
*/
@@ -90,8 +89,7 @@ public class FilterServletOutputStream extends ServletOutputStream
* @param theOutput the output stream that we wrap in a
* <code>DataOutputStream</code> in order to hold the data
*/
public FilterServletOutputStream(OutputStream theOutput)
{
public FilterServletOutputStream(OutputStream theOutput) {
stream = new DataOutputStream(theOutput);
}
@@ -100,24 +98,21 @@ public class FilterServletOutputStream extends ServletOutputStream
/**
* @see ServletOutputStream#write(int)
*/
public void write(int b) throws IOException
{
public void write(int b) throws IOException {
stream.write(b);
}
/**
* @see ServletOutputStream#write(byte[])
*/
public void write(byte[] b) throws IOException
{
public void write(byte[] b) throws IOException {
stream.write(b);
}
/**
* @see ServletOutputStream#write(byte[], int, int)
*/
public void write(byte[] b, int off, int len) throws IOException
{
public void write(byte[] b, int off, int len) throws IOException {
stream.write(b, off, len);
}
}

View File

@@ -77,12 +77,11 @@ import javax.servlet.http.HttpServletResponseWrapper;
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
* @version $Id: GenericResponseWrapper.java,v 1.1 2003/01/24 03:44:46 jvanzyl Exp $
* @version $Id: GenericResponseWrapper.java,v 1.2 2003/02/03 14:08:02 dion Exp $
*
* @see FilterServletOutputStream
*/
public class GenericResponseWrapper extends HttpServletResponseWrapper
{
public class GenericResponseWrapper extends HttpServletResponseWrapper {
/**
* Holder for the output data
*/
@@ -109,8 +108,7 @@ public class GenericResponseWrapper extends HttpServletResponseWrapper
/**
* @param theResponse the wrapped response object
*/
public GenericResponseWrapper(HttpServletResponse theResponse)
{
public GenericResponseWrapper(HttpServletResponse theResponse) {
super(theResponse);
this.output = new ByteArrayOutputStream();
}
@@ -120,8 +118,7 @@ public class GenericResponseWrapper extends HttpServletResponseWrapper
/**
* @return the data sent to the output stream
*/
public byte[] getData()
{
public byte[] getData() {
return output.toByteArray();
}
@@ -130,16 +127,14 @@ public class GenericResponseWrapper extends HttpServletResponseWrapper
/**
* @see HttpServletResponseWrapper#getOutputStream()
*/
public ServletOutputStream getOutputStream()
{
public ServletOutputStream getOutputStream() {
return new FilterServletOutputStream(this.output);
}
/**
* @see HttpServletResponseWrapper#setContentLength(int)
*/
public void setContentLength(int theLength)
{
public void setContentLength(int theLength) {
this.contentLength = theLength;
super.setContentLength(theLength);
}
@@ -147,16 +142,14 @@ public class GenericResponseWrapper extends HttpServletResponseWrapper
/**
* @see HttpServletResponseWrapper#getContentLength()
*/
public int getContentLength()
{
public int getContentLength() {
return this.contentLength;
}
/**
* @see HttpServletResponseWrapper#setContentType(String)
*/
public void setContentType(String theType)
{
public void setContentType(String theType) {
this.contentType = theType;
super.setContentType(theType);
}
@@ -164,16 +157,14 @@ public class GenericResponseWrapper extends HttpServletResponseWrapper
/**
* @see HttpServletResponseWrapper#getContentType()
*/
public String getContentType()
{
public String getContentType() {
return this.contentType;
}
/**
* @see HttpServletResponseWrapper#getWriter()
*/
public PrintWriter getWriter()
{
public PrintWriter getWriter() {
return new PrintWriter(getOutputStream(), true);
}
}

View File

@@ -70,10 +70,9 @@ import org.apache.cactus.WebResponse;
*
* @author <a href="mailto:nick@eblox.com">Nciholas Lesiecki</a>
*
* @version $Id: TestSampleBodyTag.java,v 1.1 2003/01/24 03:44:46 jvanzyl Exp $
* @version $Id: TestSampleBodyTag.java,v 1.2 2003/02/03 14:08:02 dion Exp $
*/
public class TestSampleBodyTag extends JspTestCase
{
public class TestSampleBodyTag extends JspTestCase {
private SampleBodyTag tag;
private BodyContent tagContent;
@@ -92,8 +91,7 @@ public class TestSampleBodyTag extends JspTestCase
*
* @param theArgs the arguments. Not used
*/
public static void main(String[] theArgs)
{
public static void main(String[] theArgs) {
junit.swingui.TestRunner.main(
new String[] { TestSampleBodyTag.class.getName() });
}
@@ -102,8 +100,7 @@ public class TestSampleBodyTag extends JspTestCase
* @return a test suite (<code>TestSuite</code>) that includes all methods
* starting with "test"
*/
public static Test suite()
{
public static Test suite() {
// All methods starting with "test" will be executed in the test suite.
return new TestSuite(TestSampleBodyTag.class);
}
@@ -112,8 +109,7 @@ public class TestSampleBodyTag extends JspTestCase
* In addition to creating the tag instance and adding the pageContext to
* it, this method creates a BodyContent object and passes it to the tag.
*/
public void setUp()
{
public void setUp() {
this.tag = new SampleBodyTag();
this.tag.setPageContext(this.pageContext);
@@ -161,10 +157,10 @@ public class TestSampleBodyTag extends JspTestCase
String content = theResponse.getText();
assertTrue("Response should have contained the ["
+ "replacement is now replacement] string",
+ "replacement is now replacement] string",
content.indexOf("replacement is now replacement") > -1);
assertTrue("Response should have contained the ["
+ "replacement_replacement] string",
+ "replacement_replacement] string",
content.indexOf("replacement") > -1);
}
}