new QualifiedName(
"org.apache.torque.generator.test.readConfiguration.testParentOutlet"),
outletConfiguration.getName());
}
{
JavaOutlet filenameOutlet
= (JavaOutlet) output.getFilenameOutlet();
assertEquals("ParentFoo", filenameOutlet.getFoo());
assertEquals("ParentBar", filenameOutlet.getBar());
assertEquals(
new QualifiedName(
"org.apache.torque.generator.configuration.filenameOutlet"),
filenameOutlet.getName());
}
{
Fileset sourceFileset = new Fileset(
projectPaths.getDefaultSourcePath(),
createSetFrom("parentSource"),
new HashSet<String>());
FileSourceProvider sourceProvider = new FileSourceProvider(
new XmlSourceFormat(),
sourceFileset,
false);
output.getSourceProvider().init(
configurationHandlers,
controllerState);
sourceProvider.init(
configurationHandlers,
controllerState);
assertFileSourceProviderEquals(
sourceProvider,
(FileSourceProvider) output.getSourceProvider());
}
{
SourceProcessConfiguration sourceProcessConfiguration
= new SourceProcessConfiguration();
sourceProcessConfiguration.setStartElementsPath("parentSourceElement");
List<SourceTransformerDefinition> transformerDefinitions
= new ArrayList<SourceTransformerDefinition>();
transformerDefinitions.add(
new SourceTransformerDefinition(
new OtherConfigurationTestTransformer(),
"parent/database"));
sourceProcessConfiguration.setSourceTransformerDefinitions(
transformerDefinitions);
sourceProcessConfiguration.setSkipDecider(
"org.apache.torque.generator.configuration.OtherConfigurationTestSkipDecider");
assertSourceProcessConfigurationEquals(
sourceProcessConfiguration,
output.getSourceProcessConfiguration());
}
}
{
Output output = outputList.get(1);
assertEquals(
new QualifiedName("org.apache.torque.generator.firstOutput"),
output.getName());
assertEquals(
"skip",
output.getExistingTargetStrategy());
assertEquals(
null,
output.getOutputDirKey());
assertNull(output.getFilename());
{
OutletReference outletConfiguration
= output.getContentOutlet();
assertEquals(
new QualifiedName(
"org.apache.torque.generator.test.readConfiguration.javaOutlet"),
outletConfiguration.getName());
}
{
JavaOutlet filenameOutlet
= (JavaOutlet) output.getFilenameOutlet();
assertEquals("Foo", filenameOutlet.getFoo());
assertEquals("Bar", filenameOutlet.getBar());
assertEquals(
new QualifiedName(
"org.apache.torque.generator.configuration.filenameOutlet"),
filenameOutlet.getName());
}
{
Fileset sourceFileset = new Fileset(
projectPaths.getDefaultSourcePath(),
new HashSet<String>(),
new HashSet<String>());
FileSourceProvider sourceProvider = new FileSourceProvider(
new XmlSourceFormat(),
sourceFileset,
null);
sourceProvider.init(
configurationHandlers,
controllerState);
output.getSourceProvider().init(
configurationHandlers,
controllerState);
assertFileSourceProviderEquals(
sourceProvider,
(FileSourceProvider) output.getSourceProvider());
}
assertSourceProcessConfigurationEquals(
new SourceProcessConfiguration(),
output.getSourceProcessConfiguration());
}
{
Output output = outputList.get(2);
assertEquals(
new QualifiedName("secondOutput"),
output.getName());
assertEquals(
"replace",
output.getExistingTargetStrategy());
assertEquals(
output.getOutputDirKey(),
"secondOutputDirKey");
assertNull(output.getFilename());
{
OutletReference outletConfiguration
= output.getContentOutlet();
assertEquals(
new QualifiedName(
"org.apache.torque.generator.test.readConfiguration.anotherOutlet"),
outletConfiguration.getName());
}
{
VelocityOutlet filenameOutlet
= (VelocityOutlet) output.getFilenameOutlet();
String templateContent
= filenameOutlet.getContent(controllerState);
// remove License from template by comparing only
// the last line
String templateContentLicenseRemoved
= StringUtils.substringAfterLast(templateContent, "\r\n");
assertEquals(
"test template output",
templateContentLicenseRemoved);
assertEquals(
new QualifiedName(
"org.apache.torque.generator.configuration.filenameOutlet"),
filenameOutlet.getName());
}
{
Fileset sourceFileset = new Fileset(
projectPaths.getDefaultSourcePath(),
createSetFrom("second.source.path.properties"),
createSetFrom("second.excluded.properties"));
FileSourceProvider sourceProvider = new FileSourceProvider(
new PropertiesSourceFormat(),
sourceFileset,
true);
sourceProvider.init(
configurationHandlers,
controllerState);
output.getSourceProvider().init(
configurationHandlers,
controllerState);
assertFileSourceProviderEquals(
sourceProvider,
(FileSourceProvider) output.getSourceProvider());
}
{
SourceProcessConfiguration sourceProcessConfiguration
= new SourceProcessConfiguration();
sourceProcessConfiguration.setStartElementsPath("properties/entry");
List<SourceTransformerDefinition> transformerDefinitions
= new ArrayList<SourceTransformerDefinition>();
transformerDefinitions.add(
new SourceTransformerDefinition(
new ConfigurationTestTransformer(),
null));
transformerDefinitions.add(
new SourceTransformerDefinition(
new OtherConfigurationTestTransformer(),
"database"));
sourceProcessConfiguration.setSourceTransformerDefinitions(
transformerDefinitions);
sourceProcessConfiguration.setSkipDecider(
"org.apache.torque.generator.configuration.ConfigurationTestSkipDecider");
assertSourceProcessConfigurationEquals(
sourceProcessConfiguration,
output.getSourceProcessConfiguration());
}
}
{
Output output = outputList.get(3);
assertEquals(
new QualifiedName("thirdOutput"),
output.getName());
assertEquals(
"append",
output.getExistingTargetStrategy());
assertEquals(
"thirdOutputDirKey",
output.getOutputDirKey());
assertEquals("outputFileName", output.getFilename());
assertNull(output.getFilenameOutlet());
{
OutletReference outletConfiguration
= output.getContentOutlet();
assertEquals(
new QualifiedName(
"org.apache.torque.generator.test.readConfiguration.thirdOutlet"),
outletConfiguration.getName());
}
{
JdbcMetadataSourceProvider sourceProvider
= new JdbcMetadataSourceProvider(
"jdbcUrl",
"jdbcDriver",
"jdbcUsername",
"jdbcPassword",
"jdbcSchema");
sourceProvider.init(
configurationHandlers,
controllerState);
output.getSourceProvider().init(
configurationHandlers,
controllerState);
assertJdbcMetadataSourceProviderEquals(
sourceProvider,
(JdbcMetadataSourceProvider) output.getSourceProvider());
}
assertSourceProcessConfigurationEquals(
new SourceProcessConfiguration(),
output.getSourceProcessConfiguration());
}
}
{
OutletConfiguration outletConfiguration
= unitConfiguration.getOutletConfiguration();
Map<QualifiedName, Outlet> outletMap
= outletConfiguration.getOutlets();
assertEquals(3, outletMap.size());
{
JavaOutlet outlet
= (JavaOutlet) outletMap.get(new QualifiedName(
"org.apache.torque.generator.test.readConfiguration.javaOutlet"));
assertEquals("Foo2", outlet.getFoo());
assertEquals("Bar2", outlet.getBar());
Map<String, MergepointMapping> mergepointMappings
= outlet.getMergepointMappings();
assertEquals(3, mergepointMappings.size());
{
MergepointMapping mergepointMapping
= mergepointMappings.get("properties");
assertEquals(1, mergepointMapping.getActions().size());
MergepointAction action
= mergepointMapping.getActions().get(0);
assertEquals(
new TraverseAllAction(
"entry",
"org.apache.torque.generator.velocity.propertyCopy",
true),
action);
assertEquals("inputElement", outlet.getInputElementName());
}
{
// mergepoint from the separate mapping in child
MergepointMapping mergepointMapping
= mergepointMappings.get("mergepointName");
assertEquals(1, mergepointMapping.getActions().size());
MergepointAction action
= mergepointMapping.getActions().get(0);
assertEquals(
new ApplyAction(
null,
"someOutletAction",
false),
action);
assertEquals("inputElement", outlet.getInputElementName());
}
{
// other mergepoint from the separate mapping in child
MergepointMapping mergepointMapping
= mergepointMappings.get("mergepointFromParent");
assertEquals(1, mergepointMapping.getActions().size());
MergepointAction action
= mergepointMapping.getActions().get(0);
assertEquals(
new ApplyAction(
null,
"newOutletAction",
true),
action);
assertEquals("inputElement", outlet.getInputElementName());
}
}
{
VelocityOutlet outlet
= (VelocityOutlet) outletMap.get(new QualifiedName(
"org.apache.torque.generator.test.readConfiguration.anotherOutlet"));
String templateContent
= outlet.getContent(controllerState);
// remove License from template by comparing only
// the last line
String templateContentLicenseRemoved
= StringUtils.substringAfterLast(templateContent, "\r\n");
assertEquals(
"test template output",
templateContentLicenseRemoved);
assertEquals(0, outlet.getMergepointMappings().size());
}
{
VelocityOutlet outlet
= (VelocityOutlet) outletMap.get(new QualifiedName(
"org.apache.torque.generator.test.readConfiguration.parentOutlet"));
String templateContent
= outlet.getContent(controllerState);
// remove License from template by comparing only
// the last line
String templateContentLicenseRemoved
= StringUtils.substringAfterLast(templateContent, "\r\n");
assertEquals(
"parent test template output",
templateContentLicenseRemoved);
assertEquals(0, outlet.getMergepointMappings().size());
}
}
}