001 /* 002 * #%L 003 * License Maven Plugin 004 * 005 * $Id: LicenseRepositoryTest.java 13519 2011-02-05 09:32:50Z tchemit $ 006 * $HeadURL: http://svn.codehaus.org/mojo/tags/license-maven-plugin-1.0/src/test/java/org/codehaus/mojo/license/model/LicenseRepositoryTest.java $ 007 * %% 008 * Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit 009 * %% 010 * This program is free software: you can redistribute it and/or modify 011 * it under the terms of the GNU Lesser General Public License as 012 * published by the Free Software Foundation, either version 3 of the 013 * License, or (at your option) any later version. 014 * 015 * This program is distributed in the hope that it will be useful, 016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 018 * GNU General Lesser Public License for more details. 019 * 020 * You should have received a copy of the GNU General Lesser Public 021 * License along with this program. If not, see 022 * <http://www.gnu.org/licenses/lgpl-3.0.html>. 023 * #L% 024 */ 025 026 package org.codehaus.mojo.license.model; 027 028 import org.junit.Assert; 029 import org.junit.Before; 030 import org.junit.Test; 031 032 import java.io.IOException; 033 import java.net.URL; 034 035 /** 036 * Tests {@link LicenseRepository}. 037 * 038 * @author tchemit <chemit@codelutin.com> 039 * @since 1.0 040 */ 041 public class LicenseRepositoryTest 042 { 043 044 protected LicenseRepository repository; 045 046 @Before 047 public void setUp() 048 { 049 repository = null; 050 } 051 052 @Test 053 public void testJarRepository() 054 throws IOException 055 { 056 057 repository = new LicenseRepository(); 058 URL baseURL = getClass().getResource( LicenseStore.JAR_LICENSE_REPOSITORY ); 059 repository.setBaseURL( baseURL ); 060 repository.load(); 061 062 License[] licenses = repository.getLicenses(); 063 Assert.assertNotNull( licenses ); 064 Assert.assertEquals( LicenseStoreTest.DEFAULT_LICENSES.size(), licenses.length ); 065 066 for ( String licenseName : LicenseStoreTest.DEFAULT_LICENSES ) 067 { 068 License license = repository.getLicense( licenseName ); 069 Assert.assertNotNull( license ); 070 } 071 072 for ( String licenseName : repository.getLicenseNames() ) 073 { 074 Assert.assertTrue( LicenseStoreTest.DEFAULT_LICENSES.contains( licenseName ) ); 075 } 076 } 077 }