001package org.apache.maven.scm.provider.accurev.command; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import static org.mockito.Mockito.inOrder; 023import static org.mockito.Mockito.when; 024 025import java.io.File; 026import java.io.InputStream; 027import java.util.Date; 028 029import org.apache.maven.scm.ScmTestCase; 030import org.apache.maven.scm.log.ScmLogger; 031import org.apache.maven.scm.provider.accurev.AccuRev; 032import org.apache.maven.scm.provider.accurev.AccuRevInfo; 033import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository; 034import org.apache.maven.scm.provider.accurev.Stream; 035import org.apache.maven.scm.provider.accurev.cli.AccuRevJUnitUtil; 036import org.junit.Before; 037import org.junit.runner.RunWith; 038import org.mockito.InOrder; 039import org.mockito.Mock; 040import org.mockito.runners.MockitoJUnitRunner; 041 042@RunWith( MockitoJUnitRunner.class ) 043public abstract class AbstractAccuRevCommandTest 044 extends ScmTestCase 045{ 046 047 @Override 048 protected InputStream getCustomConfiguration() 049 throws Exception 050 { 051 return AccuRevJUnitUtil.getPlexusConfiguration(); 052 } 053 054 @Mock 055 protected AccuRev accurev; 056 057 protected File basedir; 058 059 protected AccuRevInfo info; 060 061 private ScmLogger logger; 062 063 protected InOrder sequence; 064 065 protected AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository(); 066 067 @Before 068 public void setUp() 069 throws Exception 070 { 071 super.setUp(); 072 logger = AccuRevJUnitUtil.getLogger( getContainer() ); 073 basedir = getWorkingCopy(); 074 sequence = inOrder( accurev ); 075 076 info = new AccuRevInfo( basedir ); 077 info.setUser( "me" ); 078 079 when( accurev.getCommandLines() ).thenReturn( "accurev mock" ); 080 when( accurev.getErrorOutput() ).thenReturn( "accurev mock error output" ); 081 when( accurev.getClientVersion() ).thenReturn( "4.9.0" ); 082 when( accurev.showStream( "myStream" ) ).thenReturn( 083 new Stream( "myStream", 10L, "myDepot", 1L, "myDepot", 084 new Date(), "normal" ) ); 085 086 when( accurev.info( null ) ).thenReturn( info ); 087 when( accurev.info( basedir ) ).thenReturn( info ); 088 089 repo.setLogger( getLogger() ); 090 repo.setStreamName( "myStream" ); 091 repo.setAccuRev( accurev ); 092 repo.setProjectPath( "/project/dir" ); 093 094 } 095 096 protected ScmLogger getLogger() 097 { 098 return logger; 099 } 100 101}