You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ol...@apache.org on 2012/01/21 09:19:17 UTC

svn commit: r1234282 - in /tomcat/maven-plugin/trunk: ./ tomcat-maven-archetype/src/main/resources/META-INF/maven/ tomcat-maven-archetype/src/main/resources/archetype-resources/ tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-im...

Author: olamy
Date: Sat Jan 21 08:19:17 2012
New Revision: 1234282

URL: http://svn.apache.org/viewvc?rev=1234282&view=rev
Log:
add a test sample in archetype to test a servlet with the new dynamic port allocation

Added:
    tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/src/test/
    tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/src/test/java/
    tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/src/test/java/tomcat/
    tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/src/test/java/tomcat/api/
    tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/src/test/java/tomcat/api/impl/
    tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/src/test/java/tomcat/api/impl/TestDefaultHelloService.java   (with props)
Modified:
    tomcat/maven-plugin/trunk/pom.xml
    tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
    tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/pom.xml
    tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/pom.xml

Modified: tomcat/maven-plugin/trunk/pom.xml
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/pom.xml?rev=1234282&r1=1234281&r2=1234282&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/pom.xml (original)
+++ tomcat/maven-plugin/trunk/pom.xml Sat Jan 21 08:19:17 2012
@@ -66,7 +66,7 @@
     <its.ajp.port>2001</its.ajp.port>
     <!-- server port for it tests -->
     <its.server.port>2008</its.server.port>
-    <tomcat7Version>7.0.23</tomcat7Version>
+    <tomcat7Version>7.0.25</tomcat7Version>
   </properties>
 
   <prerequisites>
@@ -749,4 +749,15 @@
     </profile>
   </profiles>
 
+  <repositories>
+    <repository>
+      <id>staged-tomcat</id>
+      <url>http://repository.apache.org/content/repositories/orgapachetomcat-082/</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+  </repositories>
+
+
 </project>

Modified: tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml?rev=1234282&r1=1234281&r2=1234282&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml (original)
+++ tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml Sat Jan 21 08:19:17 2012
@@ -73,6 +73,12 @@
             <include>**/*.java</include>
           </includes>
         </fileSet>
+        <fileSet filtered="true" packaged="true" encoding="UTF-8">
+          <directory>src/test/java</directory>
+          <includes>
+            <include>**/*.java</include>
+          </includes>
+        </fileSet>
         <fileSet filtered="true" encoding="UTF-8">
           <directory>src/main/resources</directory>
           <includes>

Modified: tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/pom.xml
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/pom.xml?rev=1234282&r1=1234281&r2=1234282&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/pom.xml (original)
+++ tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/pom.xml Sat Jan 21 08:19:17 2012
@@ -47,6 +47,18 @@
           <groupId>org.eclipse.jetty</groupId>
           <artifactId>jetty-server</artifactId>
         </exclusion>
+        <exclusion>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-servlet_3.0_spec</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-javamail_1.4_spec</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.geronimo.specs</groupId>
+          <artifactId>geronimo-servlet_2.5_spec</artifactId>
+        </exclusion>
       </exclusions>
     </dependency>
     <dependency>
@@ -54,6 +66,28 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.apache.tomcat.embed</groupId>
+      <artifactId>tomcat-embed-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat</groupId>
+      <artifactId>tomcat-juli</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat.embed</groupId>
+      <artifactId>tomcat-embed-logging-juli</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat</groupId>
+      <artifactId>tomcat-servlet-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
 
 </project>

Added: tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/src/test/java/tomcat/api/impl/TestDefaultHelloService.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/src/test/java/tomcat/api/impl/TestDefaultHelloService.java?rev=1234282&view=auto
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/src/test/java/tomcat/api/impl/TestDefaultHelloService.java (added)
+++ tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/src/test/java/tomcat/api/impl/TestDefaultHelloService.java Sat Jan 21 08:19:17 2012
@@ -0,0 +1,104 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+package ${package}.tomcat.api.impl;
+
+/*
+ * 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 ${package}.tomcat.api.HelloService;
+
+import junit.framework.TestCase;
+import org.apache.catalina.Context;
+import org.apache.catalina.deploy.ApplicationParameter;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
+import org.apache.cxf.transport.servlet.CXFServlet;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import org.springframework.web.context.ContextLoaderListener;
+
+/**
+ * @author Olivier Lamy
+ */
+@RunWith( JUnit4.class )
+public class TestDefaultHelloService
+    extends TestCase
+{
+    int port;
+
+    private Tomcat tomcat;
+
+    @Before
+    public void startTomcat()
+        throws Exception
+    {
+        tomcat = new Tomcat();
+        tomcat.setBaseDir( System.getProperty( "java.io.tmpdir" ) );
+        tomcat.setPort( 0 );
+
+        Context context = tomcat.addContext( "", System.getProperty( "java.io.tmpdir" ) );
+
+        ApplicationParameter applicationParameter = new ApplicationParameter();
+        applicationParameter.setName( "contextConfigLocation" );
+        applicationParameter.setValue( getSpringConfigLocation() );
+        context.addApplicationParameter( applicationParameter );
+
+        context.addApplicationListener( ContextLoaderListener.class.getName() );
+
+        Tomcat.addServlet( context, "cxf", new CXFServlet() );
+        context.addServletMapping( "/" + getRestServicesPath() + "/*", "cxf" );
+
+        tomcat.start();
+
+        port = tomcat.getConnector().getLocalPort();
+
+        System.out.println("Tomcat started on port:"+port);
+    }
+
+    @After
+    public void stopTomcat()
+        throws Exception
+    {
+        tomcat.stop();
+    }
+
+    protected String getRestServicesPath()
+    {
+        return "foo";
+    }
+
+    protected String getSpringConfigLocation()
+    {
+        return "classpath*:META-INF/spring-context.xml";
+    }
+
+    @Test
+    public void testSayHello()
+    {
+        HelloService service =
+            JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/testServices/",
+                                       HelloService.class );
+        String who = "foo";
+        assertEquals( "Hello "+who, service.sayHello( who ) );
+    }
+}

Propchange: tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/src/test/java/tomcat/api/impl/TestDefaultHelloService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/basic-api-impl/src/test/java/tomcat/api/impl/TestDefaultHelloService.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/pom.xml
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/pom.xml?rev=1234282&r1=1234281&r2=1234282&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/pom.xml (original)
+++ tomcat/maven-plugin/trunk/tomcat-maven-archetype/src/main/resources/archetype-resources/pom.xml Sat Jan 21 08:19:17 2012
@@ -149,6 +149,30 @@
         </exclusions>
       </dependency>
       <dependency>
+        <groupId>org.apache.tomcat.embed</groupId>
+        <artifactId>tomcat-embed-core</artifactId>
+        <version>${tomcat7Version}</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.tomcat</groupId>
+        <artifactId>tomcat-juli</artifactId>
+        <version>${tomcat7Version}</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.tomcat.embed</groupId>
+        <artifactId>tomcat-embed-logging-juli</artifactId>
+        <version>${tomcat7Version}</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.tomcat</groupId>
+        <artifactId>tomcat-servlet-api</artifactId>
+        <version>${tomcat7Version}</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>4.10</version>
@@ -157,6 +181,15 @@
     </dependencies>
   </dependencyManagement>
 
+  <repositories>
+    <repository>
+      <id>staged-tomcat</id>
+      <url>http://repository.apache.org/content/repositories/orgapachetomcat-082/</url>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+  </repositories>
   <pluginRepositories>
     <pluginRepository>
       <id>apache.snapshots</id>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org