1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
37
38
39
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 }