| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.extension.internal; |
| 21 |
|
|
| 22 |
|
import java.io.IOException; |
| 23 |
|
import java.nio.charset.StandardCharsets; |
| 24 |
|
import java.util.List; |
| 25 |
|
|
| 26 |
|
import org.apache.commons.io.IOUtils; |
| 27 |
|
import org.junit.Assert; |
| 28 |
|
import org.junit.Before; |
| 29 |
|
import org.junit.Rule; |
| 30 |
|
import org.junit.Test; |
| 31 |
|
import org.xwiki.extension.ExtensionLicense; |
| 32 |
|
import org.xwiki.extension.ExtensionLicenseManager; |
| 33 |
|
import org.xwiki.test.ComponentManagerRule; |
| 34 |
|
import org.xwiki.test.annotation.ComponentList; |
| 35 |
|
|
| 36 |
|
@ComponentList({ DefaultExtensionLicenseManager.class }) |
| |
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 3 |
Complexity Density: 0.25 |
|
| 37 |
|
public class DefaultExtensionLicenseManagerTest |
| 38 |
|
{ |
| 39 |
|
@Rule |
| 40 |
|
public final ComponentManagerRule componentManager = new ComponentManagerRule(); |
| 41 |
|
|
| 42 |
|
private ExtensionLicenseManager licenseManager; |
| 43 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 44 |
2 |
@Before... |
| 45 |
|
public void setUp() throws Exception |
| 46 |
|
{ |
| 47 |
2 |
this.licenseManager = this.componentManager.getInstance(ExtensionLicenseManager.class); |
| 48 |
|
} |
| 49 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
| 50 |
1 |
@Test... |
| 51 |
|
public void testGetLicenses() |
| 52 |
|
{ |
| 53 |
1 |
Assert.assertTrue(this.licenseManager.getLicenses().size() > 0); |
| 54 |
|
} |
| 55 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
| 56 |
1 |
@Test... |
| 57 |
|
public void testGetLicense() throws IOException |
| 58 |
|
{ |
| 59 |
1 |
ExtensionLicense license = this.licenseManager.getLicense("Apache License 2.0"); |
| 60 |
|
|
| 61 |
1 |
List<String> content = IOUtils.readLines( |
| 62 |
|
getClass().getResourceAsStream("/extension/licenses/Apache License 2.0.license"), StandardCharsets.UTF_8); |
| 63 |
1 |
content = content.subList(8, content.size()); |
| 64 |
|
|
| 65 |
1 |
Assert.assertNotNull(license); |
| 66 |
1 |
Assert.assertEquals("Apache License 2.0", license.getName()); |
| 67 |
1 |
Assert.assertEquals(content, license.getContent()); |
| 68 |
|
|
| 69 |
1 |
license = this.licenseManager.getLicense("ASL"); |
| 70 |
|
|
| 71 |
1 |
Assert.assertNotNull(license); |
| 72 |
1 |
Assert.assertEquals("Apache License 2.0", license.getName()); |
| 73 |
1 |
Assert.assertEquals(content, license.getContent()); |
| 74 |
|
} |
| 75 |
|
} |