Search in sources :

Example 51 with ExtensionId

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

the class DefaultUIDistributionStep method executeNonInteractive.

@Override
public void executeNonInteractive() throws Exception {
    // Get the default UI
    ExtensionId extensionUI = this.distributionJob.getStatus().getDistributionExtensionUI();
    // Install the default UI
    install(extensionUI, true);
    // Complete task
    setState(State.COMPLETED);
}
Also used : ExtensionId(org.xwiki.extension.ExtensionId)

Example 52 with ExtensionId

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

the class InstalledExtensionIndexTest method testInstallExtensionOnRoot.

@Test
public void testInstallExtensionOnRoot() throws Exception {
    // Use superadmin
    getUtil().setDefaultCredentials(TestUtils.SUPER_ADMIN_CREDENTIALS);
    ExtensionId extensionId = new ExtensionId("maven:jar", "1.0");
    // ///////////////////////////////////////////
    // Make sure it's not yet installed on node 0 and node 1
    getUtil().switchExecutor(0);
    assertTrue("The extension is already installed on node0", !getExtensionTestUtils().isInstalled(extensionId, Namespace.ROOT));
    getUtil().switchExecutor(1);
    assertTrue("The extension is already installed on node1", !getExtensionTestUtils().isInstalled(extensionId, Namespace.ROOT));
    // ///////////////////////////////////////////
    // Install extension on node 0
    getUtil().switchExecutor(0);
    InstallRequest installRequest = new InstallRequest();
    installRequest.setId(ExtensionRequest.getJobId(ExtensionRequest.JOBID_PLAN_PREFIX, extensionId.getId(), null));
    installRequest.setInteractive(false);
    installRequest.addExtension(extensionId);
    executeJob("install", installRequest);
    // ///////////////////////////////////////////
    // Make sure it has been installed on node 0
    assertTrue("The extension was not installed on node0", getExtensionTestUtils().isInstalled(extensionId, Namespace.ROOT));
    // ///////////////////////////////////////////
    // Make sure it has been installed on node 1
    getUtil().switchExecutor(1);
    long t1 = System.currentTimeMillis();
    while (!getExtensionTestUtils().isInstalled(extensionId, Namespace.ROOT)) {
        if (System.currentTimeMillis() - t1 > 10000L) {
            fail("The extension was not installed on node1");
        }
        Thread.sleep(100);
    }
    // ///////////////////////////////////////////
    // Uninstall extension from node 1
    getUtil().switchExecutor(1);
    UninstallRequest uninstallRequest = new UninstallRequest();
    uninstallRequest.setId(ExtensionRequest.getJobId(ExtensionRequest.JOBID_PLAN_PREFIX, extensionId.getId(), null));
    uninstallRequest.setInteractive(false);
    uninstallRequest.addExtension(extensionId);
    executeJob("uninstall", uninstallRequest);
    // ///////////////////////////////////////////
    // Make sure it has been uninstalled from node 1
    assertTrue("The extension is still installed on node1", !getExtensionTestUtils().isInstalled(extensionId, Namespace.ROOT));
    // ///////////////////////////////////////////
    // Make sure it has been uninstalled from node 0
    getUtil().switchExecutor(1);
    t1 = System.currentTimeMillis();
    while (getExtensionTestUtils().isInstalled(extensionId, Namespace.ROOT)) {
        if (System.currentTimeMillis() - t1 > 10000L) {
            fail("The extension is still installed on node0");
        }
        Thread.sleep(100);
    }
}
Also used : InstallRequest(org.xwiki.extension.job.InstallRequest) ExtensionId(org.xwiki.extension.ExtensionId) UninstallRequest(org.xwiki.extension.job.UninstallRequest) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest) AbstractClusterHttpTest(org.xwiki.test.cluster.framework.AbstractClusterHttpTest)

Example 53 with ExtensionId

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

the class ImportTest method testImportExtension.

/**
 * Test the regular document import when the XAR is tagged as extension.
 *
 * @throws Exception
 */
