<?xml version="1.0" encoding="UTF-8"?>\r
<project default="javadoc">\r
<target name="javadoc">\r
-<javadoc access="public" author="true" classpath="lib/commons-logging.jar;lib/ant-launcher.jar;lib/spring-2.0.6.jar;lib/ant.jar" destdir="doc" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" packagenames="org.argeo.slc.ant,org.argeo.slc.core.structure.tree,org.argeo.slc.core.test,org.argeo.slc.ant.test,org.argeo.slc.core.structure,org.argeo.slc.ant.spring,org.argeo.slc.ant.structure" source="1.5" sourcepath="src/test/java;src/main/java" splitindex="true" use="true" version="true"/>\r
+<javadoc access="public" author="true" classpath="lib/jta.jar;lib/commons-logging.jar;lib/ant-launcher.jar;lib/hibernate3.jar;lib/spring-2.0.6.jar;lib/commons-collections-2.1.1.jar;C:\eclipse\plugins\org.junit_3.8.2.v200706111738\junit.jar;lib/ant.jar;lib/commons-pool.jar;lib/commons-lang.jar;lib/dom4j-1.6.1.jar;lib/log4j-1.2.14.jar;lib/asm.jar;lib/hsqldb.jar;lib/commons-dbcp.jar;lib/cglib-2.1.3.jar;lib/antlr-2.7.6.jar;lib/asm-attrs.jar" destdir="doc" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" packagenames="org.argeo.slc.core.structure.tree,org.argeo.slc.ant,org.argeo.slc.ant.test,org.argeo.slc.core,org.argeo.slc.ant.spring,org.argeo.slc.dao.test,org.argeo.slc.ant.structure,org.argeo.slc.core.deploy,org.argeo.slc.core.build,org.argeo.slc.core.test,org.argeo.slc.core.structure,org.argeo.slc.hibernate.test.tree,org.argeo.slc.core.test.tree" source="1.5" sourcepath="src/test/java;src/main/java" splitindex="true" use="true" version="true"/>\r
</target>\r
</project>\r
\r
import java.io.File;\r
import java.util.List;\r
-import java.util.Vector;\r
\r
import org.apache.commons.logging.Log;\r
import org.apache.commons.logging.LogFactory;\r
public class AntRegistryUtil {\r
private static Log log = LogFactory.getLog(AntRegistryUtil.class);\r
\r
- /** Read a structure registry from an Ant file without executing it. */\r
+ /** Reads a structure registry from an Ant file without executing it. */\r
public static StructureRegistry readRegistry(File antFile) {\r
-\r
+ if (log.isDebugEnabled())\r
+ log.debug("Reads registry for Ant file " + antFile);\r
Project p = new Project();\r
p.setUserProperty("ant.file", antFile.getAbsolutePath());\r
p.setBaseDir(antFile.getParentFile());\r
return registry;\r
}\r
\r
- /** Execute only the active paths of the Ant file. */\r
+ /** Executes only the active paths of the Ant file. */\r
public static void runActive(File antFile, List<StructurePath> activePaths) {\r
-\r
+ if (log.isDebugEnabled())\r
+ log.debug("Runs the " + activePaths.size()\r
+ + " provided active paths of Ant file " + antFile);\r
Project p = new Project();\r
p.setUserProperty("ant.file", antFile.getAbsolutePath());\r
p.setBaseDir(antFile.getParentFile());\r
p.executeTarget(p.getDefaultTarget());\r
}\r
\r
- /** Execute all paths of the default target of the Ant file. */\r
+ /** Executes all paths of the default target of the Ant file. */\r
public static void runAll(File antFile) {\r
+ if (log.isDebugEnabled())\r
+ log.debug("Runs all paths of Ant file " + antFile);\r
Project p = new Project();\r
p.setUserProperty("ant.file", antFile.getAbsolutePath());\r
p.setBaseDir(antFile.getParentFile());\r
helper.parse(p, antFile);\r
p.executeTarget(p.getDefaultTarget());\r
}\r
-\r
- public static void main(String[] args) {\r
- File antFile = new File(\r
- "C:/dev/workspaces/default/org.argeo.slc/src/test/slc/root/Category1/SubCategory2/build.xml");\r
- StructureRegistry registry = AntRegistryUtil.readRegistry(antFile);\r
-\r
- StringBuffer buf = new StringBuffer("");\r
-\r
- int count = 0;\r
- List<StructurePath> activePaths = new Vector<StructurePath>();\r
- for (StructurePath path : registry.listPaths()) {\r
- buf.append(path);\r
- if (count != 0 && count % 3 == 0) {\r
- // skip\r
- } else {\r
- activePaths.add(path);\r
- buf.append(" <");\r
- }\r
- buf.append('\n');\r
- count++;\r
- }\r
- log.info(buf);\r
-\r
- runActive(antFile, activePaths);\r
-\r
- }\r
}\r
import java.io.File;\r
import java.io.FileInputStream;\r
import java.io.IOException;\r
+import java.util.Map;\r
import java.util.Properties;\r
import java.util.StringTokenizer;\r
\r
\r
import org.apache.tools.ant.Project;\r
\r
-/** Load reference to directories from an slcRoot.properties file */\r
+import org.argeo.slc.core.test.WritableTestRun;\r
+\r
+/**\r
+ * <p>\r
+ * Manager and initializer of the properties required by SLC Ant.\r
+ * </p>\r
+ * \r
+ * <p>\r
+ * All properties described here will get a value one way or another (see below\r
+ * for details)/ Each property will be accessible via Ant or Spring properties.\r
+ * </p>\r
+ * \r
+ * <p>\r
+ * The property <i>slc.rootFile</i> is set based on the location of the SLC\r
+ * root property file found in the directory structure of a called Ant file. The\r
+ * default name of this file is <b>slcRoot.properties</b> (can be set by\r
+ * {@link #setSlcRootFileName(String)}). <br>\r
+ * This property provides the absolute path to the unique SLC root property file\r
+ * which marks the root of an Ant SLC tree structure.\r
+ * </p>\r
+ * \r
+ * <p>\r
+ * The property <i>slc.rootDir</i> is inferred from <i>slc.rootFile</i> and\r
+ * provides a convenient shortcut to the root directory of the Ant files\r
+ * directory structure.\r
+ * </p>\r
+ * \r
+ * <p>\r
+ * A few directory and file related properties can be set in the SLC root\r
+ * property file (if they are not explicitly set their default values will be\r
+ * used):\r
+ * \r
+ * <table border="1" cellspacing="0">\r
+ * <tr>\r
+ * <th>Property</th>\r
+ * <th>Description</th>\r
+ * <th>Default</th>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><i>slc.confDir</i></td>\r
+ * <td>Directory where to find the various configuration files of a given SLC\r
+ * Ant deployment</td>\r
+ * <td>${slc.rootDir}/../conf</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><i>slc.workDir</i></td>\r
+ * <td>Directory where data can be retrieved or generated: build outputs, test\r
+ * inputs/outputs, test results, etc. The underlying directory structure is\r
+ * specified by the specific SLC application.</td>\r
+ * <td>${slc.rootDir}/../work</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><i>slc.propertyFileNames</i></td>\r
+ * <td>Comma-separated list of the files names of the property files to load\r
+ * from the conf directory. Having various files allows to separate between SLC\r
+ * framework properties and properties specific to a given application built on\r
+ * top of SLC. All will be available across Ant and Spring.</td>\r
+ * <td>slc.properties</td>\r
+ * </tr>\r
+ * </table> <b>Note:</b> Only the properties above can be set in the SLC root\r
+ * properties file. All other properties should be defined in the registered\r
+ * conf files.\r
+ * </p>\r
+ * \r
+ * <p>\r
+ * Any property can be defined in the conf files defined in the SLC root\r
+ * properties file (see above). SLC expects some which will have defaults but\r
+ * can be overriden there. By convention they should be defined in the\r
+ * <b>slc.properties</b> file, while application specific properties should be\r
+ * defined in other conf files. This allows for a clean spearation between SLC\r
+ * and the applications built on top of it:\r
+ * \r
+ * <table border="1" cellspacing="0">\r
+ * <tr>\r
+ * <th>Property</th>\r
+ * <th>Description</th>\r
+ * <th>Default</th>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><i>slc.applicationContext</i></td>\r
+ * <td>Path to the root Spring application context file used by SLC Ant.</td>\r
+ * <td>${slc.confDir}/applicationContext.xml</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><i>slc.defaultTestRun</i></td>\r
+ * <td>Name of the {@link WritableTestRun} Spring bean that the\r
+ * <code>slc.test</code> task will use by default. This can be overridden when\r
+ * calling the task from Ant.</td>\r
+ * <td>defaultTestRun</td>\r
+ * </tr>\r
+ * </table>\r
+ * </p>\r
+ */\r
public class SlcAntConfig {\r
// SLC ROOT PROPERTIES\r
public final static String ROOT_FILE_PROPERTY = "slc.rootFile";\r
// SLC LOCAL PROPERTIES\r
public static String DIR_DESCRIPTION_PROPERTY = "slc.dirDescription";\r
\r
+ private String slcRootFileName = "slcRoot.properties";\r
+ private String slcLocalFileName = "slcLocal.properties";\r
+\r
/**\r
- * Retrieve all properties and set them as project user properties. Root\r
- * properties (that is from slcRoot file) are added to System properties\r
- * (e.g. in order to be used by Spring)\r
+ * Retrieves or infers all properties and set them as project user\r
+ * properties. All these properties will be set as project properties <b>if\r
+ * they had not been set as project properties before</b> (like by\r
+ * overriding through the standard Ant mechanisms).\r
+ * \r
+ * @param project\r
+ * the Ant <code>Project</code> being run.\r
*/\r
- public static void initProject(Project project, File slcRootFile) {\r
- System.getProperties().putAll(project.getUserProperties());\r
- System.setProperty(ROOT_FILE_PROPERTY, slcRootFile.getAbsolutePath());\r
- Properties all = prepareAllProperties();\r
+ public void initProject(Project project) {\r
+ File projectBaseDir = project.getBaseDir();\r
+ File slcRootFile = findSlcRootFile(projectBaseDir);\r
+ if (slcRootFile == null) {\r
+ throw new SlcAntException("Cannot find SLC root file");\r
+ }\r
+ // pass the project properties through the System properties\r
+ System.getProperties().putAll((Map<?, ?>) project.getUserProperties());\r
+ Properties all = prepareAllProperties(slcRootFile);\r
for (Object o : all.keySet()) {\r
String key = o.toString();\r
if (project.getUserProperty(key) == null) {// not already set\r
}\r
}\r
\r
- public static Properties prepareAllProperties() {\r
+ /**\r
+ * Retrieves or infers all required properties.\r
+ * \r
+ * @param slcRootFile\r
+ * the location of the SLC root file\r
+ * \r
+ * @return the prepared properties. Note that it also contains the System\r
+ * and Ant properties which had previously been set.\r
+ */\r
+ protected Properties prepareAllProperties(File slcRootFile) {\r
try {\r
Properties all = new Properties();\r
all.putAll(System.getProperties());\r
+ all.put(ROOT_FILE_PROPERTY, slcRootFile.getCanonicalPath());\r
\r
- if (all.getProperty(ROOT_FILE_PROPERTY) == null) {\r
- throw new RuntimeException("System Property "\r
- + ROOT_FILE_PROPERTY + " has to be set.");\r
- }\r
-\r
- File slcRootFile = new File(all.getProperty(ROOT_FILE_PROPERTY))\r
- .getAbsoluteFile();\r
- Properties rootProps = loadFile(slcRootFile.getAbsolutePath());\r
+ Properties rootProps = loadFile(slcRootFile.getCanonicalPath());\r
\r
final File confDir;\r
final File workDir;\r
PROPERTY_FILE_NAMES_PROPERTY, "slc.properties"), ",");\r
while (st.hasMoreTokens()) {\r
String fileName = st.nextToken();\r
- properties.putAll(loadFile(confDir.getAbsolutePath() + File.separator\r
- + fileName));\r
+ properties.putAll(loadFile(confDir.getAbsolutePath()\r
+ + File.separator + fileName));\r
}\r
\r
for (Object o : properties.keySet()) {\r
\r
// Default log4j\r
if (all.getProperty("log4j.configuration") == null) {\r
- System.setProperty("log4j.configuration",confDir\r
+ System.setProperty("log4j.configuration", confDir\r
.getCanonicalPath()\r
- + File.separator + "log4j.properties" );\r
+ + File.separator + "log4j.properties");\r
// TODO: fix dependency to log4j\r
- Log4jConfigurer.initLogging(confDir\r
- .getCanonicalPath()\r
+ Log4jConfigurer.initLogging(confDir.getCanonicalPath()\r
+ File.separator + "log4j.properties");\r
}\r
\r
}\r
}\r
\r
- public static Properties loadFile(String path) {\r
+ /** Loads the content of a file as <code>Properties</code>. */\r
+ private Properties loadFile(String path) {\r
Properties p = new Properties();\r
try {\r
FileInputStream in = new FileInputStream(path);\r
return p;\r
}\r
\r
+ /**\r
+ * Looks for a file named {@link #getSlcLocalFileName()} in the directory,\r
+ * loads it as properties file and return the value of the property\r
+ * {@link #DIR_DESCRIPTION_PROPERTY}.\r
+ */\r
+ public String getDescriptionForDir(File dir) {\r
+ String description = dir.getName();\r
+ File slcLocal = new File(dir.getPath() + File.separator\r
+ + getSlcLocalFileName());\r
+ if (slcLocal.exists()) {\r
+ Properties properties = loadFile(slcLocal.getAbsolutePath());\r
+ description = properties.getProperty(\r
+ SlcAntConfig.DIR_DESCRIPTION_PROPERTY, description);\r
+ }\r
+ return description;\r
+ }\r
+\r
+ /**\r
+ * Recursively scans directories downwards until it find a file names as\r
+ * defined by {@link #getSlcRootFileName()}.\r
+ */\r
+ public File findSlcRootFile(File dir) {\r
+ for (File file : dir.listFiles()) {\r
+ if (!file.isDirectory()\r
+ && file.getName().equals(getSlcRootFileName())) {\r
+ return file;\r
+ }\r
+ }\r
+\r
+ File parentDir = dir.getParentFile();\r
+ if (parentDir == null) {\r
+ return null;// stop condition: not found\r
+ } else {\r
+ return findSlcRootFile(parentDir);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Gets the file name of the file marking the root directory, default being\r
+ * <i>slcRoot.properties</i>.\r
+ */\r
+ public String getSlcRootFileName() {\r
+ return slcRootFileName;\r
+ }\r
+\r
+ /** Sets the file name of the file marking the root directory. */\r
+ public void setSlcRootFileName(String slcRootFileName) {\r
+ this.slcRootFileName = slcRootFileName;\r
+ }\r
+\r
+ /**\r
+ * Gets the file name of the file containing directory specific properties,\r
+ * default being <i>slcLocal.properties</i>.\r
+ */\r
+ public String getSlcLocalFileName() {\r
+ return slcLocalFileName;\r
+ }\r
+\r
+ /** Sets the file name of the file containing directory specific properties. */\r
+ public void setSlcLocalFileName(String slcLocalFileName) {\r
+ this.slcLocalFileName = slcLocalFileName;\r
+ }\r
+\r
}\r
\r
import org.argeo.slc.core.SlcException;\r
\r
+/** Base for all SLC Ant exceptions. */\r
public class SlcAntException extends SlcException {\r
static final long serialVersionUID = 1l;\r
\r
import java.io.IOException;\r
import java.io.InputStream;\r
import java.util.List;\r
+import java.util.Map;\r
import java.util.Properties;\r
import java.util.Vector;\r
\r
import org.argeo.slc.core.structure.tree.TreeSPath;\r
\r
/**\r
- * Custom implementation of a <code>ProjectHelper</code> binding a Spring\r
+ * Custom implementation of an Ant <code>ProjectHelper</code> binding a Spring\r
* application context and a structure registry with the Ant project.\r
*/\r
public class SlcProjectHelper extends ProjectHelperImpl {\r
- private static Log log ;\r
+ private static Log log;\r
\r
+ /** The Ant reference to the Spring application context used. */\r
public static String REF_ROOT_CONTEXT = "slcApplicationContext";\r
+ /** The Ant reference to the SLC structure registry used. */\r
public static String REF_STRUCTURE_REGISTRY = "slcStructureRegistry";\r
- public static String REF_PROJECT_PATH = "slcProjectPath";\r
-\r
- private String slcRootFileName = "slcRoot.properties";\r
- private String slcLocalFileName = "slcLocal.properties";\r
+ /** The Ant reference to the <code>TreePath</code> of the current project */\r
+ private static String REF_PROJECT_PATH = "slcProjectPath";\r
+ /**\r
+ * Resource path to the property file listing the SLC specific Ant tasks:\r
+ * /org/argeo/slc/ant/taskdefs.properties\r
+ */\r
+ private static String SLC_TASKDEFS_RESOURCE_PATH = "/org/argeo/slc/ant/taskdefs.properties";\r
\r
@Override\r
public void parse(Project project, Object source) throws BuildException {\r
\r
- // look for root file\r
- File projectBaseDir = project.getBaseDir();\r
- File slcRootFile = findSlcRootFile(projectBaseDir);\r
- if (slcRootFile == null) {\r
- throw new SlcAntException("Cannot find SLC root file");\r
- }\r
- SlcAntConfig.initProject(project, slcRootFile);\r
- \r
- if(log == null){\r
+ // initialize config\r
+ SlcAntConfig slcAntConfig = new SlcAntConfig();\r
+ slcAntConfig.initProject(project);\r
+\r
+ if (log == null) {\r
// log4j is initialized only now\r
log = LogFactory.getLog(SlcProjectHelper.class);\r
}\r
\r
// init Spring application context\r
initSpringContext(project);\r
- \r
+\r
// init structure registry\r
DefaultSRegistry registry = new DefaultSRegistry();\r
project.addReference(REF_STRUCTURE_REGISTRY, registry);\r
super.parse(project, source);\r
\r
// create structure root\r
- registerProjectAndParents(project);\r
+ registerProjectAndParents(project, slcAntConfig);\r
\r
addSlcTasks(project);\r
\r
}\r
\r
- private void registerProjectAndParents(Project project) {\r
+ /** Creates the tree-based structure for this project. */\r
+ private void registerProjectAndParents(Project project,\r
+ SlcAntConfig slcAntConfig) {\r
StructureRegistry registry = (StructureRegistry) project\r
.getReference(REF_STRUCTURE_REGISTRY);\r
File rootDir = new File(project\r
do {\r
dirs.add(currentDir);\r
currentDir = currentDir.getParentFile();\r
- log.trace("List " + currentDir);\r
+ if (log.isTraceEnabled())\r
+ log.trace("List " + currentDir);\r
} while (!currentDir.equals(rootDir.getParentFile()));\r
\r
- TreeSPath currPath = null;\r
+ // first path is root dir (because of previous algorithm)\r
+ TreeSPath currPath = TreeSPath.createRootPath(rootDir.getName());\r
for (int i = dirs.size() - 1; i >= 0; i--) {\r
File dir = dirs.get(i);\r
\r
- String description = dir.getName();\r
- File slcLocal = new File(dir.getPath() + File.separator\r
- + slcLocalFileName);\r
- if (slcLocal.exists()) {\r
- Properties properties = SlcAntConfig.loadFile(slcLocal\r
- .getAbsolutePath());\r
- description = properties\r
- .getProperty(SlcAntConfig.DIR_DESCRIPTION_PROPERTY);\r
+ // retrieves description for this path\r
+ final String description;\r
+ if (i == 0) {// project itself\r
+ description = project.getDescription() != null ? project\r
+ .getDescription() : "";\r
} else {\r
- if (i == 0) {// project it self\r
- description = project.getDescription() != null ? project\r
- .getDescription() : "";\r
- }\r
+ description = slcAntConfig.getDescriptionForDir(dir);\r
}\r
SimpleSElement element = new SimpleSElement(description);\r
\r
- if (dir.equals(rootDir)) {\r
- currPath = TreeSPath.createRootPath(rootDir.getName());\r
- } else {\r
+ // creates and register path\r
+ if (!dir.equals(rootDir)) {// already set\r
currPath = currPath.createChild(dir.getName());\r
}\r
registry.register(currPath, element);\r
project.addReference(REF_PROJECT_PATH, currPath);\r
}\r
\r
- /** Get the path of a project (root). */\r
+ /** Gets the path of a project (root). */\r
public static TreeSPath getProjectPath(Project project) {\r
return (TreeSPath) project.getReference(REF_PROJECT_PATH);\r
}\r
\r
- private File findSlcRootFile(File dir) {\r
- for (File file : dir.listFiles()) {\r
- if (!file.isDirectory() && file.getName().equals(slcRootFileName)) {\r
- return file;\r
- }\r
- }\r
-\r
- File parentDir = dir.getParentFile();\r
- if (parentDir == null) {\r
- return null;// stop condition: not found\r
- } else {\r
- return findSlcRootFile(parentDir);\r
- }\r
- }\r
-\r
+ /** Initializes the Spring application context. */\r
private void initSpringContext(Project project) {\r
- System.getProperties().putAll(project.getProperties());\r
+ System.getProperties().putAll((Map<?, ?>) project.getProperties());\r
String acPath = project\r
.getUserProperty(SlcAntConfig.APPLICATION_CONTEXT_PROPERTY);\r
- AbstractApplicationContext context = new FileSystemXmlApplicationContext(acPath);\r
+ AbstractApplicationContext context = new FileSystemXmlApplicationContext(\r
+ acPath);\r
context.registerShutdownHook();\r
project.addReference(REF_ROOT_CONTEXT, context);\r
}\r
\r
+ /** Loads the SLC specific Ant tasks. */\r
private void addSlcTasks(Project project) {\r
Properties taskdefs = new Properties();\r
try {\r
InputStream in = project.getClass().getResourceAsStream(\r
- "/org/argeo/slc/ant/taskdefs.properties");\r
+ SLC_TASKDEFS_RESOURCE_PATH);\r
taskdefs.load(in);\r
in.close();\r
} catch (IOException e) {\r
<head></head>\r
<body>\r
Bases classes for SLC Ant extensions.\r
-<h2>Usage of SLC Ant extensions</h2>\r
-Add:\r
-<pre>\r
-<taskdef resource="org/argeo/slc/ant/taskdefs.properties" />\r
-</pre>\r
-at the beginning of your file.\r
+<h2>Introduction</h2>\r
+SLC Ant allows to integrate Ant and Spring in order to run an\r
+application based on top of SLC. Sequence of actions are defined in Ant\r
+files with specific Ant tasks referencing Spring beans implementing the\r
+SLC interfaces. The properties of these beans can be overridden at\r
+runtime in the Ant scripts.\r
+<br />\r
+SLC Ant also provides a tree-based implementation of the SLC structure\r
+which allows to uniquely identify and reference the various actions.\r
\r
+<h2>Installation</h2>\r
+The structure will be first defined by the directory tree where the Ant\r
+files are stored. In order to define the root of this tree, you need to\r
+place in the root directory an\r
+<b>SLC Ant root file</b>\r
+(default name: slcRoot.properties).\r
+<br />\r
+In this root file you can define a configuration directory and a work\r
+directory (default values are provided if they are not explicitly set).\r
+<br />\r
+Additional properties can then be defined in files stored under the\r
+configuration directory.\r
+<br />\r
+For details about the configuration and the various properties, please\r
+refer to {@link org.argeo.slc.ant.SlcAntConfig}.\r
+\r
+<h2>Running SLC Ant</h2>\r
+SLC Ant can be run either via pure Ant scripts or programmatically using\r
+{@link org.argeo.slc.ant.AntRegistryUtil}. In both cases, make sure that\r
+SLC and its dependencies are in the classpath (Spring (always), logging\r
+system such as log4j, Hibernate, etc.).\r
\r
</body>\r
</html>
\ No newline at end of file
}\r
\r
/**\r
- * Retrieve the instance of the bean. <b>The value is cached.</b>\r
+ * Retrieve the instance of the bean, and sets the overriden properties.\r
+ * <b>The value is cached.</b>\r
*/\r
public Object getBeanInstance() {\r
if (beanInstance == null) {\r
\r
import org.argeo.slc.ant.SlcProjectHelper;\r
\r
-/** Abstract Ant task providing access to a Spring context.*/\r
+/** Abstract Ant task providing access to a Spring context. */\r
public abstract class AbstractSpringTask extends Task {\r
\r
- /** Gets the related Spring context.*/\r
+ /** Gets the related Spring context. */\r
protected ApplicationContext getContext() {\r
return (ApplicationContext) getProject().getReference(\r
SlcProjectHelper.REF_ROOT_CONTEXT);\r
package org.argeo.slc.ant.spring;\r
\r
+import java.util.List;\r
+import java.util.Vector;\r
+\r
import org.apache.tools.ant.BuildException;\r
\r
/** Ant type allowing to override bean properties. */\r
public class OverrideArg extends AbstractSpringArg {\r
private String name;\r
private Object value;\r
+ private OverrideList overrideList;\r
\r
- /** The nbame of the property to override. */\r
+ /** The name of the property to override. */\r
public String getName() {\r
return name;\r
}\r
\r
/** Both value and bean cannot be set. */\r
public void setValue(String value) {\r
- if (getBean() != null) {\r
- throw new BuildException(\r
- "Cannot set both 'bean' and 'value' attributes.");\r
+ if (getBean() != null || overrideList != null) {\r
+ throw new BuildException("Value already set.");\r
}\r
this.value = value;\r
}\r
\r
@Override\r
public void setBean(String bean) {\r
- if (value != null) {\r
- throw new BuildException(\r
- "Cannot set both 'bean' and 'value' attributes.");\r
+ if (value != null || overrideList != null) {\r
+ throw new BuildException("Value already set.");\r
}\r
super.setBean(bean);\r
}\r
\r
+ public OverrideList createList() {\r
+ if (value != null || getBean() != null) {\r
+ throw new BuildException("Value already set.");\r
+ }\r
+ if (overrideList == null) {\r
+ overrideList = new OverrideList();\r
+ } else {\r
+ throw new BuildException("Only one list can be declared");\r
+ }\r
+ return overrideList;\r
+ }\r
+\r
/**\r
* The related object: the value if a value had been set or an instance of\r
* the bean if not.\r
return value;\r
} else if (getBean() != null) {\r
return getBeanInstance();\r
+ } else if (overrideList != null) {\r
+ return overrideList.getAsObjectList();\r
} else {\r
throw new BuildException("Value or bean not set.");\r
}\r
}\r
\r
+ /** List of overrides */\r
+ protected class OverrideList {\r
+ private List<OverrideArg> list = new Vector<OverrideArg>();\r
+\r
+ public OverrideArg createOverride() {\r
+ OverrideArg overrideArg = new OverrideArg();\r
+ list.add(overrideArg);\r
+ return overrideArg;\r
+ }\r
+\r
+ public List<Object> getAsObjectList() {\r
+ List<Object> objectList = new Vector<Object>();\r
+ for (OverrideArg arg : list) {\r
+ objectList.add(arg.getObject());\r
+ }\r
+ return objectList;\r
+ }\r
+ }\r
}\r
--- /dev/null
+<html>\r
+<head></head>\r
+<body>\r
+Integration of Spring in Ant.\r
+</body>\r
+</html>
\ No newline at end of file
}\r
}\r
\r
+ /**\r
+ * Includes this arg in the checks for propagation of sstructure related\r
+ * information.\r
+ */\r
protected void addSAwareArg(AbstractSpringArg arg) {\r
sAwareArgs.add(arg);\r
}\r
return projectPath.createChild(target.getName());\r
}\r
\r
+ /** Gets the path under which this task is registered. */\r
public TreeSPath getPath() {\r
return path;\r
}\r
--- /dev/null
+<html>\r
+<head></head>\r
+<body>\r
+Integration of SLC structure in Ant.\r
+</body>\r
+</html>
\ No newline at end of file
import org.argeo.slc.core.test.TestReport;\r
import org.argeo.slc.core.test.TestResult;\r
\r
+/** Ant tasks closing a given result, and optionally generating a report. */\r
public class SlcCloseTestResultTask extends SAwareTask {\r
private String result;\r
private String report;\r
\r
+ @Override\r
public void executeActions(String mode) {\r
if (!mode.equals(StructureRegistry.READ)) {\r
TestResult testResult = (TestResult) getContext().getBean(result);\r
}\r
}\r
\r
+ /** Sets the bean name of the result to close. */\r
public void setResult(String bean) {\r
this.result = bean;\r
}\r
\r
+ /** Sets the bean name of the report to generate. */\r
public void setReport(String report) {\r
this.report = report;\r
}\r
\r
/** Ant task wrapping a test run. */\r
public class SlcTestTask extends SAwareTask {\r
- Log log = LogFactory.getLog(SlcTestTask.class);\r
+ private Log log = LogFactory.getLog(SlcTestTask.class);\r
+\r
+ private String testRunBean = null;\r
\r
private TestDefinitionArg testDefinitionArg;\r
private TestDataArg testDataArg;\r
\r
@Override\r
public void executeActions(String mode) throws BuildException {\r
+ final String testRunBeanT;\r
+ if (testRunBean != null) {\r
+ testRunBeanT = testRunBean;\r
+ } else {\r
+ testRunBeanT = getProject().getUserProperty(\r
+ SlcAntConfig.DEFAULT_TEST_RUN_PROPERTY);\r
+ }\r
WritableTestRun testRun = (WritableTestRun) getContext().getBean(\r
- getProject().getUserProperty(\r
- SlcAntConfig.DEFAULT_TEST_RUN_PROPERTY));\r
+ testRunBeanT);\r
\r
- // set overriden references\r
- if (testDataArg != null){\r
+ // set overridden references\r
+ if (testDataArg != null) {\r
testRun.setTestData(testDataArg.getTestData());\r
log.trace("Overrides test data");\r
}\r
- \r
- if (testDefinitionArg != null){\r
+\r
+ if (testDefinitionArg != null) {\r
testRun.setTestDefinition(testDefinitionArg.getTestDefinition());\r
log.trace("Overrides test definition");\r
}\r
- \r
- if (deployedSystemArg != null){\r
+\r
+ if (deployedSystemArg != null) {\r
testRun.setDeployedSystem(deployedSystemArg.getDeployedSystem());\r
log.trace("Overrides deployed system");\r
}\r
- \r
- if (testResultArg != null){\r
+\r
+ if (testResultArg != null) {\r
testRun.setTestResult(testResultArg.getTestResult());\r
log.trace("Overrides test result");\r
}\r
testRun.execute();\r
}\r
\r
+ /**\r
+ * The bean name of the test run to use. If not set the default is used.\r
+ * \r
+ * @see SlcAntConfig\r
+ */\r
+ public void setTestRun(String testRunBean) {\r
+ this.testRunBean = testRunBean;\r
+ }\r
+\r
public TestDefinitionArg createTestDefinition() {\r
testDefinitionArg = new TestDefinitionArg();\r
// only test definitions can add to path\r
--- /dev/null
+<html>\r
+<head></head>\r
+<body>\r
+Integration of SLC Test in Ant.\r
+</body>\r
+</html>
\ No newline at end of file
package org.argeo.slc.core;\r
\r
-/** Basis for all SLC exceptions.*/\r
+/** Basis for all SLC exceptions. This is an unchecked exception. */\r
public class SlcException extends RuntimeException {\r
static final long serialVersionUID = 1l;\r
\r
\r
import java.util.StringTokenizer;\r
\r
-\r
+/**\r
+ * <p>\r
+ * An implementation of the distribution id using the standard\r
+ * Major.Minor.Release notation. And additional arbitrary string can also be\r
+ * added.\r
+ * </p>\r
+ * \r
+ * <p>\r
+ * <b>Examples:</b><br>\r
+ * 0.2.6<br>\r
+ * 2.4.12.RC1\r
+ * </p>\r
+ */\r
public class VersionDistributionId implements DistributionId {\r
\r
private Integer major;\r
private Integer release;\r
private String additional;\r
\r
+ /** Parse the provided string in order to set the various components. */\r
public void setVersionString(String str) {\r
StringTokenizer st = new StringTokenizer(str, ".");\r
if (st.hasMoreTokens())\r
--- /dev/null
+<html>\r
+<head></head>\r
+<body>\r
+SLC Build: building of software systems.\r
+</body>\r
+</html>
\ No newline at end of file
package org.argeo.slc.core.deploy;\r
\r
-/** An instance of a software system.*/\r
+/** An instance of a software system. */\r
public interface DeployedSystem {\r
public DeployedSystemId getDeployedSystemId();\r
}\r
\r
import org.argeo.slc.core.build.DistributionId;\r
\r
-/** The id uniquely identifying a deployed system.*/\r
+/** The id uniquely identifying a deployed system. */\r
public interface DeployedSystemId {\r
public DistributionId getDistributionId();\r
}\r
\r
import org.argeo.slc.core.build.DistributionId;\r
\r
+/**\r
+ * A basic implementation of a deployed system id, based on a long value and a\r
+ * reference to a distribution id.\r
+ */\r
public class NumericDSId implements DeployedSystemId {\r
\r
private Long value;\r
return value.toString();\r
}\r
\r
- \r
}\r
--- /dev/null
+<html>\r
+<head></head>\r
+<body>\r
+SLC Deploy: deployment of software systems.\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head></head>\r
+<body>\r
+Common classes of teh SLC framework.\r
+</body>\r
+</html>
\ No newline at end of file
import org.apache.commons.logging.Log;\r
import org.apache.commons.logging.LogFactory;\r
\r
-/** Default implementation of a <code>StructureRegistry</code>.*/\r
+/** Default implementation of a <code>StructureRegistry</code>. */\r
public class DefaultSRegistry implements StructureRegistry {\r
private static Log log = LogFactory.getLog(DefaultSRegistry.class);\r
\r
return new Vector<StructurePath>(paths);\r
}\r
\r
- public void register(StructurePath path,StructureElement element) {\r
+ public void register(StructurePath path, StructureElement element) {\r
StructureElement treeSElement = element;\r
elements.add(treeSElement);\r
- paths.add( path);\r
+ paths.add(path);\r
log.debug("Registered " + path + " (desc: '"\r
+ treeSElement.getDescription() + "', position: "\r
+ elements.size() + ")");\r
}\r
\r
-// public void register(StructurePath path,StructureAware structureAware) {\r
-// register(path,structureAware.getElement());\r
-// structureAware.onRegister(this,path);\r
-// }\r
+ // public void register(StructurePath path,StructureAware structureAware) {\r
+ // register(path,structureAware.getElement());\r
+ // structureAware.onRegister(this,path);\r
+ // }\r
\r
public StructureElement getElement(StructurePath path) {\r
int index = paths.indexOf(path);\r
import org.argeo.slc.core.structure.tree.TreeSPath;\r
\r
/**\r
- * Implementation of <code>StructureElement</code> for tree based registries,\r
- * using <code>TreeSPath</code>\r
+ * Basic implementation of <code>StructureElement</code>.\r
* \r
* @see TreeSPath\r
*/\r
public class SimpleSElement implements StructureElement {\r
private String description;\r
\r
- public SimpleSElement(String description){\r
+ public SimpleSElement(String description) {\r
this.description = description;\r
}\r
- \r
- public SimpleSElement(String description, String defaultDescription){\r
- this(description!=null?description:defaultDescription);\r
+\r
+ public SimpleSElement(String description, String defaultDescription) {\r
+ this(description != null ? description : defaultDescription);\r
}\r
- \r
+\r
public String getDescription() {\r
return description;\r
}\r
package org.argeo.slc.core.structure;\r
\r
-/** Atomic element holding the reference to the element which is structured. */\r
+/**\r
+ * Atomic element holding metadata such as description about the element which\r
+ * registered.\r
+ */\r
public interface StructureElement {\r
/** Description of this element. */\r
public String getDescription();\r
--- /dev/null
+<html>\r
+<head></head>\r
+<body>\r
+SLC structure framework allowing to uniquely reference actions.\r
+</body>\r
+</html>
\ No newline at end of file
\r
/**\r
* Path for tree based <code>StructureRegistry</code> implementations.\r
- * \r
- * @see TreeSRegistry\r
*/\r
public class TreeSPath implements StructurePath, Comparable<StructurePath> {\r
/** Default character to use a separator: #. */\r
String parentStr = parent != null ? parent.getAsUniqueString() : "";\r
return parentStr + separator + name;\r
}\r
- \r
- public void setAsUniqueString(String str){\r
+\r
+ public void setAsUniqueString(String str) {\r
TreeSPath twin = parseToCreatePath(str, getSeparator());\r
name = twin.name;\r
parent = twin.parent;\r
return currPath;\r
}\r
\r
- public List<TreeSPath> listChildren(StructureRegistry registry){\r
+ public List<TreeSPath> listChildren(StructureRegistry registry) {\r
return listChildrenPaths(registry, this);\r
}\r
- \r
+\r
public static List<TreeSPath> listChildrenPaths(StructureRegistry registry,\r
TreeSPath path) {\r
List<TreeSPath> paths = new Vector<TreeSPath>();\r
return getAsUniqueString().compareTo(o.getAsUniqueString());\r
}\r
\r
- \r
}\r
--- /dev/null
+<html>\r
+<head></head>\r
+<body>\r
+Tree-based implementation of the SLC structure framework.\r
+</body>\r
+</html>
\ No newline at end of file
import org.argeo.slc.core.SlcException;\r
\r
/**\r
- * Excception to throw when a test definition cannot interpret the provided tets\r
+ * Exception to throw when a test definition cannot interpret the provided test\r
* data.\r
*/\r
public class IncompatibleTestDataException extends SlcException {\r
\r
import org.argeo.slc.core.deploy.DeployedSystemId;\r
\r
+/**\r
+ * Basic implementation of test run id based on a long value and a reference to\r
+ * a deployed system id.\r
+ */\r
public class NumericTRId implements TestResultId {\r
/** For ORM */\r
private Long tid;\r
\r
private Long value;\r
private DeployedSystemId deployedSystemId;\r
- \r
+\r
+ /**\r
+ * Initializes the long value with the current time (based on\r
+ * <code>java.lang.System.currentTimeMillis()</code>).\r
+ */\r
public void init() {\r
if (getValue() == null) {\r
setValue(System.currentTimeMillis());\r
}\r
}\r
\r
-\r
public Long getValue() {\r
return value;\r
}\r
void setTid(Long tid) {\r
this.tid = tid;\r
}\r
- \r
- \r
\r
}\r
package org.argeo.slc.core.test;\r
\r
+/**\r
+ * <p>\r
+ * Basic implementation of a result part, implementing the standard three status\r
+ * approach for test results.\r
+ * </p>\r
+ * <p>\r
+ * <ul>\r
+ * <li>{@link #PASSED}: the test succeeded</li>\r
+ * <li>{@link #FAILED}: the test could run, but did not reach the expected\r
+ * result</li>\r
+ * <li>{@link #ERROR}: an error during the test run prevented to get a\r
+ * significant information on the tested system.</li>\r
+ * </ul>\r
+ * </p>\r
+ */\r
public class SimpleResultPart implements TestResultPart {\r
\r
+ /** The flag for a passed test: 1 */\r
public final static int PASSED = 1;\r
+ /** The flag for a failed test: 2 */\r
public final static int FAILED = 2;\r
+ /** The flag for a test which could not properly run because of an error: 3 */\r
public final static int ERROR = 3;\r
\r
/** For ORM */\r
private Long tid;\r
- \r
+\r
private Integer status;\r
private String message;\r
private Throwable exception;\r
\r
import org.argeo.slc.core.deploy.DeployedSystem;\r
\r
+/**\r
+ * A basic bean implementation of a <code>WritableTestRun</code>, holding\r
+ * references to the various parts of a test run.\r
+ */\r
public class SimpleTestRun implements WritableTestRun {\r
private DeployedSystem deployedSystem;\r
private TestData testData;\r
private TestDefinition testDefinition;\r
private TestResult testResult;\r
\r
- public void execute(){\r
+ /** Executes the underlying test definition. */\r
+ public void execute() {\r
testDefinition.execute(this);\r
}\r
- \r
+\r
public DeployedSystem getDeployedSystem() {\r
return deployedSystem;\r
}\r
package org.argeo.slc.core.test;\r
\r
+/**\r
+ * A report that can be generated based on a given test result. <b>This\r
+ * interface may change in the future.</b>\r
+ */\r
public interface TestReport {\r
+ /** Performs the actions necessary to generate a report. */\r
public void generateTestReport(TestResult result);\r
}\r
\r
/** The result of a test */\r
public interface TestResult {\r
+ /** Gets the id of the related test result. */\r
public TestResultId getTestResultId();\r
+\r
+ /** Adds a part of the result. */\r
public void addResultPart(TestResultPart part);\r
+\r
+ /**\r
+ * Marks that the collection of test results is completed and free the\r
+ * related resources (also closing listeners).\r
+ */\r
public void close();\r
}\r
\r
import org.argeo.slc.core.deploy.DeployedSystemId;\r
\r
-/** The unique id referencing a test result.*/\r
+/** The unique id referencing a test result. */\r
public interface TestResultId {\r
+ /** Gets the id of the related deployed system. */\r
public DeployedSystemId getDeployedSystemId();\r
- \r
+\r
}\r
package org.argeo.slc.core.test;\r
\r
+/** Listener to the operations on a test result. */\r
public interface TestResultListener {\r
+ /** Notified when a part was added to a test result. */\r
public void resultPartAdded(TestResult testResult,\r
TestResultPart testResultPart);\r
+\r
+ /** Stops listening and release the related resources. */\r
public void close();\r
}\r
package org.argeo.slc.core.test;\r
\r
+/**\r
+ * Part of a test result.\r
+ * \r
+ * @see TestResult\r
+ */\r
public interface TestResultPart {\r
\r
}\r
\r
/** The actual run of a test */\r
public interface TestRun {\r
+ /** Gets the related test definition. */\r
public TestDefinition getTestDefinition();\r
\r
+ /** Gets the related test data */\r
public TestData getTestData();\r
\r
+ /** Gets the related deployed system. */\r
public DeployedSystem getDeployedSystem();\r
\r
+ /** Gets the related result where to record results. */\r
public TestResult getTestResult();\r
- \r
+\r
+ /** Executes this test run. */\r
public void execute();\r
}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-import org.argeo.slc.core.deploy.DeployedSystemId;\r
-\r
-public class TimeTestResultId extends NumericTRId {\r
- private DeployedSystemId deployedSystemId;\r
-\r
- public void init() {\r
- if (getValue() == null) {\r
- setValue(System.currentTimeMillis());\r
- }\r
- }\r
-\r
- public void setDeployedSystemId(DeployedSystemId deployedSystemId) {\r
- this.deployedSystemId = deployedSystemId;\r
- }\r
-\r
- public DeployedSystemId getDeployedSystemId() {\r
- return deployedSystemId;\r
- }\r
-}\r
\r
import org.argeo.slc.core.deploy.DeployedSystem;\r
\r
+/** Test run whose various components can be externally set. */\r
public interface WritableTestRun extends TestRun {\r
public void setDeployedSystem(DeployedSystem deployedSystem);\r
\r
--- /dev/null
+<html>\r
+<head></head>\r
+<body>\r
+SLC Test: test of software systems.\r
+</body>\r
+</html>
\ No newline at end of file
import org.argeo.slc.core.test.TestResultListener;\r
import org.argeo.slc.core.test.TestResultPart;\r
\r
+/**\r
+ * Abstract asynchronous implementation of a listener listening to a\r
+ * <code>TreeTestResult</code>.\r
+ * \r
+ * @see TreeTestResult\r
+ */\r
public abstract class AsynchronousTreeTestResultListener implements\r
TestResultListener, Runnable {\r
private Vector<PartStruct> partStructs = new Vector<PartStruct>();\r
}\r
}\r
\r
+ /** Called when a result part has been added. */\r
protected abstract void resultPartAdded(PartStruct partStruct);\r
\r
public void run() {\r
}\r
}\r
\r
+ /** Structure used to pass tree specific information to subclasses. */\r
protected static class PartStruct {\r
+ /** The tree path of this part. */\r
public final TreeSPath path;\r
+ /** The test result id of the related test result */\r
public final NumericTRId resultId;\r
+ /** The part itself */\r
public final TestResultPart part;\r
+ /** The tree test result itself. */\r
public final TreeTestResult result;\r
\r
public PartStruct(TreeSPath path, NumericTRId resultId,\r
import org.argeo.slc.core.test.TestResult;\r
import org.argeo.slc.core.test.TestRun;\r
\r
+/**\r
+ * Collection of test definitions propagating tree structure information to its\r
+ * children.\r
+ */\r
public class CompositeTreeTestDefinition implements TestDefinition,\r
StructureAware {\r
private Log log = LogFactory.getLog(CompositeTreeTestDefinition.class);\r
}\r
}\r
\r
+ /** Sets the list of children test definitions */\r
public void setTasks(List<TestDefinition> tasks) {\r
this.tasks = tasks;\r
if (tasks != null) {\r
import org.argeo.slc.core.test.TestResultPart;\r
import org.argeo.slc.dao.test.TestResultDao;\r
\r
+/**\r
+ * Basic implementation of TestReport generating static HTML pages. If a\r
+ * <code>TestResultDao</code> is passed, all the datas are dumped, otherwise\r
+ * only the passed <code>TestResult</code>.\r
+ */\r
public class FullHtmlTreeReport implements TestReport, StructureAware {\r
private TestResultDao testResultDao;\r
private File reportDir;\r
}\r
}\r
\r
+ /**\r
+ * Generates a result page for one test result\r
+ * \r
+ * @param file\r
+ * file to which generate the HTML\r
+ * @param result\r
+ * the result to dump\r
+ */\r
protected void generateResultPage(File file, TreeTestResult result) {\r
StringBuffer buf = new StringBuffer("");\r
buf.append("<html>\n");\r
}\r
}\r
\r
+ /**\r
+ * Generates a result file location based on the report dir and the id of\r
+ * the test result.\r
+ */\r
protected File getResultFile(TreeTestResult result) {\r
return new File(reportDir.getPath() + File.separator\r
+ result.getTestResultId() + ".html");\r
}\r
\r
+ /** Sets the dao to use to extract all data. */\r
public void setTestResultDao(TestResultDao testResultDao) {\r
this.testResultDao = testResultDao;\r
}\r
\r
+ /** Sets the directory where to generate all the data. */\r
public void setReportDir(File reportDir) {\r
this.reportDir = reportDir;\r
}\r
\r
import org.argeo.slc.core.test.TestResultPart;\r
\r
+/**\r
+ * List of <code>TestResultPart</code>. It can be used to build complex\r
+ * <code>TestResult</code> affording the possibility to a\r
+ * <code>TestDefinition</code> to add a list of result part under the same\r
+ * <code>StructurePath</code>.\r
+ * \r
+ * @see TreeTestResult\r
+ */\r
public class PartSubList {\r
- \r
+\r
/** For ORM */\r
private Long tid;\r
\r
this.tid = tid;\r
}\r
\r
- \r
}\r
import org.argeo.slc.core.test.TestResultListener;\r
import org.argeo.slc.core.test.TestResultPart;\r
\r
+/**\r
+ * Complex implementation of a test result compatible with a tree based\r
+ * structure.\r
+ */\r
public class TreeTestResult implements TestResult, StructureAware {\r
private Log log = LogFactory.getLog(TreeTestResult.class);\r
/** For ORM */\r
private List<TestResultListener> listeners;\r
\r
private TreeSPath currentPath;\r
- \r
+\r
private boolean isClosed = false;\r
\r
private SortedMap<TreeSPath, PartSubList> resultParts = new TreeMap<TreeSPath, PartSubList>();\r
return testResultId;\r
}\r
\r
+ /**\r
+ * Use of a <code>NumericTRId</code> is required by Hibernate. <b>It may\r
+ * change in the future.</b>\r
+ */\r
public NumericTRId getNumericResultId() {\r
return testResultId;\r
}\r
return currentPath;\r
}\r
\r
+ /** Gets all the results structured as a map of <code>PartSubList<code>s. */\r
public SortedMap<TreeSPath, PartSubList> getResultParts() {\r
return resultParts;\r
}\r
\r
+ /** Used by ORM systems. */\r
void setResultParts(SortedMap<TreeSPath, PartSubList> resultParts) {\r
this.resultParts = resultParts;\r
}\r
\r
public void close() {\r
- if(isClosed){\r
- throw new SlcException("Test Result #"+getTestResultId()+" alredy closed.");\r
+ if (isClosed) {\r
+ throw new SlcException("Test Result #" + getTestResultId()\r
+ + " alredy closed.");\r
}\r
- \r
+\r
synchronized (listeners) {\r
for (TestResultListener listener : listeners) {\r
listener.close();\r
listeners.clear();\r
}\r
isClosed = true;\r
- log.info("Test Result #"+getTestResultId()+" closed.");\r
+ log.info("Test Result #" + getTestResultId() + " closed.");\r
}\r
\r
Long getTid() {\r
import org.apache.commons.logging.Log;\r
import org.apache.commons.logging.LogFactory;\r
\r
-public class TreeTestResultLogger extends\r
- AsynchronousTreeTestResultListener {\r
+/**\r
+ * Listener logging tree-based test results to the underlying logging system.\r
+ * \r
+ * @see TreeTestResult\r
+ * \r
+ */\r
+public class TreeTestResultLogger extends AsynchronousTreeTestResultListener {\r
\r
- private static Log log = LogFactory\r
- .getLog(TreeTestResultLogger.class);\r
+ private static Log log = LogFactory.getLog(TreeTestResultLogger.class);\r
\r
@Override\r
protected void resultPartAdded(PartStruct partStruct) {\r
\r
import org.argeo.slc.dao.test.TestResultDao;\r
\r
+/**\r
+ * Listener persisting tree-based results.\r
+ * \r
+ * @see TreeTestResult\r
+ */\r
public class TreeTestResultPersister extends AsynchronousTreeTestResultListener {\r
private static Log log = LogFactory.getLog(TreeTestResultPersister.class);\r
\r
}\r
}\r
\r
+ /** Sets the dao to use in order to persist the results. */\r
public void setTestResultDao(TestResultDao testResultDao) {\r
this.testResultDao = testResultDao;\r
}\r
--- /dev/null
+<html>\r
+<head></head>\r
+<body>\r
+Extension of SLC Test integrating tree-based structure.\r
+</body>\r
+</html>
\ No newline at end of file
import org.argeo.slc.core.test.TestResult;\r
import org.argeo.slc.core.test.TestResultId;\r
\r
+/**\r
+ * The dao for <code>TestResult</code>.\r
+ * \r
+ * @see TestResult\r
+ */\r
public interface TestResultDao {\r
+ /** Gets a test result based on its id. */\r
public TestResult getTestResult(TestResultId id);\r
+\r
+ /** Persists a new test result. */\r
public void create(TestResult testResult);\r
+\r
+ /** Updates an already persisted test result. */\r
public void update(TestResult testResult);\r
+\r
+ /** Lists all test results. */\r
public List<TestResult> listTestResults();\r
}\r
--- /dev/null
+<html>\r
+<head></head>\r
+<body>\r
+Data Access Objects for SLC Test.\r
+</body>\r
+</html>
\ No newline at end of file
import org.argeo.slc.core.test.NumericTRId;\r
import org.argeo.slc.core.test.TestResult;\r
import org.argeo.slc.core.test.TestResultId;\r
+import org.argeo.slc.core.test.tree.TreeTestResult;\r
import org.argeo.slc.dao.test.TestResultDao;\r
\r
+/**\r
+ * The Hibernate implementation for tree-based result of the test result dao.\r
+ * \r
+ * @see TreeTestResult\r
+ */\r
public class TestResultDaoHibernate extends HibernateDaoSupport implements\r
TestResultDao {\r
\r
--- /dev/null
+<html>\r
+<head></head>\r
+<body>\r
+Hibernate based dao implementation for tree-based SLC Test.\r
+</body>\r
+</html>
\ No newline at end of file
try {\r
// execute\r
appli.filter(args);\r
- \r
+\r
executePart.setStatus(SimpleResultPart.PASSED);\r
} catch (Exception e) {\r
executePart.setStatus(SimpleResultPart.ERROR);\r
executePart.setException(e);\r
}\r
result.addResultPart(executePart);\r
- if(executePart.getStatus()==SimpleResultPart.ERROR){\r
+ if (executePart.getStatus() == SimpleResultPart.ERROR) {\r
return;\r
}\r
\r
}\r
String input = args[0];\r
String output = args[1];\r
- if(args.length>2){\r
+ if (args.length > 2) {\r
skipFreq = Integer.parseInt(args[2]);\r
}\r
\r
File antFile = new File(slcBaseDir.getPath()\r
+ "/root/Category1/SubCategory2/build.xml");\r
AntRegistryUtil.runAll(antFile);\r
- \r
+\r
}\r
}\r
<property name="deployedSystem" ref="exampleDeployedSystem" />\r
</bean>\r
\r
+ <bean id="otherTestRun"\r
+ class="org.argeo.slc.core.test.SimpleTestRun" scope="prototype">\r
+ <property name="testResult" ref="testResult2" />\r
+ <property name="deployedSystem" ref="exampleDeployedSystem" />\r
+ </bean>\r
+\r
<bean id="testResult"\r
class="org.argeo.slc.core.test.tree.TreeTestResult">\r
<property name="numericResultId" ref="testResultId" />\r
<testData bean="testData.un" />\r
</slc.test>\r
\r
- <slc.test description="EU-reform">\r
+ <slc.test description="EU-reform" testRun="otherTestRun">\r
<testDefinition bean="simpleExampleTestDef" />\r
<testData bean="testData.eu-reform" />\r
</slc.test>\r
- \r
+\r
<slc.test description="Distinct test">\r
<testDefinition bean="simpleExampleTestDef" />\r
<testData bean="testData.eu-reform" />\r
- <deployedSystem bean="exampleDeployedSystem2"/>\r
- <testResult bean="testResult2"/>\r
+ <deployedSystem bean="exampleDeployedSystem2" />\r
+ <testResult bean="testResult2" />\r
</slc.test>\r
\r
</target>\r
<testDefinition bean="complexExampleTestDef" />\r
<testData bean="testData.un" />\r
</slc.test>\r
+ <slc.test description="Complex overridden">\r
+ <testDefinition bean="complexExampleTestDef">\r
+ <override name="tasks">\r
+ <list>\r
+ <override bean="dummyTask" />\r
+ </list>\r
+ </override>\r
+ </testDefinition>\r
+ <testData bean="testData.un" />\r
+ </slc.test>\r
</target>\r
\r
</project>
\ No newline at end of file