View Javadoc

1   package org.apache.maven.wagon.providers.http;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.wagon.Wagon;
23  import org.codehaus.plexus.PlexusTestCase;
24  import org.mortbay.jetty.Server;
25  import org.mortbay.jetty.handler.ResourceHandler;
26  import org.mortbay.jetty.servlet.Context;
27  
28  /**
29   * User: jdumay Date: 24/01/2008 Time: 18:15:53
30   */
31  public abstract class HttpWagonHttpServerTestCase
32      extends PlexusTestCase
33  {
34      protected final int httpServerPort = 10008;
35  
36      private Server server;
37  
38      protected ResourceHandler resourceHandler;
39  
40      protected Context context;
41  
42      protected void setUp()
43          throws Exception
44      {
45          super.setUp();
46          server = new Server( httpServerPort );
47  
48          context = new Context( server, "/", Context.SESSIONS );
49  
50          resourceHandler = new ResourceHandler();
51          server.addHandler( resourceHandler );
52      }
53  
54      protected Wagon getWagon()
55          throws Exception
56      {
57          return (Wagon) lookup( HttpWagon.ROLE );
58      }
59  
60      protected void startServer()
61          throws Exception
62      {
63          server.start();
64      }
65  
66      protected void stopServer()
67          throws Exception
68      {
69          server.stop();
70      }
71  }