use of com.continuuity.weave.filesystem.LocalLocationFactory in project weave by continuuity.
the class ApplicationBundlerTest method testFindDependencies.
@Test
public void testFindDependencies() throws IOException, ClassNotFoundException {
Location location = new LocalLocationFactory(tmpDir.newFolder()).create("test.jar");
// Create a jar file with by tracing dependency
ApplicationBundler bundler = new ApplicationBundler(ImmutableList.<String>of());
bundler.createBundle(location, ApplicationBundler.class);
File targetDir = tmpDir.newFolder();
unjar(new File(location.toURI()), targetDir);
// Load the class back, it should be loaded by the custom classloader
ClassLoader classLoader = createClassLoader(targetDir);
Class<?> clz = classLoader.loadClass(ApplicationBundler.class.getName());
Assert.assertSame(classLoader, clz.getClassLoader());
// For system classes, they shouldn't be packaged, hence loaded by different classloader.
clz = classLoader.loadClass(Object.class.getName());
Assert.assertNotSame(classLoader, clz.getClassLoader());
}
Aggregations