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