Search in sources :

Example 61 with ExtensionId

use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.

the class ExtensionIT method testInstallAndUninstallWithoutReload.

/**
 * Tests that an extension can be installed and uninstalled without reloading the extension manager UI.
 */
@Test
public void testInstallAndUninstallWithoutReload() throws Exception {
    // Setup the extension.
    ExtensionId extensionId = new ExtensionId("alice-xar-extension", "1.3");
    getRepositoryTestUtils().addExtension(getRepositoryTestUtils().getTestExtension(extensionId, "xar"));
    // Search the extension to install.
    ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
    ExtensionPane extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId).getExtension(0);
    // Install and uninstall.
    extensionPane = extensionPane.install().confirm().uninstall().confirm().confirm().install();
    assertEquals("remote", extensionPane.getStatus());
}
Also used : ExtensionAdministrationPage(org.xwiki.extension.test.po.ExtensionAdministrationPage) ExtensionId(org.xwiki.extension.ExtensionId) ExtensionPane(org.xwiki.extension.test.po.ExtensionPane) Test(org.junit.Test)

Example 62 with ExtensionId

use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.

the class ExtensionIT method testUninstall.

/**
 * Tests how an extension is uninstalled.
 */
@Test
public void testUninstall() throws Exception {
    // Setup the extension and its dependencies.
    ExtensionId dependencyId = new ExtensionId("bob-xar-extension", "2.5-milestone-2");
    getRepositoryTestUtils().addExtension(getRepositoryTestUtils().getTestExtension(dependencyId, "xar"));
    ExtensionId extensionId = new ExtensionId("alice-xar-extension", "1.3");
    TestExtension extension = getRepositoryTestUtils().getTestExtension(extensionId, "xar");
    extension.addDependency(new DefaultExtensionDependency(dependencyId.getId(), new DefaultVersionConstraint(dependencyId.getVersion().getValue())));
    getRepositoryTestUtils().addExtension(extension);
    // Install the extensions.
    getExtensionTestUtils().install(extensionId);
    // Check if the installed pages are present.
    assertTrue(getUtil().pageExists("ExtensionTest", "Alice"));
    assertTrue(getUtil().pageExists("ExtensionTest", "Bob"));
    // Uninstall the dependency.
    ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoInstalledExtensions();
    ExtensionPane extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(dependencyId).getExtension(0);
    extensionPane = extensionPane.uninstall();
    // Check the uninstall plan. Both extensions should be included.
    List<DependencyPane> uninstallPlan = extensionPane.openProgressSection().getJobPlan();
    assertEquals(2, uninstallPlan.size());
    assertEquals(extensionId, uninstallPlan.get(0).getId());
    assertEquals("installed", uninstallPlan.get(0).getStatus());
    assertEquals("Installed", uninstallPlan.get(0).getStatusMessage());
    assertEquals(dependencyId, uninstallPlan.get(1).getId());
    assertEquals("installed-dependency", uninstallPlan.get(1).getStatus());
    assertEquals("Installed as dependency", uninstallPlan.get(1).getStatusMessage());
    // Check the confirmation to delete the unused wiki pages.
    extensionPane = extensionPane.confirm();
    UnusedPagesPane unusedPages = extensionPane.openProgressSection().getUnusedPages();
    assertTrue(unusedPages.contains("ExtensionTest", "Alice"));
    assertTrue(unusedPages.contains("ExtensionTest", "Bob"));
    // Finish the uninstall and check the log.
    extensionPane = extensionPane.confirm();
    List<LogItemPane> log = extensionPane.openProgressSection().getJobLog();
    assertTrue(log.size() > 2);
    assertEquals("info", log.get(2).getLevel());
    assertEquals("Resolving extension [bob-xar-extension 2.5-milestone-2] from namespace [Home]", log.get(2).getMessage());
    assertEquals("info", log.get(log.size() - 1).getLevel());
    assertEquals("Finished job of type [uninstall] with identifier " + "[extension/action/bob-xar-extension/wiki:xwiki]", log.get(log.size() - 1).getMessage());
    // Check if the uninstalled pages have been deleted.
    assertFalse(getUtil().pageExists("ExtensionTest", "Alice"));
    assertFalse(getUtil().pageExists("ExtensionTest", "Bob"));
    // Install both extension again and uninstall only the one with the dependency.
    getExtensionTestUtils().install(extensionId);
    adminPage = ExtensionAdministrationPage.gotoInstalledExtensions();
    extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId).getExtension(0);
    extensionPane = extensionPane.uninstall();
    // Check the uninstall plan. Only one extension should be included.
    uninstallPlan = extensionPane.openProgressSection().getJobPlan();
    assertEquals(1, uninstallPlan.size());
    assertEquals(extensionId, uninstallPlan.get(0).getId());
    // Check the confirmation to delete the unused wiki pages.
    extensionPane = extensionPane.confirm();
    unusedPages = extensionPane.openProgressSection().getUnusedPages();
    assertTrue(unusedPages.contains("ExtensionTest", "Alice"));
    assertFalse(unusedPages.contains("ExtensionTest", "Bob"));
    // Finish the uninstall and check the log.
    log = extensionPane.confirm().openProgressSection().getJobLog();
    assertTrue(log.size() > 2);
    assertEquals("info", log.get(2).getLevel());
    assertEquals("Resolving extension [alice-xar-extension 1.3] from namespace [Home]", log.get(2).getMessage());
    assertEquals("info", log.get(log.size() - 1).getLevel());
    assertEquals("Finished job of type [uninstall] with identifier " + "[extension/action/alice-xar-extension/wiki:xwiki]", log.get(log.size() - 1).getMessage());
    // Check if the uninstalled pages have been deleted.
    assertFalse(getUtil().pageExists("ExtensionTest", "Alice"));
    assertTrue(getUtil().pageExists("ExtensionTest", "Bob"));
    // Check the list of installed extensions. It should contain only the second extension.
    adminPage = ExtensionAdministrationPage.gotoInstalledExtensions();
    SearchResultsPane searchResults = adminPage.getSearchBar().search("alice");
    assertEquals(0, searchResults.getDisplayedResultsCount());
    assertNotNull(searchResults.getNoResultsMessage());
    searchResults = new SimpleSearchPane().search("bob");
    assertEquals(1, searchResults.getDisplayedResultsCount());
    extensionPane = searchResults.getExtension(0);
    assertEquals("installed-dependency", extensionPane.getStatus());
    assertEquals(dependencyId, extensionPane.getId());
}
Also used : ExtensionAdministrationPage(org.xwiki.extension.test.po.ExtensionAdministrationPage) DependencyPane(org.xwiki.extension.test.po.DependencyPane) ExtensionId(org.xwiki.extension.ExtensionId) TestExtension(org.xwiki.repository.test.TestExtension) ExtensionPane(org.xwiki.extension.test.po.ExtensionPane) SimpleSearchPane(org.xwiki.extension.test.po.SimpleSearchPane) LogItemPane(org.xwiki.extension.test.po.LogItemPane) DefaultVersionConstraint(org.xwiki.extension.version.internal.DefaultVersionConstraint) SearchResultsPane(org.xwiki.extension.test.po.SearchResultsPane) DefaultExtensionDependency(org.xwiki.extension.DefaultExtensionDependency) UnusedPagesPane(org.xwiki.extension.test.po.UnusedPagesPane) Test(org.junit.Test)

