environment.setConfigId(configId);
ArtifactManager artifactManager = new DefaultArtifactManager();
ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, Collections.EMPTY_SET, null);
SimpleConfigurationManager configurationManager = new SimpleConfigurationManager(Collections.EMPTY_SET, artifactResolver, Collections.EMPTY_SET);
DeploymentContext context = new DeploymentContext(basedir, null, environment, null, ConfigurationModuleType.CAR, new Jsr77Naming(), configurationManager, Collections.EMPTY_SET);
Enhancer enhancer = new Enhancer();
enhancer.setInterfaces(new Class[]{DataSource.class});
enhancer.setCallbackType(MethodInterceptor.class);
enhancer.setStrategy(new DefaultGeneratorStrategy() {
public byte[] transform(byte[] b) {
classBytes = b;
return b;
}
});
enhancer.setClassLoader(new URLClassLoader(new URL[0], this.getClass().getClassLoader()));
Class type = enhancer.createClass();
URI location = new URI("cglib/");
context.addClass(location, type.getName(), classBytes);
ClassLoader cl = context.getClassLoader();
Class loadedType = cl.loadClass(type.getName());
assertTrue(DataSource.class.isAssignableFrom(loadedType));