1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codehaus.mojo.license.model;
17
18 import org.junit.Assert;
19 import org.junit.Before;
20 import org.junit.Test;
21
22 import java.io.IOException;
23 import java.net.URL;
24
25
26
27
28
29
30
31 public class LicenseRepositoryTest
32 {
33
34 protected LicenseRepository repository;
35
36 @Before
37 public void setUp()
38 {
39 repository = null;
40 }
41
42 @Test
43 public void testJarRepository()
44 throws IOException
45 {
46
47 repository = new LicenseRepository();
48 URL baseURL = getClass().getResource( LicenseStore.JAR_LICENSE_REPOSITORY );
49 repository.setBaseURL( baseURL );
50 repository.load();
51
52 License[] licenses = repository.getLicenses();
53 Assert.assertNotNull( licenses );
54 Assert.assertEquals( LicenseStoreTest.DEFAULT_LICENSES.size(), licenses.length );
55
56 for ( String licenseName : LicenseStoreTest.DEFAULT_LICENSES )
57 {
58 License license = repository.getLicense( licenseName );
59 Assert.assertNotNull( license );
60 }
61
62 for ( String licenseName : repository.getLicenseNames() )
63 {
64 Assert.assertTrue( LicenseStoreTest.DEFAULT_LICENSES.contains( licenseName ) );
65 }
66 }
67 }