Search in sources :

Example 1 with EmptyExtension

use of org.xwiki.extension.test.EmptyExtension in project xwiki-platform by xwiki.

the class WikiCopiedEventListenerTest method setUp.

@Before
public void setUp() throws Exception {
    this.localExtensionRepository = this.repositoryUtil.getComponentManager().getInstance(LocalExtensionRepository.class);
    this.installedExtensionRepository = this.repositoryUtil.getComponentManager().getInstance(InstalledExtensionRepository.class);
    this.observation = this.repositoryUtil.getComponentManager().getInstance(ObservationManager.class);
    // Extensions
    EmptyExtension extension = new EmptyExtension(new ExtensionId("id", "version"), "xar");
    EmptyExtension extensionDependency = new EmptyExtension(new ExtensionId("dependency", "version"), "xar");
    extension.addDependency(new DefaultExtensionDependency(extensionDependency.getId().getId(), new DefaultVersionConstraint(null, extensionDependency.getId().getVersion())));
    this.localExtensionDependency1 = this.localExtensionRepository.storeExtension(extensionDependency);
    this.localExtension1 = this.localExtensionRepository.storeExtension(extension);
}
Also used : EmptyExtension(org.xwiki.extension.test.EmptyExtension) DefaultVersionConstraint(org.xwiki.extension.version.internal.DefaultVersionConstraint) DefaultLocalExtensionRepository(org.xwiki.extension.repository.internal.local.DefaultLocalExtensionRepository) LocalExtensionRepository(org.xwiki.extension.repository.LocalExtensionRepository) ObservationManager(org.xwiki.observation.ObservationManager) ExtensionId(org.xwiki.extension.ExtensionId) DefaultExtensionDependency(org.xwiki.extension.DefaultExtensionDependency) InstalledExtensionRepository(org.xwiki.extension.repository.InstalledExtensionRepository) Before(org.junit.Before)

Example 2 with EmptyExtension

use of org.xwiki.extension.test.EmptyExtension 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 3 with EmptyExtension

use of org.xwiki.extension.test.EmptyExtension 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)

Aggregations

ExtensionId (org.xwiki.extension.ExtensionId)3 EmptyExtension (org.xwiki.extension.test.EmptyExtension)3 Test (org.junit.Test)2 Before (org.junit.Before)1 DefaultExtensionDependency (org.xwiki.extension.DefaultExtensionDependency)1 InstalledExtensionRepository (org.xwiki.extension.repository.InstalledExtensionRepository)1 LocalExtensionRepository (org.xwiki.extension.repository.LocalExtensionRepository)1 DefaultLocalExtensionRepository (org.xwiki.extension.repository.internal.local.DefaultLocalExtensionRepository)1 DefaultVersionConstraint (org.xwiki.extension.version.internal.DefaultVersionConstraint)1 ObservationManager (org.xwiki.observation.ObservationManager)1