Search in sources :

Example 66 with Application

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

the class ApplicationResourceTest method install_url_not_allowed_protocol.

@Test
public void install_url_not_allowed_protocol() throws Exception {
    Application application = createApplication("ftp://enonic.jar");
    Mockito.when(this.applicationService.installGlobalApplication(new URL(application.getUrl()))).thenReturn(application);
    String jsonString = request().path("app/installUrl").entity("{\"URL\":\"" + application.getUrl() + "\"}", MediaType.APPLICATION_JSON_TYPE).post().getAsString();
    assertEquals("{\"applicationInstalledJson\":null,\"failure\":\"Illegal protocol: ftp\"}", jsonString);
}
Also used : Application(com.enonic.xp.app.Application) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Example 67 with Application

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

the class ApplicationResourceTest method install_invalid_url.

@Test
public void install_invalid_url() throws Exception {
    Application application = createApplication("invalid url");
    String jsonString = request().path("app/installUrl").entity("{\"URL\":\"" + application.getUrl() + "\"}", MediaType.APPLICATION_JSON_TYPE).post().getAsString();
    assertEquals("{\"applicationInstalledJson\":null,\"failure\":\"Failed to upload application from invalid url\"}", jsonString);
}
Also used : Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Example 68 with Application

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

the class ApplicationResourceTest method test_start_application.

@Test
public void test_start_application() throws Exception {
    final Application application = createApplication();
    request().path("app/start").entity("{\"key\": \"" + application.getKey() + "\" }", MediaType.APPLICATION_JSON_TYPE).post();
    final InOrder inOrder = Mockito.inOrder(applicationService);
    inOrder.verify(this.applicationService).startApplication(application.getKey(), true);
    inOrder.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder) Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Aggregations

Application (com.enonic.xp.app.Application)68 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