This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/tomcat-maven-plugin.git


The following commit(s) were added to refs/heads/trunk by this push:
     new fcbe31d  Add tests
fcbe31d is described below

commit fcbe31d0ec7926f195eb06ae3a310ff027d319d9
Author: remm <[email protected]>
AuthorDate: Tue Apr 14 21:08:11 2026 +0200

    Add tests
---
 .../tomcat/maven/it/TomcatContainerGoalsIT.java    |  63 +++++++++
 src/test/resources/container-goals-test/pom.xml    | 150 +++++++++++++++++++++
 .../src/main/tomcatconf/empty.txt                  |  19 +++
 .../src/main/tomcatconf/logging.properties         |  66 +++++++++
 .../src/main/tomcatconf/server.xml                 |  48 +++++++
 .../src/main/tomcatconf/tomcat-users.xml           |  25 ++++
 .../container-goals-test/src/main/webapp/index.jsp |  17 +++
 .../container-goals-test/src/main/webapp/web.xml   |  24 ++++
 .../container-goals-test/src/test/java/WaitIT.java |  34 +++++
 9 files changed, 446 insertions(+)

diff --git 
a/src/test/java/org/apache/tomcat/maven/it/TomcatContainerGoalsIT.java 
b/src/test/java/org/apache/tomcat/maven/it/TomcatContainerGoalsIT.java
new file mode 100644
index 0000000..6eb13e3
--- /dev/null
+++ b/src/test/java/org/apache/tomcat/maven/it/TomcatContainerGoalsIT.java
@@ -0,0 +1,63 @@
+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 java.io.File;
+
+import static junitx.framework.StringAssert.assertContains;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class TomcatContainerGoalsIT extends AbstractWarProjectIT {
+    @Override
+    protected String getWebappUrl() {
+        return "http://localhost:"; + getHttpItPort() + "/foo/";
+    }
+
+    @Override
+    protected String getWarArtifactId() {
+        return "container-goals-test";
+    }
+
+    @Test
+    public void testContainerGoals() 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());
+
+        logger.info("Verifying container goals output");
+        verifier.verifyTextInLog("Manager: list: Listing contexts for virtual 
host");
+        verifier.verifyTextInLog("Manager: serverinfo");
+        verifier.verifyTextInLog("Manager: resources:  Listing resources of 
all types");
+
+        logger.info("Error Free Log check");
+        verifier.verifyErrorFreeLog();
+    }
+
+    @Override
+    protected int getTimeout() {
+        return 40000;
+    }
+}
\ No newline at end of file
diff --git a/src/test/resources/container-goals-test/pom.xml 
b/src/test/resources/container-goals-test/pom.xml
new file mode 100644
index 0000000..33e4b57
--- /dev/null
+++ b/src/test/resources/container-goals-test/pom.xml
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.tomcat.maven.it</groupId>
+    <artifactId>container-goals-test</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>war</packaging>
+
+    <properties>
+        
<project.build.sourceEncoding>${project.build.sourceEncoding}</project.build.sourceEncoding>
+    </properties>
+
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-war-plugin</artifactId>
+                    <version>3.5.1</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>3.15.0</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.tomcat.maven</groupId>
+                    <artifactId>tomcat-maven-plugin</artifactId>
+                    <version>@pom.version@</version>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+
+        <plugins>
+            <plugin>
+                <artifactId>maven-war-plugin</artifactId>
+                <configuration>
+                    <webXml>src/main/webapp/web.xml</webXml>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.tomcat.maven</groupId>
+                <artifactId>tomcat-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>tomcat-run</id>
+                        <goals>
+                            <goal>run-war-only</goal>
+                        </goals>
+                        <phase>pre-integration-test</phase>
+                        <configuration>
+                            <fork>true</fork>
+                            <path>/foo</path>
+                            
<serverXml>src/main/tomcatconf/server.xml</serverXml>
+                            
<tomcatUsers>src/main/tomcatconf/tomcat-users.xml</tomcatUsers>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>tomcat-deploy</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>deploy</goal>
+                        </goals>
+                        <configuration>
+                            
<url>http://localhost:${its.http.port}/manager</url>
+                            <username>tomcat</username>
+                            <password>tomcat</password>
+                            <path>/foo</path>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>tomcat-container-goals</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>list</goal>
+                            <goal>serverinfo</goal>
+                            <goal>resources</goal>
+                        </goals>
+                        <configuration>
+                            
<url>http://localhost:${its.http.port}/manager</url>
+                            <username>tomcat</username>
+                            <password>tomcat</password>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>tomcat-shutdown</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>shutdown</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <version>3.5.5</version>
+                <executions>
+                    <execution>
+                        <id>integration-test</id>
+                        <goals>
+                            <goal>integration-test</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>verify</id>
+                        <goals>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context-support</artifactId>
+            <version>2.5.6</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.13.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>
diff --git 
a/src/test/resources/container-goals-test/src/main/tomcatconf/empty.txt 
b/src/test/resources/container-goals-test/src/main/tomcatconf/empty.txt
new file mode 100644
index 0000000..11925e4
--- /dev/null
+++ b/src/test/resources/container-goals-test/src/main/tomcatconf/empty.txt
@@ -0,0 +1,19 @@
+ ~~ 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.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/doxia/references/apt-format.html
\ No newline at end of file
diff --git 
a/src/test/resources/container-goals-test/src/main/tomcatconf/logging.properties
 
