1 /*
2 * #%L
3 * License Maven Plugin
4 *
5 * $Id: LicenseRepositoryTest.java 13519 2011-02-05 09:32:50Z tchemit $
6 * $HeadURL: http://svn.codehaus.org/mojo/tags/license-maven-plugin-1.0/src/test/java/org/codehaus/mojo/license/model/LicenseRepositoryTest.java $
7 * %%
8 * Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit
9 * %%
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation, either version 3 of the
13 * License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Lesser Public License for more details.
19 *
20 * You should have received a copy of the GNU General Lesser Public
21 * License along with this program. If not, see
22 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
23 * #L%
24 */
25
26 package org.codehaus.mojo.license.model;
27
28 import org.junit.Assert;
29 import org.junit.Before;
30 import org.junit.Test;
31
32 import java.io.IOException;
33 import java.net.URL;
34
35 /**
36 * Tests {@link LicenseRepository}.
37 *
38 * @author tchemit <chemit@codelutin.com>
39 * @since 1.0
40 */
41 public class LicenseRepositoryTest
42 {
43
44 protected LicenseRepository repository;
45
46 @Before
47 public void setUp()
48 {
49 repository = null;
50 }
51
52 @Test
53 public void testJarRepository()
54 throws IOException
55 {
56
57 repository = new LicenseRepository();
58 URL baseURL = getClass().getResource( LicenseStore.JAR_LICENSE_REPOSITORY );
59 repository.setBaseURL( baseURL );
60 repository.load();
61
62 License[] licenses = repository.getLicenses();
63 Assert.assertNotNull( licenses );
64 Assert.assertEquals( LicenseStoreTest.DEFAULT_LICENSES.size(), licenses.length );
65
66 for ( String licenseName : LicenseStoreTest.DEFAULT_LICENSES )
67 {
68 License license = repository.getLicense( licenseName );
69 Assert.assertNotNull( license );
70 }
71
72 for ( String licenseName : repository.getLicenseNames() )
73 {
74 Assert.assertTrue( LicenseStoreTest.DEFAULT_LICENSES.contains( licenseName ) );
75 }
76 }
77 }