Author: olamy Date: Thu Oct 13 08:57:41 2011 New Revision: 1182727 URL: http://svn.apache.org/viewvc?rev=1182727&view=rev Log: move test classes to o.a.t.m namespace
Added: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/ tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/ tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/ tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/ tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractDeployWarOnlyProjectIT.java (with props) tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractDeployWarProjectIT.java (with props) tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractSimpleWarProjectIT.java (with props) tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractTomcatRunMultiConfigIT.java (with props) tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractUsageContextpathIT.java (with props) tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractWarProjectIT.java (with props) Removed: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/codehaus/mojo/tomcat/it/AbstractDeployWarOnlyProjectIT.java tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/codehaus/mojo/tomcat/it/AbstractDeployWarProjectIT.java tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/codehaus/mojo/tomcat/it/AbstractSimpleWarProjectIT.java tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/codehaus/mojo/tomcat/it/AbstractTomcatRunMultiConfigIT.java tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/codehaus/mojo/tomcat/it/AbstractUsageContextpathIT.java tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/codehaus/mojo/tomcat/it/AbstractWarProjectIT.java Modified: tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6DeployWarOnlyProjectIT.java tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6DeployWarProjectIT.java tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6RunMultiConfigIT.java tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6SimpleWarProjectIT.java tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6UsageContextpathIT.java tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7DeployWarOnlyProjectIT.java tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7DeployWarProjectIT.java tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7RunMultiConfigIT.java tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7SimpleWarProjectIT.java Added: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractDeployWarOnlyProjectIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractDeployWarOnlyProjectIT.java?rev=1182727&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractDeployWarOnlyProjectIT.java (added) +++ tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractDeployWarOnlyProjectIT.java Thu Oct 13 08:57:41 2011 @@ -0,0 +1,73 @@ +package org.apache.tomcat.maven.it; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; + +import static junitx.framework.StringAssert.assertContains; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +/** + * @author Mark Michaelis + */ +public abstract class AbstractDeployWarOnlyProjectIT + extends AbstractWarProjectIT +{ + private static final Logger LOG = LoggerFactory.getLogger( AbstractDeployWarOnlyProjectIT.class ); + + @Override + protected String getWebappUrl() + { + return "http://localhost:" + getHttpItPort() + "/bar/"; + } + + @Override + protected String getWarArtifactId() + { + return "deploy-only-war-project"; + } + + @Test + public void testIt() + throws Exception + { + final String responseBody = executeVerifyWithGet(); + assertNotNull("Received message body must not be null.", responseBody); + assertContains( "Response must match expected content.", "It works !!", responseBody ); + + assertTrue( "Tomcat folder should exist in target folder of project at " + webappHome, + new File( webappHome, "target/tomcat" ).exists() ); + LOG.info( "Error Free Log check" ); + verifier.verifyErrorFreeLog(); + } + + @Override + protected int getTimeout() + { + return 40000; + } +} Propchange: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractDeployWarOnlyProjectIT.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractDeployWarOnlyProjectIT.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractDeployWarProjectIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractDeployWarProjectIT.java?rev=1182727&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractDeployWarProjectIT.java (added) +++ tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractDeployWarProjectIT.java Thu Oct 13 08:57:41 2011 @@ -0,0 +1,73 @@ +package org.apache.tomcat.maven.it; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; + +import static junitx.framework.StringAssert.assertContains; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +/** + * @author Mark Michaelis + */ +public abstract class AbstractDeployWarProjectIT + extends AbstractWarProjectIT +{ + private static final Logger LOG = LoggerFactory.getLogger( AbstractDeployWarProjectIT.class ); + + @Override + protected String getWebappUrl() + { + return "http://localhost:" + getHttpItPort() + "/foo/"; + } + + @Override + protected String getWarArtifactId() + { + return "deploy-war-project"; + } + + @Test + public void testIt() + throws Exception + { + final String responseBody = executeVerifyWithGet(); + assertNotNull("Received message body must not be null.", responseBody); + assertContains( "Response must match expected content.", "It works !!", responseBody ); + + assertTrue( "Tomcat folder should exist in target folder of project at " + webappHome, + new File( webappHome, "target/tomcat" ).exists() ); + LOG.info( "Error Free Log check" ); + verifier.verifyErrorFreeLog(); + } + + @Override + protected int getTimeout() + { + return 40000; + } +} Propchange: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractDeployWarProjectIT.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractDeployWarProjectIT.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractSimpleWarProjectIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractSimpleWarProjectIT.java?rev=1182727&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractSimpleWarProjectIT.java (added) +++ tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractSimpleWarProjectIT.java Thu Oct 13 08:57:41 2011 @@ -0,0 +1,76 @@ +package org.apache.tomcat.maven.it; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + + +import org.apache.maven.it.VerificationException; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; + +import static junitx.framework.StringAssert.assertContains; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +/** + * @author Mark Michaelis + */ +public abstract class AbstractSimpleWarProjectIT + extends AbstractWarProjectIT +{ + private static final Logger LOG = LoggerFactory.getLogger( AbstractSimpleWarProjectIT.class ); + + @Override + protected String getWebappUrl() + { + return "http://localhost:" + getHttpItPort() + "/"; + } + + @Override + protected String getWarArtifactId() + { + return "simple-war-project"; + } + + @Test + public void testIt() + throws Exception + { + final String responseBody = executeVerifyWithGet(); + assertNotNull( "Received message body must not be null.", responseBody ); + assertContains( "Response must match expected content.", "It works !!", responseBody ); + + assertTrue( "Tomcat folder should exist in target folder of project at " + webappHome, + new File( webappHome, "target/tomcat" ).exists() ); + + LOG.info( "Error Free Log check" ); + verifier.verifyErrorFreeLog(); + verifyConnectorsStarted(); + } + + /** + * impls check the logs if http/https/apr has been started + */ + protected abstract void verifyConnectorsStarted() + throws VerificationException; +} Propchange: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractSimpleWarProjectIT.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractSimpleWarProjectIT.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractTomcatRunMultiConfigIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractTomcatRunMultiConfigIT.java?rev=1182727&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractTomcatRunMultiConfigIT.java (added) +++ tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractTomcatRunMultiConfigIT.java Thu Oct 13 08:57:41 2011 @@ -0,0 +1,103 @@ +package org.apache.tomcat.maven.it; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +import org.apache.maven.it.VerificationException; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.net.URI; +import java.net.URISyntaxException; + +import static junitx.framework.StringAssert.assertContains; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +/** + * Tests a bunch of configuration options for the tomcat-run Mojo. + * + * @author Mark Michaelis + */ +public abstract class AbstractTomcatRunMultiConfigIT + extends AbstractWarProjectIT +{ + private static final Logger LOG = LoggerFactory.getLogger(AbstractTomcatRunMultiConfigIT.class); + + private static final String URL_QUERY = "\u3053\u3093\u306b\u3061\u306f"; + + /** + * ArtifactId of the sample WAR project. + */ + private static final String WAR_ARTIFACT_ID = "tomcat-run-multi-config"; + + @Override + protected String getWebappUrl() + { + try + { + return new URI("http://localhost:" + getHttpItPort() + "/multi-config/index.jsp?string=" + URL_QUERY).toASCIIString(); + } + catch ( URISyntaxException e ) + { + LOG.error("An exception occurred.", e); + return "http://localhost:" + getHttpItPort() + "/multi-config"; + } + } + + @Override + protected String getWarArtifactId() + { + return WAR_ARTIFACT_ID; + } + + @Test + public void testIt() + throws Exception + { + final String responseBody = executeVerifyWithGet(); + assertNotNull("Received message body from " + getWebappUrl() + " must not be null.", responseBody); + assertContains("Response from " + getWebappUrl() + " must match expected content.", URL_QUERY, responseBody); + + final File tomcatFolder = new File(webappHome, "target/tc"); + final File emptyLocation = new File(tomcatFolder, "conf/empty.txt"); + + assertTrue( + "Tomcat folder \"" + tomcatFolder.getAbsolutePath() + "\" should exist in target folder of project at " + + webappHome, tomcatFolder.exists()); + assertTrue( + "File \"" + emptyLocation.getAbsolutePath() + "\" should have been copied from tcconf to tomcat/conf", + emptyLocation.exists()); + + LOG.info("Error Free Log check"); + verifier.verifyErrorFreeLog(); + verifyConnectorsStarted(); + + } + + /** + * impls check the logs if http/https/apr has been started + */ + protected abstract void verifyConnectorsStarted() + throws VerificationException; + +} Propchange: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractTomcatRunMultiConfigIT.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractTomcatRunMultiConfigIT.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractUsageContextpathIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractUsageContextpathIT.java?rev=1182727&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractUsageContextpathIT.java (added) +++ tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractUsageContextpathIT.java Thu Oct 13 08:57:41 2011 @@ -0,0 +1,71 @@ +package org.apache.tomcat.maven.it; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static junitx.framework.StringAssert.assertContains; +import static org.junit.Assert.assertNotNull; + +/** + * Tests the example "Using a different context path" as the WAR gets deployed below the contextpath /lorem. + * + * @author Mark Michaelis + */ +public class AbstractUsageContextpathIT + extends AbstractWarProjectIT +{ + private static final Logger LOG = LoggerFactory.getLogger( AbstractUsageContextpathIT.class ); + + private static final String WEBAPP_URL = "http://localhost:" + getHttpItPort() + "/lorem/index.html"; + + /** + * ArtifactId of the sample WAR project. + */ + private static final String WAR_ARTIFACT_ID = "usage-contextpath"; + + @Override + protected String getWebappUrl() + { + return WEBAPP_URL; + } + + @Override + protected String getWarArtifactId() + { + return WAR_ARTIFACT_ID; + } + + @Test + public void testIt() + throws Exception + { + final String responseBody = executeVerifyWithGet(); + assertNotNull( "Received message body must not be null.", responseBody ); + assertContains( "Response must match expected content.", "Success!", responseBody ); + + LOG.info( "Error Free Log check" ); + verifier.verifyErrorFreeLog(); + } + +} Propchange: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractUsageContextpathIT.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractUsageContextpathIT.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractWarProjectIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractWarProjectIT.java?rev=1182727&view=auto ============================================================================== --- tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractWarProjectIT.java (added) +++ tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractWarProjectIT.java Thu Oct 13 08:57:41 2011 @@ -0,0 +1,219 @@ +package org.apache.tomcat.maven.it; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +import org.apache.http.HttpResponse; +import org.apache.http.client.ResponseHandler; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpHead; +import org.apache.http.impl.client.BasicResponseHandler; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; +import org.apache.maven.it.VerificationException; +import org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; +import org.junit.After; +import org.junit.Before; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; + +/** + * Base class for all tests which have a war-project using the tomcat-maven-plugin below project-resources. + * + * @author Mark Michaelis + */ +public abstract class AbstractWarProjectIT +{ + private static final Logger LOG = LoggerFactory.getLogger( AbstractWarProjectIT.class ); + + /** + * This URL will be queried for content. It will also be used to wait for the startup of the webapp. + * + * @return the URL to ping + */ + protected abstract String getWebappUrl(); + + /** + * Artifact ID of the war project. Needed to uninstall any artifacts. + * + * @return artifact ID of the war project under test + */ + protected abstract String getWarArtifactId(); + + /** + * HttpClient to use to connect to the deployed web-application. + */ + private DefaultHttpClient httpClient; + + /** + * Helper for Maven-Integration-Tests. + */ + protected Verifier verifier; + + /** + * Where the war project got placed to. + */ + protected File webappHome; + + @Before + public void setUp() + throws Exception + { + httpClient = new DefaultHttpClient(); + + + final HttpParams params = httpClient.getParams(); + HttpConnectionParams.setConnectionTimeout( params, getTimeout() ); + HttpConnectionParams.setSoTimeout( params, getTimeout() ); + + + webappHome = ResourceExtractor.simpleExtractResources( getClass(), "/" + getWarArtifactId() ); + verifier = new Verifier( webappHome.getAbsolutePath() ); + + boolean debugVerifier = Boolean.getBoolean( "verifier.maven.debug" ); + + verifier.setMavenDebug( debugVerifier ); + verifier.setDebugJvm( Boolean.getBoolean( "verifier.debugJvm" ) ); + verifier.displayStreamBuffers(); + + verifier.deleteArtifact( "org.codehaus.mojo.tomcat.it", getWarArtifactId(), "1.0-SNAPSHOT", "war" ); + } + + @After + public void tearDown() + throws Exception + { + httpClient.getConnectionManager().shutdown(); + verifier.resetStreams(); + verifier.deleteArtifact( "org.codehaus.mojo.tomcat.it", getWarArtifactId(), "1.0-SNAPSHOT", "war" ); + } + + /** + * Executes mvn verify and retrieves the response from the web application. + * + * @return the response given + * @throws VerificationException if the verifier failed to execute the goal + * @throws InterruptedException if the execution got interrupted in some way + */ + protected final String executeVerifyWithGet() + throws VerificationException, InterruptedException, IOException + { + final String[] responseBodies = new String[]{ null }; + + final Thread thread = new Thread( "webapp-response-retriever" ) + { + @Override + public void run() + { + responseBodies[0] = getResponseBody( getTimeout() ); + } + }; + + thread.start(); + + LOG.info( "Executing verify on " + webappHome.getAbsolutePath() ); + verifier.executeGoal( "verify" ); + + verifier.displayStreamBuffers(); + + thread.join(); + + return responseBodies[0]; + } + + private String getResponseBody( int timeout ) + { + String responseBody = null; + final long startTime = System.currentTimeMillis(); + final long endTime = startTime + timeout; + long currentTime = System.currentTimeMillis(); + try + { + while ( pingUrl() != 200 && currentTime < endTime ) + { + LOG.debug( "Ping..." ); + Thread.sleep( 500 ); + currentTime = System.currentTimeMillis(); + } + if ( currentTime < endTime ) + { + responseBody = getResponseBody(); + LOG.debug( "Received: " + responseBody ); + } + else + { + LOG.error( "Timeout met while trying to access web application." ); + } + } + catch ( IOException e ) + { + LOG.error( "Exception while trying to access web application.", e ); + } + catch ( InterruptedException e ) + { + LOG.error( "Exception while trying to access web application.", e ); + } + return responseBody; + } + + private String getResponseBody() + throws IOException + { + HttpGet httpGet = new HttpGet( getWebappUrl() ); + ResponseHandler<String> responseHandler = new BasicResponseHandler(); + return httpClient.execute( httpGet, responseHandler ); + } + + private int pingUrl() + { + final HttpHead httpHead = new HttpHead( getWebappUrl() ); + try + { + final HttpResponse response = httpClient.execute( httpHead ); + return response.getStatusLine().getStatusCode(); + } + catch ( IOException e ) + { + LOG.debug( "Ignoring exception while pinging URL " + httpHead.getURI(), e ); + return -1; + } + } + + protected int getTimeout() + { + return 15000; + } + + protected static String getHttpItPort() + { + return System.getProperty( "its.http.port" ); + } + + protected static String getAjpItPort() + { + return System.getProperty( "its.ajp.port" ); + } + +} Propchange: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractWarProjectIT.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/maven-plugin/trunk/tomcat-maven-plugin-it/src/main/java/org/apache/tomcat/maven/it/AbstractWarProjectIT.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6DeployWarOnlyProjectIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6DeployWarOnlyProjectIT.java?rev=1182727&r1=1182726&r2=1182727&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6DeployWarOnlyProjectIT.java (original) +++ tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6DeployWarOnlyProjectIT.java Thu Oct 13 08:57:41 2011 @@ -18,6 +18,8 @@ package org.codehaus.mojo.tomcat.it; * under the License. */ +import org.apache.tomcat.maven.it.AbstractDeployWarOnlyProjectIT; + /** * @author Olivier Lamy */ Modified: tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6DeployWarProjectIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6DeployWarProjectIT.java?rev=1182727&r1=1182726&r2=1182727&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6DeployWarProjectIT.java (original) +++ tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6DeployWarProjectIT.java Thu Oct 13 08:57:41 2011 @@ -18,6 +18,8 @@ package org.codehaus.mojo.tomcat.it; * under the License. */ +import org.apache.tomcat.maven.it.AbstractDeployWarProjectIT; + /** * @author Olivier Lamy */ Modified: tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6RunMultiConfigIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6RunMultiConfigIT.java?rev=1182727&r1=1182726&r2=1182727&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6RunMultiConfigIT.java (original) +++ tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6RunMultiConfigIT.java Thu Oct 13 08:57:41 2011 @@ -19,6 +19,7 @@ package org.codehaus.mojo.tomcat.it; */ import org.apache.maven.it.VerificationException; +import org.apache.tomcat.maven.it.AbstractTomcatRunMultiConfigIT; /** * @author Olivier Lamy Modified: tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6SimpleWarProjectIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6SimpleWarProjectIT.java?rev=1182727&r1=1182726&r2=1182727&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6SimpleWarProjectIT.java (original) +++ tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6SimpleWarProjectIT.java Thu Oct 13 08:57:41 2011 @@ -19,6 +19,7 @@ package org.codehaus.mojo.tomcat.it; */ import org.apache.maven.it.VerificationException; +import org.apache.tomcat.maven.it.AbstractSimpleWarProjectIT; /** * @author Olivier Lamy Modified: tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6UsageContextpathIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6UsageContextpathIT.java?rev=1182727&r1=1182726&r2=1182727&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6UsageContextpathIT.java (original) +++ tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/test/java/org/codehaus/mojo/tomcat/it/Tomcat6UsageContextpathIT.java Thu Oct 13 08:57:41 2011 @@ -18,6 +18,8 @@ package org.codehaus.mojo.tomcat.it; * under the License. */ +import org.apache.tomcat.maven.it.AbstractUsageContextpathIT; + /** * @author Olivier Lamy */ Modified: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7DeployWarOnlyProjectIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7DeployWarOnlyProjectIT.java?rev=1182727&r1=1182726&r2=1182727&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7DeployWarOnlyProjectIT.java (original) +++ tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7DeployWarOnlyProjectIT.java Thu Oct 13 08:57:41 2011 @@ -18,7 +18,7 @@ package org.apache.tomcat.maven.plugin.t * under the License. */ -import org.codehaus.mojo.tomcat.it.AbstractDeployWarOnlyProjectIT; +import org.apache.tomcat.maven.it.AbstractDeployWarOnlyProjectIT; /** * @author Olivier Lamy Modified: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7DeployWarProjectIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7DeployWarProjectIT.java?rev=1182727&r1=1182726&r2=1182727&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7DeployWarProjectIT.java (original) +++ tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7DeployWarProjectIT.java Thu Oct 13 08:57:41 2011 @@ -18,7 +18,7 @@ package org.apache.tomcat.maven.plugin.t * under the License. */ -import org.codehaus.mojo.tomcat.it.AbstractDeployWarProjectIT; +import org.apache.tomcat.maven.it.AbstractDeployWarProjectIT; /** * @author Olivier Lamy Modified: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7RunMultiConfigIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7RunMultiConfigIT.java?rev=1182727&r1=1182726&r2=1182727&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7RunMultiConfigIT.java (original) +++ tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7RunMultiConfigIT.java Thu Oct 13 08:57:41 2011 @@ -19,7 +19,7 @@ package org.apache.tomcat.maven.plugin.t */ import org.apache.maven.it.VerificationException; -import org.codehaus.mojo.tomcat.it.AbstractTomcatRunMultiConfigIT; +import org.apache.tomcat.maven.it.AbstractTomcatRunMultiConfigIT; /** * @author Olivier Lamy Modified: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7SimpleWarProjectIT.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7SimpleWarProjectIT.java?rev=1182727&r1=1182726&r2=1182727&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7SimpleWarProjectIT.java (original) +++ tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/test/java/org/apache/tomcat/maven/plugin/tomcat7/Tomcat7SimpleWarProjectIT.java Thu Oct 13 08:57:41 2011 @@ -19,7 +19,7 @@ package org.apache.tomcat.maven.plugin.t */ import org.apache.maven.it.VerificationException; -import org.codehaus.mojo.tomcat.it.AbstractSimpleWarProjectIT; +import org.apache.tomcat.maven.it.AbstractSimpleWarProjectIT; /** * @author Olivier Lamy --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org