View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.scm.manager;
20  
21  import java.io.File;
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  import org.apache.maven.scm.provider.ScmProvider;
26  import org.apache.maven.scm.provider.ScmProviderStub;
27  import org.apache.maven.scm.repository.ScmRepository;
28  import org.apache.maven.scm.repository.ScmRepositoryStub;
29  import org.junit.Before;
30  import org.junit.Test;
31  
32  import static org.junit.Assert.assertSame;
33  
34  /**
35   * Test for the ScmManagerStub
36   *
37   * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
38   *
39   */
40  public class ScmManagerStubTest {
41  
42      private ScmManagerStub scmManagerStub;
43  
44      private List<String> messages;
45  
46      private ScmProvider scmProvider;
47  
48      private ScmRepository scmRepository;
49  
50      @Before
51      public void setUp() throws Exception {
52          messages = new ArrayList<>(0);
53          scmProvider = new ScmProviderStub();
54          scmRepository = new ScmRepositoryStub();
55  
56          scmManagerStub = new ScmManagerStub();
57          scmManagerStub.setMessages(messages);
58          scmManagerStub.setScmProvider(scmProvider);
59          scmManagerStub.setScmRepository(scmRepository);
60      }
61  
62      /*
63       * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.makeScmRepository(String)'
64       */
65      @Test
66      public void testMakeScmRepository() throws Exception {
67          ScmRepository repository = scmManagerStub.makeScmRepository("");
68          assertSame(scmRepository, repository);
69      }
70  
71      /*
72       * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.makeProviderScmRepository(String, File)'
73       */
74      @Test
75      public void testMakeProviderScmRepository() throws Exception {
76          ScmRepository repository = scmManagerStub.makeProviderScmRepository("", new File(""));
77          assertSame(scmRepository, repository);
78      }
79  
80      /*
81       * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.validateScmRepository(String)'
82       */
83      @Test
84      public void testValidateScmRepository() {
85          List<String> list = scmManagerStub.validateScmRepository("");
86          assertSame(messages, list);
87      }
88  
89      /*
90       * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.getProviderByUrl(String)'
91       */
92      @Test
93      public void testGetProviderByUrl() throws Exception {
94          ScmProvider providerByUrl = scmManagerStub.getProviderByUrl("");
95          assertSame(scmProvider, providerByUrl);
96      }
97  
98      /*
99       * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.getProviderByType(String)'
100      */
101     @Test
102     public void testGetProviderByType() throws Exception {
103         ScmProvider providerByType = scmManagerStub.getProviderByType("");
104         assertSame(scmProvider, providerByType);
105     }
106 
107     /*
108      * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.getProviderByRepository(ScmRepository)'
109      */
110     @Test
111     public void testGetProviderByRepository() throws Exception {
112         ScmProvider providerByRepository = scmManagerStub.getProviderByRepository(new ScmRepositoryStub());
113         assertSame(scmProvider, providerByRepository);
114     }
115 }