001package org.apache.maven.scm.provider.jazz.command.add; 002 003import org.apache.maven.scm.log.DefaultLog; 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 JazzAddCommandTest 031 extends JazzScmTestCase 032{ 033 private JazzScmProviderRepository repo; 034 035 private JazzAddConsumer addConsumer; 036 037 protected void setUp() 038 throws Exception 039 { 040 super.setUp(); 041 042 repo = getScmProviderRepository(); 043 044 addConsumer = new JazzAddConsumer( repo, new DefaultLog() ); 045 } 046 047 public void testCreateAddCommand() 048 throws Exception 049 { 050 Commandline cmd = new JazzAddCommand().createAddCommand( repo, getScmFileSet() ).getCommandline(); 051 String expected = "scm checkin --username myUserName --password myPassword " + getFiles(); 052 assertCommandLine( expected, getWorkingDirectory(), cmd ); 053 } 054 055 public void testCheckInConsumerWithFiles() 056 throws Exception 057 { 058 addConsumer.consumeLine( "Committing..." ); 059 addConsumer.consumeLine( 060 "Workspace: (1903) \"MavenSCMTestWorkspace_1332908068770\" <-> (1903) \"MavenSCMTestWorkspace_1332908068770\"" ); 061 addConsumer.consumeLine( " Component: (1768) \"MavenSCMTestComponent\"" ); 062 addConsumer.consumeLine( " Outgoing:" ); 063 addConsumer.consumeLine( " Change sets:" ); 064 addConsumer.consumeLine( " (1907) *--@ \"Commit message\"" ); 065 addConsumer.consumeLine( " Changes:" ); 066 addConsumer.consumeLine( " --a-- \\src\\main\\java\\Me.java" ); 067 addConsumer.consumeLine( " --a-- \\src\\main\\java\\Me1.java" ); 068 addConsumer.consumeLine( " --a-- \\src\\main\\java\\Me2.java" ); 069 070 assertEquals( "Wrong number of files parsed!", 3, addConsumer.getFiles().size() ); 071 assertEquals( "Parsing error for file1!", "src\\main\\java\\Me.java", 072 addConsumer.getFiles().get( 0 ).getPath() ); 073 assertEquals( "Parsing error for file2!", "src\\main\\java\\Me1.java", 074 addConsumer.getFiles().get( 1 ).getPath() ); 075 assertEquals( "Parsing error for file3!", "src\\main\\java\\Me2.java", 076 addConsumer.getFiles().get( 2 ).getPath() ); 077 } 078 079 public void testCheckInConsumerWithOutFiles() 080 throws Exception 081 { 082 addConsumer.consumeLine( "Committing..." ); 083 addConsumer.consumeLine( 084 "Workspace: (1004) \"Release Repository Workspace\" <-> (1005) \"Maven Release Plugin Stream\"" ); 085 addConsumer.consumeLine( " Component: (1006) \"Release Component\"" ); 086 addConsumer.consumeLine( " Outgoing:" ); 087 addConsumer.consumeLine( " Change sets:" ); 088 addConsumer.consumeLine( " (1008) --@ <No comment>" ); 089 090 assertEquals( "Wrong number of files parsed!", 0, addConsumer.getFiles().size() ); 091 } 092}