View Javadoc

1   /**
2    * Copyright 2010-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * Tests {@link LicenseRepository}.
27   *
28   * @author tchemit <chemit@codelutin.com>
29   * @since 1.0
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  }