View Javadoc

1   package org.apache.maven.continuum.wagon;
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.continuum.model.project.BuildDefinition;
23  import org.apache.maven.continuum.model.project.BuildResult;
24  import org.apache.maven.continuum.model.project.Project;
25  import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
26  import org.apache.maven.continuum.notification.MessageContext;
27  import org.apache.maven.continuum.notification.Notifier;
28  import org.apache.maven.continuum.project.ContinuumProjectState;
29  import org.codehaus.plexus.spring.PlexusInSpringTestCase;
30  
31  /**
32   * @author <a href="mailto:nramirez@exist">Napoleon Esmundo C. Ramirez</a>
33   */
34  public class WagonContinuumNotifierTest
35      extends PlexusInSpringTestCase
36  {
37      private ServletServer server;
38  
39      private Notifier notifier;
40  
41      private MessageContext context;
42  
43  
44      public void setUp()
45          throws Exception
46      {
47          super.setUp();
48  
49          server = (ServletServer) lookup( ServletServer.ROLE );
50          notifier = (Notifier) lookup( Notifier.class.getName(), "wagon" );
51  
52          Project project = new Project();
53          project.setId( 2 );
54  
55          BuildResult build = new BuildResult();
56          build.setId( 1 );
57          build.setProject( project );
58          build.setStartTime( System.currentTimeMillis() );
59          build.setEndTime( System.currentTimeMillis() + 1234567 );
60          build.setState( ContinuumProjectState.OK );
61          build.setTrigger( ContinuumProjectState.TRIGGER_FORCED );
62          build.setExitCode( 0 );
63  
64          BuildDefinition buildDefinition = new BuildDefinition();
65          buildDefinition.setBuildFile( "pom.xml" );
66  
67          context = new MessageContext();
68          context.setProject( project );
69          context.setBuildResult( build );
70          context.setBuildDefinition( buildDefinition );
71  
72          String basedir = System.getProperty( "basedir" );
73          if ( basedir == null )
74          {
75              throw new Exception( "basedir must be defined" );
76          }
77      }
78  
79      public void testSendNotification()
80          throws Exception
81      {
82          notifier.sendMessage( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE, context );
83      }
84  
85      protected void tearDown()
86          throws Exception
87      {
88          release( server );
89      }
90  }