use of org.xwiki.extension.DefaultExtensionAuthor in project xwiki-platform by xwiki.
the class ExtensionIT method testShowDetails.
/**
* Tests the extension details (license, web site).
*/
@Test
public void testShowDetails() throws Exception {
// Setup the extension.
ExtensionId extensionId = new ExtensionId("alice-xar-extension", "1.3");
TestExtension extension = getRepositoryTestUtils().getTestExtension(extensionId, "xar");
extension.setName("Alice Wiki Macro");
extension.setSummary("A **useless** macro");
extension.addAuthor(new DefaultExtensionAuthor("Thomas", (String) null));
extension.addAuthor(new DefaultExtensionAuthor("Marius", (String) null));
extension.addFeature("alice-extension");
extension.addLicense(new ExtensionLicense("My own license", null));
extension.setWebsite("http://www.alice.com");
extension.setScm(new DefaultExtensionScm("https://github.com/xwiki-contrib/alice-xar-extension", new DefaultExtensionScmConnection("git", "git://github.com/xwiki-contrib/alice-xar-extension.git"), new DefaultExtensionScmConnection("git", "git:git@github.com:xwiki-contrib/alice-xar-extension.git")));
extension.setIssueManagement(new DefaultExtensionIssueManagement("jira", "https://jira.xwiki.org/browse/ALICE"));
getRepositoryTestUtils().addExtension(extension);
// Search the extension and assert the displayed information.
ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
ExtensionPane extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId).getExtension(0);
assertEquals("remote", extensionPane.getStatus());
assertNull(extensionPane.getStatusMessage());
assertEquals(extension.getName(), extensionPane.getName());
assertEquals(extensionId.getVersion().getValue(), extensionPane.getVersion());
List<WebElement> authors = extensionPane.getAuthors();
assertEquals(2, authors.size());
assertEquals("Thomas", authors.get(0).getText());
assertEquals("Marius", authors.get(1).getText());
assertEquals(extension.getSummary(), extensionPane.getSummary());
// Check the extension details.
ExtensionDescriptionPane descriptionPane = extensionPane.openDescriptionSection();
assertEquals(extension.getLicenses().iterator().next().getName(), descriptionPane.getLicense());
assertEquals(extension.getId().getId(), descriptionPane.getId());
assertEquals(extension.getFeatures().iterator().next(), descriptionPane.getFeatures().get(0));
assertEquals(extension.getType(), descriptionPane.getType());
WebElement webSiteLink = descriptionPane.getWebSite();
assertEquals(extension.getWebSite().substring("http://".length()), webSiteLink.getText());
assertEquals(extension.getWebSite() + '/', webSiteLink.getAttribute("href"));
// Install the extension to check the details that are specific to installed extensions.
Date beforeInstall = new Date();
descriptionPane = extensionPane.install().confirm().openDescriptionSection();
Date afterInstall = new Date();
List<String> namespaces = descriptionPane.getNamespaces();
assertEquals(1, namespaces.size());
String prefix = "Home, by superadmin on ";
assertTrue(namespaces.get(0).startsWith(prefix));
Date installDate = new SimpleDateFormat("yyyy/MM/dd HH:mm").parse(namespaces.get(0).substring(prefix.length()));
// Ignore the seconds as they are not displayed.
assertTrue(String.format("Install date [%s] should be after [%s].", installDate, beforeInstall), installDate.getTime() / 60000 >= beforeInstall.getTime() / 60000);
assertTrue(String.format("Install date [%s] should be before [%s].", installDate, afterInstall), installDate.before(afterInstall));
}
use of org.xwiki.extension.DefaultExtensionAuthor in project xwiki-platform by xwiki.
the class RepositoryTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
// base extension informations
this.baseExtension = getRepositoryTestUtils().getTestExtension(new ExtensionId(IDPREFIX + "macro-jar-extension", "1.0"), "jar");
this.baseExtension.setName("Macro JAR extension");
this.baseExtension.setDescription("extension description");
this.baseExtension.setSummary("extension summary, **not bold**");
this.baseLicense = new ExtensionLicense("Do What The Fuck You Want To Public License 2", null);
this.baseExtension.addLicense(this.baseLicense);
this.baseAuthor = new DefaultExtensionAuthor("User Name", getUtil().getURL("XWiki", USER_CREDENTIALS.getUserName()));
this.baseExtension.addAuthor(this.baseAuthor);
this.baseExtension.addDependency(new DefaultExtensionDependency("dependencyid1", new DefaultVersionConstraint("1.0")));
this.baseExtension.addDependency(new DefaultExtensionDependency("dependencyid2", new DefaultVersionConstraint("2.0")));
this.sizeOfFile = FileUtils.sizeOf(this.baseExtension.getFile().getFile());
}
Aggregations