001 /** 002 * Copyright 2010-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.codehaus.mojo.license.model; 017 018 import org.junit.Assert; 019 import org.junit.Before; 020 import org.junit.Test; 021 022 import java.io.IOException; 023 import java.net.URL; 024 025 /** 026 * Tests {@link LicenseRepository}. 027 * 028 * @author tchemit <chemit@codelutin.com> 029 * @since 1.0 030 */ 031 public class LicenseRepositoryTest 032 { 033 034 protected LicenseRepository repository; 035 036 @Before 037 public void setUp() 038 { 039 repository = null; 040 } 041 042 @Test 043 public void testJarRepository() 044 throws IOException 045 { 046 047 repository = new LicenseRepository(); 048 URL baseURL = getClass().getResource( LicenseStore.JAR_LICENSE_REPOSITORY ); 049 repository.setBaseURL( baseURL ); 050 repository.load(); 051 052 License[] licenses = repository.getLicenses(); 053 Assert.assertNotNull( licenses ); 054 Assert.assertEquals( LicenseStoreTest.DEFAULT_LICENSES.size(), licenses.length ); 055 056 for ( String licenseName : LicenseStoreTest.DEFAULT_LICENSES ) 057 { 058 License license = repository.getLicense( licenseName ); 059 Assert.assertNotNull( license ); 060 } 061 062 for ( String licenseName : repository.getLicenseNames() ) 063 { 064 Assert.assertTrue( LicenseStoreTest.DEFAULT_LICENSES.contains( licenseName ) ); 065 } 066 } 067 }