View Javadoc
1   package org.apache.maven.scm.provider.jazz.command.tag;
2   
3   import org.apache.maven.scm.ScmTagParameters;
4   import org.apache.maven.scm.provider.jazz.JazzScmTestCase;
5   import org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository;
6   import org.codehaus.plexus.util.cli.Commandline;
7   
8   /*
9    * Licensed to the Apache Software Foundation (ASF) under one
10   * or more contributor license agreements.  See the NOTICE file
11   * distributed with this work for additional information
12   * regarding copyright ownership.  The ASF licenses this file
13   * to you under the Apache License, Version 2.0 (the
14   * "License"); you may not use this file except in compliance
15   * with the License.  You may obtain a copy of the License at
16   *
17   * http://www.apache.org/licenses/LICENSE-2.0
18   *
19   * Unless required by applicable law or agreed to in writing,
20   * software distributed under the License is distributed on an
21   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22   * KIND, either express or implied.  See the License for the
23   * specific language governing permissions and limitations
24   * under the License.
25   */
26  
27  /**
28   * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
29   */
30  public class JazzTagCommandTest
31      extends JazzScmTestCase
32  {
33      private JazzScmProviderRepository repo;
34  
35      protected void setUp()
36          throws Exception
37      {
38          super.setUp();
39          repo = getScmProviderRepository();
40  
41          // Simulate the output of the parsing of the "scm status" command.
42          // IE, fill in the workspace and stream details
43          // Only needed for tests that require "pushChanges" type operations.
44          repo.setWorkspace( "Dave's Repository Workspace" );
45          repo.setFlowTarget( "Dave's Stream" );
46      }
47  
48      public void testCreateTagCreateSnapshotCommand()
49          throws Exception
50      {
51          ScmTagParameters scmTagParameters = new ScmTagParameters( "My Tag Message" );
52          Commandline cmd = new JazzTagCommand().createTagCreateSnapshotCommand( repo, getScmFileSet(), "My_Tag_Name",
53                                                                                 scmTagParameters ).getCommandline();
54          String expected =
55              "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\"";
56          assertCommandLine( expected, getWorkingDirectory(), cmd );
57      }
58  
59      public void testCreateTagCreateWorkspaceCommand()
60          throws Exception
61      {
62          Commandline cmd = new JazzTagCommand().createTagCreateWorkspaceCommand( repo, getScmFileSet(),
63                                                                                  "My_Snapshot_Name" ).getCommandline();
64          String expected =
65              "scm create workspace --repository-uri https://localhost:9443/jazz --username myUserName --password myPassword My_Snapshot_Name --snapshot My_Snapshot_Name";
66          assertCommandLine( expected, getWorkingDirectory(), cmd );
67      }
68  
69      public void testCreateTagDeliverCommand()
70          throws Exception
71      {
72          Commandline cmd =
73              new JazzTagCommand().createTagDeliverCommand( repo, getScmFileSet(), "My_Tag_Name" ).getCommandline();
74          String expected =
75              "scm deliver --repository-uri https://localhost:9443/jazz --username myUserName --password myPassword --source My_Tag_Name --target \"Dave's Stream\"";
76          assertCommandLine( expected, getWorkingDirectory(), cmd );
77      }
78  
79      public void testCreateTagSnapshotPromoteCommand()
80          throws Exception
81      {
82          Commandline cmd = new JazzTagCommand().createTagSnapshotPromoteCommand( repo, getScmFileSet(),
83                                                                                  "My_Snapshot_Name" ).getCommandline();
84          String expected =
85              "scm snapshot promote --repository-uri https://localhost:9443/jazz --username myUserName --password myPassword \"Dave's Stream\" My_Snapshot_Name";
86          assertCommandLine( expected, getWorkingDirectory(), cmd );
87      }
88  }