You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2010/02/24 20:33:20 UTC
svn commit: r915943 - in /db/torque/torque4/trunk/torque-generator/src:
main/java/org/apache/torque/gf/configuration/controller/
main/java/org/apache/torque/gf/file/ main/java/org/apache/torque/gf/source/
main/resources/org/apache/torque/gf/configurati...
Author: tfischer
Date: Wed Feb 24 19:33:20 2010
New Revision: 915943
URL: http://svn.apache.org/viewvc?rev=915943&view=rev
Log:
changed configuration xsd such that several source file includes and excludes can be specified for one output
Modified:
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/controller/SourceConfigurationTags.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/controller/SourceSaxHandler.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/file/Fileset.java
db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/FileSourcesImpl.java
db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/gf/configuration/configuration.xsd
db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gf-parent/conf/control.xml
db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gf/conf/control.xml
db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/conf/control.xml
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/configuration/ReadConfigurationTest.java
db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/file/FilesetTest.java
db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gf/conf/control.xml
db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gf/conf/control.xml
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/controller/SourceConfigurationTags.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/controller/SourceConfigurationTags.java?rev=915943&r1=915942&r2=915943&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/controller/SourceConfigurationTags.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/controller/SourceConfigurationTags.java Wed Feb 24 19:33:20 2010
@@ -37,9 +37,6 @@
/** Attribute name for the "type" attribute. */
public static final String TYPE_ATTRIBUTE = "type";
- /** Attribute name for the "path" attribute. */
- public static final String PATH_ATTRIBUTE = "path";
-
/** Attribute name for the "elements" attribute. */
public static final String ELEMENTS_ATTRIBUTE = "elements";
@@ -51,4 +48,11 @@
/** Tag name for the "class" attribute of the "transformer" tag. */
public static final String TRANSFORMER_CLASS_ATTRIBUTE = "class";
+
+ /** Tag name for the "transformer" tag. */
+ public static final String INCLUDE_TAG = "include";
+
+ /** Tag name for the "transformer" tag. */
+ public static final String EXCLUDE_TAG = "exclude";
+
}
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/controller/SourceSaxHandler.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/controller/SourceSaxHandler.java?rev=915943&r1=915942&r2=915943&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/controller/SourceSaxHandler.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/configuration/controller/SourceSaxHandler.java Wed Feb 24 19:33:20 2010
@@ -20,13 +20,15 @@
*/
import static org.apache.torque.gf.configuration.controller.SourceConfigurationTags.ELEMENTS_ATTRIBUTE;
-import static org.apache.torque.gf.configuration.controller.SourceConfigurationTags.PATH_ATTRIBUTE;
import static org.apache.torque.gf.configuration.controller.SourceConfigurationTags.SOURCE_FILTER_ATTRIBUTE;
import static org.apache.torque.gf.configuration.controller.SourceConfigurationTags.SOURCE_TAG;
import static org.apache.torque.gf.configuration.controller.SourceConfigurationTags.TRANSFORMER_TAG;
import static org.apache.torque.gf.configuration.controller.SourceConfigurationTags.TYPE_ATTRIBUTE;
+import static org.apache.torque.gf.configuration.controller.SourceConfigurationTags.INCLUDE_TAG;
+import static org.apache.torque.gf.configuration.controller.SourceConfigurationTags.EXCLUDE_TAG;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -34,6 +36,7 @@
import org.apache.torque.gf.configuration.ConfigurationHandlers;
import org.apache.torque.gf.configuration.ConfigurationProvider;
import org.apache.torque.gf.configuration.paths.ProjectPaths;
+import org.apache.torque.gf.file.Fileset;
import org.apache.torque.gf.source.FileSourcesImpl;
import org.apache.torque.gf.source.SourceType;
import org.apache.torque.gf.source.Sources;
@@ -59,8 +62,17 @@
/** The file type of the sources element which is currently parsed. */
private String type;
- /** The file path of the sources element which is currently parsed. */
- private String path;
+ /** The source file names which should be included in generation. */
+ private Set<String> includes = new HashSet<String>();
+
+ /** The source file names which should be excluded from generation. */
+ private Set<String> excludes = new HashSet<String>();
+
+ /** Whether an include tag is currently parsed. */
+ private boolean inInclude = false;
+
+ /** Whether an exclude tag is currently parsed. */
+ private boolean inExclude = false;
/**
* The start elements path of the sources element
@@ -149,15 +161,17 @@
else if (rawName.equals(SOURCE_TAG))
{
type = attributes.getValue(TYPE_ATTRIBUTE);
- path = attributes.getValue(PATH_ATTRIBUTE);
- if (path == null)
- {
- throw new SAXException(
- "path must not be null for source");
- }
startElementsPath = attributes.getValue(ELEMENTS_ATTRIBUTE);
sourceFilter = attributes.getValue(SOURCE_FILTER_ATTRIBUTE);
}
+ else if (rawName.equals(INCLUDE_TAG))
+ {
+ inInclude = true;
+ }
+ else if (rawName.equals(EXCLUDE_TAG))
+ {
+ inExclude = true;
+ }
else
{
throw new SAXException("Unknown element " + rawName);
@@ -185,6 +199,14 @@
transformerSaxHandler = null;
}
}
+ else if (rawName.equals(INCLUDE_TAG))
+ {
+ inInclude = false;
+ }
+ else if (rawName.equals(EXCLUDE_TAG))
+ {
+ inExclude = false;
+ }
else if (rawName.equals(SOURCE_TAG))
{
try
@@ -208,14 +230,17 @@
+ " Known types are: " + sourceTypes);
}
}
+ Fileset fileset = new Fileset(
+ projectPaths.getDefaultSourcePath(),
+ includes,
+ excludes);
sources = new FileSourcesImpl(
sourceType,
- path,
+ fileset,
startElementsPath,
sourceFilter,
transformerDefinitions,
- configurationHandlers,
- projectPaths.getDefaultSourcePath());
+ configurationHandlers);
}
catch (ConfigurationException e)
{
@@ -238,6 +263,24 @@
{
transformerSaxHandler.characters(ch, start, length);
}
+ else if (inInclude)
+ {
+ StringBuilder include = new StringBuilder();
+ for (int i = start; i < start + length; ++i)
+ {
+ include.append(ch[i]);
+ }
+ includes.add(include.toString());
+ }
+ else if (inExclude)
+ {
+ StringBuilder exclude = new StringBuilder();
+ for (int i = start; i < start + length; ++i)
+ {
+ exclude.append(ch[i]);
+ }
+ excludes.add(exclude.toString());
+ }
}
/**
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/file/Fileset.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/file/Fileset.java?rev=915943&r1=915942&r2=915943&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/file/Fileset.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/file/Fileset.java Wed Feb 24 19:33:20 2010
@@ -141,7 +141,7 @@
public List<File> getFiles() throws IOException
{
List<File> result = new ArrayList<File>();
- if (includes == null)
+ if (includes == null || includes.isEmpty())
{
getAllFiles(basedir, result);
return result;
@@ -405,4 +405,12 @@
}
return normalizedParts;
}
+
+ @Override
+ public String toString()
+ {
+ return "Fileset [basedir=" + basedir
+ + ", excludes=" + excludes
+ + ", includes=" + includes + "]";
+ }
}
Modified: db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/FileSourcesImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/FileSourcesImpl.java?rev=915943&r1=915942&r2=915943&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/FileSourcesImpl.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/java/org/apache/torque/gf/source/FileSourcesImpl.java Wed Feb 24 19:33:20 2010
@@ -22,7 +22,6 @@
import java.io.File;
import java.io.IOException;
import java.util.Collections;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -46,10 +45,8 @@
*/
private SourceType type;
- /**
- * The path to the file(s).
- */
- private String path;
+ /** The fileset defining the source files. */
+ private Fileset sourceFileset;
/** The paths of all contained Files. */
private List<File> paths;
@@ -67,14 +64,12 @@
*
* @param type the source type, or null if the source type should
* be determined from the file extension.
- * @param path the path to the file(s) to read, not null.
+ * @param sourceFileset the fileset defining the source files, not null.
* @param elements the path to the source elements to read, or null
* if the root element should be used.
* @param sourceFilter the fully qualified class name of the source filter,
* or null. The referenced class must have a standard constructor.
* @param configurationHandlers All known configuration handlers, not null.
- * @param sourcesDir The directory where the sources should be read from,
- * not null.
*
* @throws IllegalArgumentException if the source type is unknown.
* @throws NullPointerException if path is null.
@@ -83,41 +78,30 @@
*/
public FileSourcesImpl(
SourceType type,
- String path,
+ Fileset sourceFileset,
String elements,
String sourceFilter,
List<TransformerDefinition> transformerDefinitions,
- ConfigurationHandlers configurationHandlers,
- File sourcesDir)
+ ConfigurationHandlers configurationHandlers)
throws ConfigurationException
{
super(elements, sourceFilter, transformerDefinitions);
- if (path == null)
+ if (sourceFileset == null)
{
- throw new NullPointerException("path must not be null");
+ throw new NullPointerException("sourceFileset must not be null");
}
if (configurationHandlers == null)
{
throw new NullPointerException(
"configurationHandlers must not be null");
}
- if (sourcesDir == null)
- {
- throw new NullPointerException("sourcesDir must not be null");
- }
this.type = type;
- this.path = path;
+ this.sourceFileset = sourceFileset;
this.configurationHandlers = configurationHandlers;
- Fileset fileset = new Fileset();
- fileset.setBasedir(sourcesDir);
- Set<String> includes = new HashSet<String>();
- includes.add(path);
- fileset.setIncludes(includes);
-
try
{
- paths = fileset.getFiles();
+ paths = sourceFileset.getFiles();
}
catch (IOException e)
{
@@ -181,7 +165,7 @@
public String toString()
{
StringBuffer result = new StringBuffer();
- result.append("(path=").append(path)
+ result.append("(sourceFileset=").append(sourceFileset)
.append(",type=").append(type)
.append(",sourceFilter=").append(getSourceFilter())
.append(",startElementsPath=").append(getStartElementsPath())
@@ -195,10 +179,45 @@
{
return type;
}
+
+ /**
+ * Returns all included source file patterns, or null or an empty set
+ * if all files are included.
+ *
+ * @return all included file patterns, or null.
+ */
+ public Set<String> getIncludes()
+ {
+ if (sourceFileset.getIncludes() == null)
+ {
+ return null;
+ }
+ return Collections.unmodifiableSet(sourceFileset.getIncludes());
+ }
- public String getPath()
+ /**
+ * Returns all excluded source file patterns, or null or an empty set
+ * if no files are excluded.
+ *
+ * @return all excluded file patterns, or null.
+ */
+ public Set<String> getExcludes()
+ {
+ if (sourceFileset.getExcludes() == null)
+ {
+ return null;
+ }
+ return Collections.unmodifiableSet(sourceFileset.getExcludes());
+ }
+
+ /**
+ * Returns the base directory for the source files.
+ *
+ * @return the base directory for the source files, or null.
+ */
+ public File getBasedir()
{
- return path;
+ return sourceFileset.getBasedir();
}
public List<File> getPaths()
Modified: db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/gf/configuration/configuration.xsd
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/gf/configuration/configuration.xsd?rev=915943&r1=915942&r2=915943&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/gf/configuration/configuration.xsd (original)
+++ db/torque/torque4/trunk/torque-generator/src/main/resources/org/apache/torque/gf/configuration/configuration.xsd Wed Feb 24 19:33:20 2010
@@ -101,12 +101,22 @@
</attribute>
</complexType>
- <complexType name="source">
+ <complexType name="fileset">
<sequence>
- <element name="transformer" type="configuration:transformer" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="include" type="string" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="exclude" type="string" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
- <attribute name="type" type="string" use="optional"/>
- <attribute name="path" type="string" use="required"/>
+ </complexType>
+
+ <complexType name="source">
+ <complexContent>
+ <extension base="configuration:fileset">
+ <sequence>
+ <element name="transformer" type="configuration:transformer" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="type" type="string" use="optional"/>
+ </extension>
+ </complexContent>
</complexType>
<complexType name="transformer">
Modified: db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gf-parent/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gf-parent/conf/control.xml?rev=915943&r1=915942&r2=915943&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gf-parent/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gf-parent/conf/control.xml Wed Feb 24 19:33:20 2010
@@ -30,12 +30,17 @@
<foo>ParentFoo</foo>
<bar>ParentBar</bar>
</filenameGenerator>
- <source element="sourceElement" path="parentSource" type="xml"/>
+ <source element="sourceElement" type="xml">
+ <include>parentSource</include>
+ </source>
<generator name="org.apache.torque.gf.test.readConfiguration.testParentGenerator"/>
</output>
<output name="secondOutput">
<filenameGenerator xsi:type="velocityGenerator" path="testTemplate.vm"/>
- <source path="parentSource" type="properties"/>
+ <source path="parentSource" type="properties">
+ <include>secondParentSource</include>
+ <exclude>secondParentExclude</exclude>
+ </source>
<generator name="org.apache.torque.gf.test.readConfiguration.parentGenerator"/>
</output>
</control>
Modified: db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gf/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gf/conf/control.xml?rev=915943&r1=915942&r2=915943&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gf/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/configuration/src/main/torque-gf/conf/control.xml Wed Feb 24 19:33:20 2010
@@ -30,16 +30,22 @@
<foo>Foo</foo>
<bar>Bar</bar>
</filenameGenerator>
- <source path="source" type="xml"/>
+ <source type="xml"/>
<generator name="org.apache.torque.gf.test.readConfiguration.javaGenerator"/>
</output>
<output name="secondOutput">
<filenameGenerator xsi:type="velocityGenerator" path="testTemplate.vm"/>
- <source elements="properties/entry" path="secondSourcePath" type="properties"/>
+ <source elements="properties/entry" type="properties">
+ <include>second.source.path.properties</include>
+ <exclude>second.excluded.properties</exclude>
+ </source>
<generator name="org.apache.torque.gf.test.readConfiguration.anotherGenerator"/>
</output>
<output name="thirdOutput" file="outputFileName">
- <source path="third.source.path.properties"/>
+ <source>
+ <include>third.source.path.properties</include>
+ <exclude>third.excluded.properties</exclude>
+ </source>
<generator name="org.apache.torque.gf.test.readConfiguration.thirdGenerator"/>
</output>
</control>
Modified: db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/conf/control.xml?rev=915943&r1=915942&r2=915943&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/deeplyNestedMergepoints/src/main/torque-gf/conf/control.xml Wed Feb 24 19:33:20 2010
@@ -23,7 +23,9 @@
xsi:schemaLocation="http://db.apache.org/torque/gf/4.0/configuration http://db.apache.org/torque/gf/4.0/configuration.xsd"
xmlns="http://db.apache.org/torque/gf/4.0/configuration">
<output name="output" file="output.txt">
- <source element="sourceElement" path="source.xml" type="xml"/>
+ <source element="sourceElement" type="xml">
+ <include>source.xml</include>
+ </source>
<generator name="nestingGenerator0"/>
</output>
</control>
Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/configuration/ReadConfigurationTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/configuration/ReadConfigurationTest.java?rev=915943&r1=915942&r2=915943&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/configuration/ReadConfigurationTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/configuration/ReadConfigurationTest.java Wed Feb 24 19:33:20 2010
@@ -28,8 +28,10 @@
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.torque.gf.BaseTest;
@@ -48,6 +50,7 @@
import org.apache.torque.gf.control.action.ApplyAction;
import org.apache.torque.gf.control.action.MergepointAction;
import org.apache.torque.gf.control.action.TraverseAllAction;
+import org.apache.torque.gf.file.Fileset;
import org.apache.torque.gf.generator.Generator;
import org.apache.torque.gf.java.JavaGenerator;
import org.apache.torque.gf.option.Option;
@@ -196,14 +199,17 @@
}
{
+ Fileset sourceFileset = new Fileset(
+ projectPaths.getDefaultSourcePath(),
+ new HashSet<String>(),
+ new HashSet<String>());
FileSourcesImpl sources = new FileSourcesImpl(
new XmlSourceType(),
- "source",
+ sourceFileset,
null,
null,
new ArrayList<TransformerDefinition>(),
- configurationHandlers,
- projectPaths.getDefaultSourcePath());
+ configurationHandlers);
assertSourcesEquals(
sources,
(FileSourcesImpl) outputFile.getSources());
@@ -252,14 +258,17 @@
}
{
+ Fileset sourceFileset = new Fileset(
+ projectPaths.getDefaultSourcePath(),
+ createSetFrom("second.source.path.properties"),
+ createSetFrom("second.excluded.properties"));
FileSourcesImpl sources = new FileSourcesImpl(
new PropertiesSourceType(),
- "secondSourcePath",
+ sourceFileset,
"properties/entry",
null,
new ArrayList<TransformerDefinition>(),
- configurationHandlers,
- projectPaths.getDefaultSourcePath());
+ configurationHandlers);
assertSourcesEquals(
sources,
(FileSourcesImpl) outputFile.getSources());
@@ -286,14 +295,17 @@
assertFalse(outputFile.isSkipIfExists());
{
+ Fileset sourceFileset = new Fileset(
+ projectPaths.getDefaultSourcePath(),
+ createSetFrom("third.source.path.properties"),
+ createSetFrom("third.excluded.properties"));
FileSourcesImpl sources = new FileSourcesImpl(
null,
- "third.source.path.properties",
+ sourceFileset,
null,
null,
new ArrayList<TransformerDefinition>(),
- configurationHandlers,
- projectPaths.getDefaultSourcePath());
+ configurationHandlers);
assertSourcesEquals(
sources,
(FileSourcesImpl) outputFile.getSources());
@@ -613,14 +625,17 @@
}
{
+ Fileset sourceFileset = new Fileset(
+ projectPaths.getDefaultSourcePath(),
+ createSetFrom("parentSource"),
+ new HashSet<String>());
FileSourcesImpl sources = new FileSourcesImpl(
new XmlSourceType(),
- "parentSource",
+ sourceFileset,
null,
null,
new ArrayList<TransformerDefinition>(),
- configurationHandlers,
- projectPaths.getDefaultSourcePath());
+ configurationHandlers);
assertSourcesEquals(
sources,
(FileSourcesImpl) outputFile.getSources());
@@ -656,14 +671,17 @@
}
{
+ Fileset sourceFileset = new Fileset(
+ projectPaths.getDefaultSourcePath(),
+ new HashSet<String>(),
+ new HashSet<String>());
FileSourcesImpl sources = new FileSourcesImpl(
new XmlSourceType(),
- "source",
+ sourceFileset,
null,
null,
new ArrayList<TransformerDefinition>(),
- configurationHandlers,
- projectPaths.getDefaultSourcePath());
+ configurationHandlers);
assertSourcesEquals(
sources,
(FileSourcesImpl) outputFile.getSources());
@@ -708,14 +726,17 @@
}
{
+ Fileset sourceFileset = new Fileset(
+ projectPaths.getDefaultSourcePath(),
+ createSetFrom("second.source.path.properties"),
+ createSetFrom("second.excluded.properties"));
FileSourcesImpl sources = new FileSourcesImpl(
new PropertiesSourceType(),
- "secondSourcePath",
+ sourceFileset,
"properties/entry",
null,
new ArrayList<TransformerDefinition>(),
- configurationHandlers,
- projectPaths.getDefaultSourcePath());
+ configurationHandlers);
assertSourcesEquals(
sources,
(FileSourcesImpl) outputFile.getSources());
@@ -739,14 +760,17 @@
assertEquals("outputFileName", outputFile.getFilename());
assertNull(outputFile.getFilenameGenerator());
{
+ Fileset sourceFileset = new Fileset(
+ projectPaths.getDefaultSourcePath(),
+ createSetFrom("third.source.path.properties"),
+ createSetFrom("third.excluded.properties"));
FileSourcesImpl sources = new FileSourcesImpl(
null,
- "third.source.path.properties",
+ sourceFileset,
null,
null,
new ArrayList<TransformerDefinition>(),
- configurationHandlers,
- projectPaths.getDefaultSourcePath());
+ configurationHandlers);
assertSourcesEquals(
sources,
(FileSourcesImpl) outputFile.getSources());
@@ -872,10 +896,33 @@
expected.getType(),
actual.getType());
assertEquals(
- expected.getPath(),
- actual.getPath());
+ expected.getIncludes(),
+ actual.getIncludes());
+ assertEquals(
+ expected.getExcludes(),
+ actual.getExcludes());
+ assertEquals(
+ expected.getBasedir(),
+ actual.getBasedir());
assertEquals(
expected.getPaths(),
actual.getPaths());
}
+
+ /**
+ * Creates as set containing the Strings in content.
+ *
+ * @param content The Strings which should be in the set.
+ *
+ * @return the Set containing all the strings.
+ */
+ private static Set<String> createSetFrom(String... content)
+ {
+ Set<String> result = new HashSet<String>();
+ for (String part : content)
+ {
+ result.add(part);
+ }
+ return result;
+ }
}
Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/file/FilesetTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/file/FilesetTest.java?rev=915943&r1=915942&r2=915943&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/file/FilesetTest.java (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/gf/file/FilesetTest.java Wed Feb 24 19:33:20 2010
@@ -123,7 +123,7 @@
{
Fileset fileset = new Fileset(
TEST_BASE_DIR,
- getSetWith("1.properties"),
+ createSetFrom("1.properties"),
null);
assertFileListEquals(
fileset,
@@ -135,7 +135,7 @@
{
Fileset fileset = new Fileset(
TEST_BASE_DIR,
- getSetWith("subfolder/2.properties"),
+ createSetFrom("subfolder/2.properties"),
null);
assertFileListEquals(
fileset,
@@ -147,7 +147,7 @@
{
Fileset fileset = new Fileset(
TEST_BASE_DIR,
- getSetWith("subfolder/subsubfolder\\3.properties"),
+ createSetFrom("subfolder/subsubfolder\\3.properties"),
null);
assertFileListEquals(
fileset,
@@ -159,7 +159,7 @@
{
Fileset fileset = new Fileset(
TEST_BASE_DIR,
- getSetWith("*//2.properties"),
+ createSetFrom("*//2.properties"),
null);
assertFileListEquals(
fileset,
@@ -171,7 +171,7 @@
{
Fileset fileset = new Fileset(
TEST_BASE_DIR,
- getSetWith("?.properties"),
+ createSetFrom("?.properties"),
null);
assertFileListEquals(
fileset,
@@ -183,7 +183,7 @@
{
Fileset fileset = new Fileset(
TEST_BASE_DIR,
- getSetWith("*.properties"),
+ createSetFrom("*.properties"),
null);
assertFileListEquals(
fileset,
@@ -196,7 +196,7 @@
{
Fileset fileset = new Fileset(
TEST_BASE_DIR,
- getSetWith("subfolder/../1.properties"),
+ createSetFrom("subfolder/../1.properties"),
null);
assertFileListEquals(
fileset,
@@ -208,7 +208,7 @@
{
Fileset fileset = new Fileset(
new File(TEST_BASE_DIR, "subfolder"),
- getSetWith("../1.properties"),
+ createSetFrom("../1.properties"),
null);
assertFileListEquals(
fileset,
@@ -222,7 +222,7 @@
*
* @return the Set containing all the strings.
*/
- private static Set<String> getSetWith(String... content)
+ private static Set<String> createSetFrom(String... content)
{
Set<String> result = new HashSet<String>();
for (String part : content)
@@ -259,12 +259,37 @@
}
@Test
+ public void testFilelistAllEmpty() throws IOException
+ {
+ Fileset fileset = new Fileset(
+ TEST_BASE_DIR,
+ new HashSet<String>(),
+ new HashSet<String>());
+ List<File> fileList = fileset.getFiles();
+ Iterator<File> fileIt = fileList.iterator();
+ while (fileIt.hasNext())
+ {
+ File file = fileIt.next();
+ if (file.getPath().indexOf(".svn") != -1)
+ {
+ fileIt.remove();
+ }
+ }
+ assertFileListEquals(
+ fileList,
+ new File(TEST_BASE_DIR, "1.properties"),
+ new File(TEST_BASE_DIR, "11.properties"),
+ new File(TEST_BASE_DIR, "package.html"),
+ new File(TEST_BASE_DIR, "subfolder/2.properties"),
+ new File(TEST_BASE_DIR, "subfolder/subsubfolder/3.properties"));
+ }
+ @Test
public void testFilelistExcludeInBasedir() throws IOException
{
Fileset fileset = new Fileset(
TEST_BASE_DIR,
- getSetWith("*"),
- getSetWith("11.properties"));
+ createSetFrom("*"),
+ createSetFrom("11.properties"));
assertFileListEquals(
fileset,
new File(TEST_BASE_DIR, "./package.html"),
@@ -276,8 +301,8 @@
{
Fileset fileset = new Fileset(
TEST_BASE_DIR,
- getSetWith("subfolder/*"),
- getSetWith("subfolder/2.properties"));
+ createSetFrom("subfolder/*"),
+ createSetFrom("subfolder/2.properties"));
assertFileListEquals(
fileset,
new File[] {});
@@ -288,8 +313,8 @@
{
Fileset fileset = new Fileset(
TEST_BASE_DIR,
- getSetWith("subfolder/*"),
- getSetWith("subfolder\\2.properties"));
+ createSetFrom("subfolder/*"),
+ createSetFrom("subfolder\\2.properties"));
assertFileListEquals(
fileset,
new File[] {});
@@ -300,8 +325,8 @@
{
Fileset fileset = new Fileset(
TEST_BASE_DIR,
- getSetWith("subfolder/*"),
- getSetWith("*/2.properties"));
+ createSetFrom("subfolder/*"),
+ createSetFrom("*/2.properties"));
assertFileListEquals(
fileset,
new File[] {});
@@ -312,8 +337,8 @@
{
Fileset fileset = new Fileset(
TEST_BASE_DIR,
- getSetWith("subfolder/*"),
- getSetWith("su??old?r/2.properties"));
+ createSetFrom("subfolder/*"),
+ createSetFrom("su??old?r/2.properties"));
assertFileListEquals(
fileset,
new File[] {});
@@ -324,8 +349,8 @@
{
Fileset fileset = new Fileset(
TEST_BASE_DIR,
- getSetWith("subfolder/*"),
- getSetWith("su??old?r/./2.properties"));
+ createSetFrom("subfolder/*"),
+ createSetFrom("su??old?r/./2.properties"));
assertFileListEquals(
fileset,
new File[] {});
@@ -336,8 +361,8 @@
{
Fileset fileset = new Fileset(
TEST_BASE_DIR,
- getSetWith("*"),
- getSetWith("subfolder/../11.properties"));
+ createSetFrom("*"),
+ createSetFrom("subfolder/../11.properties"));
assertFileListEquals(
fileset,
new File(TEST_BASE_DIR, "./package.html"),
@@ -349,8 +374,8 @@
{
Fileset fileset = new Fileset(
new File(TEST_BASE_DIR, "subfolder"),
- getSetWith("../*"),
- getSetWith("../1.properties", ".././package.html"));
+ createSetFrom("../*"),
+ createSetFrom("../1.properties", ".././package.html"));
assertFileListEquals(
fileset,
new File(TEST_BASE_DIR, "subfolder/../11.properties"));
Modified: db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gf/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gf/conf/control.xml?rev=915943&r1=915942&r2=915943&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gf/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/propertyToJava/src/main/torque-gf/conf/control.xml Wed Feb 24 19:33:20 2010
@@ -34,7 +34,9 @@
<action xsi:type="optionAction" option="package" />
</mergepoint>
</filenameGenerator>
- <source element="properties" path="propertiesData.properties"/>
+ <source element="properties">
+ <include>propertiesData.properties</include>
+ </source>
<generator name="org.apache.torque.gf.velocity.propertiesToJava" />
</output>
<output name="extendingClass">
@@ -47,11 +49,15 @@
<action xsi:type="optionAction" option="package" />
</mergepoint>
</filenameGenerator>
- <source element="properties" path="propertiesData.properties"/>
+ <source element="properties">
+ <include>propertiesData.properties</include>
+ </source>
<generator name="org.apache.torque.gf.velocity.propertiesExtendedToJava" />
</output>
<output name="properties" file="Properties.properties">
- <source element="properties" path="propertiesData.properties"/>
+ <source element="properties">
+ <include>propertiesData.properties</include>
+ </source>
<generator name="org.apache.torque.gf.velocity.propertiesCopy"/>
</output>
</control>
Modified: db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gf/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gf/conf/control.xml?rev=915943&r1=915942&r2=915943&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gf/conf/control.xml (original)
+++ db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gf/conf/control.xml Wed Feb 24 19:33:20 2010
@@ -25,7 +25,9 @@
loglevel="debug">
<output name="propertyKeys"
file="org/apache/torque/gf/example/gettingstarted/PropertyKeys.java">
- <source path="propertiesData.properties"/>
+ <source>
+ <include>propertiesData.properties</include>
+ </source>
<generator name="classFrame"/>
</output>
</control>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org