Search in sources :

Example 1 with ApplicationUrlResolver

use of com.enonic.xp.core.impl.app.resolver.ApplicationUrlResolver in project xp by enonic.

the class ApplicationFactoryTest method createUrlResolver_prod.

@Test
public void createUrlResolver_prod() throws Exception {
    final Bundle bundle = deploy("app1", true, false);
    final ApplicationUrlResolver resolver = new ApplicationFactory(RunMode.PROD).createUrlResolver(bundle);
    assertNotNull(resolver);
    assertTrue(resolver instanceof BundleApplicationUrlResolver);
}
Also used : MultiApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.MultiApplicationUrlResolver) BundleApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.BundleApplicationUrlResolver) ApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.ApplicationUrlResolver) Bundle(org.osgi.framework.Bundle) TinyBundle(org.ops4j.pax.tinybundles.core.TinyBundle) BundleApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.BundleApplicationUrlResolver) Test(org.junit.jupiter.api.Test)

Example 2 with ApplicationUrlResolver

use of com.enonic.xp.core.impl.app.resolver.ApplicationUrlResolver in project xp by enonic.

the class ApplicationFactoryTest method createUrlResolver_dev_with_source.

@Test
public void createUrlResolver_dev_with_source() throws Exception {
    final Bundle bundle = deploy("app1", true, true);
    final ApplicationUrlResolver resolver = new ApplicationFactory(RunMode.DEV).createUrlResolver(bundle);
    assertNotNull(resolver);
    assertTrue(resolver instanceof MultiApplicationUrlResolver);
}
Also used : MultiApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.MultiApplicationUrlResolver) BundleApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.BundleApplicationUrlResolver) ApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.ApplicationUrlResolver) Bundle(org.osgi.framework.Bundle) TinyBundle(org.ops4j.pax.tinybundles.core.TinyBundle) MultiApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.MultiApplicationUrlResolver) Test(org.junit.jupiter.api.Test)

Example 3 with ApplicationUrlResolver

use of com.enonic.xp.core.impl.app.resolver.ApplicationUrlResolver in project xp by enonic.

the class ApplicationFactory method createUrlResolver.

ApplicationUrlResolver createUrlResolver(final Bundle bundle) {
    final ApplicationUrlResolver bundleUrlResolver = new BundleApplicationUrlResolver(bundle);
    if (this.runMode != RunMode.DEV) {
        return bundleUrlResolver;
    }
    final List<String> sourcePaths = ApplicationHelper.getSourcePaths(bundle);
    if (sourcePaths.isEmpty()) {
        return bundleUrlResolver;
    }
    final ApplicationUrlResolver classLoaderUrlResolver = createClassLoaderUrlResolver(sourcePaths);
    return new MultiApplicationUrlResolver(classLoaderUrlResolver, bundleUrlResolver);
}
Also used : MultiApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.MultiApplicationUrlResolver) BundleApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.BundleApplicationUrlResolver) ApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.ApplicationUrlResolver) ClassLoaderApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.ClassLoaderApplicationUrlResolver) BundleApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.BundleApplicationUrlResolver) MultiApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.MultiApplicationUrlResolver)

Example 4 with ApplicationUrlResolver

use of com.enonic.xp.core.impl.app.resolver.ApplicationUrlResolver in project xp by enonic.

the class ApplicationFactoryTest method createUrlResolver_dev_no_source.

@Test
public void createUrlResolver_dev_no_source() throws Exception {
    final Bundle bundle = deploy("app1", true, false);
    final ApplicationUrlResolver resolver = new ApplicationFactory(RunMode.DEV).createUrlResolver(bundle);
    assertNotNull(resolver);
    assertTrue(resolver instanceof BundleApplicationUrlResolver);
}
Also used : MultiApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.MultiApplicationUrlResolver) BundleApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.BundleApplicationUrlResolver) ApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.ApplicationUrlResolver) Bundle(org.osgi.framework.Bundle) TinyBundle(org.ops4j.pax.tinybundles.core.TinyBundle) BundleApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.BundleApplicationUrlResolver) Test(org.junit.jupiter.api.Test)

Example 5 with ApplicationUrlResolver

use of com.enonic.xp.core.impl.app.resolver.ApplicationUrlResolver in project xp by enonic.

the class ApplicationImplTest method testApplication.

@Test
public void testApplication() throws Exception {
    final Bundle bundle = deployBundle();
    final ApplicationUrlResolver urlResolver = Mockito.mock(ApplicationUrlResolver.class);
    final Application application = new ApplicationBuilder().bundle(bundle).urlResolver(urlResolver).build();
    assertEquals("myapplication", application.getKey().toString());
    assertEquals("1.0.0", application.getVersion().toString());
    assertEquals("myapplication", application.getDisplayName());
    assertEquals("http://enonic.com/path/to/application", application.getUrl());
    assertEquals("Enonic AS", application.getVendorName());
    assertEquals("http://enonic.com", application.getVendorUrl());
    assertEquals(bundle, application.getBundle());
    assertTrue(application.getModifiedTime().getEpochSecond() > 0);
    assertFalse(application.isStarted());
    assertTrue(ApplicationBundleUtils.isApplication(bundle));
    assertNotNull(application.getClassLoader());
    assertEquals("[1.2.0,2.0.0)", application.getSystemVersion());
    assertEquals("2.0.0", application.getMaxSystemVersion());
    assertEquals("1.2.0", application.getMinSystemVersion());
    application.getFiles();
    Mockito.verify(urlResolver, Mockito.times(1)).findFiles();
    application.resolveFile("a/b.txt");
    Mockito.verify(urlResolver, Mockito.times(1)).findUrl("a/b.txt");
    bundle.start();
    assertTrue(application.isStarted());
}
Also used : ApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.ApplicationUrlResolver) Bundle(org.osgi.framework.Bundle) Application(com.enonic.xp.app.Application) Test(org.junit.jupiter.api.Test)

Aggregations

ApplicationUrlResolver (com.enonic.xp.core.impl.app.resolver.ApplicationUrlResolver)5 BundleApplicationUrlResolver (com.enonic.xp.core.impl.app.resolver.BundleApplicationUrlResolver)4 MultiApplicationUrlResolver (com.enonic.xp.core.impl.app.resolver.MultiApplicationUrlResolver)4 Test (org.junit.jupiter.api.Test)4 Bundle (org.osgi.framework.Bundle)4 TinyBundle (org.ops4j.pax.tinybundles.core.TinyBundle)3 Application (com.enonic.xp.app.Application)1 ClassLoaderApplicationUrlResolver (com.enonic.xp.core.impl.app.resolver.ClassLoaderApplicationUrlResolver)1