Search in sources :

Example 46 with ApplicationKey

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

the class DeployDirectoryWatcher method installApplication.

private void installApplication(final File file) {
    // Installs the application
    final ByteSource byteSource = Files.asByteSource(file);
    final Application application = DeployHelper.runAsAdmin(() -> applicationService.installLocalApplication(byteSource, file.getName()));
    final ApplicationKey applicationKey = application.getKey();
    final String path = file.getPath();
    // Stores a mapping fileName -> applicationKey. Needed for uninstallation
    this.applicationKeyByPath.put(path, applicationKey);
    // Updates the mapping applicationKey -> stack<fileName>. Needed in some particular case for uninstallatioon
    this.pathsByApplicationKey.compute(applicationKey, (applicationKeyParam, fileNameStack) -> {
        if (fileNameStack == null) {
            fileNameStack = new Stack<>();
        }
        fileNameStack.remove(path);
        fileNameStack.push(path);
        return fileNameStack;
    });
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) ByteSource(com.google.common.io.ByteSource) Application(com.enonic.xp.app.Application)

Example 47 with ApplicationKey

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

the class ValidationErrorCodeTest method from.

@Test
void from() {
    final ApplicationKey applicationKey = ApplicationKey.from("someApp");
    final ValidationErrorCode validationErrorCode = ValidationErrorCode.from(applicationKey, "someCode");
    assertEquals(applicationKey, validationErrorCode.getApplicationKey());
    assertEquals("someCode", validationErrorCode.getCode());
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Test(org.junit.jupiter.api.Test)

Example 48 with ApplicationKey

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

the class ApplicationServiceImplTest method configuration_comes_twice_invalidators_called.

@Test
public void configuration_comes_twice_invalidators_called() throws Exception {
    final ApplicationKey key = ApplicationKey.from("myapp");
    final Bundle bundle = deployAppBundle("myapp");
    applicationRegistry.installApplication(bundle);
    service.getInstalledApplication(key);
    final ApplicationInvalidator mock = mock(ApplicationInvalidator.class);
    applicationRegistry.addInvalidator(mock);
    applicationRegistry.configureApplication(bundle, ConfigBuilder.create().add("a", "b").build());
    applicationRegistry.configureApplication(bundle, ConfigBuilder.create().add("c", "d").build());
    verify(mock, times(1)).invalidate(eq(key), eq(ApplicationInvalidationLevel.FULL));
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Bundle(org.osgi.framework.Bundle) ApplicationInvalidator(com.enonic.xp.app.ApplicationInvalidator) Test(org.junit.jupiter.api.Test)

Example 49 with ApplicationKey

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

the class ApplicationServiceImplTest method start_application_no_triggerEvent.

@Test
public void start_application_no_triggerEvent() 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, false);
    assertEquals(Bundle.ACTIVE, bundle.getState());
    verify(this.eventPublisher, never()).publish(Mockito.argThat(new ApplicationEventMatcher(ApplicationClusterEvents.start(applicationKey))));
    verify(this.eventPublisher, never()).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 50 with ApplicationKey

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

the class ApplicationServiceImplTest method stop_system_application_ignored.

@Test
public void stop_system_application_ignored() throws Exception {
    final Bundle bundle = deploySystemAppBundle("systemApp");
    applicationRegistry.installApplication(bundle);
    bundle.start();
    assertEquals(Bundle.ACTIVE, bundle.getState());
    final ApplicationKey applicationKey = ApplicationKey.from("systemApp");
    this.service.stopApplication(applicationKey, true);
    assertEquals(Bundle.ACTIVE, bundle.getState());
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Bundle(org.osgi.framework.Bundle) Test(org.junit.jupiter.api.Test)

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