public class DataChannelProjectLoaderTest extends TestCase {
public void testLoad() {
DataChannelProjectLoader loader = new DataChannelProjectLoader();
Module testModule = new Module() {
public void configure(Binder binder) {
binder.bind(DataMapLoader.class).to(XMLDataMapLoader.class);
binder.bind(DataChannelDescriptorLoader.class).to(
XMLDataChannelDescriptorLoader.class);
binder.bind(ConfigurationNameMapper.class).to(
DefaultConfigurationNameMapper.class);
}
};
Injector injector = DIBootstrap.createInjector(testModule);
injector.injectMembers(loader);
String testConfigName = "PROJECT1";
String baseUrl = getClass().getPackage().getName().replace('.', '/');
URL url = getClass().getClassLoader().getResource(
baseUrl + "/cayenne-" + testConfigName + ".xml");
Resource rootSource = new URLResource(url);
Project project = loader.loadProject(rootSource);
assertNotNull(project);
DataChannelDescriptor rootNode = (DataChannelDescriptor) project.getRootNode();
assertNotNull(rootNode);
assertSame(rootSource, rootNode.getConfigurationSource());