001package org.apache.maven.scm.provider.jazz.command.tag; 002 003import org.apache.maven.scm.ScmTagParameters; 004import org.apache.maven.scm.provider.jazz.JazzScmTestCase; 005import org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository; 006import org.codehaus.plexus.util.cli.Commandline; 007 008/* 009 * Licensed to the Apache Software Foundation (ASF) under one 010 * or more contributor license agreements. See the NOTICE file 011 * distributed with this work for additional information 012 * regarding copyright ownership. The ASF licenses this file 013 * to you under the Apache License, Version 2.0 (the 014 * "License"); you may not use this file except in compliance 015 * with the License. You may obtain a copy of the License at 016 * 017 * http://www.apache.org/licenses/LICENSE-2.0 018 * 019 * Unless required by applicable law or agreed to in writing, 020 * software distributed under the License is distributed on an 021 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 022 * KIND, either express or implied. See the License for the 023 * specific language governing permissions and limitations 024 * under the License. 025 */ 026 027/** 028 * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a> 029 */ 030public class JazzTagCommandTest 031 extends JazzScmTestCase 032{ 033 private JazzScmProviderRepository repo; 034 035 protected void setUp() 036 throws Exception 037 { 038 super.setUp(); 039 repo = getScmProviderRepository(); 040 041 // Simulate the output of the parsing of the "scm status" command. 042 // IE, fill in the workspace and stream details 043 // Only needed for tests that require "pushChanges" type operations. 044 repo.setWorkspace( "Dave's Repository Workspace" ); 045 repo.setFlowTarget( "Dave's Stream" ); 046 } 047 048 public void testCreateTagCreateSnapshotCommand() 049 throws Exception 050 { 051 ScmTagParameters scmTagParameters = new ScmTagParameters( "My Tag Message" ); 052 Commandline cmd = new JazzTagCommand().createTagCreateSnapshotCommand( repo, getScmFileSet(), "My_Tag_Name", 053 scmTagParameters ).getCommandline(); 054 String expected = 055 "scm create snapshot --repository-uri https://localhost:9443/jazz --username myUserName --password myPassword --name My_Tag_Name --description \"My Tag Message\" \"Dave's Repository Workspace\""; 056 assertCommandLine( expected, getWorkingDirectory(), cmd ); 057 } 058 059 public void testCreateTagCreateWorkspaceCommand() 060 throws Exception 061 { 062 Commandline cmd = new JazzTagCommand().createTagCreateWorkspaceCommand( repo, getScmFileSet(), 063 "My_Snapshot_Name" ).getCommandline(); 064 String expected = 065 "scm create workspace --repository-uri https://localhost:9443/jazz --username myUserName --password myPassword My_Snapshot_Name --snapshot My_Snapshot_Name"; 066 assertCommandLine( expected, getWorkingDirectory(), cmd ); 067 } 068 069 public void testCreateTagDeliverCommand() 070 throws Exception 071 { 072 Commandline cmd = 073 new JazzTagCommand().createTagDeliverCommand( repo, getScmFileSet(), "My_Tag_Name" ).getCommandline(); 074 String expected = 075 "scm deliver --repository-uri https://localhost:9443/jazz --username myUserName --password myPassword --source My_Tag_Name --target \"Dave's Stream\""; 076 assertCommandLine( expected, getWorkingDirectory(), cmd ); 077 } 078 079 public void testCreateTagSnapshotPromoteCommand() 080 throws Exception 081 { 082 Commandline cmd = new JazzTagCommand().createTagSnapshotPromoteCommand( repo, getScmFileSet(), 083 "My_Snapshot_Name" ).getCommandline(); 084 String expected = 085 "scm snapshot promote --repository-uri https://localhost:9443/jazz --username myUserName --password myPassword \"Dave's Stream\" My_Snapshot_Name"; 086 assertCommandLine( expected, getWorkingDirectory(), cmd ); 087 } 088}