Search in sources :

Example 21 with Application

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

the class ApplicationFactoryTest method create_app.

@Test
public void create_app() throws Exception {
    final Bundle bundle = deploy("app1", true, false);
    final Application app = new ApplicationFactory(RunMode.PROD).create(bundle);
    assertNotNull(app);
    assertNull(app.getConfig());
}
Also used : Bundle(org.osgi.framework.Bundle) TinyBundle(org.ops4j.pax.tinybundles.core.TinyBundle) Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Example 22 with Application

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

the class ApplicationClusterEventListenerTest method start.

@Test
void start() {
    final Application application = mock(Application.class);
    final ApplicationKey appKey = ApplicationKey.from("appKey");
    when(application.getKey()).thenReturn(appKey);
    this.applicationClusterEventListener.onEvent(Event.create(ApplicationClusterEvents.EVENT_TYPE).localOrigin(false).value(ApplicationClusterEvents.EVENT_TYPE_KEY, ApplicationClusterEvents.START).value(ApplicationClusterEvents.APPLICATION_KEY_PARAM, appKey).build());
    verify(this.applicationService, times(1)).startApplication(appKey, false);
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Example 23 with Application

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

the class ApplicationClusterEventListenerTest method installed.

@Test
void installed() {
    final Node node = Node.create().name("myNode").id(NodeId.from("myNodeId")).parentPath(NodePath.ROOT).build();
    final Application application = mock(Application.class);
    when(application.getKey()).thenReturn(ApplicationKey.from("appKey"));
    when(applicationService.installStoredApplication(eq(node.id()), any())).thenReturn(application);
    this.applicationClusterEventListener.onEvent(Event.create(ApplicationClusterEvents.EVENT_TYPE).localOrigin(false).value(ApplicationClusterEvents.NODE_ID_PARAM, node.id()).value(ApplicationClusterEvents.EVENT_TYPE_KEY, ApplicationClusterEvents.INSTALLED).build());
    verify(this.applicationService, times(1)).installStoredApplication(node.id(), ApplicationInstallationParams.create().start(false).triggerEvent(false).build());
}
Also used : Node(com.enonic.xp.node.Node) Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Example 24 with Application

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

the class ApplicationClusterEventListenerTest method stop.

@Test
void stop() {
    final Application application = mock(Application.class);
    final ApplicationKey appKey = ApplicationKey.from("appKey");
    when(application.getKey()).thenReturn(appKey);
    this.applicationClusterEventListener.onEvent(Event.create(ApplicationClusterEvents.EVENT_TYPE).localOrigin(false).value(ApplicationClusterEvents.EVENT_TYPE_KEY, ApplicationClusterEvents.STOP).value(ApplicationClusterEvents.APPLICATION_KEY_PARAM, appKey).build());
    verify(this.applicationService, times(1)).stopApplication(appKey, false);
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Example 25 with Application

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

the class ApplicationServiceImplTest method install_stored_application_denied.

@Test
public void install_stored_application_denied() throws Exception {
    when(appFilterService.accept(any(ApplicationKey.class))).thenReturn(false);
    final Node node = Node.create().id(NodeId.from("myNodeId")).name("myBundle").parentPath(ApplicationRepoServiceImpl.APPLICATION_PATH).build();
    final String bundleName = "my-bundle";
    when(this.repoService.getApplicationSource(node.id())).thenReturn(createBundleSource(bundleName));
    final Application application = this.service.installStoredApplication(node.id());
    assertNull(application);
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) Node(com.enonic.xp.node.Node) Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Aggregations

Application (com.enonic.xp.app.Application)66 Test (org.junit.jupiter.api.Test)42 ApplicationKey (com.enonic.xp.app.ApplicationKey)20 Node (com.enonic.xp.node.Node)16 Bundle (org.osgi.framework.Bundle)16 ByteSource (com.google.common.io.ByteSource)12 URL (java.net.URL)11 ResourceKey (com.enonic.xp.resource.ResourceKey)9 ApplicationService (com.enonic.xp.app.ApplicationService)8 ResourceService (com.enonic.xp.resource.ResourceService)8 BundleContext (org.osgi.framework.BundleContext)8 UrlResource (com.enonic.xp.resource.UrlResource)7 ScriptAsyncService (com.enonic.xp.script.impl.async.ScriptAsyncService)7 ScriptRuntimeFactoryImpl (com.enonic.xp.script.impl.standard.ScriptRuntimeFactoryImpl)7 PortalScriptServiceImpl (com.enonic.xp.portal.impl.script.PortalScriptServiceImpl)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 IOException (java.io.IOException)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 PropertyTree (com.enonic.xp.data.PropertyTree)4 PortalRequest (com.enonic.xp.portal.PortalRequest)4