Search in sources :

Example 1 with ClassLoaderApplicationUrlResolver

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

the class MockApplication method setResourcePath.

public void setResourcePath(final Path resourcePath) {
    final URL url;
    try {
        url = resourcePath.toUri().toURL();
    } catch (MalformedURLException e) {
        throw new UncheckedIOException(e);
    }
    final URLClassLoader loader = new URLClassLoader(new URL[] { url }, null);
    this.urlResolver = new ClassLoaderApplicationUrlResolver(loader);
}
Also used : ClassLoaderApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.ClassLoaderApplicationUrlResolver) MalformedURLException(java.net.MalformedURLException) URLClassLoader(java.net.URLClassLoader) UncheckedIOException(java.io.UncheckedIOException) URL(java.net.URL)

Example 2 with ClassLoaderApplicationUrlResolver

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

the class ScriptTestSupport method createApplication.

private Application createApplication() throws Exception {
    final ApplicationBuilder builder = new ApplicationBuilder();
    builder.classLoader(getClass().getClassLoader());
    URL[] resourcesPath = { Path.of("src/test/resources").toUri().toURL() };
    URLClassLoader loader = new URLClassLoader(resourcesPath, ClassLoader.getPlatformClassLoader());
    builder.urlResolver(new ClassLoaderApplicationUrlResolver(loader));
    builder.config(ConfigBuilder.create().build());
    builder.bundle(createBundle());
    return builder.build();
}
Also used : ClassLoaderApplicationUrlResolver(com.enonic.xp.core.impl.app.resolver.ClassLoaderApplicationUrlResolver) ApplicationBuilder(com.enonic.xp.core.impl.app.ApplicationBuilder) URLClassLoader(java.net.URLClassLoader) URL(java.net.URL)

Aggregations

ClassLoaderApplicationUrlResolver (com.enonic.xp.core.impl.app.resolver.ClassLoaderApplicationUrlResolver)2 URL (java.net.URL)2 URLClassLoader (java.net.URLClassLoader)2 ApplicationBuilder (com.enonic.xp.core.impl.app.ApplicationBuilder)1 UncheckedIOException (java.io.UncheckedIOException)1 MalformedURLException (java.net.MalformedURLException)1