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);
}
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);
}
}
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()));
}
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));
}
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));
}
Aggregations