Example 63 with ExtensionId

use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.

the class ExtensionInstanceOutputFilterStreamTest method testImportExtensionIdWithoutNamespace.

@Test
public void testImportExtensionIdWithoutNamespace() throws FilterException, ResolveException, UnsupportedEncodingException {
    doReturn(new EmptyExtension(new ExtensionId("extensionid", "version"), "test")).when(this.extensionRepositoryMock).resolve(new ExtensionId("extensionid", "version"));
    importFromXML("extensionidwithoutnamespace");
    Assert.assertNotNull(this.installedExtensionRepository.getInstalledExtension("extensionid", null));
    Assert.assertNotNull(this.installedExtensionRepository.getInstalledExtension("extensionid", "namespace"));
    Assert.assertEquals("version", this.installedExtensionRepository.getInstalledExtension("extensionid", "namespace").getId().getVersion().getValue());
}
Also used : EmptyExtension(org.xwiki.extension.test.EmptyExtension) ExtensionId(org.xwiki.extension.ExtensionId) Test(org.junit.Test)

Example 64 with ExtensionId

use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.

the class JARTranslationBundleFactoryTest method uninstallExtension.

@Test
public void uninstallExtension() throws ComponentLookupException {
    ExtensionId extensionId = new ExtensionId("jar", "1.0");
    mockInstallExtension(extensionId, null);
    assertTranslation("test.key", "default translation", Locale.ROOT);
    mockUninstallExtension(extensionId, null);
    assertTranslation("test.key", null, Locale.ROOT);
}
Also used : ExtensionId(org.xwiki.extension.ExtensionId) Test(org.junit.Test)

Example 65 with ExtensionId

use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.

the class JARTranslationBundleFactoryTest method installEmptyJar.

// tests
@Test
public void installEmptyJar() throws TranslationBundleDoesNotExistsException, TranslationBundleFactoryDoesNotExistsException, ComponentLookupException {
    ExtensionId extensionId = new ExtensionId("emptyjar", "1.0");
    mockInstallExtension(extensionId, null);
    Assert.assertNotNull(this.localizationManager.getTranslationBundle("jar", this.extensionPackager.getExtensionFile(extensionId).toURI().toString()));
}
Also used : ExtensionId(org.xwiki.extension.ExtensionId) Test(org.junit.Test)

Aggregations

ExtensionId (org.xwiki.extension.ExtensionId)67 Test (org.junit.Test)37 InstalledExtension (org.xwiki.extension.InstalledExtension)13 ExtensionAdministrationPage (org.xwiki.extension.test.po.ExtensionAdministrationPage)11 TestExtension (org.xwiki.repository.test.TestExtension)11 ExtensionPane (org.xwiki.extension.test.po.ExtensionPane)9 DocumentReference (org.xwiki.model.reference.DocumentReference)9 InstalledExtensionRepository (org.xwiki.extension.repository.InstalledExtensionRepository)8 Extension (org.xwiki.extension.Extension)7 InstallRequest (org.xwiki.extension.job.InstallRequest)6 DefaultVersionConstraint (org.xwiki.extension.version.internal.DefaultVersionConstraint)6 WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)6 IOException (java.io.IOException)5 DefaultExtensionDependency (org.xwiki.extension.DefaultExtensionDependency)5 SearchResultsPane (org.xwiki.extension.test.po.SearchResultsPane)5 ViewPage (org.xwiki.test.ui.po.ViewPage)5 XWikiContext (com.xpn.xwiki.XWikiContext)4 ResolveException (org.xwiki.extension.ResolveException)4 DependencyPane (org.xwiki.extension.test.po.DependencyPane)4 LogItemPane (org.xwiki.extension.test.po.LogItemPane)4