Search in sources :

Example 16 with ApplicationKey

use of com.enonic.xp.app.ApplicationKey in project xp by enonic.

the class ApplicationServiceImplTest method start_application.

@Test
public void start_application() throws Exception {
    final Bundle bundle = deployAppBundle("app1");
    applicationRegistry.installApplication(bundle);
    final ApplicationKey applicationKey = ApplicationKey.from("app1");
    assertEquals(Bundle.INSTALLED, bundle.getState());
    this.service.startApplication(applicationKey, true);
    assertEquals(Bundle.ACTIVE, bundle.getState());
    verify(this.eventPublisher, times(1)).publish(Mockito.argThat(new ApplicationEventMatcher(ApplicationClusterEvents.start(applicationKey))));
    verify(this.eventPublisher, times(1)).publish(Mockito.argThat(new ApplicationEventMatcher(ApplicationClusterEvents.started(applicationKey))));
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Bundle(org.osgi.framework.Bundle) Test(org.junit.jupiter.api.Test)

Example 17 with ApplicationKey

use of com.enonic.xp.app.ApplicationKey in project xp by enonic.

the class ApplicationServiceImplTest method configuration_comes_last.

@Test
public void configuration_comes_last() throws Exception {
    final ApplicationKey key = ApplicationKey.from("myapp");
    final Bundle bundle = deployAppBundle("myapp");
    applicationRegistry.installApplication(bundle);
    final Application app = service.getInstalledApplication(key);
    applicationRegistry.configureApplication(bundle, ConfigBuilder.create().add("a", "b").build());
    assertEquals(ConfigBuilder.create().add("a", "b").build(), app.getConfig());
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Bundle(org.osgi.framework.Bundle) Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Example 18 with ApplicationKey

use of com.enonic.xp.app.ApplicationKey in project xp by enonic.

the class IconLoader method toResourceKey.

private static ResourceKey toResourceKey(final MacroKey macroKey, final String ext, final String path) {
    final ApplicationKey appKey = macroKey.getApplicationKey();
    final String localName = macroKey.getName();
    return ResourceKey.from(appKey, path + "/" + localName + "/" + localName + "." + ext);
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey)

Example 19 with ApplicationKey

use of com.enonic.xp.app.ApplicationKey in project xp by enonic.

the class ContentServiceImplTest_findByApplicationKey method test.

@Test
public void test() throws Exception {
    final ApplicationKey applicationKey1 = ApplicationKey.from("app:key1");
    final ApplicationKey applicationKey2 = ApplicationKey.from("app:key2");
    final Content site1 = createSite("a", SiteConfigs.from(SiteConfig.create().application(applicationKey1).config(new PropertyTree()).build()));
    final Content site1_2 = createSite("b", SiteConfigs.from(SiteConfig.create().application(applicationKey1).config(new PropertyTree()).build(), SiteConfig.create().application(applicationKey2).config(new PropertyTree()).build()));
    final Content site2 = createSite("c", SiteConfigs.from(SiteConfig.create().application(applicationKey2).config(new PropertyTree()).build()));
    assertEquals(Contents.from(site1, site1_2).getIds(), contentService.findByApplicationKey(applicationKey1).getIds());
    assertEquals(Contents.from(site1_2, site2).getIds(), contentService.findByApplicationKey(applicationKey2).getIds());
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 20 with ApplicationKey

use of com.enonic.xp.app.ApplicationKey in project xp by enonic.

the class LocaleScriptBean method getPreferredLocale.

private String getPreferredLocale(final List<String> localeTags, final String[] bundleNames) {
    if (localeTags == null || localeTags.isEmpty()) {
        return null;
    }
    final ApplicationKey applicationKey = getApplication();
    final List<Locale> locales = localeTags.stream().map(Locale::forLanguageTag).collect(toList());
    final Locale preferredLocale = this.localeService.get().getSupportedLocale(locales, applicationKey, bundleNames);
    return preferredLocale == null ? null : preferredLocale.toLanguageTag();
}
Also used : Locale(java.util.Locale) ApplicationKey(com.enonic.xp.app.ApplicationKey)

Aggregations

ApplicationKey (com.enonic.xp.app.ApplicationKey)78 Test (org.junit.jupiter.api.Test)40 Application (com.enonic.xp.app.Application)16 SiteDescriptor (com.enonic.xp.site.SiteDescriptor)12 Bundle (org.osgi.framework.Bundle)10 ResourceKey (com.enonic.xp.resource.ResourceKey)6 PropertyTree (com.enonic.xp.data.PropertyTree)5 ExtraData (com.enonic.xp.content.ExtraData)4 Site (com.enonic.xp.site.Site)4 Node (com.enonic.xp.node.Node)3 DescriptorKey (com.enonic.xp.page.DescriptorKey)3 PortalRequest (com.enonic.xp.portal.PortalRequest)3 PortalResponse (com.enonic.xp.portal.PortalResponse)3 XDataName (com.enonic.xp.schema.xdata.XDataName)3 ByteSource (com.google.common.io.ByteSource)3 ApplicationInvalidator (com.enonic.xp.app.ApplicationInvalidator)2 ExtraDatas (com.enonic.xp.content.ExtraDatas)2 PropertySet (com.enonic.xp.data.PropertySet)2 ControllerScript (com.enonic.xp.portal.controller.ControllerScript)2 RenderException (com.enonic.xp.portal.impl.rendering.RenderException)2