b/src/test/resources/container-goals-test/src/main/tomcatconf/logging.properties
new file mode 100644
index 0000000..df3dac5
--- /dev/null
+++ 
b/src/test/resources/container-goals-test/src/main/tomcatconf/logging.properties
@@ -0,0 +1,66 @@
+# 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.
+
+handlers = 1catalina.org.apache.juli.FileHandler, 
2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 
4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
+
+.handlers = 1catalina.org.apache.juli.FileHandler, 
java.util.logging.ConsoleHandler
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+1catalina.org.apache.juli.FileHandler.level = FINE
+1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
+1catalina.org.apache.juli.FileHandler.prefix = catalina.
+
+2localhost.org.apache.juli.FileHandler.level = FINE
+2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
+2localhost.org.apache.juli.FileHandler.prefix = localhost.
+
+3manager.org.apache.juli.FileHandler.level = FINE
+3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
+3manager.org.apache.juli.FileHandler.prefix = manager.
+
+4host-manager.org.apache.juli.FileHandler.level = FINE
+4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
+4host-manager.org.apache.juli.FileHandler.prefix = host-manager.
+
+java.util.logging.ConsoleHandler.level = FINE
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+
+
+############################################################
+# Facility specific properties.
+# Provides extra control for each logger.
+############################################################
+
+org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
+org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 
2localhost.org.apache.juli.FileHandler
+
+org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level 
= INFO
+org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers
 = 3manager.org.apache.juli.FileHandler
+
+org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level
 = INFO
+org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers
 = 4host-manager.org.apache.juli.FileHandler
+
+# For example, set the org.apache.catalina.util.LifecycleBase logger to log
+# each component that extends LifecycleBase changing state:
+#org.apache.catalina.util.LifecycleBase.level = FINE
+
+# To see debug messages in TldLocationsCache, uncomment the following line:
+#org.apache.jasper.compiler.TldLocationsCache.level = FINE
+
+org.apache.catalina.realm.MemoryRealm = FINE
diff --git 
a/src/test/resources/container-goals-test/src/main/tomcatconf/server.xml 
b/src/test/resources/container-goals-test/src/main/tomcatconf/server.xml
new file mode 100644
index 0000000..4a67442
--- /dev/null
+++ b/src/test/resources/container-goals-test/src/main/tomcatconf/server.xml
@@ -0,0 +1,48 @@
+<!--
+  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.
+-->
+
+<Server port="${its.server.port}" shutdown="SHUTDOWN">
+
+    <GlobalNamingResources>
+        <!-- Used by Manager webapp -->
+        <Resource name="UserDatabase" auth="Container"
+            type="org.apache.catalina.UserDatabase"
+            description="User database that can be updated and saved"
+            factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
+            pathname="conf/tomcat-users.xml" />
+    </GlobalNamingResources>
+
+    <Service name="Catalina">
+        <Connector port="${its.http.port}" keepAliveTimeout="1800000"
+            maxKeepAliveRequests="30000" maxThreads="300" />
+        <Engine name="Catalina" defaultHost="localhost">
+            <Valve className="org.apache.catalina.valves.AccessLogValve"
+                
pattern="%t-ip:%a-protocol::%H-status:%s-localPort:%p-path:%U-time:%D ms"
+                buffered="false" />
+            <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
+                resourceName="UserDatabase" />
+            <Host name="localhost"
+                
appBase="${project.build.directory}/test-classes/deploy-war-project/target/tomcat/webapps">
+                <Context path="/manager" privileged="true"
+                    docBase="${managerWebAppPath}/manager" />
+            </Host>
+        </Engine>
+
+    </Service>
+</Server>
diff --git 
a/src/test/resources/container-goals-test/src/main/tomcatconf/tomcat-users.xml 
b/src/test/resources/container-goals-test/src/main/tomcatconf/tomcat-users.xml
new file mode 100644
index 0000000..6c079d3
--- /dev/null
+++ 
b/src/test/resources/container-goals-test/src/main/tomcatconf/tomcat-users.xml
@@ -0,0 +1,25 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+  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.
+-->
+<tomcat-users>
+    <role rolename="manager" />
+    <role rolename="manager-gui" />
+    <role rolename="manager-script" />
+    <user username="admin" password="admin123"
+        roles="manager,manager-gui,manager-script" />
+    <user username="tomcat" password="tomcat" roles="manager" />
+</tomcat-users>
diff --git a/src/test/resources/container-goals-test/src/main/webapp/index.jsp 
b/src/test/resources/container-goals-test/src/main/webapp/index.jsp
new file mode 100644
index 0000000..2197216
--- /dev/null
+++ b/src/test/resources/container-goals-test/src/main/webapp/index.jsp
@@ -0,0 +1,17 @@
+<%--
+  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.
+--%>
+It works !!
\ No newline at end of file
diff --git a/src/test/resources/container-goals-test/src/main/webapp/web.xml 
b/src/test/resources/container-goals-test/src/main/webapp/web.xml
new file mode 100644
index 0000000..634342d
--- /dev/null
+++ b/src/test/resources/container-goals-test/src/main/webapp/web.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"; version="2.4" 
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";>
+</web-app>
\ No newline at end of file
diff --git a/src/test/resources/container-goals-test/src/test/java/WaitIT.java 
b/src/test/resources/container-goals-test/src/test/java/WaitIT.java
new file mode 100644
index 0000000..b30d04a
--- /dev/null
+++ b/src/test/resources/container-goals-test/src/test/java/WaitIT.java
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+@SuppressWarnings({ "WrongPackageStatement" })
+public final class WaitIT {
+    @Test
+    public void testWait() throws Exception {
+        System.out.println("Just wait a while...");
+        Thread.sleep(${it.sleep.time});
+    }
+
+    @Test
+    public void testContainerGoals() throws Exception {
+        System.out.println("Container goals test completed successfully");
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to