Search in sources :

Example 11 with ApplicationKey

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

the class ApplicationServiceImplTest method start_missing_application.

@Test
public void start_missing_application() {
    final ApplicationKey applicationKey = ApplicationKey.from("app1");
    this.service.startApplication(applicationKey, true);
    verify(this.eventPublisher, times(1)).publish(Mockito.argThat(new ApplicationEventMatcher(ApplicationClusterEvents.start(applicationKey))));
    verifyNoMoreInteractions(this.eventPublisher);
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Test(org.junit.jupiter.api.Test)

Example 12 with ApplicationKey

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

the class ApplicationServiceImplTest method stop_application_no_triggerEvent.

@Test
public void stop_application_no_triggerEvent() throws Exception {
    final Bundle bundle = deployAppBundle("app1");
    applicationRegistry.installApplication(bundle);
    bundle.start();
    assertEquals(Bundle.ACTIVE, bundle.getState());
    final ApplicationKey applicationKey = ApplicationKey.from("app1");
    this.service.stopApplication(applicationKey, false);
    assertEquals(Bundle.RESOLVED, bundle.getState());
    verify(this.eventPublisher, never()).publish(Mockito.argThat(new ApplicationEventMatcher(ApplicationClusterEvents.stop(applicationKey))));
    verify(this.eventPublisher, never()).publish(Mockito.argThat(new ApplicationEventMatcher(ApplicationClusterEvents.stopped(applicationKey))));
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Bundle(org.osgi.framework.Bundle) Test(org.junit.jupiter.api.Test)

Example 13 with ApplicationKey

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

the class ApplicationServiceImplTest method install_stored_applications.

@Test
public void install_stored_applications() throws Exception {
    final String bundleName1 = "my-bundle1";
    final String bundleName2 = "my-bundle2";
    ApplicationKey applicationKey1 = ApplicationKey.from(bundleName1);
    ApplicationKey applicationKey2 = ApplicationKey.from(bundleName2);
    when(appFilterService.accept(applicationKey2)).thenReturn(false);
    final Node node1 = Node.create().id(NodeId.from("myNodeId1")).name("myBundle1").parentPath(ApplicationRepoServiceImpl.APPLICATION_PATH).build();
    final Node node2 = Node.create().id(NodeId.from("myNodeId2")).name("myBundle2").parentPath(ApplicationRepoServiceImpl.APPLICATION_PATH).build();
    when(this.repoService.getApplications()).thenReturn(Nodes.from(node1, node2));
    when(this.repoService.getApplicationSource(node1.id())).thenReturn(createBundleSource(bundleName1));
    when(this.repoService.getApplicationSource(node2.id())).thenReturn(createBundleSource(bundleName2));
    this.service.installAllStoredApplications(ApplicationInstallationParams.create().triggerEvent(false).build());
    assertFalse(this.service.isLocalApplication(applicationKey1));
    assertNotNull(this.service.getInstalledApplication(applicationKey1));
    assertNull(this.service.getInstalledApplication(applicationKey2));
    verifyInstalledEvents(node1, never());
    verifyStartedEvent(applicationKey1, never());
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 14 with ApplicationKey

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

the class ApplicationServiceImplTest method stop_application.

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

Example 15 with ApplicationKey

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

the class ApplicationServiceImplTest method configuration_comes_first.

@Test
public void configuration_comes_first() throws Exception {
    final ApplicationKey key = ApplicationKey.from("myapp");
    final Bundle bundle = deployAppBundle("myapp");
    applicationRegistry.configureApplication(bundle, ConfigBuilder.create().add("a", "b").build());
    final Application app = service.getInstalledApplication(key);
    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)

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