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  public abstract class AbstractTomcatRunMultiConfigIT
42      extends AbstractWarProjectIT
43  {
44  
45      private static final String URL_QUERY = "\u3053\u3093\u306b\u3061\u306f";
46  
47      
48  
49  
50      private static final String WAR_ARTIFACT_ID = "tomcat-run-multi-config";
51  
52      @Override
53      protected String getWebappUrl()
54      {
55          try
56          {
57              return new URI(
58                  "http://localhost:" + getHttpItPort() + "/multi-config/index.jsp?string=" + URL_QUERY ).toASCIIString();
59          }
60          catch ( URISyntaxException e )
61          {
62              logger.error( "An exception occurred.", e );
63              return "http://localhost:" + getHttpItPort() + "/multi-config";
64          }
65      }
66  
67      @Override
68      protected String getWarArtifactId()
69      {
70          return WAR_ARTIFACT_ID;
71      }
72  
73      @Test
74      public void testIt()
75          throws Exception
76      {
77          final String responseBody = executeVerifyWithGet();
78          assertNotNull( "Received message body from " + getWebappUrl() + " must not be null.", responseBody );
79          assertContains( "Response from " + getWebappUrl() + " must match expected content.", URL_QUERY, responseBody );
80  
81          final File tomcatFolder = new File( webappHome, "target/tc" );
82          final File emptyLocation = new File( tomcatFolder, "conf/empty.txt" );
83  
84          assertTrue(
85              "Tomcat folder \"" + tomcatFolder.getAbsolutePath() + "\" should exist in target folder of project at "
86                  + webappHome, tomcatFolder.exists() );
87          assertTrue(
88              "File \"" + emptyLocation.getAbsolutePath() + "\" should have been copied from tcconf to tomcat/conf",
89              emptyLocation.exists() );
90  
91          logger.info( "Error Free Log check" );
92          verifier.verifyErrorFreeLog();
93          verifyConnectorsStarted();
94  
95      }
96  
97      
98  
99  
100     protected abstract void verifyConnectorsStarted()
101         throws VerificationException;
102 
103 }