Search in sources :

Example 41 with ExtensionId

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

the class ExtensionPingDataProviderTest method provideData.

@Test
public void provideData() throws Exception {
    ExtensionId extensionId = new ExtensionId("extensionid", "1.0");
    InstalledExtension extension = mock(InstalledExtension.class);
    when(extension.getId()).thenReturn(extensionId);
    when(extension.getFeatures()).thenReturn(Arrays.asList("feature1", "feature2"));
    InstalledExtensionRepository repository = this.mocker.getInstance(InstalledExtensionRepository.class);
    when(repository.getInstalledExtensions()).thenReturn(Collections.singletonList(extension));
    Map<String, Object> data = this.mocker.getComponentUnderTest().provideData();
    assertEquals(1, data.size());
    JSONObject[] extensions = (JSONObject[]) data.get("extensions");
    assertEquals(1, extensions.length);
    JSONObject propertiesData = extensions[0];
    assertEquals(3, propertiesData.size());
    assertEquals("extensionid", propertiesData.get("id"));
    assertEquals("1.0", propertiesData.get("version"));
    JSONArray features = (JSONArray) propertiesData.get("features");
    assertEquals(2, features.size());
    assertEquals("feature1", features.get(0));
    assertEquals("feature2", features.get(1));
}
Also used : InstalledExtension(org.xwiki.extension.InstalledExtension) JSONObject(net.sf.json.JSONObject) JSONArray(net.sf.json.JSONArray) ExtensionId(org.xwiki.extension.ExtensionId) JSONObject(net.sf.json.JSONObject) InstalledExtensionRepository(org.xwiki.extension.repository.InstalledExtensionRepository) Test(org.junit.Test)

Example 42 with ExtensionId

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

the class RepairXarJobTest method testRepairInvalidOnRoot.

@Test
public void testRepairInvalidOnRoot() throws Throwable {
    ExtensionId extensionId = new ExtensionId("invalid", "1.0");
    repair(extensionId, null, LogLevel.ERROR);
    InstalledExtension installedExtension = this.xarExtensionRepository.resolve(extensionId);
    assertFalse(installedExtension.isValid(null));
}
Also used : InstalledExtension(org.xwiki.extension.InstalledExtension) ExtensionId(org.xwiki.extension.ExtensionId) Test(org.junit.Test) AbstractExtensionHandlerTest(org.xwiki.extension.test.AbstractExtensionHandlerTest)

Example 43 with ExtensionId

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

the class RepairXarJobTest method testRepairOnRoot.

@Test
public void testRepairOnRoot() throws Throwable {
    ExtensionId extensionId = new ExtensionId("test", "1.0");
    repair(extensionId, null, LogLevel.WARN);
    InstalledExtension installedExtension = this.xarExtensionRepository.resolve(extensionId);
    assertTrue(installedExtension.isValid(null));
    installedExtension = this.xarExtensionRepository.resolve(new ExtensionId("dependency", "1.0"));
    assertTrue(installedExtension.isValid(null));
}
Also used : InstalledExtension(org.xwiki.extension.InstalledExtension) ExtensionId(org.xwiki.extension.ExtensionId) Test(org.junit.Test) AbstractExtensionHandlerTest(org.xwiki.extension.test.AbstractExtensionHandlerTest)

Example 44 with ExtensionId

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

the class RepairXarJobTest method testRepairOnWiki.

@Test
public void testRepairOnWiki() throws Throwable {
    ExtensionId extensionId = new ExtensionId("test", "1.0");
    repair(extensionId, new String[] { "wiki:wiki1" }, LogLevel.WARN);
    InstalledExtension installedExtension = this.xarExtensionRepository.resolve(extensionId);
    assertTrue(installedExtension.isValid(null));
    installedExtension = this.xarExtensionRepository.resolve(new ExtensionId("dependency", "1.0"));
    assertTrue(installedExtension.isValid(null));
}
Also used : InstalledExtension(org.xwiki.extension.InstalledExtension) ExtensionId(org.xwiki.extension.ExtensionId) Test(org.junit.Test) AbstractExtensionHandlerTest(org.xwiki.extension.test.AbstractExtensionHandlerTest)

Example 45 with ExtensionId

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

the class XarInstalledExtensionRepositoryTest method testInit.

// Tests
@Test
public void testInit() throws ResolveException, SearchException {
    assertEquals(1, this.installedExtensionRepository.countExtensions());
    XarInstalledExtension xarInstalledExtension = this.installedExtensionRepository.resolve(new ExtensionId("xarinstalledextension", "1.0"));
    assertNotNull(xarInstalledExtension);
    assertNotNull(this.installedExtensionRepository.getInstalledExtension(new ExtensionId("xarinstalledextension", "1.0")));
    assertNotNull(this.installedExtensionRepository.getInstalledExtension("xarinstalledextension", null));
    assertNull(this.installedExtensionRepository.getInstalledExtension("notexisting", null));
    assertEquals(1, this.installedExtensionRepository.getInstalledExtensions().size());
    assertEquals(1, this.installedExtensionRepository.getInstalledExtensions(null).size());
    assertEquals(1, this.installedExtensionRepository.search("xarinstalledextension", 0, -1).getSize());
    assertEquals(1, this.installedExtensionRepository.search(null, 0, -1).getSize());
    assertEquals(1, this.installedExtensionRepository.searchInstalledExtensions("xarinstalledextension", null, 0, -1).getSize());
    assertEquals(1, this.installedExtensionRepository.searchInstalledExtensions(null, null, 0, -1).getSize());
    assertEquals(Arrays.asList(xarInstalledExtension), this.installedExtensionRepository.getXarInstalledExtensions(new DocumentReference("xwiki", "space", "page")));
    assertEquals(Arrays.asList(xarInstalledExtension), this.installedExtensionRepository.getXarInstalledExtensions(new DocumentReference("wiki2", "space", "page")));
    assertEquals(Arrays.asList(xarInstalledExtension), this.installedExtensionRepository.getXarInstalledExtensions(new DocumentReference("xwiki", "space", "page", Locale.ROOT)));
    assertEquals(0, this.installedExtensionRepository.getXarInstalledExtensions(new DocumentReference("xwiki", "space", "page", Locale.ENGLISH)).size());
}
Also used : ExtensionId(org.xwiki.extension.ExtensionId) DocumentReference(org.xwiki.model.reference.DocumentReference) 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