| 1 | |
package org.apache.tomcat.maven.it; |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
import org.apache.maven.it.VerificationException; |
| 24 | |
import org.junit.Test; |
| 25 | |
import org.slf4j.Logger; |
| 26 | |
import org.slf4j.LoggerFactory; |
| 27 | |
|
| 28 | |
import java.io.File; |
| 29 | |
import java.net.URI; |
| 30 | |
import java.net.URISyntaxException; |
| 31 | |
|
| 32 | |
import static junitx.framework.StringAssert.assertContains; |
| 33 | |
import static org.junit.Assert.assertNotNull; |
| 34 | |
import static org.junit.Assert.assertTrue; |
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | 0 | public abstract class AbstractTomcatRunMultiConfigIT |
| 42 | |
extends AbstractWarProjectIT |
| 43 | |
{ |
| 44 | 0 | private static final Logger LOG = LoggerFactory.getLogger( AbstractTomcatRunMultiConfigIT.class ); |
| 45 | |
|
| 46 | |
private static final String URL_QUERY = "\u3053\u3093\u306b\u3061\u306f"; |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
private static final String WAR_ARTIFACT_ID = "tomcat-run-multi-config"; |
| 52 | |
|
| 53 | |
@Override |
| 54 | |
protected String getWebappUrl() |
| 55 | |
{ |
| 56 | |
try |
| 57 | |
{ |
| 58 | 0 | return new URI( |
| 59 | |
"http://localhost:" + getHttpItPort() + "/multi-config/index.jsp?string=" + URL_QUERY ).toASCIIString(); |
| 60 | |
} |
| 61 | 0 | catch ( URISyntaxException e ) |
| 62 | |
{ |
| 63 | 0 | LOG.error( "An exception occurred.", e ); |
| 64 | 0 | return "http://localhost:" + getHttpItPort() + "/multi-config"; |
| 65 | |
} |
| 66 | |
} |
| 67 | |
|
| 68 | |
@Override |
| 69 | |
protected String getWarArtifactId() |
| 70 | |
{ |
| 71 | 0 | return WAR_ARTIFACT_ID; |
| 72 | |
} |
| 73 | |
|
| 74 | |
@Test |
| 75 | |
public void testIt() |
| 76 | |
throws Exception |
| 77 | |
{ |
| 78 | 0 | final String responseBody = executeVerifyWithGet(); |
| 79 | 0 | assertNotNull( "Received message body from " + getWebappUrl() + " must not be null.", responseBody ); |
| 80 | 0 | assertContains( "Response from " + getWebappUrl() + " must match expected content.", URL_QUERY, responseBody ); |
| 81 | |
|
| 82 | 0 | final File tomcatFolder = new File( webappHome, "target/tc" ); |
| 83 | 0 | final File emptyLocation = new File( tomcatFolder, "conf/empty.txt" ); |
| 84 | |
|
| 85 | 0 | assertTrue( |
| 86 | |
"Tomcat folder \"" + tomcatFolder.getAbsolutePath() + "\" should exist in target folder of project at " |
| 87 | |
+ webappHome, tomcatFolder.exists() ); |
| 88 | 0 | assertTrue( |
| 89 | |
"File \"" + emptyLocation.getAbsolutePath() + "\" should have been copied from tcconf to tomcat/conf", |
| 90 | |
emptyLocation.exists() ); |
| 91 | |
|
| 92 | 0 | LOG.info( "Error Free Log check" ); |
| 93 | 0 | verifier.verifyErrorFreeLog(); |
| 94 | 0 | verifyConnectorsStarted(); |
| 95 | |
|
| 96 | 0 | } |
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
protected abstract void verifyConnectorsStarted() |
| 102 | |
throws VerificationException; |
| 103 | |
|
| 104 | |
} |