001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.maven.scm.manager; 020 021import java.io.File; 022import java.util.ArrayList; 023import java.util.List; 024 025import org.apache.maven.scm.provider.ScmProvider; 026import org.apache.maven.scm.provider.ScmProviderStub; 027import org.apache.maven.scm.repository.ScmRepository; 028import org.apache.maven.scm.repository.ScmRepositoryStub; 029import org.junit.Before; 030import org.junit.Test; 031 032import static org.junit.Assert.assertSame; 033 034/** 035 * Test for the ScmManagerStub 036 * 037 * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a> 038 * 039 */ 040public class ScmManagerStubTest { 041 042 private ScmManagerStub scmManagerStub; 043 044 private List<String> messages; 045 046 private ScmProvider scmProvider; 047 048 private ScmRepository scmRepository; 049 050 @Before 051 public void setUp() throws Exception { 052 messages = new ArrayList<>(0); 053 scmProvider = new ScmProviderStub(); 054 scmRepository = new ScmRepositoryStub(); 055 056 scmManagerStub = new ScmManagerStub(); 057 scmManagerStub.setMessages(messages); 058 scmManagerStub.setScmProvider(scmProvider); 059 scmManagerStub.setScmRepository(scmRepository); 060 } 061 062 /* 063 * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.makeScmRepository(String)' 064 */ 065 @Test 066 public void testMakeScmRepository() throws Exception { 067 ScmRepository repository = scmManagerStub.makeScmRepository(""); 068 assertSame(scmRepository, repository); 069 } 070 071 /* 072 * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.makeProviderScmRepository(String, File)' 073 */ 074 @Test 075 public void testMakeProviderScmRepository() throws Exception { 076 ScmRepository repository = scmManagerStub.makeProviderScmRepository("", new File("")); 077 assertSame(scmRepository, repository); 078 } 079 080 /* 081 * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.validateScmRepository(String)' 082 */ 083 @Test 084 public void testValidateScmRepository() { 085 List<String> list = scmManagerStub.validateScmRepository(""); 086 assertSame(messages, list); 087 } 088 089 /* 090 * Test method for 'org.apache.maven.scm.manager.ScmManagerStub.getProviderByUrl(String)' 091 */ 092 @Test 093 public void testGetProviderByUrl() throws Exception { 094 ScmProvider providerByUrl = scmManagerStub.getProviderByUrl(""); 095 assertSame(scmProvider, providerByUrl); 096 } 097 098 /* 099 * 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}