View Javadoc
1   package org.apache.maven.scm.provider.accurev.command;
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 static org.mockito.Mockito.inOrder;
23  import static org.mockito.Mockito.when;
24  
25  import java.io.File;
26  import java.io.InputStream;
27  import java.util.Date;
28  
29  import org.apache.maven.scm.ScmTestCase;
30  import org.apache.maven.scm.log.ScmLogger;
31  import org.apache.maven.scm.provider.accurev.AccuRev;
32  import org.apache.maven.scm.provider.accurev.AccuRevInfo;
33  import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
34  import org.apache.maven.scm.provider.accurev.Stream;
35  import org.apache.maven.scm.provider.accurev.cli.AccuRevJUnitUtil;
36  import org.junit.Before;
37  import org.junit.runner.RunWith;
38  import org.mockito.InOrder;
39  import org.mockito.Mock;
40  import org.mockito.runners.MockitoJUnitRunner;
41  
42  @RunWith( MockitoJUnitRunner.class )
43  public abstract class AbstractAccuRevCommandTest
44      extends ScmTestCase
45  {
46  
47      @Override
48      protected InputStream getCustomConfiguration()
49          throws Exception
50      {
51          return AccuRevJUnitUtil.getPlexusConfiguration();
52      }
53  
54      @Mock
55      protected AccuRev accurev;
56  
57      protected File basedir;
58  
59      protected AccuRevInfo info;
60  
61      private ScmLogger logger;
62  
63      protected InOrder sequence;
64  
65      protected AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
66  
67      @Before
68      public void setUp()
69          throws Exception
70      {
71          super.setUp();
72          logger = AccuRevJUnitUtil.getLogger( getContainer() );
73          basedir = getWorkingCopy();
74          sequence = inOrder( accurev );
75  
76          info = new AccuRevInfo( basedir );
77          info.setUser( "me" );
78  
79          when( accurev.getCommandLines() ).thenReturn( "accurev mock" );
80          when( accurev.getErrorOutput() ).thenReturn( "accurev mock error output" );
81          when( accurev.getClientVersion() ).thenReturn( "4.9.0" );
82          when( accurev.showStream( "myStream" ) ).thenReturn(
83                                                               new Stream( "myStream", 10L, "myDepot", 1L, "myDepot",
84                                                                           new Date(), "normal" ) );
85  
86          when( accurev.info( null ) ).thenReturn( info );
87          when( accurev.info( basedir ) ).thenReturn( info );
88  
89          repo.setLogger( getLogger() );
90          repo.setStreamName( "myStream" );
91          repo.setAccuRev( accurev );
92          repo.setProjectPath( "/project/dir" );
93  
94      }
95  
96      protected ScmLogger getLogger()
97      {
98          return logger;
99      }
100 
101 }