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