Search in sources :

Example 31 with ExtensionId

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

the class ExtensionInstanceOutputFilterStreamTest method testImportExtensionId.

// tests
@Test
public void testImportExtensionId() throws FilterException, ResolveException, UnsupportedEncodingException {
    doReturn(new EmptyExtension(new ExtensionId("extensionid1", "version1"), "test")).when(this.extensionRepositoryMock).resolve(new ExtensionId("extensionid1", "version1"));
    doReturn(new EmptyExtension(new ExtensionId("extensionid2", "version2"), "test")).when(this.extensionRepositoryMock).resolve(new ExtensionId("extensionid2", "version2"));
    importFromXML("extensionid");
    Assert.assertNull(this.installedExtensionRepository.getInstalledExtension("extensionid1", null));
    Assert.assertNotNull(this.installedExtensionRepository.getInstalledExtension("extensionid1", "namespace1"));
    Assert.assertEquals("version1", this.installedExtensionRepository.getInstalledExtension("extensionid1", "namespace1").getId().getVersion().getValue());
    Assert.assertNull(this.installedExtensionRepository.getInstalledExtension("extensionid2", null));
    Assert.assertNotNull(this.installedExtensionRepository.getInstalledExtension("extensionid2", "wiki:wiki2"));
    Assert.assertEquals("version2", this.installedExtensionRepository.getInstalledExtension("extensionid2", "wiki:wiki2").getId().getVersion().getValue());
}
Also used : EmptyExtension(org.xwiki.extension.test.EmptyExtension) ExtensionId(org.xwiki.extension.ExtensionId) Test(org.junit.Test)

Example 32 with ExtensionId

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

the class JARTranslationBundleFactoryTest method installJar.

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

Example 33 with ExtensionId

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

the class JARTranslationBundleFactoryTest method upgradeJar.

@Test
public void upgradeJar() throws ComponentLookupException {
    ExtensionId previousExtensionId = new ExtensionId("jar", "1.0");
    mockInstallExtension(previousExtensionId, null);
    assertTranslation("test.key", "default translation", Locale.ROOT);
    assertTranslation("test.key", "en translation", Locale.ENGLISH);
    assertTranslation("test.key", "en_US translation", Locale.US);
    ExtensionId newExtensionId = new ExtensionId("jar", "2.0");
    mockUpgradeExtension(previousExtensionId, newExtensionId, null);
    assertTranslation("test.key", "default translation 2.0", Locale.ROOT);
    assertTranslation("test.key", "default translation 2.0", Locale.ENGLISH);
    assertTranslation("test.key", "default translation 2.0", Locale.US);
}
Also used : ExtensionId(org.xwiki.extension.ExtensionId) Test(org.junit.Test)

Example 34 with ExtensionId

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

the class JARTranslationBundleFactoryTest method getInstalledJarTranslations.

@Test
public void getInstalledJarTranslations() throws ComponentLookupException {
    ExtensionId extensionId = new ExtensionId("jar", "1.0");
    Mockito.when(mockInstalledExtensionRepository.getInstalledExtensions()).thenReturn(Arrays.<InstalledExtension>asList(mockInstalledExtension(extensionId, null)));
    // Trigger initialization
    this.componentManager.getInstance(EventListener.class, JARTranslationBundleFactoryListener.NAME);
    assertTranslation("test.key", "default translation", Locale.ROOT);
    assertTranslation("test.key", "en translation", Locale.ENGLISH);
    assertTranslation("test.key", "en_US translation", Locale.US);
}
Also used : ExtensionId(org.xwiki.extension.ExtensionId) Test(org.junit.Test)

Example 35 with ExtensionId

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

the class DefaultDistributionManager method initialize.

@Override
public void initialize() throws InitializationException {
    // Get default UI from the configuration.
    this.mainUIExtensionId = this.configuration.getProperty("distribution.defaultUI", ExtensionId.class);
    this.wikiUIExtensionId = this.configuration.getProperty("distribution.defaultWikiUI", ExtensionId.class);
    // Get the current distribution
    this.distributionExtension = this.coreExtensionRepository.getEnvironmentExtension();
    // Extract various configuration from the distribution extension
    if (this.distributionExtension != null) {
        // Main wiki default UI
        if (this.mainUIExtensionId == null) {
            String mainUIId = this.distributionExtension.getProperty("xwiki.extension.distribution.ui");
            if (mainUIId != null) {
                String mainUIVersion = this.distributionExtension.getProperty("xwiki.extension.distribution.ui.version");
                this.mainUIExtensionId = new ExtensionId(mainUIId, mainUIVersion != null ? new DefaultVersion(mainUIVersion) : this.distributionExtension.getId().getVersion());
            }
        } else if (this.mainUIExtensionId.getVersion() == null) {
            this.mainUIExtensionId = new ExtensionId(this.mainUIExtensionId.getId(), this.distributionExtension.getId().getVersion());
        }
        // Subwikis defualt UI
        if (this.wikiUIExtensionId == null) {
            String wikiUIId = this.distributionExtension.getProperty("xwiki.extension.distribution.wikiui");
            if (wikiUIId != null) {
                String wikiUIVersion = this.distributionExtension.getProperty("xwiki.extension.distribution.wikiui.version");
                this.wikiUIExtensionId = new ExtensionId(wikiUIId, wikiUIVersion != null ? new DefaultVersion(wikiUIVersion) : this.distributionExtension.getId().getVersion());
            }
        } else if (this.wikiUIExtensionId.getVersion() == null) {
            this.wikiUIExtensionId = new ExtensionId(this.wikiUIExtensionId.getId(), this.distributionExtension.getId().getVersion());
        }
    }
}
Also used : DefaultVersion(org.xwiki.extension.version.internal.DefaultVersion) ExtensionId(org.xwiki.extension.ExtensionId)

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