1 package org.apache.maven.continuum.web.action;
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.continuum.web.action.AbstractActionTest;
23 import org.apache.maven.continuum.Continuum;
24 import org.apache.maven.continuum.model.project.Project;
25 import org.jmock.Mock;
26
27 /**
28 * Test for {@link ReleasePrepareAction}
29 *
30 * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
31 * @version $Id: ReleasePrepareActionTest.java 952508 2010-06-08 02:04:28Z ctan $
32 */
33 public class ReleasePrepareActionTest
34 extends AbstractActionTest
35 {
36 private ReleasePrepareAction action;
37
38 private Mock continuumMock;
39
40 protected void setUp()
41 throws Exception
42 {
43 super.setUp();
44
45 action = new ReleasePrepareAction();
46 continuumMock = new Mock( Continuum.class );
47 //securitySessionMock = new Mock( SecuritySession.class );
48 //Map map = new HashMap();
49 //map.put( SecuritySystemConstants.SECURITY_SESSION_KEY, securitySessionMock );
50 //action.setSession( map );
51 action.setContinuum( (Continuum) continuumMock.proxy() );
52 }
53
54 /**
55 * Test that the tag base url for Subversion is correctly constructed
56 *
57 * @throws Exception
58 */
59 public void testScmTagBaseSvn()
60 throws Exception
61 {
62 //commented out because of problems in authorization checks
63
64 String svnUrl = "https://svn.apache.org/repos/asf/maven/continuum";
65 String scmUrl = "scm:svn:" + svnUrl + "/trunk/";
66 //ProjectGroup projectGroup = new ProjectGroup();
67 //continuumMock.expects( once() ).method( "getProjectGroupByProjectId" ).will( returnValue( projectGroup ) );
68 Project project = new Project();
69 project.setScmUrl( scmUrl );
70 project.setWorkingDirectory( "." );
71 continuumMock.expects( once() ).method( "getProject" ).will( returnValue( project ) );
72 action.input();
73 assertEquals( svnUrl + "/tags", action.getScmTagBase() );
74 continuumMock.verify();
75 }
76
77 /**
78 * Test that tag base url for non Subverson SCMs is empty
79 *
80 * @throws Exception
81 */
82 public void testScmTagBaseNonSvn()
83 throws Exception
84 {
85 //commented out because of problems in authorization checks
86
87 Project project = new Project();
88 project.setScmUrl( "scm:cvs:xxx" );
89 project.setWorkingDirectory( "." );
90 continuumMock.expects( once() ).method( "getProject" ).will( returnValue( project ) );
91 action.input();
92 assertEquals( "", action.getScmTagBase() );
93 continuumMock.verify();
94 }
95 }