return suite(InMemoryClasesUnitTestCase.class);
}
public void testInMemory() throws Exception
{
DeployerClient mainDeployer = getMainDeployer();
MainDeployerStructure main = (MainDeployerStructure) mainDeployer;
Version v1 = Version.parseVersion("1");
Deployment ad = createDeployment("A");
ClassLoadingMetaData clmd = addClassLoadingMetaData(ad, v1, true, A.class);
clmd.setBlackListable(false);
assertDeploy(mainDeployer, ad);
VFSDeploymentUnit unit = (VFSDeploymentUnit) main.getDeploymentUnit("A");
VirtualFile file = unit.getAttachment(InMemoryClassesDeployer.DYNAMIC_CLASS_KEY, VirtualFile.class);
assertNotNull(file);
assertTrue("dynamic classes should be in the classpath", unit.getClassPath().contains(file));
URL root = unit.getAttachment(InMemoryClassesDeployer.DYNAMIC_CLASS_URL_KEY, URL.class);
assertNotNull(root);
String aPackage = A.class.getPackage().getName();
aPackage = aPackage.replace(".", "/");
String resourceName = aPackage + "/TestInMemory";
URL testResource = new URL(root, resourceName);
ClassLoader cl = unit.getClassLoader();
assertNull(cl.getResource(resourceName));
byte[] bytes = new byte[0];
MemoryFileFactory.putFile(testResource, bytes);
URL resource = cl.getResource(resourceName);
assertNotNull(resource);
// dunno why direct URL equals fails?
assertEquals(testResource.toExternalForm(), resource.toExternalForm());
mainDeployer.undeploy(ad);
mainDeployer.checkComplete();
assertFalse("dynamic classes should NOT be in the classpath", unit.getClassPath().contains(file));
}