public void testImportExtension() throws Exception {
    ExtensionId extensionId = new ExtensionId("test", "1.0");
    XWikiDocument doc1 = new XWikiDocument(new DocumentReference("Test", "Test", "DocImport"));
    doc1.setDefaultLanguage("en");
    byte[] zipFile = this.createZipFile(new XWikiDocument[] { doc1 }, new String[] { "ISO-8859-1" }, extensionId);
    // Store the extension in the local repository
    DefaultLocalExtension localExtension = new DefaultLocalExtension(null, extensionId, "xar");
    File file = File.createTempFile("temp", ".xar");
    FileUtils.writeByteArrayToFile(file, zipFile);
    localExtension.setFile(file);
    LocalExtensionRepository localeRepository = getComponentManager().getInstance(LocalExtensionRepository.class);
    localeRepository.storeExtension(localExtension);
    // Listen to extension installed event
    Mock extensionListener = mock(EventListener.class);
    extensionListener.stubs().method("getEvents").will(returnValue(Arrays.asList(new ExtensionInstalledEvent())));
    extensionListener.stubs().method("getName").will(returnValue("extension installed listener"));
    extensionListener.expects(once()).method("onEvent");
    ObservationManager observationManager = getComponentManager().getInstance(ObservationManager.class);
    observationManager.addListener((EventListener) extensionListener.proxy());
    // make sure no data is in the packager from the other tests run
    this.pack = new Package();
    // import and install this document
    this.pack.Import(zipFile, getContext());
    this.pack.install(getContext());
    // check if it is there
    XWikiDocument foundDocument = this.xwiki.getDocument(new DocumentReference("Test", "Test", "DocImport"), getContext());
    assertFalse(foundDocument.isNew());
    XWikiDocument nonExistingDocument = this.xwiki.getDocument(new DocumentReference("Test", "Test", "DocImportNonexisting"), getContext());
    assertTrue(nonExistingDocument.isNew());
    XWikiDocument foundTranslationDocument = foundDocument.getTranslatedDocument("fr", getContext());
    assertSame(foundDocument, foundTranslationDocument);
    XWikiDocument doc1Translation = new XWikiDocument(new DocumentReference("Test", "Test", "DocImport"));
    doc1Translation.setLanguage("fr");
    doc1Translation.setDefaultLanguage("en");
    this.xwiki.saveDocument(doc1Translation, getContext());
    foundTranslationDocument = foundDocument.getTranslatedDocument("fr", getContext());
    assertNotSame(foundDocument, foundTranslationDocument);
    // Check that the extension has been registered
    InstalledExtensionRepository installedExtensionRepository = getComponentManager().getInstance(InstalledExtensionRepository.class);
    assertNotNull(installedExtensionRepository.getInstalledExtension(extensionId));
    assertNotNull(installedExtensionRepository.getInstalledExtension(extensionId.getId(), "wiki:" + getContext().getWikiId()));
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) LocalExtensionRepository(org.xwiki.extension.repository.LocalExtensionRepository) ExtensionId(org.xwiki.extension.ExtensionId) ObservationManager(org.xwiki.observation.ObservationManager) DefaultLocalExtension(org.xwiki.extension.repository.internal.local.DefaultLocalExtension) File(java.io.File) DocumentReference(org.xwiki.model.reference.DocumentReference) Mock(org.jmock.Mock) InstalledExtensionRepository(org.xwiki.extension.repository.InstalledExtensionRepository) ExtensionInstalledEvent(org.xwiki.extension.event.ExtensionInstalledEvent)

Example 54 with ExtensionId

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

the class XARInputFilterStreamTest method testSkipFirstDocument.

@Test
public void testSkipFirstDocument() throws FilterException, IOException, ComponentLookupException {
    XARInputProperties xarProperties = new XARInputProperties();
    xarProperties.setSource(new DefaultFileInputSource(extensionPackager.getExtensionFile(new ExtensionId("xar1", "1.0"))));
    EntityReferenceSet entities = new EntityReferenceSet();
    entities.includes(new LocalDocumentReference("space2", "page2"));
    xarProperties.setEntities(entities);
    assertXML("testSkipFirstDocument", xarProperties);
    assertTrue(this.allLogRule.getMarker(0).contains(WikiDocumentFilter.LOG_DOCUMENT_SKIPPED));
}
Also used : EntityReferenceSet(org.xwiki.model.reference.EntityReferenceSet) LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) XARInputProperties(org.xwiki.filter.xar.input.XARInputProperties) DefaultFileInputSource(org.xwiki.filter.input.DefaultFileInputSource) ExtensionId(org.xwiki.extension.ExtensionId) Test(org.junit.Test)

Example 55 with ExtensionId

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

the class XARInputFilterStreamTest method testSkipLastSpace.

@Test
public void testSkipLastSpace() throws FilterException, IOException, ComponentLookupException {
    XARInputProperties xarProperties = new XARInputProperties();
    xarProperties.setSource(new DefaultFileInputSource(extensionPackager.getExtensionFile(new ExtensionId("xar1", "1.0"))));
    EntityReferenceSet entities = new EntityReferenceSet();
    entities.excludes(new EntityReference("space2", EntityType.SPACE));
    xarProperties.setEntities(entities);
    assertXML("testSkipLastSpace", xarProperties);
    assertTrue(this.allLogRule.getMarker(0).contains(WikiDocumentFilter.LOG_DOCUMENT_SKIPPED));
}
Also used : EntityReferenceSet(org.xwiki.model.reference.EntityReferenceSet) XARInputProperties(org.xwiki.filter.xar.input.XARInputProperties) EntityReference(org.xwiki.model.reference.EntityReference) DefaultFileInputSource(org.xwiki.filter.input.DefaultFileInputSource) 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