Search in sources :

Example 6 with PluginsClassLoader

use of org.ligoj.app.resource.plugin.PluginsClassLoader in project plugin-prov by ligoj.

the class TerraformResourceTest method toFile.

@Test
public void toFile() throws IOException {
    ThreadClassLoaderScope scope = null;
    try {
        final PluginsClassLoader classLoader = Mockito.mock(PluginsClassLoader.class);
        scope = new ThreadClassLoaderScope(new URLClassLoader(new URL[0], classLoader));
        final File file = new File("");
        final Subscription entity = new Subscription();
        entity.setId(15);
        Mockito.when(classLoader.toFile(entity, "15", "some")).thenReturn(file);
        Assertions.assertSame(file, resource.toFile(entity, "some"));
        Assertions.assertNotNull(PluginsClassLoader.getInstance());
    } finally {
        IOUtils.closeQuietly(scope);
    }
}
Also used : URLClassLoader(java.net.URLClassLoader) ThreadClassLoaderScope(org.eclipse.jetty.util.thread.ThreadClassLoaderScope) Subscription(org.ligoj.app.model.Subscription) PluginsClassLoader(org.ligoj.app.resource.plugin.PluginsClassLoader) File(java.io.File) AbstractAppTest(org.ligoj.app.AbstractAppTest) Test(org.junit.jupiter.api.Test)

Aggregations

PluginsClassLoader (org.ligoj.app.resource.plugin.PluginsClassLoader)6 Test (org.junit.jupiter.api.Test)3 File (java.io.File)2 AbstractAppTest (org.ligoj.app.AbstractAppTest)2 Subscription (org.ligoj.app.model.Subscription)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 URLClassLoader (java.net.URLClassLoader)1 ThreadClassLoaderScope (org.eclipse.jetty.util.thread.ThreadClassLoaderScope)1 AbstractServerTest (org.ligoj.app.AbstractServerTest)1 QuoteVo (org.ligoj.app.plugin.prov.QuoteVo)1 ServicePluginLocator (org.ligoj.app.resource.ServicePluginLocator)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1