<version>0.9-SNAPSHOT</version>
<relativePath>../org.argeo.slc</relativePath>
</parent>
- <artifactId>argeo-slc-core</artifactId>
- <name>Argeo SLC Core</name>
- <description>SLC Core</description>
+ <artifactId>argeo-slc-hibernate</artifactId>
+ <name>Argeo SLC Hibernate</name>
<scm>
<connection>
- scm:svn:https://www.argeo.org/svn/slc/trunk/org.argeo.slc.core
+ scm:svn:https://www.argeo.org/svn/slc/trunk/org.argeo.slc.hibernate
</connection>
- <url>
- https://www.argeo.org/svn/slc/trunk/org.argeo.slc.core
- </url>
</scm>
<build>
<plugins>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptors>
- <descriptor>src/assembly/base.xml</descriptor>
- </descriptors>
- </configuration>
- <executions>
- <execution>
- <id>assembly-base</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</build>
<dependencies>
<dependency>
- <groupId>javax.transaction</groupId>
- <artifactId>jta</artifactId>
+ <groupId>org.argeo.slc</groupId>
+ <artifactId>argeo-slc-core</artifactId>
+ <version>${project.version}</version>
</dependency>
+
<dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
</dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
- <dependency>
- <groupId>org.springframework.ws</groupId>
- <artifactId>spring-ws-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.ws</groupId>
- <artifactId>spring-oxm</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.castor</groupId>
- <artifactId>castor</artifactId>
- </dependency>
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- </dependency>
-
- <dependency>
- <groupId>javax.xml.soap</groupId>
- <artifactId>saaj-api</artifactId>
- </dependency>
- <dependency>
- <groupId>com.sun.xml.messaging.saaj</groupId>
- <artifactId>saaj-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.activation</groupId>
- <artifactId>activation</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant-commons-logging</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
<dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
- <dependency>
- <groupId>xalan</groupId>
- <artifactId>xalan</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-embedder</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-settings</artifactId>
- </dependency>
-
</dependencies>
</project>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.ant;\r
-\r
-import java.io.File;\r
-import java.net.URL;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Properties;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.apache.tools.ant.Project;\r
-import org.apache.tools.ant.ProjectHelper;\r
-import org.apache.tools.ant.listener.CommonsLoggingListener;\r
-import org.argeo.slc.core.structure.StructurePath;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-\r
-/** Utilities to manipulate the structure registry in SLC Ant. */\r
-public class AntRegistryUtil {\r
- private static Log log = LogFactory.getLog(AntRegistryUtil.class);\r
-\r
- /** Reads a structure registry from an Ant file without executing it. */\r
- public static StructureRegistry readRegistry(File antFile) {\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
- p.init();\r
- ProjectHelper helper = new SlcProjectHelper();\r
- p.addReference(ProjectHelper.PROJECTHELPER_REFERENCE, helper);\r
- helper.parse(p, antFile);\r
-\r
- StructureRegistry registry = (StructureRegistry) p\r
- .getReference(SlcProjectHelper.REF_STRUCTURE_REGISTRY);\r
- registry.setMode(StructureRegistry.READ);\r
-\r
- p.executeTarget(p.getDefaultTarget());\r
- return registry;\r
- }\r
-\r
- /** Executes only the active paths of the Ant file. */\r
- public static Project runActive(File antFile,\r
- List<StructurePath> activePaths) {\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.init();\r
- ProjectHelper helper = new SlcProjectHelper();\r
- p.addReference(ProjectHelper.PROJECTHELPER_REFERENCE, helper);\r
- helper.parse(p, antFile);\r
-\r
- StructureRegistry registry = (StructureRegistry) p\r
- .getReference(SlcProjectHelper.REF_STRUCTURE_REGISTRY);\r
- registry.setMode(StructureRegistry.ACTIVE);\r
- registry.setActivePaths(activePaths);\r
-\r
- runProject(p, null);\r
- return p;\r
- }\r
-\r
- /** Executes all paths of the provided target of the Ant file. */\r
- public static Project runAll(File antFile, String target) {\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
- p.init();\r
- ProjectHelper helper = new SlcProjectHelper();\r
- p.addReference(ProjectHelper.PROJECTHELPER_REFERENCE, helper);\r
- helper.parse(p, antFile);\r
-\r
- runProject(p, target);\r
- return p;\r
- }\r
-\r
- /** Executes all paths of the provided target of the Ant URL. */\r
- public static Project runAll(URL url, String target, Properties properties) {\r
- if (log.isDebugEnabled())\r
- log.debug("Runs all paths of Ant URL " + url);\r
- Project p = new Project();\r
- p.setUserProperty("ant.file", url.toString());\r
- // p.setBaseDir(url.toString());\r
- p.addBuildListener(new CommonsLoggingListener());\r
- p.init();\r
- ProjectHelper helper = new SlcProjectHelper();\r
- p.addReference(ProjectHelper.PROJECTHELPER_REFERENCE, helper);\r
- helper.parse(p, url);\r
-\r
- if (properties != null) {\r
- for (Map.Entry<Object, Object> entry : properties.entrySet()) {\r
- p.setUserProperty(entry.getKey().toString(), entry.getValue()\r
- .toString());\r
- }\r
- }\r
-\r
- runProject(p, target);\r
- return p;\r
- }\r
-\r
- /** Executes all paths of the default target of the Ant file. */\r
- public static Project runAll(File antFile) {\r
- return runAll(antFile, null);\r
- }\r
-\r
- protected static void runProject(Project p, String target) {\r
- p.fireBuildStarted();\r
- Throwable exception = null;\r
- try {\r
- p.executeTarget(target != null ? target : p.getDefaultTarget());\r
- } catch (Throwable e) {\r
- exception = e;\r
- log.error("Exception when running Ant: ",e);\r
- } finally {\r
- p.fireBuildFinished(exception);\r
- }\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.ant;\r
-\r
-import java.io.File;\r
-import java.net.URL;\r
-import java.util.Arrays;\r
-import java.util.Collections;\r
-import java.util.Map;\r
-import java.util.Properties;\r
-import java.util.Vector;\r
-\r
-import org.springframework.context.ApplicationContext;\r
-\r
-import org.apache.tools.ant.Project;\r
-import org.apache.tools.ant.ProjectHelper;\r
-\r
-public class AntRunner {\r
- private ApplicationContext context;\r
- private ProjectHelper projectHelper;\r
- private URL buildFile;\r
- private String[] targets;\r
- private Properties properties;\r
-\r
- public AntRunner() {\r
-\r
- }\r
-\r
- public AntRunner(ApplicationContext context, ProjectHelper projectHelper,\r
- URL buildFile, String[] targets) {\r
- super();\r
- this.context = context;\r
- this.projectHelper = projectHelper;\r
- this.buildFile = buildFile;\r
- this.targets = targets;\r
- }\r
-\r
- public AntRunner(ApplicationContext context, URL buildFile, String target) {\r
- super();\r
- this.context = context;\r
-\r
- BasicSlcProjectHelper basicSlcProjectHelper = new BasicSlcProjectHelper();\r
- this.projectHelper = basicSlcProjectHelper;\r
- basicSlcProjectHelper.setContext(context);\r
-\r
- this.buildFile = buildFile;\r
- this.targets = new String[] { target };\r
- }\r
-\r
- public void run() {\r
- Project p = new Project();\r
-\r
- String path = buildFile.getFile();\r
- p.setUserProperty("ant.file", path);\r
- p.setBaseDir(extractBaseDir(path));\r
-\r
- p.init();\r
- p.addReference(ProjectHelper.PROJECTHELPER_REFERENCE, projectHelper);\r
- projectHelper.parse(p, buildFile);\r
-\r
- if (properties != null) {\r
- for (Map.Entry<Object, Object> entry : properties.entrySet()) {\r
- p.setUserProperty(entry.getKey().toString(), entry.getValue()\r
- .toString());\r
- }\r
- }\r
-\r
- p.fireBuildStarted();\r
- Throwable exception = null;\r
- try {\r
- if (targets == null) {\r
- p.executeTarget(p.getDefaultTarget());\r
- } else {\r
- p.executeTargets(new Vector<String>(Arrays.asList(targets)));\r
- }\r
- } catch (Throwable e) {\r
- exception = e;\r
- throw new SlcAntException("Could not run Ant script " + buildFile,\r
- e);\r
- } finally {\r
- p.fireBuildFinished(exception);\r
- }\r
-\r
- }\r
-\r
- private File extractBaseDir(String path) {\r
- String baseDir = null;\r
- if (path.length() > 1) {\r
- int indx = path.lastIndexOf('/', path.length() - 1);\r
- if (indx == -1 || indx == 0) {\r
- baseDir = "/";\r
- } else {\r
- baseDir = path.substring(0, indx) + "/";\r
- }\r
- } else {\r
- baseDir = "/";\r
- }\r
- File file = new File(baseDir);\r
- if (file.exists()) {\r
- return file;\r
- } else {\r
- return new File(System.getProperty("user.dir"));\r
- }\r
- }\r
-\r
- public static void main(String[] args) {\r
- // TODO Auto-generated method stub\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.ant;\r
-\r
-import org.springframework.context.ApplicationContext;\r
-\r
-import org.apache.tools.ant.BuildException;\r
-import org.apache.tools.ant.Project;\r
-import org.apache.tools.ant.helper.ProjectHelper2;\r
-\r
-import org.argeo.slc.core.structure.SimpleSElement;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.structure.tree.TreeSRegistry;\r
-\r
-public class BasicSlcProjectHelper extends ProjectHelper2 {\r
- private ApplicationContext context;\r
-\r
- private String projectRootPath = "/project";\r
-\r
- @Override\r
- public void parse(Project project, Object source) throws BuildException {\r
- TreeSRegistry registry = new TreeSRegistry();\r
- TreeSPath projectPath = TreeSPath.parseToCreatePath(projectRootPath);\r
- \r
- // FIXME\r
- registry.register(projectPath, new SimpleSElement("ROOT"));\r
- \r
- project.addReference(SlcProjectHelper.REF_STRUCTURE_REGISTRY, registry);\r
- project.addReference(SlcProjectHelper.REF_PROJECT_PATH, projectPath);\r
-\r
- super.parse(project, source);\r
- \r
- project.addReference(SlcProjectHelper.REF_ROOT_CONTEXT, context);\r
- SlcProjectHelper.createAndRegisterSlcExecution(project);\r
-\r
- SlcProjectHelper.addCustomTaskAndTypes(project);\r
- }\r
-\r
- public void setContext(ApplicationContext context) {\r
- this.context = context;\r
- }\r
-\r
- \r
- \r
-}\r
+++ /dev/null
-package org.argeo.slc.ant;\r
-\r
-import org.apache.tools.ant.BuildListener;\r
-import org.apache.tools.ant.Project;\r
-\r
-public interface ProjectRelatedBuildListener extends BuildListener {\r
- public Project getProject();\r
- \r
- /** SlcExecution must already have been registered in project*/\r
- public void init(Project project);\r
-}\r
+++ /dev/null
-package org.argeo.slc.ant;
-
-import java.util.StringTokenizer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.tools.ant.util.FileNameMapper;
-
-public class RemoveRootDirMapper implements FileNameMapper {
- private Log log = LogFactory.getLog(RemoveRootDirMapper.class);
- private String to = "enabled";
-
- public String[] mapFileName(String sourceFileName) {
- StringTokenizer st = new StringTokenizer(sourceFileName, "/");
- boolean first = true;
- boolean skipRoot = !to.equals("disabled");
- StringBuffer buf = new StringBuffer("");
- while (st.hasMoreTokens()) {
- if (first && skipRoot) { // skip
- st.nextToken();
- first = false;
- } else {
- buf.append(st.nextToken()).append('/');
- }
- }
-
- if (log.isTraceEnabled()) {
- log.trace("Source: " + sourceFileName + " - out: " + buf);
- }
- return new String[] { buf.toString() };
- }
-
- public void setFrom(String from) {
- }
-
- public void setTo(String to) {
- this.to = to;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.ant;\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
-import org.springframework.util.Log4jConfigurer;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.apache.tools.ant.Project;\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
- /** Property for the root file (SLC root property file). */\r
- public final static String ROOT_FILE_PROPERTY = "slc.rootFile";\r
- /** Property for the root dir (SLC root property file). */\r
- public final static String ROOT_DIR_PROPERTY = "slc.rootDir";\r
- /** Property for the conf dir (SLC root property file). */\r
- public final static String CONF_DIR_PROPERTY = "slc.confDir";\r
- /** Property for the work dir (SLC root property file). */\r
- public final static String WORK_DIR_PROPERTY = "slc.workDir";\r
- /**\r
- * Comma-separated list of property file names to load from the conf dir and\r
- * add to project user properties\r
- */\r
- public final static String PROPERTY_FILE_NAMES_PROPERTY = "slc.propertyFileNames";\r
-\r
- // SLC CONF PROPERTIES\r
- /** Path to the root Spring application context */\r
- public static String APPLICATION_CONTEXT_PROPERTY = "slc.applicationContext";\r
- /** Name of the Spring bean used by default */\r
- public static String DEFAULT_TEST_RUN_PROPERTY = "slc.defaultTestRun";\r
-\r
- // SLC LOCAL PROPERTIES\r
- /** Property for the dir label (SLC local property file). */\r
- public static String DIR_LABEL_PROPERTY = "slc.dirLabel";\r
-\r
- private String slcRootFileName = "slcRoot.properties";\r
- private String slcLocalFileName = "slcLocal.properties";\r
-\r
- /**\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
- * @return whether the project could be initialized for SLC usage (e.g.\r
- * presence of an SLC root file)\r
- */\r
- public boolean initProject(Project project) {\r
- File projectBaseDir = project.getBaseDir();\r
- File slcRootFile = findSlcRootFile(projectBaseDir);\r
- if (slcRootFile == null) {\r
- return false;\r
- }\r
-\r
- // pass the project properties through the System properties\r
- System.getProperties().putAll((Map<?, ?>) project.getUserProperties());\r
- Properties all = new Properties();\r
- all.putAll(System.getProperties());\r
- prepareAllProperties(slcRootFile, all);\r
-\r
- Log log = LogFactory.getLog(this.getClass());\r
- for (Object o : all.keySet()) {\r
- String key = o.toString();\r
- // System.out.println(key+"="+all.getProperty(key));\r
- if (project.getUserProperty(key) == null) {// not already set\r
- // if (log.isDebugEnabled())\r
- // log.debug(key + "=" + all.getProperty(key));\r
- project.setUserProperty(key, all.getProperty(key));\r
- }\r
- }\r
- return true;\r
- }\r
-\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
- public void prepareAllProperties(File slcRootFile, Properties all) {\r
- try {\r
- final String fileUrlPrefix = "";\r
-\r
- all.put(ROOT_FILE_PROPERTY, slcRootFile.getCanonicalPath());\r
- // Remove basedir property in order to avoid conflict with Maven\r
- if (all.containsKey("basedir"))\r
- all.remove("basedir");\r
-\r
- Properties rootProps = loadFile(slcRootFile.getCanonicalPath());\r
-\r
- final File confDir;\r
- final File workDir;\r
- // Root dir\r
- final File rootDir = slcRootFile.getParentFile();\r
- all.setProperty(ROOT_DIR_PROPERTY, fileUrlPrefix\r
- + rootDir.getCanonicalPath());\r
-\r
- // Conf dir\r
- if (all.getProperty(CONF_DIR_PROPERTY) == null) {\r
- confDir = new File(rootProps.getProperty(CONF_DIR_PROPERTY,\r
- rootDir.getAbsolutePath() + "/../conf"))\r
- .getCanonicalFile();\r
- all.setProperty(CONF_DIR_PROPERTY, fileUrlPrefix\r
- + confDir.getAbsolutePath());\r
- } else {\r
- confDir = new File(all.getProperty(CONF_DIR_PROPERTY))\r
- .getCanonicalFile();\r
- }\r
-\r
- // Work dir\r
- if (all.getProperty(WORK_DIR_PROPERTY) == null) {\r
- workDir = new File(rootProps.getProperty(WORK_DIR_PROPERTY,\r
- rootDir.getAbsolutePath() + "/../work"))\r
- .getCanonicalFile();\r
- all.setProperty(WORK_DIR_PROPERTY, fileUrlPrefix\r
- + workDir.getAbsolutePath());\r
- } else {\r
- workDir = new File(all.getProperty(WORK_DIR_PROPERTY))\r
- .getCanonicalFile();\r
- }\r
-\r
- // Properties from the conf dir files\r
- Properties properties = new Properties();\r
- StringTokenizer st = new StringTokenizer(rootProps.getProperty(\r
- PROPERTY_FILE_NAMES_PROPERTY, "slc.properties"), ",");\r
- while (st.hasMoreTokens()) {\r
- String fileName = st.nextToken();\r
- properties.putAll(loadFile(confDir.getAbsolutePath()\r
- + File.separator + fileName));\r
- }\r
-\r
- for (Object o : properties.keySet()) {\r
- String key = o.toString();\r
- if (all.getProperty(key) == null) {// not already set\r
- all.setProperty(key, properties.getProperty(key));\r
- }\r
- }\r
-\r
- // Default application context\r
- if (all.getProperty(APPLICATION_CONTEXT_PROPERTY) == null) {\r
- all.setProperty(APPLICATION_CONTEXT_PROPERTY, confDir\r
- .getAbsolutePath()\r
- + "/applicationContext.xml");\r
- }\r
- // Default test run\r
- if (all.getProperty(DEFAULT_TEST_RUN_PROPERTY) == null) {\r
- all.setProperty(DEFAULT_TEST_RUN_PROPERTY,\r
- "defaultTestRun");\r
- }\r
-\r
- // Default log4j\r
- if (all.getProperty("log4j.configuration") == null) {\r
- System.setProperty("log4j.configuration", confDir\r
- .getCanonicalPath()\r
- + File.separator + "log4j.properties");\r
- // TODO: fix dependency to log4j\r
- Log4jConfigurer.initLogging(confDir.getCanonicalPath()\r
- + File.separator + "log4j.properties");\r
- }\r
- } catch (Exception e) {\r
- throw new SlcAntException("Unexpected exception while configuring",\r
- e);\r
- }\r
- }\r
-\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
- p.load(in);\r
- in.close();\r
- } catch (IOException e) {\r
- throw new SlcAntException("Cannot read SLC root file", e);\r
- }\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_LABEL_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_LABEL_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
+++ /dev/null
-package org.argeo.slc.ant;\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
- /** Constructor. */\r
- public SlcAntException(String message) {\r
- super(message);\r
- }\r
-\r
- /** Constructor. */\r
- public SlcAntException(String message, Throwable cause) {\r
- super(message, cause);\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.ant;\r
-\r
-import java.util.List;\r
-import java.util.Vector;\r
-\r
-import org.apache.log4j.AppenderSkeleton;\r
-import org.apache.log4j.LogManager;\r
-import org.apache.log4j.spi.LoggingEvent;\r
-import org.apache.tools.ant.BuildEvent;\r
-import org.apache.tools.ant.Project;\r
-\r
-import org.argeo.slc.core.process.SlcExecution;\r
-import org.argeo.slc.core.process.SlcExecutionNotifier;\r
-import org.argeo.slc.core.process.SlcExecutionStep;\r
-import org.argeo.slc.core.process.WebServiceSlcExecutionNotifier;\r
-\r
-public class SlcExecutionBuildListener extends AppenderSkeleton implements\r
- ProjectRelatedBuildListener {\r
- public static final String ANT_TYPE = "org.apache.tools.ant";\r
- public static final String SLC_ANT_TYPE = "org.argeo.slc.ant";\r
-\r
- public static final String REF_SLC_EXECUTION = "slcExecution";\r
-\r
- private Project project;\r
-\r
- // to avoid stack overflow when logging for log4j\r
- private boolean isLogging = false;\r
-\r
- private List<SlcExecutionNotifier> notifiers = new Vector<SlcExecutionNotifier>();\r
-\r
- private boolean currentStepNotified = true;\r
-\r
- // CUSTOMIZATIONS\r
- private boolean logBeforeFirstTarget = false;\r
- private boolean firstTargetStarted = false;\r
-\r
- private boolean logTaskStartFinish = true;\r
-\r
- public void init(Project project) {\r
- if (this.project != null) {\r
- throw new SlcAntException("Build listener already initialized");\r
- }\r
-\r
- this.project = project;\r
-\r
- if (!LogManager.getRootLogger().isAttached(this)) {\r
- LogManager.getRootLogger().addAppender(this);\r
- }\r
-\r
- SlcExecution slcExecution = (SlcExecution) project\r
- .getReference(REF_SLC_EXECUTION);\r
- if (slcExecution == null)\r
- throw new SlcAntException("No SLC Execution registered.");\r
-\r
- for (SlcExecutionNotifier notifier : notifiers) {\r
- notifier.newExecution(slcExecution);\r
- }\r
-\r
- }\r
-\r
- public void buildStarted(BuildEvent event) {\r
- }\r
-\r
- public void buildFinished(BuildEvent event) {\r
- SlcExecution slcExecution = getSlcExecution(event);\r
- String oldStatus = slcExecution.getStatus();\r
- slcExecution.setStatus(SlcExecution.STATUS_FINISHED);\r
-\r
- for (SlcExecutionNotifier notifier : notifiers) {\r
- notifier.updateStatus(slcExecution, oldStatus, slcExecution\r
- .getStatus());\r
- }\r
- }\r
-\r
- public void messageLogged(BuildEvent event) {\r
- if (!shouldLog())\r
- return;\r
-\r
- SlcExecution slcExecution = getSlcExecution(event);\r
- if (slcExecution != null) {\r
- if (currentStepNotified) {\r
- slcExecution.getSteps().add(\r
- new SlcExecutionStep("LOG", event.getMessage()));\r
- notifyStep(slcExecution, slcExecution.currentStep());\r
- currentStepNotified = true;\r
- } else {\r
- slcExecution.currentStep().addLog(event.getMessage());\r
- }\r
- } else {\r
- // TODO: log before initialization?\r
- }\r
- }\r
-\r
- public void targetStarted(BuildEvent event) {\r
- if (!firstTargetStarted)\r
- firstTargetStarted = true;\r
-\r
- addLogStep(event, "Target " + event.getTarget().getName() + " started");\r
- }\r
-\r
- public void targetFinished(BuildEvent event) {\r
- addLogStep(event, "Target " + event.getTarget().getName() + " finished");\r
- }\r
-\r
- public void taskStarted(BuildEvent event) {\r
- if (!shouldLog())\r
- return;\r
-\r
- SlcExecution slcExecution = getSlcExecution(event);\r
- if (!currentStepNotified) {\r
- notifyStep(slcExecution, slcExecution.currentStep());\r
- currentStepNotified = true;\r
- }\r
-\r
- String msg = null;\r
- if (logTaskStartFinish)\r
- msg = "Task " + event.getTask().getTaskName() + " started";\r
-\r
- slcExecution.getSteps().add(new SlcExecutionStep("LOG", msg));\r
-\r
- currentStepNotified = false;\r
- }\r
-\r
- public void taskFinished(BuildEvent event) {\r
- if (!shouldLog())\r
- return;\r
-\r
- SlcExecution slcExecution = getSlcExecution(event);\r
- if (!currentStepNotified) {\r
-\r
- if (logTaskStartFinish)\r
- slcExecution.currentStep().addLog(\r
- "Task " + event.getTask().getTaskName() + " finished");\r
-\r
- notifyStep(slcExecution, slcExecution.currentStep());\r
- currentStepNotified = true;\r
- }\r
- }\r
-\r
- public void setNotifiers(List<SlcExecutionNotifier> notifiers) {\r
- this.notifiers = notifiers;\r
- }\r
-\r
- protected SlcExecution getSlcExecution(BuildEvent event) {\r
- Project projectEvt = event.getProject();\r
- if (!projectEvt.equals(project))\r
- throw new SlcAntException("Event project " + projectEvt\r
- + " not consistent with listener project " + project);\r
-\r
- SlcExecution slcExecution = (SlcExecution) project\r
- .getReference(REF_SLC_EXECUTION);\r
-\r
- if (slcExecution == null)\r
- throw new SlcAntException("No SLC Execution registered.");\r
- return slcExecution;\r
- }\r
-\r
- protected void addLogStep(BuildEvent event, String msg) {\r
- SlcExecution slcExecution = getSlcExecution(event);\r
- slcExecution.getSteps().add(new SlcExecutionStep("LOG", msg));\r
-\r
- notifyStep(slcExecution, slcExecution.currentStep());\r
- currentStepNotified = true;\r
- }\r
-\r
- protected void notifyStep(SlcExecution slcExecution, SlcExecutionStep step) {\r
- Vector<SlcExecutionStep> additionalSteps = new Vector<SlcExecutionStep>();\r
- additionalSteps.add(step);\r
- notifySteps(slcExecution, additionalSteps);\r
- }\r
-\r
- protected void notifySteps(SlcExecution slcExecution,\r
- List<SlcExecutionStep> additionalSteps) {\r
- for (SlcExecutionNotifier notifier : notifiers) {\r
- notifier.addSteps(slcExecution, additionalSteps);\r
- }\r
- }\r
-\r
- /* Log4j methods */\r
-\r
- @Override\r
- protected void append(LoggingEvent event) {\r
- if (isLogging) {\r
- // avoid StackOverflow if notification calls Log4j itself.\r
- return;\r
- }\r
-\r
- if (event.getLoggerName().equals(\r
- WebServiceSlcExecutionNotifier.class.getName())) {\r
- return;\r
- }\r
-\r
- isLogging = true;\r
-\r
- try {\r
- SlcExecution slcExecution = (SlcExecution) project\r
- .getReference(REF_SLC_EXECUTION);\r
- if (slcExecution != null) {\r
- if (currentStepNotified) {\r
- slcExecution.getSteps().add(\r
- new SlcExecutionStep("LOG", event.getMessage()\r
- .toString()));\r
- currentStepNotified = false;\r
- }\r
- slcExecution.currentStep()\r
- .addLog(event.getMessage().toString());\r
- } else {\r
- // TODO: log before initialization?\r
- }\r
- } finally {\r
- isLogging = false;\r
- }\r
-\r
- }\r
-\r
- protected boolean shouldLog() {\r
- return logBeforeFirstTarget || firstTargetStarted;\r
- }\r
-\r
- @Override\r
- public void close() {\r
- }\r
-\r
- @Override\r
- public boolean requiresLayout() {\r
- return false;\r
- }\r
-\r
- public Project getProject() {\r
- return project;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.ant;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.net.InetAddress;\r
-import java.net.UnknownHostException;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Properties;\r
-import java.util.UUID;\r
-import java.util.Vector;\r
-\r
-import org.springframework.beans.factory.ListableBeanFactory;\r
-import org.springframework.context.ApplicationContext;\r
-import org.springframework.context.support.AbstractApplicationContext;\r
-import org.springframework.context.support.FileSystemXmlApplicationContext;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.apache.log4j.LogManager;\r
-import org.apache.tools.ant.BuildException;\r
-import org.apache.tools.ant.BuildListener;\r
-import org.apache.tools.ant.Project;\r
-import org.apache.tools.ant.helper.ProjectHelper2;\r
-\r
-import org.argeo.slc.core.process.SlcExecution;\r
-import org.argeo.slc.core.process.SlcExecutionNotifier;\r
-import org.argeo.slc.core.structure.DefaultSRegistry;\r
-import org.argeo.slc.core.structure.SimpleSElement;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-\r
-/**\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 ProjectHelper2 {\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
- /** The Ant reference to the <code>TreePath</code> of the current project */\r
- public 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
- private static String SLC_TYPEDEFS_RESOURCE_PATH = "/org/argeo/slc/ant/typedefs.properties";\r
-\r
- protected SlcAntConfig slcAntConfig = null;\r
-\r
- @Override\r
- public void parse(Project project, Object source) throws BuildException {\r
-\r
- if (source instanceof File) {\r
- File sourceFile = (File) source;\r
- // Reset basedir property, in order to avoid base dir override when\r
- // running in Maven\r
- project.setProperty("basedir", sourceFile.getParentFile()\r
- .getAbsolutePath());\r
- }\r
-\r
- if (slcAntConfig != null) {\r
- // Config already initialized (probably import), only parse\r
- super.parse(project, source);\r
- return;\r
- }\r
-\r
- // Initialize config\r
- slcAntConfig = new SlcAntConfig();\r
-\r
- if (!slcAntConfig.initProject(project)) {\r
- // not SLC compatible, do normal Ant\r
- super.parse(project, source);\r
- return;\r
- }\r
-\r
- if (log == null) {\r
- // log4j is initialized only now\r
- log = LogFactory.getLog(SlcProjectHelper.class);\r
- }\r
-\r
- if (log.isDebugEnabled())\r
- log.debug("SLC properties are set, starting initialization for "\r
- + source + " (projectHelper=" + this + ")");\r
-\r
- beforeParsing(project);\r
-\r
- // Calls the underlying implementation to do the actual work\r
- super.parse(project, source);\r
-\r
- afterParsing(project);\r
- }\r
-\r
- /**\r
- * Performs operations after config initialization and before Ant file\r
- * parsing. Performed only once when the main project file is parsed. Should\r
- * be called by overriding methods.\r
- */\r
- protected void beforeParsing(Project project) {\r
- // Init Spring application context\r
- initSpringContext(project);\r
-\r
- // Init structure registry\r
- DefaultSRegistry registry = new DefaultSRegistry();\r
- project.addReference(REF_STRUCTURE_REGISTRY, registry);\r
- }\r
-\r
- /**\r
- * Performs operations after parsing of the main file. Called only once (not\r
- * for imports).\r
- */\r
- protected void afterParsing(Project project) {\r
- // Creates structure root\r
- registerProjectAndParents(project, slcAntConfig);\r
- addCustomTaskAndTypes(project);\r
- }\r
-\r
- /** Creates the tree-based structure for this project. */\r
- private void registerProjectAndParents(Project project,\r
- SlcAntConfig slcAntConfig) {\r
- StructureRegistry<TreeSPath> registry = (StructureRegistry<TreeSPath>) project\r
- .getReference(REF_STRUCTURE_REGISTRY);\r
- File rootDir = new File(project\r
- .getUserProperty(SlcAntConfig.ROOT_DIR_PROPERTY))\r
- .getAbsoluteFile();\r
- File baseDir = project.getBaseDir().getAbsoluteFile();\r
- List<File> dirs = new Vector<File>();\r
- File currentDir = baseDir;\r
- do {\r
- dirs.add(currentDir);\r
- currentDir = currentDir.getParentFile();\r
- if (log.isTraceEnabled())\r
- log.trace("List " + currentDir);\r
- } while (!currentDir.equals(rootDir.getParentFile()));\r
-\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
- // retrieves description for this path\r
- final String description;\r
- if (i == 0) {// project itself\r
- description = project.getDescription() != null\r
- && !project.getDescription().equals("") ? project\r
- .getDescription() : project.getName() != null ? project\r
- .getName() : slcAntConfig.getDescriptionForDir(dir);\r
- } else {\r
- description = slcAntConfig.getDescriptionForDir(dir);\r
- if (log.isTraceEnabled())\r
- log.trace("Dir desc " + i + "/" + dirs.size() + ": "\r
- + description);\r
- }\r
- SimpleSElement element = new SimpleSElement(description);\r
-\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
- }\r
- project.addReference(REF_PROJECT_PATH, currPath);\r
- }\r
-\r
- /** Gets the path of a project (root). */\r
- // private static TreeSPath getProjectPath(Project project) {\r
- // return (TreeSPath) project.getReference(REF_PROJECT_PATH);\r
- // }\r
- /** Initializes the Spring application context. */\r
- private void initSpringContext(Project project) {\r
- System.getProperties().putAll((Map<?, ?>) project.getProperties());\r
- String acPath = project\r
- .getUserProperty(SlcAntConfig.APPLICATION_CONTEXT_PROPERTY);\r
- if (log.isDebugEnabled())\r
- log.debug("Loading Spring application context from " + acPath);\r
- // FIXME: workaround to the removal of leading '/' by Spring\r
- // use URL instead?\r
- AbstractApplicationContext context = new FileSystemXmlApplicationContext(\r
- '/' + acPath);\r
- context.registerShutdownHook();\r
- project.addReference(REF_ROOT_CONTEXT, context);\r
-\r
- createAndRegisterSlcExecution(project);\r
- // Add build listeners declared in Spring context\r
- // Map<String, BuildListener> listeners = context.getBeansOfType(\r
- // BuildListener.class, false, true);\r
- // for (BuildListener listener : listeners.values()) {\r
- // project.addBuildListener(listener);\r
- // }\r
- }\r
-\r
- /** Loads the SLC specific Ant tasks. */\r
- protected static void addCustomTaskAndTypes(Project project) {\r
- Properties taskdefs = getDefs(project, SLC_TASKDEFS_RESOURCE_PATH);\r
- for (Object o : taskdefs.keySet()) {\r
- String name = o.toString();\r
- try {\r
- project.addTaskDefinition(name, Class.forName(taskdefs\r
- .getProperty(name)));\r
- } catch (ClassNotFoundException e) {\r
- log.error("Unknown class for task " + name, e);\r
- }\r
- }\r
- Properties typedefs = getDefs(project, SLC_TYPEDEFS_RESOURCE_PATH);\r
- for (Object o : typedefs.keySet()) {\r
- String name = o.toString();\r
- try {\r
- project.addDataTypeDefinition(name, Class.forName(typedefs\r
- .getProperty(name)));\r
- } catch (ClassNotFoundException e) {\r
- log.error("Unknown class for type " + name, e);\r
- }\r
- }\r
- }\r
-\r
- private static Properties getDefs(Project project, String path) {\r
- Properties defs = new Properties();\r
- try {\r
- InputStream in = project.getClass().getResourceAsStream(path);\r
- defs.load(in);\r
- in.close();\r
- } catch (IOException e) {\r
- throw new SlcAntException("Cannot load task definitions", e);\r
- }\r
- return defs;\r
- }\r
-\r
- protected static void createAndRegisterSlcExecution(Project project) {\r
- SlcExecution slcExecution = new SlcExecution();\r
- slcExecution.setUuid(UUID.randomUUID().toString());\r
- try {\r
- slcExecution.setHost(InetAddress.getLocalHost().getHostName());\r
- } catch (UnknownHostException e) {\r
- slcExecution.setHost(SlcExecution.UNKOWN_HOST);\r
- }\r
-\r
- if (project.getReference(SlcProjectHelper.REF_ROOT_CONTEXT) != null) {\r
- slcExecution.setType(SlcExecutionBuildListener.SLC_ANT_TYPE);\r
- } else {\r
- slcExecution.setType(SlcExecutionBuildListener.ANT_TYPE);\r
- }\r
-\r
- slcExecution.setUser(System.getProperty("user.name"));\r
- slcExecution.setStatus(SlcExecution.STATUS_RUNNING);\r
- slcExecution.getAttributes().put("ant.file",\r
- project.getProperty("ant.file"));\r
-\r
- project.addReference(SlcExecutionBuildListener.REF_SLC_EXECUTION,\r
- slcExecution);\r
-\r
- // Add build listeners declared in Spring context\r
- Map<String, ProjectRelatedBuildListener> listeners = ((ListableBeanFactory) project\r
- .getReference(REF_ROOT_CONTEXT)).getBeansOfType(\r
- ProjectRelatedBuildListener.class, false, true);\r
- for (ProjectRelatedBuildListener listener : listeners.values()) {\r
- listener.init(project);\r
- project.addBuildListener(listener);\r
- }\r
-\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.ant.deploy;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.apache.tools.ant.BuildException;\r
-\r
-import org.argeo.slc.ant.spring.AbstractSpringArg;\r
-import org.argeo.slc.ant.structure.SAwareTask;\r
-import org.argeo.slc.core.deploy.DeploymentData;\r
-import org.argeo.slc.core.deploy.TargetData;\r
-import org.argeo.slc.core.deploy.WritableDeployment;\r
-\r
-/** Ant task wrapping a deployment. */\r
-public class SlcDeployTask extends SAwareTask {\r
- private Log log = LogFactory.getLog(SlcDeployTask.class);\r
-\r
- private String deploymentBean = null;\r
-\r
- private DeploymentDataArg deploymentDataArg;\r
- private TargetDataArg targetDataArg;\r
-\r
- @Override\r
- public void executeActions(String mode) throws BuildException {\r
- WritableDeployment deployment = (WritableDeployment) getContext()\r
- .getBean(deploymentBean);\r
-\r
- // set overridden references\r
- if (deploymentDataArg != null) {\r
- deployment.setDeploymentData(deploymentDataArg.getDeploymentData());\r
- log.trace("Overrides deployment data");\r
- }\r
-\r
- if (targetDataArg != null) {\r
- deployment.setTargetData(targetDataArg.getTargetData());\r
- log.trace("Overrides target data");\r
- }\r
-\r
- deployment.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 setDeployment(String deploymentBean) {\r
- this.deploymentBean = deploymentBean;\r
- }\r
-\r
- /** Creates deployment data sub tag. */\r
- public DeploymentDataArg createDeploymentData() {\r
- deploymentDataArg = new DeploymentDataArg();\r
- return deploymentDataArg;\r
- }\r
-\r
- /** Creates target data sub tag. */\r
- public TargetDataArg createTargetData() {\r
- targetDataArg = new TargetDataArg();\r
- return targetDataArg;\r
- }\r
-}\r
-\r
-class DeploymentDataArg extends AbstractSpringArg {\r
- DeploymentData getDeploymentData() {\r
- return (DeploymentData) getBeanInstance();\r
- }\r
-\r
-}\r
-\r
-class TargetDataArg extends AbstractSpringArg {\r
- TargetData getTargetData() {\r
- return (TargetData) getBeanInstance();\r
- }\r
-\r
-}\r
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-Integration of SLC Deploy in Ant.\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-Bases classes for SLC Ant extensions.\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
+++ /dev/null
-package org.argeo.slc.ant.spring;\r
-\r
-import java.util.List;\r
-import java.util.Vector;\r
-\r
-import org.springframework.beans.BeanWrapper;\r
-import org.springframework.beans.BeanWrapperImpl;\r
-import org.springframework.beans.factory.InitializingBean;\r
-import org.springframework.context.ApplicationContext;\r
-\r
-import org.apache.commons.logging.LogFactory;\r
-import org.apache.tools.ant.types.DataType;\r
-\r
-import org.argeo.slc.ant.SlcAntException;\r
-import org.argeo.slc.ant.SlcProjectHelper;\r
-import org.argeo.slc.core.SlcException;\r
-\r
-/** Abstract Ant type wrapping a Spring bean. */\r
-public abstract class AbstractSpringArg extends DataType {\r
- private List<OverrideArg> overrides = new Vector<OverrideArg>();\r
-\r
- private String bean;\r
-\r
- // cache bean instance to avoid reading it twice if it is a prototype\r
- private Object beanInstance = null;\r
-\r
- /** The <u>name</u> of the underlying bean, as set throught the attribute. */\r
- public String getBean() {\r
- return bean;\r
- }\r
-\r
- /** Setter for the bean name. */\r
- public void setBean(String bean) {\r
- this.bean = bean;\r
- }\r
-\r
- /**\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
- beanInstance = getContext().getBean(bean);\r
- \r
- setOverridenProperties(beanInstance);\r
-\r
- if (beanInstance instanceof InitializingBean) {\r
- try {\r
- ((InitializingBean) beanInstance).afterPropertiesSet();\r
- } catch (Exception e) {\r
- throw new SlcException("Could not initialize bean", e);\r
- }\r
- }\r
- }\r
- return beanInstance;\r
- }\r
- \r
- protected void setOverridenProperties(Object obj){\r
- BeanWrapper wrapper = new BeanWrapperImpl(obj);\r
- for (OverrideArg override : overrides) {\r
- if (override.getName() == null) {\r
- throw new SlcAntException(\r
- "The name of the property to override has to be set.");\r
- }\r
-\r
-// LogFactory.getLog(getClass()).debug(\r
-// "Prop " + override.getName());\r
- wrapper.setPropertyValue(override.getName(), override\r
- .getObject());\r
- }\r
- \r
- }\r
-\r
- /** Creates an override subtag. */\r
- public OverrideArg createOverride() {\r
- OverrideArg propertyArg = new OverrideArg();\r
- overrides.add(propertyArg);\r
- return propertyArg;\r
- }\r
-\r
- /** The related Spring application context. */\r
- protected ApplicationContext getContext() {\r
- return (ApplicationContext) getProject().getReference(\r
- SlcProjectHelper.REF_ROOT_CONTEXT);\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.ant.spring;\r
-\r
-import org.springframework.context.ApplicationContext;\r
-\r
-import org.apache.tools.ant.Task;\r
-\r
-import org.argeo.slc.ant.SlcExecutionBuildListener;\r
-import org.argeo.slc.ant.SlcProjectHelper;\r
-import org.argeo.slc.core.process.SlcExecution;\r
-\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
- protected ApplicationContext getContext() {\r
- return (ApplicationContext) getProject().getReference(\r
- SlcProjectHelper.REF_ROOT_CONTEXT);\r
- }\r
-\r
- /** Gets the related slc execution or null if not is registered. */\r
- protected SlcExecution getSlcExecution() {\r
- return (SlcExecution) getProject().getReference(\r
- SlcExecutionBuildListener.REF_SLC_EXECUTION);\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.ant.spring;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.TreeMap;\r
-import java.util.Vector;\r
-\r
-import org.apache.tools.ant.BuildException;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-\r
-public class MapArg {\r
- private List<EntryArg> entries = new Vector<EntryArg>();\r
- private Map<String, Object> map = new TreeMap<String, Object>();\r
-\r
- public EntryArg createEntry() {\r
- EntryArg arg = new EntryArg();\r
- entries.add(arg);\r
- return arg;\r
- }\r
-\r
- public Map<String, Object> getMap() {\r
- if (map.size() == 0) {\r
- for (EntryArg arg : entries) {\r
- String key = arg.getKey();\r
- if (map.containsKey(key)) {\r
- throw new SlcException("Key '" + key + "' already set.");\r
- } else {\r
- map.put(key, arg.getValueStr());\r
- }\r
- }\r
- }\r
- return map;\r
- }\r
-\r
- public static class EntryArg {\r
- private String key;\r
- private Object valueStr;\r
- private OverrideArg overrideArg;\r
-\r
- public String getKey() {\r
- return key;\r
- }\r
-\r
- public void setKey(String key) {\r
- this.key = key;\r
- }\r
-\r
- public Object getValueStr() {\r
- if (overrideArg != null) {\r
- return overrideArg.getObject();\r
- } else if (valueStr != null) {\r
- return valueStr;\r
- } else {\r
- throw new BuildException("Value not set.");\r
- }\r
- }\r
-\r
- public void setValue(String value) {\r
- check();\r
- this.valueStr = value;\r
- }\r
-\r
- public OverrideArg createOverride() {\r
- check();\r
- overrideArg = new OverrideArg();\r
- return overrideArg;\r
- }\r
-\r
- private void check() {\r
- if (valueStr != null || overrideArg != null) {\r
- throw new BuildException("Value already set");\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-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
-import org.argeo.slc.core.SlcException;\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
- private MapArg overrideMap;\r
- private String antref;\r
-\r
- /** The name of the property to override. */\r
- public String getName() {\r
- return name;\r
- }\r
-\r
- /** Sets the name. */\r
- public void setName(String name) {\r
- this.name = name;\r
- }\r
-\r
- /** Sets a reference to an ant data type. */\r
- public void setAntref(String antref) {\r
- checkValueAlreadySet();\r
- this.antref = antref;\r
- }\r
-\r
- /** Both value and bean cannot be set. */\r
- public void setValue(String value) {\r
- checkValueAlreadySet();\r
- this.value = value;\r
- }\r
-\r
- @Override\r
- public void setBean(String bean) {\r
- checkValueAlreadySet();\r
- super.setBean(bean);\r
- }\r
-\r
- /** Creates override list sub tag. */\r
- public OverrideList createList() {\r
- checkValueAlreadySet();\r
- overrideList = new OverrideList();\r
- return overrideList;\r
- }\r
-\r
- public MapArg createMap() {\r
- checkValueAlreadySet();\r
- overrideMap = new MapArg();\r
- return overrideMap;\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
- */\r
- public Object getObject() {\r
- if (value != null) {\r
- return value;\r
- } else if (getBean() != null) {\r
- return getBeanInstance();\r
- } else if (overrideList != null) {\r
- return overrideList.getAsObjectList();\r
- } else if (overrideMap != null) {\r
- return overrideMap.getMap();\r
- } else if (antref != null) {\r
- Object obj = getProject().getReference(antref);\r
- if (obj == null) {\r
- throw new SlcException("No object found for reference "\r
- + antref);\r
- }\r
- setOverridenProperties(obj);\r
- return obj;\r
- } else {\r
- throw new BuildException("Value or bean not set.");\r
- }\r
- }\r
-\r
- private void checkValueAlreadySet() {\r
- if (value != null || overrideList != null || antref != null\r
- || getBean() != null || overrideMap != null) {\r
- throw new BuildException("Value already set.");\r
- }\r
- }\r
-\r
- /** List of overrides */\r
- protected class OverrideList {\r
- private List<OverrideArg> list = new Vector<OverrideArg>();\r
-\r
- /** Creates override sub tag. */\r
- public OverrideArg createOverride() {\r
- OverrideArg overrideArg = new OverrideArg();\r
- list.add(overrideArg);\r
- return overrideArg;\r
- }\r
-\r
- /** Gets as list of objects. */\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
+++ /dev/null
-package org.argeo.slc.ant.structure;\r
-\r
-import java.util.List;\r
-import java.util.Vector;\r
-\r
-import org.apache.tools.ant.BuildException;\r
-import org.apache.tools.ant.Target;\r
-\r
-import org.argeo.slc.ant.SlcAntException;\r
-import org.argeo.slc.ant.SlcProjectHelper;\r
-import org.argeo.slc.ant.spring.AbstractSpringArg;\r
-import org.argeo.slc.ant.spring.AbstractSpringTask;\r
-import org.argeo.slc.core.structure.SimpleSElement;\r
-import org.argeo.slc.core.structure.StructureAware;\r
-import org.argeo.slc.core.structure.StructureElement;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-\r
-/** Ant task that can be registered within a structure. */\r
-public abstract class SAwareTask extends AbstractSpringTask {\r
- private String path;\r
- private TreeSPath treeSPath;\r
- private final List<AbstractSpringArg> sAwareArgs = new Vector<AbstractSpringArg>();\r
-\r
- private StructureElementArg structureElementArg;\r
-\r
- @Override\r
- public void init() throws BuildException {\r
- StructureRegistry<TreeSPath> registry = getRegistry();\r
- Target target = getOwningTarget();\r
-\r
- TreeSPath targetPath = createTargetPath(target);\r
- SimpleSElement targetElement = (SimpleSElement) registry\r
- .getElement(createTargetPath(target));\r
-\r
- if (targetElement == null) {\r
- targetElement = new SimpleSElement(target.getDescription(),\r
- "<no target desc>");\r
- registry.register(targetPath, targetElement);\r
- }\r
- }\r
-\r
- /**\r
- * Includes this arg in the checks for propagation of structure related\r
- * information.\r
- */\r
- protected void addSAwareArg(AbstractSpringArg arg) {\r
- sAwareArgs.add(arg);\r
- }\r
-\r
- @Override\r
- /**\r
- * Called by Ant at runtime. Decides whether to call the actions depending\r
- * of the mode of the underlying structure registry.\r
- * \r
- * @see #executeActions\r
- * @see StructureRegistry\r
- */\r
- public final void execute() throws BuildException {\r
- if (path == null) {\r
- // register the task in the structure\r
- TreeSPath targetPath = createTargetPath(getOwningTarget());\r
- TreeSPath taskPath = targetPath.createChild(getTaskName()\r
- + targetPath.listChildren(getRegistry()).size());\r
-\r
- treeSPath = taskPath;\r
- } else {\r
- treeSPath = new TreeSPath(path);\r
- }\r
-\r
- if (getRegistry().getElement(treeSPath) == null) {\r
- // No structure element registered.\r
- if (structureElementArg != null) {\r
- getRegistry().register(treeSPath,\r
- structureElementArg.getStructureElement());\r
- } else {\r
- if (getDescription() != null) {\r
- getRegistry().register(treeSPath,\r
- new SimpleSElement(getDescription()));\r
- }\r
- }\r
- }\r
-\r
- // notify registered args\r
- for (AbstractSpringArg arg : sAwareArgs) {\r
- Object obj = arg.getBeanInstance();\r
-\r
- if (obj instanceof StructureAware) {\r
- StructureAware<TreeSPath> sAwareT = (StructureAware<TreeSPath>) obj;\r
- sAwareT.notifyCurrentPath(getRegistry(), treeSPath);\r
- }\r
- }\r
-\r
- // execute depending on the registry mode\r
- String mode = getRegistry().getMode();\r
- if (mode.equals(StructureRegistry.ALL)) {\r
- executeActions(mode);\r
- } else if (mode.equals(StructureRegistry.ACTIVE)) {\r
- List<TreeSPath> activePaths = getRegistry().getActivePaths();\r
-\r
- if (activePaths.contains(treeSPath)) {\r
- if (activePaths.contains(treeSPath)) {\r
- executeActions(mode);\r
- }\r
- }\r
- }\r
-\r
- }\r
-\r
- /** Actions to be executed by the implementor. */\r
- protected abstract void executeActions(String mode);\r
-\r
- /** Create a reference to an external structure element. */\r
- public StructureElementArg createStructureElement() {\r
- if (structureElementArg != null)\r
- throw new SlcAntException("Arg already set.");\r
- structureElementArg = new StructureElementArg();\r
- return structureElementArg;\r
- }\r
-\r
- /** Gets the underlying structure registry. */\r
- protected StructureRegistry<TreeSPath> getRegistry() {\r
- return (StructureRegistry<TreeSPath>) getProject().getReference(\r
- SlcProjectHelper.REF_STRUCTURE_REGISTRY);\r
- }\r
-\r
- /** Creates the treeSPath for a given Ant target. */\r
- protected static TreeSPath createTargetPath(Target target) {\r
- TreeSPath projectPath = (TreeSPath) target.getProject().getReference(\r
- SlcProjectHelper.REF_PROJECT_PATH);\r
- return projectPath.createChild(target.getName());\r
- }\r
-\r
- /** Gets the treeSPath under which this task is registered. */\r
- public TreeSPath getTreeSPath() {\r
- return treeSPath;\r
- }\r
-\r
- public String getLabel() {\r
- String description = super.getDescription();\r
- if (description == null) {\r
- return "<no task def>";\r
- } else {\r
- return description;\r
- }\r
- }\r
-\r
- public void setPath(String path) {\r
- this.path = path;\r
- }\r
-}\r
-\r
-class StructureElementArg extends AbstractSpringArg {\r
- public StructureElement getStructureElement() {\r
- return (StructureElement) getBeanInstance();\r
- }\r
-}
\ No newline at end of file
+++ /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
+++ /dev/null
-package org.argeo.slc.ant.test;\r
-\r
-import java.util.Collection;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Vector;\r
-\r
-import org.apache.tools.ant.types.DataType;\r
-\r
-import org.argeo.slc.ant.spring.MapArg;\r
-import org.argeo.slc.core.SlcException;\r
-import org.argeo.slc.core.test.context.ContextAware;\r
-import org.argeo.slc.core.test.context.ContextUtils;\r
-import org.argeo.slc.core.test.context.ParentContextAware;\r
-\r
-public class ParentContextType extends DataType implements ParentContextAware {\r
- private MapArg values = null;\r
- private MapArg expectedValues = null;\r
-\r
- private String contextAnyFlag = DEFAULT_ANY_FLAG;\r
- private String contextSkipFlag = DEFAULT_SKIP_FLAG;\r
-\r
- private String basedon = null;\r
-\r
- private List<ContextAware> children = new Vector<ContextAware>();\r
-\r
- public MapArg createValues() {\r
- values = new MapArg();\r
- return values;\r
- }\r
-\r
- public MapArg createExpectedValues() {\r
- expectedValues = new MapArg();\r
- return expectedValues;\r
- }\r
-\r
- public void addChildContext(ContextAware contextAware) {\r
- children.add(contextAware);\r
- }\r
-\r
- public Collection<ContextAware> getChildContexts() {\r
- return children;\r
- }\r
-\r
- public String getContextAnyFlag() {\r
- return contextAnyFlag;\r
- }\r
-\r
- public void setContextAnyFlag(String contextAnyFlag) {\r
- this.contextAnyFlag = contextAnyFlag;\r
- }\r
-\r
- public String getContextSkipFlag() {\r
- return contextSkipFlag;\r
- }\r
-\r
- public void setContextSkipFlag(String contextSkipFlag) {\r
- this.contextSkipFlag = contextSkipFlag;\r
- }\r
-\r
- public Map<String, Object> getExpectedValues() {\r
- if (expectedValues == null)\r
- expectedValues = new MapArg();\r
- if (basedon != null) {\r
- Map<String, Object> map = getBaseContext().getExpectedValues();\r
- ContextUtils.putNotContained(expectedValues.getMap(), map);\r
- }\r
- return expectedValues.getMap();\r
- }\r
-\r
- public Map<String, Object> getValues() {\r
- if (values == null)\r
- values = new MapArg();\r
- if (basedon != null) {\r
- Map<String, Object> map = getBaseContext().getValues();\r
- ContextUtils.putNotContained(values.getMap(), map);\r
- }\r
- return values.getMap();\r
- }\r
-\r
- private ParentContextType getBaseContext() {\r
- return (ParentContextType) getProject().getReference(basedon);\r
- }\r
-\r
- public void setValues(Map<String, Object> values) {\r
- throw new SlcException("Cannot override values map.");\r
- }\r
-\r
- public void setUpdateValues(Map<String, Object> overrideValues) {\r
- getValues().putAll(overrideValues);\r
- }\r
-\r
- public void setUpdateExpectedValues(\r
- Map<String, Object> overrideExpectedValues) {\r
- getExpectedValues().putAll(overrideExpectedValues);\r
- }\r
-\r
- public void setBasedon(String basedon) {\r
- this.basedon = basedon;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.ant.test;\r
-\r
-import org.argeo.slc.ant.structure.SAwareTask;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-import org.argeo.slc.core.test.TestResult;\r
-\r
-/** Ant tasks closing a given result. */\r
-public class SlcCloseTestResultTask extends SAwareTask {\r
- private String result;\r
-\r
- @Override\r
- public void executeActions(String mode) {\r
- if (!mode.equals(StructureRegistry.READ)) {\r
- TestResult testResult = (TestResult) getContext().getBean(result);\r
- testResult.close();\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
-}\r
+++ /dev/null
-package org.argeo.slc.ant.test;\r
-\r
-import org.argeo.slc.ant.structure.SAwareTask;\r
-import org.argeo.slc.core.structure.StructureAware;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-import org.argeo.slc.core.test.TestReport;\r
-import org.argeo.slc.core.test.TestResult;\r
-\r
-/** Ant tasks generating a report. */\r
-public class SlcReportTask 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 = null;\r
- if (result != null) {\r
- testResult = (TestResult) getContext().getBean(result);\r
- }\r
- TestReport testReport = (TestReport) getContext().getBean(report);\r
- if (testReport instanceof StructureAware) {\r
- ((StructureAware) testReport).notifyCurrentPath(getRegistry(),\r
- null);\r
- }\r
- testReport.generateTestReport(testResult);\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
-}\r
+++ /dev/null
-package org.argeo.slc.ant.test;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.apache.tools.ant.BuildException;\r
-\r
-import org.argeo.slc.ant.SlcAntConfig;\r
-import org.argeo.slc.ant.spring.AbstractSpringArg;\r
-import org.argeo.slc.ant.structure.SAwareTask;\r
-import org.argeo.slc.core.SlcException;\r
-import org.argeo.slc.core.deploy.DeployedSystem;\r
-import org.argeo.slc.core.process.SlcExecution;\r
-import org.argeo.slc.core.process.SlcExecutionAware;\r
-import org.argeo.slc.core.structure.StructureAware;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.test.ExecutableTestRun;\r
-import org.argeo.slc.core.test.SimpleTestResult;\r
-import org.argeo.slc.core.test.SimpleTestRun;\r
-import org.argeo.slc.core.test.TestData;\r
-import org.argeo.slc.core.test.TestDefinition;\r
-import org.argeo.slc.core.test.TestResult;\r
-import org.argeo.slc.core.test.WritableTestRun;\r
-import org.argeo.slc.spring.SpringUtils;\r
-\r
-/** Ant task wrapping a test run. */\r
-public class SlcTestTask extends SAwareTask {\r
- private Log log = LogFactory.getLog(SlcTestTask.class);\r
-\r
- private String testRunBean = null;\r
-\r
- private TestDefinitionArg testDefinitionArg;\r
- private TestDataArg testDataArg;\r
- private DeployedSystemArg deployedSystemArg;\r
- private TestResultArg testResultArg;\r
-\r
- @Override\r
- public void executeActions(String mode) throws BuildException {\r
- // find test run\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 = null;\r
-\r
- if (testRunBeanT != null) {\r
- testRun = (WritableTestRun) getContext().getBean(testRunBeanT);\r
- if (log.isTraceEnabled())\r
- log.trace("Load test run bean from bean name " + testRunBeanT);\r
- }\r
-\r
- if (testRun == null) {\r
- testRun = loadSingleFromContext(WritableTestRun.class);\r
- if (testRun == null) {\r
- testRun = new SimpleTestRun();\r
- log.warn("Created default simple test run");\r
- } else {\r
- if (log.isTraceEnabled())\r
- log.trace("Load test run from scanning Spring context");\r
- }\r
- }\r
-\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
- testRun.setTestDefinition(testDefinitionArg.getTestDefinition());\r
- log.trace("Overrides test definition");\r
- }\r
-\r
- if (deployedSystemArg != null) {\r
- testRun.setDeployedSystem(deployedSystemArg.getDeployedSystem());\r
- log.trace("Overrides deployed system");\r
- }\r
-\r
- if (testResultArg != null) {\r
- testRun.setTestResult(testResultArg.getTestResult());\r
- log.trace("Overrides test result");\r
- }\r
-\r
- // notify path to test result\r
- TestResult result = testRun.getTestResult();\r
- if (result == null) {\r
- result = loadSingleFromContext(TestResult.class);\r
- if (result == null) {\r
- result = new SimpleTestResult();\r
- log.warn("Created default simple test result");\r
- } else {\r
- if (log.isTraceEnabled())\r
- log.trace("Load test result from scanning Spring context");\r
- }\r
- testRun.setTestResult(result);\r
- }\r
-\r
- SlcExecution slcExecution = getSlcExecution();\r
- testRun.notifySlcExecution(slcExecution);\r
-\r
- if (result != null && result instanceof StructureAware) {\r
- ((StructureAware<TreeSPath>) result).notifyCurrentPath(\r
- getRegistry(), getTreeSPath());\r
- }\r
-\r
- ((ExecutableTestRun) 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
- /** Creates sub tag. */\r
- public TestDefinitionArg createTestDefinition() {\r
- testDefinitionArg = new TestDefinitionArg();\r
- // only test definitions can add to path\r
- addSAwareArg(testDefinitionArg);\r
- return testDefinitionArg;\r
- }\r
-\r
- /** Creates sub tag. */\r
- public TestDataArg createTestData() {\r
- testDataArg = new TestDataArg();\r
- return testDataArg;\r
- }\r
-\r
- /** Creates sub tag. */\r
- public DeployedSystemArg createDeployedSystem() {\r
- deployedSystemArg = new DeployedSystemArg();\r
- return deployedSystemArg;\r
- }\r
-\r
- /** Creates sub tag. */\r
- public TestResultArg createTestResult() {\r
- testResultArg = new TestResultArg();\r
- return testResultArg;\r
- }\r
-\r
- protected <T> T loadSingleFromContext(Class<T> clss) {\r
- return SpringUtils.loadSingleFromContext(getContext(), clss);\r
- }\r
-}\r
-\r
-class TestDefinitionArg extends AbstractSpringArg {\r
- TestDefinition getTestDefinition() {\r
- return (TestDefinition) getBeanInstance();\r
- }\r
-}\r
-\r
-class TestDataArg extends AbstractSpringArg {\r
- TestData getTestData() {\r
- return (TestData) getBeanInstance();\r
- }\r
-\r
-}\r
-\r
-class DeployedSystemArg extends AbstractSpringArg {\r
- DeployedSystem getDeployedSystem() {\r
- return (DeployedSystem) getBeanInstance();\r
- }\r
-\r
-}\r
-\r
-class TestResultArg extends AbstractSpringArg {\r
- TestResult getTestResult() {\r
- return (TestResult) getBeanInstance();\r
- }\r
-\r
-}\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
+++ /dev/null
-package org.argeo.slc.castor.structure.tree;
-
-import org.exolab.castor.mapping.AbstractFieldHandler;
-import org.exolab.castor.mapping.MapItem;
-
-import org.argeo.slc.core.structure.tree.TreeSPath;
-
-public class TreeSPathFieldHandler extends AbstractFieldHandler {
-
- @Override
- public Object getValue(Object object) throws IllegalStateException {
- MapItem part = (MapItem) object;
- return ((TreeSPath) part.getKey()).getAsUniqueString();
- }
-
- @Override
- public Object newInstance(Object parent) throws IllegalStateException {
- return null;
- }
-
- @Override
- public Object newInstance(Object parent, Object[] args)
- throws IllegalStateException {
- return null;
- }
-
- @Override
- public void resetValue(Object object) throws IllegalStateException,
- IllegalArgumentException {
- MapItem part = (MapItem) object;
- part.setKey(null);
- }
-
- @Override
- public void setValue(Object object, Object value)
- throws IllegalStateException, IllegalArgumentException {
- MapItem part = (MapItem) object;
- part.setKey(TreeSPath.parseToCreatePath(value.toString()));
- }
-
-}
+++ /dev/null
-package org.argeo.slc.castor.test.tree;
-
-import org.argeo.slc.core.test.SimpleResultPart;
-import org.argeo.slc.core.test.SlcTestUtils;
-import org.argeo.slc.core.test.TestStatus;
-import org.exolab.castor.mapping.AbstractFieldHandler;
-
-public class StatusFieldHandler extends AbstractFieldHandler {
-
- @Override
- public Object getValue(Object object) throws IllegalStateException {
- SimpleResultPart part = (SimpleResultPart) object;
- return SlcTestUtils.statusToString(part.getStatus());
- }
-
- @Override
- public Object newInstance(Object parent) throws IllegalStateException {
- return null;
- }
-
- @Override
- public Object newInstance(Object parent, Object[] args)
- throws IllegalStateException {
- return null;
- }
-
- @Override
- public void resetValue(Object object) throws IllegalStateException,
- IllegalArgumentException {
- SimpleResultPart part = (SimpleResultPart) object;
- // ERROR by default since it should be explicitely set
- part.setStatus(TestStatus.ERROR);
- }
-
- @Override
- public void setValue(Object object, Object value)
- throws IllegalStateException, IllegalArgumentException {
- SimpleResultPart part = (SimpleResultPart) object;
- Integer status = SlcTestUtils.stringToStatus((String) value);
- part.setStatus(status);
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core;\r
-\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
- /** Constructor. */\r
- public SlcException(String message) {\r
- super(message);\r
- }\r
-\r
- /** Constructor. */\r
- public SlcException(String message, Throwable cause) {\r
- super(message, cause);\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core;\r
-\r
-/** Exception for unsupported features or actions. */\r
-public class UnsupportedException extends SlcException {\r
- static final long serialVersionUID = 1l;\r
-\r
- /** Action not supported. */\r
- public UnsupportedException() {\r
- this("Action not supported");\r
- }\r
-\r
- /** Constructor with a message. */\r
- public UnsupportedException(String message) {\r
- super(message);\r
- }\r
-\r
- /**\r
- * Constructor generating a message.\r
- * \r
- * @param nature\r
- * the nature of the unsupported object\r
- * @param obj\r
- * the object itself (its class name will be used in message)\r
- */\r
- public UnsupportedException(String nature, Object obj) {\r
- super("Unsupported " + nature + ": "\r
- + (obj != null ? obj.getClass() : "[object is null]"));\r
- }\r
-\r
- /**\r
- * Constructor generating a message.\r
- * \r
- * @param nature\r
- * the nature of the unsupported object\r
- * @param clss\r
- * the class itself (will be used in message)\r
- */\r
- public UnsupportedException(String nature, Class<?> clss) {\r
- super("Unsupported " + nature + ": " + clss);\r
- }\r
-\r
- /**\r
- * Constructor generating a message.\r
- * \r
- * @param nature\r
- * the nature of the unsupported object\r
- * @param value\r
- * the problematic value itself\r
- */\r
- public UnsupportedException(String nature, String value) {\r
- super("Unsupported " + nature + ": " + value);\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.build;\r
-\r
-public interface Distribution {\r
- public String getDistributionId();\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.build;\r
-\r
-/** The id uniquely identifying the distribution of a software system. \r
- * @deprecated*/\r
-public interface DistributionId {\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.build;\r
-\r
-import java.util.StringTokenizer;\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 minor;\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
- major = Integer.parseInt(st.nextToken());\r
- if (st.hasMoreTokens())\r
- minor = Integer.parseInt(st.nextToken());\r
- if (st.hasMoreTokens())\r
- release = Integer.parseInt(st.nextToken());\r
- if (st.hasMoreTokens())\r
- additional = st.nextToken();\r
- }\r
-\r
- public Integer getMajor() {\r
- return major;\r
- }\r
-\r
- public void setMajor(Integer major) {\r
- this.major = major;\r
- }\r
-\r
- public Integer getMinor() {\r
- return minor;\r
- }\r
-\r
- public void setMinor(Integer minor) {\r
- this.minor = minor;\r
- }\r
-\r
- public Integer getRelease() {\r
- return release;\r
- }\r
-\r
- public void setRelease(Integer release) {\r
- this.release = release;\r
- }\r
-\r
- public String getAdditional() {\r
- return additional;\r
- }\r
-\r
- public void setAdditional(String additional) {\r
- this.additional = additional;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- // TODO Auto-generated method stub\r
- return super.equals(obj);\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return major + "." + minor + "." + release\r
- + (additional != null ? "." + additional : "");\r
- }\r
-\r
-}\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
+++ /dev/null
-package org.argeo.slc.core.deploy;
-
-import java.io.File;
-import java.util.Map;
-
-public interface DeployEnvironment {
- public void unpackTo(Object packg, File targetLocation,
- Map<String, String> filter);
-}
+++ /dev/null
-package org.argeo.slc.core.deploy;\r
-\r
-import org.argeo.slc.core.build.Distribution;\r
-\r
-/** An instance of a software system. */\r
-public interface DeployedSystem {\r
- public String getDeployedSystemId();\r
- public Distribution getDistribution();\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.deploy;\r
-\r
-import org.argeo.slc.core.build.DistributionId;\r
-\r
-/** The id uniquely identifying a deployed system. \r
- * @deprecated*/\r
-public interface DeployedSystemId {\r
- public DistributionId getDistributionId();\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.deploy;\r
-\r
-public interface Deployment {\r
- public DeployedSystem getDeployedSystem();\r
-\r
- public TargetData getTargetData();\r
-\r
- public DeploymentData getDeploymentData();\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.deploy;\r
-\r
-public interface DeploymentData {\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.deploy;\r
-\r
-public interface ExecutableDeployment extends Deployment {\r
- public void execute();\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.deploy;\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
- private DistributionId distributionId;\r
-\r
- public Long getValue() {\r
- return value;\r
- }\r
-\r
- public void setValue(Long value) {\r
- this.value = value;\r
- }\r
-\r
- public DistributionId getDistributionId() {\r
- return distributionId;\r
- }\r
-\r
- public void setDistributionId(DistributionId distributionId) {\r
- this.distributionId = distributionId;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- return value.toString().equals(obj.toString());\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return value.toString();\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.deploy;\r
-\r
-public interface TargetData {\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.deploy;\r
-\r
-public interface WritableDeployment extends ExecutableDeployment {\r
- public void setDeployedSystem(DeployedSystem deployedSystem);\r
-\r
- public void setTargetData(TargetData targetData);\r
-\r
- public void setDeploymentData(DeploymentData deploymentData);\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
+++ /dev/null
-package org.argeo.slc.core.process;\r
-\r
-import java.io.File;\r
-import java.io.FileWriter;\r
-import java.text.SimpleDateFormat;\r
-import java.util.Date;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import javax.xml.transform.stream.StreamResult;\r
-\r
-import org.springframework.oxm.Marshaller;\r
-\r
-import org.apache.commons.io.IOUtils;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-\r
-public class FileSlcExecutionNotifier implements SlcExecutionNotifier {\r
- private final static SimpleDateFormat sdf = new SimpleDateFormat(\r
- "yyyyMMdd-HHmmss");\r
-\r
- private String basePath;\r
- private Marshaller marshaller;\r
-\r
- private Map<String, String> uuidToDir = new HashMap<String, String>();\r
-\r
- public void addSteps(SlcExecution slcExecution,\r
- List<SlcExecutionStep> additionalSteps) {\r
- writeSlcExecution(slcExecution);\r
- }\r
-\r
- public void newExecution(SlcExecution slcExecution) {\r
- String dirPath = basePath + File.separator + sdf.format(new Date())\r
- + '-' + slcExecution.getUuid();\r
- File dir = new File(dirPath);\r
- dir.mkdirs();\r
-\r
- uuidToDir.put(slcExecution.getUuid(), dirPath);\r
-\r
- writeSlcExecution(slcExecution);\r
- }\r
-\r
- public void updateExecution(SlcExecution slcExecution) {\r
- writeSlcExecution(slcExecution);\r
- }\r
-\r
- public void updateStatus(SlcExecution slcExecution, String oldStatus,\r
- String newStatus) {\r
- writeSlcExecution(slcExecution);\r
- }\r
-\r
- protected void writeSlcExecution(SlcExecution slcExecution) {\r
- FileWriter out = null;\r
- try {\r
- out = new FileWriter(getFilePath(slcExecution));\r
- marshaller.marshal(slcExecution, new StreamResult(out));\r
- } catch (Exception e) {\r
- throw new SlcException("Cannot marshall SlcExecution to "\r
- + getFilePath(slcExecution), e);\r
- } finally {\r
- IOUtils.closeQuietly(out);\r
- }\r
- }\r
-\r
- protected String getFileName(SlcExecution slcExecution) {\r
- return "SlcExecution-" + slcExecution.getUuid() + ".xml";\r
- }\r
-\r
- protected String getFilePath(SlcExecution slcExecution) {\r
- String dirPath = uuidToDir.get(slcExecution.getUuid());\r
- return dirPath + File.separator + "SlcExecution-"\r
- + slcExecution.getUuid() + ".xml";\r
- }\r
-\r
- public void setBasePath(String basePath) {\r
- this.basePath = basePath;\r
- }\r
-\r
- public void setMarshaller(Marshaller marshaller) {\r
- this.marshaller = marshaller;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.process;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.TreeMap;\r
-import java.util.Vector;\r
-\r
-public class SlcExecution {\r
- public final static String STATUS_SCHEDULED = "SCHEDULED";\r
- public final static String STATUS_RUNNING = "RUNNING";\r
- public final static String STATUS_FINISHED = "FINISHED";\r
- public final static String STATUS_ERROR = "ERROR";\r
- public final static String STATUS_CLEANED = "CLEANED";\r
-\r
- public final static String UNKOWN_HOST = "UNKOWN_HOST";\r
-\r
- private String uuid;\r
- private String host;\r
- private String user;\r
- private String type;\r
- private String status;\r
- private Map<String, String> attributes = new TreeMap<String, String>();\r
-\r
- private List<SlcExecutionStep> steps = new Vector<SlcExecutionStep>();\r
-\r
- public List<SlcExecutionStep> getSteps() {\r
- return steps;\r
- }\r
-\r
- public void setSteps(List<SlcExecutionStep> steps) {\r
- this.steps = steps;\r
- }\r
-\r
- public String getUuid() {\r
- return uuid;\r
- }\r
-\r
- public void setUuid(String uuid) {\r
- this.uuid = uuid;\r
- }\r
-\r
- public String getHost() {\r
- return host;\r
- }\r
-\r
- public void setHost(String host) {\r
- this.host = host;\r
- }\r
-\r
- public String getUser() {\r
- return user;\r
- }\r
-\r
- public void setUser(String path) {\r
- this.user = path;\r
- }\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public void setType(String type) {\r
- this.type = type;\r
- }\r
-\r
- public String getStatus() {\r
- return status;\r
- }\r
-\r
- public void setStatus(String status) {\r
- this.status = status;\r
- }\r
-\r
- public SlcExecutionStep currentStep() {\r
- if (steps.size() > 0)\r
- return steps.get(steps.size() - 1);\r
- else\r
- return null;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (obj instanceof SlcExecution) {\r
- return getUuid().equals(((SlcExecution) obj).getUuid());\r
- }\r
- return false;\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return getUuid().hashCode();\r
- }\r
-\r
- public Map<String, String> getAttributes() {\r
- return attributes;\r
- }\r
-\r
- public void setAttributes(Map<String, String> attributes) {\r
- this.attributes = attributes;\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.process;\r
-\r
-public interface SlcExecutionAware {\r
- public void notifySlcExecution(SlcExecution slcExecution);\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.process;\r
-\r
-import java.util.List;\r
-\r
-public interface SlcExecutionNotifier {\r
- public void newExecution(SlcExecution slcExecution);\r
-\r
- public void addSteps(SlcExecution slcExecution,\r
- List<SlcExecutionStep> additionalSteps);\r
-\r
- public void updateExecution(SlcExecution slcExecution);\r
-\r
- public void updateStatus(SlcExecution slcExecution, String oldStatus,\r
- String newStatus);\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.process;\r
-\r
-import java.io.IOException;\r
-import java.io.StringReader;\r
-import java.io.StringWriter;\r
-import java.util.Date;\r
-import java.util.List;\r
-import java.util.UUID;\r
-import java.util.Vector;\r
-\r
-import org.apache.commons.io.IOUtils;\r
-\r
-public class SlcExecutionStep {\r
- private String uuid;\r
- private String type;\r
- private Date begin;\r
- private List<String> logLines = new Vector<String>();\r
-\r
- /** Empty constructor */\r
- public SlcExecutionStep() {\r
- }\r
-\r
- public SlcExecutionStep(String type, String log) {\r
- this.type = type;\r
- this.begin = new Date();\r
- this.uuid = UUID.randomUUID().toString();\r
- addLog(log);\r
- }\r
-\r
- public String getUuid() {\r
- return uuid;\r
- }\r
-\r
- public void setUuid(String uuid) {\r
- this.uuid = uuid;\r
- }\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public void setType(String type) {\r
- this.type = type;\r
- }\r
-\r
- public Date getBegin() {\r
- return begin;\r
- }\r
-\r
- public void setBegin(Date begin) {\r
- this.begin = begin;\r
- }\r
-\r
- public List<String> getLogLines() {\r
- return logLines;\r
- }\r
-\r
- public void setLogLines(List<String> logLines) {\r
- this.logLines = logLines;\r
- }\r
-\r
- public String logAsString() {\r
- StringWriter writer = new StringWriter();\r
- String log = writer.toString();\r
- IOUtils.closeQuietly(writer);\r
- return log;\r
- }\r
-\r
- public void addLog(String log) {\r
- if (log == null)\r
- return;\r
-\r
- try {\r
- List<String> lines = IOUtils.readLines(new StringReader(log));\r
- logLines.addAll(lines);\r
- } catch (IOException e) {\r
- throw new RuntimeException("Cannot add log", e);\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.process;\r
-\r
-import java.util.List;\r
-\r
-import org.springframework.ws.client.WebServiceIOException;\r
-import org.springframework.ws.client.core.WebServiceTemplate;\r
-import org.springframework.ws.soap.client.SoapFaultClientException;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.msg.process.SlcExecutionRequest;\r
-import org.argeo.slc.msg.process.SlcExecutionStatusRequest;\r
-import org.argeo.slc.msg.process.SlcExecutionStepsRequest;\r
-import org.argeo.slc.ws.client.WebServiceUtils;\r
-\r
-public class WebServiceSlcExecutionNotifier implements SlcExecutionNotifier {\r
- private WebServiceTemplate template;\r
-\r
- private Log log = LogFactory.getLog(getClass());\r
-\r
- private Boolean cannotConnect = false;\r
-\r
- public void newExecution(SlcExecution slcExecution) {\r
- if (cannotConnect)\r
- return;\r
-\r
- SlcExecutionRequest req = new SlcExecutionRequest();\r
- req.setSlcExecution(slcExecution);\r
- try {\r
- WebServiceUtils.marshalSendAndReceive(template, req);\r
- if (log.isTraceEnabled())\r
- log.trace("Notified creation of slc execution "\r
- + slcExecution.getUuid());\r
- } catch (SoapFaultClientException e) {\r
- WebServiceUtils.manageSoapException(e);\r
- } catch (WebServiceIOException e) {\r
- manageIoException(e);\r
- }\r
- }\r
-\r
- public void updateExecution(SlcExecution slcExecution) {\r
- if (cannotConnect)\r
- return;\r
-\r
- SlcExecutionRequest req = new SlcExecutionRequest();\r
- req.setSlcExecution(slcExecution);\r
- try {\r
- WebServiceUtils.marshalSendAndReceive(template, req);\r
- if (log.isTraceEnabled())\r
- log.trace("Notified update of slc execution "\r
- + slcExecution.getUuid());\r
- } catch (SoapFaultClientException e) {\r
- WebServiceUtils.manageSoapException(e);\r
- } catch (WebServiceIOException e) {\r
- manageIoException(e);\r
- }\r
- }\r
-\r
- public void updateStatus(SlcExecution slcExecution, String oldStatus,\r
- String newStatus) {\r
- if (cannotConnect)\r
- return;\r
-\r
- SlcExecutionStatusRequest req = new SlcExecutionStatusRequest(\r
- slcExecution.getUuid(), newStatus);\r
- try {\r
- WebServiceUtils.marshalSendAndReceive(template, req);\r
- if (log.isTraceEnabled())\r
- log.trace("Notified status update of slc execution "\r
- + slcExecution.getUuid());\r
- } catch (SoapFaultClientException e) {\r
- WebServiceUtils.manageSoapException(e);\r
- } catch (WebServiceIOException e) {\r
- manageIoException(e);\r
- }\r
- }\r
-\r
- public void addSteps(SlcExecution slcExecution,\r
- List<SlcExecutionStep> additionalSteps) {\r
- if (cannotConnect)\r
- return;\r
-\r
- SlcExecutionStepsRequest req = new SlcExecutionStepsRequest();\r
- req.setSlcExecutionUuid(slcExecution.getUuid());\r
- req.setSteps(additionalSteps);\r
- if (log.isTraceEnabled()) {\r
- for (SlcExecutionStep step : additionalSteps) {\r
- log.trace("Step " + step.getUuid() + ": " + step.logAsString());\r
- }\r
- }\r
-\r
- try {\r
- WebServiceUtils.marshalSendAndReceive(template, req);\r
- if (log.isTraceEnabled())\r
- log.trace("Added steps to slc execution "\r
- + slcExecution.getUuid());\r
- } catch (SoapFaultClientException e) {\r
- WebServiceUtils.manageSoapException(e);\r
- } catch (WebServiceIOException e) {\r
- manageIoException(e);\r
- }\r
- }\r
-\r
- public void setTemplate(WebServiceTemplate template) {\r
- this.template = template;\r
- }\r
-\r
- protected void manageIoException(WebServiceIOException e) {\r
- if (!cannotConnect) {\r
- log.error("Cannot connect to " + template.getDefaultUri()\r
- + ". Won't try again.", e);\r
- cannotConnect = true;\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.structure;\r
-\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
-\r
-/** Default implementation of a <code>StructureRegistry</code>. */\r
-public class DefaultSRegistry implements StructureRegistry<StructurePath> {\r
- private static Log log = LogFactory.getLog(DefaultSRegistry.class);\r
-\r
- private List<StructureElement> elements = new Vector<StructureElement>();\r
- private List<StructurePath> paths = new Vector<StructurePath>();\r
- private String mode = StructureRegistry.ALL;\r
-\r
- private List<StructurePath> activePaths;\r
-\r
- public List<StructureElement> listElements() {\r
- return new Vector<StructureElement>(elements);\r
- }\r
-\r
- public List<StructurePath> listPaths() {\r
- return new Vector<StructurePath>(paths);\r
- }\r
-\r
- public void register(StructurePath path, StructureElement element) {\r
- StructureElement treeSElement = element;\r
- elements.add(treeSElement);\r
- paths.add(path);\r
-\r
- if (log.isTraceEnabled())\r
- log.trace("Registered " + path + " (label: '"\r
- + treeSElement.getLabel() + "', position: "\r
- + elements.size() + ")");\r
- }\r
-\r
- public StructureElement getElement(StructurePath path) {\r
- int index = paths.indexOf(path);\r
- if (index >= 0) {\r
- return elements.get(index);\r
- } else {// not found\r
- return null;\r
- }\r
- }\r
-\r
- public String getMode() {\r
- return mode;\r
- }\r
-\r
- public void setMode(String mode) {\r
- this.mode = mode;\r
- }\r
-\r
- public List<StructurePath> getActivePaths() {\r
- return activePaths;\r
- }\r
-\r
- public void setActivePaths(List<StructurePath> activePaths) {\r
- this.activePaths = activePaths;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.structure;\r
-\r
-import java.util.Map;\r
-import java.util.TreeMap;\r
-\r
-import javax.swing.tree.TreeSelectionModel;\r
-\r
-/**\r
- * Basic implementation of <code>StructureElement</code>.\r
- * \r
- * @see TreeSPath\r
- */\r
-public class SimpleSElement implements StructureElement {\r
- /** For ORM */\r
- private Long tid;\r
- private String label;\r
- private Map<String, String> tags = new TreeMap<String, String>();\r
-\r
- /** For ORM */\r
- public SimpleSElement() {\r
- }\r
-\r
- /** Constructor */\r
- public SimpleSElement(String label) {\r
- this.label = label;\r
- }\r
-\r
- /** Constructor */\r
- public SimpleSElement(String label, String defaultLabel) {\r
- this(label != null ? label : defaultLabel);\r
- }\r
-\r
- /** Constructor */\r
- public SimpleSElement(SimpleSElement sElement) {\r
- setLabel(sElement.getLabel());\r
- setTags(new TreeMap<String, String>(sElement.getTags()));\r
- }\r
-\r
- public String getLabel() {\r
- return label;\r
- }\r
-\r
- /** Sets the label. */\r
- public void setLabel(String label) {\r
- this.label = label;\r
- }\r
-\r
- public Long getTid() {\r
- return tid;\r
- }\r
-\r
- void setTid(Long tid) {\r
- this.tid = tid;\r
- }\r
-\r
- public Map<String, String> getTags() {\r
- return tags;\r
- }\r
-\r
- public void setTags(Map<String, String> tags) {\r
- this.tags = tags;\r
- }\r
-\r
- @Override\r
- public SimpleSElement clone(){\r
- return new SimpleSElement(this);\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.structure;\r
-\r
-/**\r
- * Wrapper for an element, which is able to propagate registration to\r
- * sub-elements.\r
- */\r
-public interface StructureAware<T extends StructurePath> {\r
- /** Called <b>after</b> registration. */\r
- public void notifyCurrentPath(StructureRegistry<T> registry, T path);\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.structure;\r
-\r
-/**\r
- * Atomic element holding metadata such as description about the element which\r
- * registered.\r
- */\r
-public interface StructureElement {\r
- /** Label of this element. */\r
- public String getLabel();\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.structure;\r
-\r
-public interface StructureElementProvider {\r
- public StructureElement createStructureElement();\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.structure;\r
-\r
-/**\r
- * Path allowing to uniquely identify a <code>StructureElement</code> within a\r
- * registry.\r
- * \r
- * @see StructureElement\r
- * @see StructurePath\r
- */\r
-public interface StructurePath {\r
- /**\r
- * Unique representation as a string. Most implementation will also provide\r
- * a mean to interpret this string.\r
- */\r
- public String getAsUniqueString();\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.structure;\r
-\r
-import java.util.List;\r
-\r
-import org.argeo.slc.core.deploy.DeployedSystem;\r
-\r
-/** Registry where the whole structure is stored. */\r
-public interface StructureRegistry<P extends StructurePath> {\r
- /** Read mode: the structure is only read. */\r
- public static String READ = "READ";\r
- /** All mode: everything is executed regardless of the active paths. */\r
- public static String ALL = "ALL";\r
- /** Active mode: only the active paths are executed. */\r
- public static String ACTIVE = "STATUS_ACTIVE";\r
-\r
- /** Adds an element to the registry. */\r
- public void register(P path, StructureElement element);\r
-\r
- /** Lists <b>all</b> registered elements. */\r
- public List<StructureElement> listElements();\r
-\r
- /** Lists <b>all</b> registered elements. */\r
- public List<P> listPaths();\r
-\r
- /** Gets a element based on its path. */\r
- public <T extends StructureElement> T getElement(P path);\r
-\r
- /**\r
- * Set the interpreter mode: read, all or active.\r
- * \r
- * @see #READ\r
- * @see #ALL\r
- * @see #STATUS_ACTIVE\r
- */\r
- public void setMode(String mode);\r
-\r
- /**\r
- * Gets the current interpreter mode.\r
- * \r
- * @see #READ\r
- * @see #ALL\r
- * @see #STATUS_ACTIVE\r
- */\r
- public String getMode();\r
-\r
- /**\r
- * Gets the list of active paths, which will be run if executed in\r
- * <code>STATUS_ACTIVE</code> mode.\r
- */\r
- public List<P> getActivePaths();\r
-\r
- /**\r
- * Sets the list of active path, which will be run if executed in\r
- * <code>STATUS_ACTIVE</code> mode.\r
- */\r
- public void setActivePaths(List<P> activePaths);\r
-}\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
+++ /dev/null
-package org.argeo.slc.core.structure.tree;\r
-\r
-import java.util.List;\r
-import java.util.StringTokenizer;\r
-import java.util.Vector;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-import org.argeo.slc.core.structure.StructurePath;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-\r
-/**\r
- * Path for tree based <code>StructureRegistry</code> implementations.\r
- */\r
-public class TreeSPath implements StructurePath, Comparable<StructurePath> {\r
- /** Default character to use a separator: /. */\r
- private static Character DEFAULT_SEPARATOR = '/';\r
-\r
- private Character separator = DEFAULT_SEPARATOR;\r
-\r
- private String asUniqueString;\r
-\r
- /** For ORM */\r
- private Long tid;\r
-\r
- public TreeSPath() {\r
-\r
- }\r
-\r
- public TreeSPath(String asUniqueString) {\r
- this.asUniqueString = checkAndFormatPath(asUniqueString);\r
- }\r
-\r
- public String getAsUniqueString() {\r
- return asUniqueString;\r
- }\r
-\r
- /**\r
- * Sets all the required data from a string. <b>ATTENTION</b>: the path is\r
- * not checked for performance reason. This method should be used only by\r
- * ORM/OXM frameworks. Use constructor to create immutable tree structure\r
- * paths.\r
- */\r
- public void setAsUniqueString(String str) {\r
- this.asUniqueString = str;\r
- }\r
-\r
- /** The separator actually used by this path. */\r
- public Character getSeparator() {\r
- return separator;\r
- }\r
-\r
- /** Gets the parent path. */\r
- public TreeSPath getParent() {\r
- int lastSep = getAsUniqueString().lastIndexOf(separator);\r
- if (lastSep < 1) {\r
- return null;\r
- }\r
- String parentUniqueString = getAsUniqueString().substring(0, lastSep);\r
- return new TreeSPath(parentUniqueString);\r
- }\r
-\r
- /** Gets the name part of the path. */\r
- public String getName() {\r
- int lastSep = getAsUniqueString().lastIndexOf(separator);\r
- return getAsUniqueString().substring(lastSep+1);\r
- }\r
-\r
- /** Create a path without parent. */\r
- public static TreeSPath createRootPath(String name) {\r
- if (name.indexOf(DEFAULT_SEPARATOR) >= 0) {\r
- throw new SlcException("Name cannot contain " + DEFAULT_SEPARATOR);\r
- }\r
- return new TreeSPath('/' + name);\r
- }\r
-\r
- /** Create a child . */\r
- public TreeSPath createChild(String name) {\r
- if (name.indexOf(separator) > -1) {\r
- throw new SlcException("Tree path name '" + name\r
- + "' contains separator character " + separator);\r
- }\r
- return new TreeSPath(getAsUniqueString() + '/' + name);\r
- }\r
-\r
- /**\r
- * Parses a string to a path.\r
- * \r
- * @deprecated use constructor instead\r
- */\r
- public static TreeSPath parseToCreatePath(String path) {\r
- return parseToCreatePath(path, DEFAULT_SEPARATOR);\r
- }\r
-\r
- protected String checkAndFormatPath(String str) {\r
- if (str.length() < 2) {\r
- throw new SlcException("Path " + str + " is not short");\r
- }\r
- if (str.charAt(0) != separator) {\r
- throw new SlcException("Path " + str + " have to start with "\r
- + separator);\r
- }\r
-\r
- StringBuffer buf = new StringBuffer(str.length() + 5);\r
- StringTokenizer st = new StringTokenizer(str, separator.toString());\r
- while (st.hasMoreTokens()) {\r
- buf.append(separator).append(st.nextToken());\r
- }\r
- return buf.toString();\r
- }\r
-\r
- /**\r
- * Parses a string to a path.\r
- * \r
- * @deprecated use constructor instead\r
- */\r
- public static TreeSPath parseToCreatePath(String path, Character separator) {\r
- return new TreeSPath(path);\r
- }\r
-\r
- /** Lists the children from a registry. */\r
- public List<TreeSPath> listChildren(StructureRegistry<TreeSPath> registry) {\r
- return listChildrenPaths(registry, this);\r
- }\r
-\r
- /** Lists the children from a given path from a registry. */\r
- public static List<TreeSPath> listChildrenPaths(\r
- StructureRegistry<TreeSPath> registry, TreeSPath path) {\r
- List<TreeSPath> paths = new Vector<TreeSPath>();\r
- List<TreeSPath> allPaths = registry.listPaths();\r
- for (TreeSPath pathT : allPaths) {\r
- if (pathT.getParent() != null && pathT.getParent().equals(path)) {\r
- paths.add(pathT);\r
- }\r
- }\r
- return paths;\r
- }\r
-\r
- /** Gets the root tree path of this path. */\r
- public TreeSPath getRoot() {\r
- TreeSPath root = this;\r
- while (root.getParent() != null) {\r
- root = root.getParent();\r
- }\r
- return root;\r
- }\r
-\r
- /** Depth of this path. */\r
- public Integer getDepth() {\r
- return depthImpl(this);\r
- }\r
-\r
- protected int depthImpl(TreeSPath path) {\r
- if (path.getParent() == null) {\r
- return 1;\r
- } else {\r
- return depthImpl(path.getParent()) + 1;\r
- }\r
- }\r
-\r
- public List<TreeSPath> getHierarchyAsList() {\r
- List<TreeSPath> lst = new Vector<TreeSPath>();\r
- addParentToList(lst, this);\r
- lst.add(this);\r
- return lst;\r
- }\r
-\r
- protected void addParentToList(List<TreeSPath> lst, TreeSPath current) {\r
- TreeSPath parent = current.getParent();\r
- if (parent != null) {\r
- addParentToList(lst, parent);\r
- lst.add(parent);\r
- }\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return getAsUniqueString();\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (obj instanceof StructurePath) {\r
- StructurePath path = (StructurePath) obj;\r
- return getAsUniqueString().equals(path.getAsUniqueString());\r
- }\r
- return false;\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return getAsUniqueString().hashCode();\r
- }\r
-\r
- public int compareTo(StructurePath o) {\r
- return getAsUniqueString().compareTo(o.getAsUniqueString());\r
- }\r
-\r
- public Long getTid() {\r
- return tid;\r
- }\r
-\r
- void setTid(Long tid) {\r
- this.tid = tid;\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.structure.tree;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.TreeMap;\r
-import java.util.Vector;\r
-\r
-import org.argeo.slc.core.UnsupportedException;\r
-import org.argeo.slc.core.structure.SimpleSElement;\r
-import org.argeo.slc.core.structure.StructureElement;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-\r
-/** Tree based implementation of a structure registry. */\r
-public class TreeSRegistry implements StructureRegistry<TreeSPath> {\r
- public final static String STATUS_ACTIVE = "STATUS_ACTIVE";\r
-\r
- /** For ORM */\r
- private Long tid;\r
- private String status;\r
- private Map<TreeSPath, SimpleSElement> elements = new TreeMap<TreeSPath, SimpleSElement>();\r
-\r
- private String mode = StructureRegistry.ALL;\r
-\r
- private List<TreeSPath> activePaths;\r
-\r
- public <T extends StructureElement> T getElement(TreeSPath path) {\r
- return (T)elements.get(path);\r
- }\r
-\r
- public List<StructureElement> listElements() {\r
- return new Vector<StructureElement>(elements.values());\r
- }\r
-\r
- public List<TreeSPath> listPaths() {\r
- return new Vector<TreeSPath>(elements.keySet());\r
- }\r
-\r
- public void register(TreeSPath path, StructureElement element) {\r
- final SimpleSElement simpleSElement;\r
- if (element instanceof SimpleSElement) {\r
- simpleSElement = (SimpleSElement) element;\r
- } else {\r
- simpleSElement = new SimpleSElement(element.getLabel());\r
- }\r
-\r
- if (path == null)\r
- throw new UnsupportedException("Path cannot be null.");\r
-\r
- elements.put(path, simpleSElement);\r
-\r
- }\r
-\r
- public String getMode() {\r
- return mode;\r
- }\r
-\r
- public void setMode(String mode) {\r
- this.mode = mode;\r
- }\r
-\r
- public List<TreeSPath> getActivePaths() {\r
- return activePaths;\r
- }\r
-\r
- public void setActivePaths(List<TreeSPath> activePaths) {\r
- this.activePaths = activePaths;\r
- }\r
-\r
- public String getStatus() {\r
- return status;\r
- }\r
-\r
- public void setStatus(String status) {\r
- this.status = status;\r
- }\r
-\r
- /** Gets the elements. */\r
- public Map<TreeSPath, SimpleSElement> getElements() {\r
- return elements;\r
- }\r
-\r
- /** Sets the elements (for ORM). */\r
- public void setElements(Map<TreeSPath, SimpleSElement> elements) {\r
- this.elements = elements;\r
- }\r
-\r
- Long getTid() {\r
- return tid;\r
- }\r
-\r
- void setTid(Long tid) {\r
- this.tid = tid;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.structure.tree;\r
-\r
-import org.argeo.slc.core.structure.StructureAware;\r
-import org.argeo.slc.core.structure.StructureElement;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-\r
-public interface TreeSRelated extends StructureAware<TreeSPath>{\r
- public TreeSPath getBasePath();\r
- public StructureRegistry<TreeSPath> getRegistry();\r
- public StructureElement getStructureElement(String key);\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.structure.tree;\r
-\r
-import org.argeo.slc.core.structure.SimpleSElement;\r
-import org.argeo.slc.core.structure.StructureElement;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-\r
-/**\r
- * Provides default implementations of some methods of <code>TreeSRelated</code>.\r
- */\r
-public abstract class TreeSRelatedHelper implements TreeSRelated {\r
- private TreeSPath basePath;\r
- private StructureRegistry<TreeSPath> registry;\r
-\r
- public TreeSPath getBasePath() {\r
- return basePath;\r
- }\r
-\r
- public StructureRegistry<TreeSPath> getRegistry() {\r
- return registry;\r
- }\r
-\r
- public void notifyCurrentPath(StructureRegistry<TreeSPath> registry,\r
- TreeSPath path) {\r
- basePath = path;\r
- this.registry = registry;\r
- }\r
-\r
- public StructureElement getStructureElement(String key) {\r
- return new SimpleSElement(key);\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
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-\r
-public class BasicTestData implements TestData {\r
- private Object expected;\r
- private Object reached;\r
-\r
- public Object getExpected() {\r
- return expected;\r
- }\r
-\r
- public void setExpected(Object expected) {\r
- this.expected = expected;\r
- }\r
-\r
- public Object getReached() {\r
- return reached;\r
- }\r
-\r
- public void setReached(Object reached) {\r
- this.reached = reached;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-import org.argeo.slc.core.structure.tree.TreeSRelatedHelper;\r
-import org.argeo.slc.core.test.context.ContextAware;\r
-import org.argeo.slc.core.test.context.ContextUtils;\r
-\r
-/** Understands basic test data and context aware test data. */\r
-public class BasicTestDefinition extends TreeSRelatedHelper implements\r
- TestDefinition {\r
-\r
- public void execute(TestRun testRun) {\r
- if (testRun.<TestData> getTestData() instanceof BasicTestData) {\r
- BasicTestData testData = testRun.getTestData();\r
- TestResult result = testRun.getTestResult();\r
-\r
- try {\r
- if (testData.getExpected().equals(testData.getReached())) {\r
- result.addResultPart(new SimpleResultPart(\r
- TestStatus.PASSED, "Reached and expected equals"));\r
- } else {\r
- result.addResultPart(new SimpleResultPart(\r
- TestStatus.FAILED, "Expected "\r
- + testData.getExpected() + " but reched "\r
- + testData.getReached()));\r
- }\r
- } catch (Exception e) {\r
- result.addResultPart(new SimpleResultPart(TestStatus.ERROR,\r
- "Could not compare", e));\r
- }\r
- } else if (testRun.<TestData> getTestData() instanceof ContextAware) {\r
- TestData testData = testRun.getTestData();\r
- ContextUtils.compareReachedExpected((ContextAware) testData,\r
- testRun.getTestResult(), this);\r
- }\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-/** A test run that can be executed */\r
-public interface ExecutableTestRun extends TestRun {\r
-\r
- /** Executes this test run. */\r
- public void execute();\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-\r
-/**\r
- * Exception to throw when a test definition cannot interpret the provided test\r
- * data.\r
- */\r
-public class IncompatibleTestDataException extends SlcException {\r
- static final long serialVersionUID = 1l;\r
-\r
- public IncompatibleTestDataException(TestData testData,\r
- TestDefinition testDefinition) {\r
- super("TestData " + testData.getClass()\r
- + " is not compatible with TestDefinition "\r
- + testDefinition.getClass());\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\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
- * @deprecated\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
- /** For ORM */\r
- public NumericTRId() {\r
-\r
- }\r
-\r
- public NumericTRId(Long value) {\r
- this.value = value;\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
- public Long getValue() {\r
- return value;\r
- }\r
-\r
- public void setValue(Long value) {\r
- this.value = value;\r
- }\r
-\r
- public DeployedSystemId getDeployedSystemId() {\r
- return deployedSystemId;\r
- }\r
-\r
- public void setDeployedSystemId(DeployedSystemId deployedSystemId) {\r
- this.deployedSystemId = deployedSystemId;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- return value.toString().equals(obj.toString());\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return value.toString();\r
- }\r
-\r
- Long getTid() {\r
- return tid;\r
- }\r
-\r
- void setTid(Long tid) {\r
- this.tid = tid;\r
- }\r
-\r
-}\r
+++ /dev/null
-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
- * \r
- * @see TestStatus\r
- */\r
-public class SimpleResultPart implements TestResultPart, TestStatus,\r
- TestRunAware {\r
-\r
- /** @deprecated */\r
- private Long tid;\r
-\r
- private String testRunUuid;\r
-\r
- /** The status. Default to ERROR since it should always be explicitely set. */\r
- private Integer status = ERROR;\r
- private String message;\r
- private String exceptionMessage;\r
-\r
- public SimpleResultPart() {\r
- }\r
-\r
- public SimpleResultPart(Integer status, String message) {\r
- this(status, message, null);\r
- }\r
-\r
- public SimpleResultPart(Integer status, String message, Exception exception) {\r
- this.status = status;\r
- this.message = message;\r
- setException(exception);\r
- }\r
-\r
- public String getMessage() {\r
- return message;\r
- }\r
-\r
- public void setMessage(String message) {\r
- this.message = message;\r
- }\r
-\r
- public void setStatus(Integer status) {\r
- this.status = status;\r
- }\r
-\r
- public Integer getStatus() {\r
- return status;\r
- }\r
-\r
- public String getExceptionMessage() {\r
- return exceptionMessage;\r
- }\r
-\r
- public void setException(Exception exception) {\r
- if (exception == null)\r
- return;\r
-\r
- StringBuffer buf = new StringBuffer("");\r
- buf.append(exception.toString());\r
- buf.append('\n');\r
- for (StackTraceElement elem : exception.getStackTrace()) {\r
- buf.append('\t').append(elem.toString()).append('\n');\r
- }\r
-\r
- if (exception.getCause() != null)\r
- addRootCause(buf, exception.getCause());\r
-\r
- this.exceptionMessage = buf.toString();\r
- }\r
-\r
- protected void addRootCause(StringBuffer buf, Throwable cause) {\r
- if (cause == null)\r
- return;\r
-\r
- buf.append("Caused by: " + cause.getMessage());\r
- for (StackTraceElement elem : cause.getStackTrace()) {\r
- buf.append('\t').append(elem.toString()).append('\n');\r
- }\r
-\r
- if (cause.getCause() != null) {\r
- addRootCause(buf, cause.getCause());\r
- }\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- StringBuffer buf = new StringBuffer("");\r
- buf.append(SlcTestUtils.statusToString(status));\r
- if (status == PASSED || status == FAILED) {\r
- buf.append(' ');\r
- } else if (status == ERROR) {\r
- buf.append(" ");\r
- }\r
- buf.append(message);\r
- return buf.toString();\r
- }\r
-\r
- /** @deprecated */\r
- Long getTid() {\r
- return tid;\r
- }\r
-\r
- /** @deprecated */\r
- void setTid(Long tid) {\r
- this.tid = tid;\r
- }\r
-\r
- public String getTestRunUuid() {\r
- return testRunUuid;\r
- }\r
-\r
- /** For ORM */\r
- public void setTestRunUuid(String testRunUuid) {\r
- this.testRunUuid = testRunUuid;\r
- }\r
-\r
- public void notifyTestRun(TestRun testRun) {\r
- testRunUuid = testRun.getUuid();\r
- }\r
-\r
- public void setExceptionMessage(String exceptionMessage) {\r
- this.exceptionMessage = exceptionMessage;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-import java.util.Date;\r
-import java.util.List;\r
-import java.util.UUID;\r
-import java.util.Vector;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-\r
-/**\r
- * Basic implementation of a test result containing only a list of result parts.\r
- */\r
-public class SimpleTestResult implements TestResult {\r
- private static Log log = LogFactory.getLog(SimpleTestResult.class);\r
-\r
- private String uuid;\r
- private String currentTestRunUuid;\r
-\r
- private Boolean throwError = true;\r
-\r
- private Date closeDate;\r
- private List<TestResultPart> parts = new Vector<TestResultPart>();\r
-\r
- public void addResultPart(TestResultPart part) {\r
- if (throwError && part.getStatus() == ERROR) {\r
- throw new SlcException(\r
- "There was an error in the underlying test: "\r
- + part.getExceptionMessage());\r
- }\r
- parts.add(part);\r
- if (log.isDebugEnabled())\r
- log.debug(part);\r
- }\r
-\r
- public void close() {\r
- parts.clear();\r
- closeDate = new Date();\r
- }\r
-\r
- public List<TestResultPart> getParts() {\r
- return parts;\r
- }\r
-\r
- public Date getCloseDate() {\r
- return closeDate;\r
- }\r
-\r
- public void setThrowError(Boolean throwError) {\r
- this.throwError = throwError;\r
- }\r
-\r
- public void notifyTestRun(TestRun testRun) {\r
- currentTestRunUuid = testRun.getUuid();\r
- }\r
-\r
- public String getUuid() {\r
- if (uuid == null) {\r
- uuid = UUID.randomUUID().toString();\r
- }\r
- return uuid;\r
- }\r
-\r
- public void setUuid(String uuid) {\r
- this.uuid = uuid;\r
- }\r
-\r
- public String getCurrentTestRunUuid() {\r
- return currentTestRunUuid;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-import java.util.UUID;\r
-\r
-import org.argeo.slc.core.deploy.DeployedSystem;\r
-import org.argeo.slc.core.process.SlcExecution;\r
-import org.argeo.slc.core.process.SlcExecutionStep;\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, ExecutableTestRun {\r
- private String uuid;\r
-\r
- private String slcExecutionUuid;\r
- private String slcExecutionStepUuid;\r
-\r
- private DeployedSystem deployedSystem;\r
- private TestData testData;\r
- private TestDefinition testDefinition;\r
- private TestResult testResult;\r
-\r
- /** Executes the underlying test definition. */\r
- public void execute() {\r
- uuid = UUID.randomUUID().toString();\r
- if (testResult != null)\r
- testResult.notifyTestRun(this);\r
- testDefinition.execute(this);\r
- }\r
-\r
- public <T extends DeployedSystem> T getDeployedSystem() {\r
- return (T) deployedSystem;\r
- }\r
-\r
- public void setDeployedSystem(DeployedSystem deployedSystem) {\r
- this.deployedSystem = deployedSystem;\r
- }\r
-\r
- public <T extends TestData> T getTestData() {\r
- return (T) testData;\r
- }\r
-\r
- public void setTestData(TestData testData) {\r
- this.testData = testData;\r
- }\r
-\r
- public <T extends TestDefinition> T getTestDefinition() {\r
- return (T) testDefinition;\r
- }\r
-\r
- public void setTestDefinition(TestDefinition testDefinition) {\r
- this.testDefinition = testDefinition;\r
- }\r
-\r
- public <T extends TestResult> T getTestResult() {\r
- return (T) testResult;\r
- }\r
-\r
- public void setTestResult(TestResult testResult) {\r
- this.testResult = testResult;\r
- }\r
-\r
- public String getUuid() {\r
- return uuid;\r
- }\r
-\r
- public void setUuid(String uuid) {\r
- this.uuid = uuid;\r
- }\r
-\r
- public String getSlcExecutionUuid() {\r
- return slcExecutionUuid;\r
- }\r
-\r
- public void setSlcExecutionUuid(String slcExecutionUuid) {\r
- this.slcExecutionUuid = slcExecutionUuid;\r
- }\r
-\r
- public String getSlcExecutionStepUuid() {\r
- return slcExecutionStepUuid;\r
- }\r
-\r
- public void setSlcExecutionStepUuid(String slcExecutionStepUuid) {\r
- this.slcExecutionStepUuid = slcExecutionStepUuid;\r
- }\r
-\r
- public void notifySlcExecution(SlcExecution slcExecution) {\r
- slcExecutionUuid = slcExecution.getUuid();\r
- SlcExecutionStep step = slcExecution.currentStep();\r
- if (step != null) {\r
- slcExecutionStepUuid = step.getUuid();\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;
-
-import org.argeo.slc.core.SlcException;
-
-public abstract class SlcTestUtils {
- public static String statusToString(Integer status){
- if(status.equals(TestStatus.PASSED)){
- return TestStatus.STATUSSTR_PASSED;
- }
- else if(status.equals(TestStatus.FAILED)){
- return TestStatus.STATUSSTR_FAILED;
- }
- else if(status.equals(TestStatus.ERROR)){
- return TestStatus.STATUSSTR_ERROR;
- }
- else{
- throw new SlcException("Unrecognized status "+status);
- }
- }
-
- public static Integer stringToStatus(String statusStr){
- if(statusStr.equals(TestStatus.STATUSSTR_PASSED)){
- return TestStatus.PASSED;
- }
- else if(statusStr.equals(TestStatus.STATUSSTR_FAILED)){
- return TestStatus.FAILED;
- }
- else if(statusStr.equals(TestStatus.STATUSSTR_ERROR)){
- return TestStatus.ERROR;
- }
- else{
- throw new SlcException("Unrecognized status string "+statusStr);
- }
- }
-
- private SlcTestUtils(){
-
- }
-
-}
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-/**\r
- * Any data required by a test in order to run: configuration, expected,\r
- * reached, etc.\r
- */\r
-public interface TestData {\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-public interface TestDataProvider {\r
- public <T extends TestData> T getTestData(Class<T> clss, String key);\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-import org.argeo.slc.core.UnsupportedException;\r
-\r
-/** Utilities for dealing with test datas. */\r
-public class TestDataUtils {\r
- /** Extracts the test data from the given provider. */\r
- public static <T extends TestData> T getFromProvider(Object obj,\r
- Class<T> clss, String key) {\r
- if (obj instanceof TestDataProvider) {\r
- TestDataProvider testDataProvider = (TestDataProvider) obj;\r
- return testDataProvider.getTestData(clss, key);\r
- } else {\r
- throw new UnsupportedException("test data provider", obj);\r
- }\r
- }\r
-\r
- /**\r
- * Extracts the test data from the given provider using <code>null</code>\r
- * as key.\r
- */\r
- public static <T extends TestData> T getFromProvider(Object obj,\r
- Class<T> clss) {\r
- return getFromProvider(obj, clss, null);\r
- }\r
-\r
- /**\r
- * Returns it self after making the proper checks. Used for test data being\r
- * their own data providers.\r
- */\r
- public static <T extends TestData> T getItSelf(Class<T> clss,\r
- TestData testDataObject) {\r
- if (clss.isAssignableFrom(testDataObject.getClass())) {\r
- return (T) testDataObject;\r
- } else {\r
- throw new UnsupportedException("test data", testDataObject);\r
- }\r
-\r
- }\r
-\r
- /** Makes sure this is an utility class. */\r
- private TestDataUtils() {\r
-\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-/**\r
- * The programmatic definition of a test, which will be associated with\r
- * transient objects within a test run.\r
- */\r
-public interface TestDefinition extends TestStatus {\r
- /** Performs the test. */\r
- public void execute(TestRun testRun);\r
-}\r
+++ /dev/null
-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
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-import java.util.Date;\r
-\r
-/** The result of a test */\r
-public interface TestResult extends TestStatus, TestRunAware {\r
- public String getUuid();\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
- * The date when this test result was closed. Can be null, which means the\r
- * result is not closed.\r
- */\r
- public Date getCloseDate();\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-import org.argeo.slc.core.deploy.DeployedSystemId;\r
-\r
-/**\r
- * The unique id referencing a test result.\r
- * \r
- * @deprecated\r
- */\r
-public interface TestResultId {\r
- /** Gets the id of the related deployed system. */\r
- public DeployedSystemId getDeployedSystemId();\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-/** Listener to the operations on a test result. */\r
-public interface TestResultListener<T extends TestResult> {\r
- /** Notified when a part was added to a test result. */\r
- public void resultPartAdded(T testResult,\r
- TestResultPart testResultPart);\r
-\r
- /** Stops listening and release the related resources. */\r
- public void close(T testResult);\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-\r
-/**\r
- * Part of a test result.\r
- * \r
- * @see TestResult\r
- */\r
-public interface TestResultPart {\r
- /** The status, as defined in {@link TestStatus}. */\r
- public Integer getStatus();\r
-\r
- /** The related message. */\r
- public String getMessage();\r
-\r
- /** The underlying <code>Exception</code>. Can be null. */\r
- public String getExceptionMessage();\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-import org.argeo.slc.core.deploy.DeployedSystem;\r
-import org.argeo.slc.core.process.SlcExecutionAware;\r
-\r
-/** The actual run of a test */\r
-public interface TestRun extends SlcExecutionAware{\r
- /** Gets UUID */\r
- public String getUuid();\r
-\r
- /** Gets the related test definition. */\r
- public <T extends TestDefinition> T getTestDefinition();\r
-\r
- /** Gets the related test data */\r
- public <T extends TestData> T getTestData();\r
-\r
- /** Gets the related deployed system. */\r
- public <T extends DeployedSystem> T getDeployedSystem();\r
-\r
- /** Gets the related result where to record results. */\r
- public <T extends TestResult> T getTestResult();\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-public interface TestRunAware {\r
- /** Notifies the current test run. */\r
- public void notifyTestRun(TestRun testRun);\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-import org.argeo.slc.core.deploy.DeployedSystem;\r
-import org.argeo.slc.core.process.SlcExecution;\r
-\r
-public class TestRunDescriptor {\r
- private String testRunUuid;\r
- private String slcExecutionUuid;\r
- private String slcExecutionStepUuid;\r
- private String testResultUuid;\r
- private String deployedSytemId;\r
-\r
- public TestRunDescriptor() {\r
-\r
- }\r
-\r
- public TestRunDescriptor(TestRun testRun) {\r
- testRunUuid = testRun.getUuid();\r
-\r
- if (testRun.getTestResult() != null)\r
- testResultUuid = testRun.<TestResult> getTestResult().getUuid();\r
-\r
- if (testRun.getDeployedSystem() != null)\r
- deployedSytemId = testRun.<DeployedSystem> getDeployedSystem()\r
- .getDeployedSystemId();\r
-\r
- if (testRun instanceof SimpleTestRun) {\r
- slcExecutionUuid = ((SimpleTestRun) testRun).getSlcExecutionUuid();\r
- slcExecutionStepUuid = ((SimpleTestRun) testRun)\r
- .getSlcExecutionStepUuid();\r
- }\r
- }\r
-\r
- public String getTestRunUuid() {\r
- return testRunUuid;\r
- }\r
-\r
- public void setTestRunUuid(String testRunUuid) {\r
- this.testRunUuid = testRunUuid;\r
- }\r
-\r
- public String getSlcExecutionUuid() {\r
- return slcExecutionUuid;\r
- }\r
-\r
- public void setSlcExecutionUuid(String slcExecutionUuid) {\r
- this.slcExecutionUuid = slcExecutionUuid;\r
- }\r
-\r
- public String getSlcExecutionStepUuid() {\r
- return slcExecutionStepUuid;\r
- }\r
-\r
- public void setSlcExecutionStepUuid(String slcExecutionStepUuid) {\r
- this.slcExecutionStepUuid = slcExecutionStepUuid;\r
- }\r
-\r
- public String getTestResultUuid() {\r
- return testResultUuid;\r
- }\r
-\r
- public void setTestResultUuid(String testResultUuid) {\r
- this.testResultUuid = testResultUuid;\r
- }\r
-\r
- public String getDeployedSytemId() {\r
- return deployedSytemId;\r
- }\r
-\r
- public void setDeployedSytemId(String deploymentId) {\r
- this.deployedSytemId = deploymentId;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (obj instanceof TestRunDescriptor) {\r
- return getTestRunUuid().equals(\r
- ((TestRunDescriptor) obj).getTestRunUuid());\r
- }\r
- return false;\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\r
-\r
-/**\r
- * Simple statuses.\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 interface TestStatus {\r
- /** The flag for a passed test: 0 */\r
- public final static Integer PASSED = 0;\r
- /** The flag for a failed test: 1 */\r
- public final static Integer FAILED = 1;\r
- /**\r
- * The flag for a test which could not properly run because of an error\r
- * (there is no feedback on the behavior of the tested component): 2\r
- */\r
- public final static Integer ERROR = 2;\r
- public final static String STATUSSTR_PASSED = "PASSED";\r
- public final static String STATUSSTR_FAILED = "FAILED";\r
- public final static String STATUSSTR_ERROR = "ERROR";\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test;\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 ExecutableTestRun {\r
- public void setDeployedSystem(DeployedSystem deployedSystem);\r
-\r
- public void setTestData(TestData testData);\r
-\r
- public void setTestDefinition(TestDefinition testDefinition);\r
-\r
- public void setTestResult(TestResult testResult);\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.context;\r
-\r
-import java.util.Map;\r
-\r
-public interface ContextAware {\r
- public final static String DEFAULT_SKIP_FLAG = "!";\r
- public final static String DEFAULT_ANY_FLAG = "*";\r
-\r
- public Map<String, Object> getValues();\r
-\r
- public void setValues(Map<String, Object> values);\r
-\r
- public Map<String, Object> getExpectedValues();\r
-\r
- public String getContextSkipFlag();\r
-\r
- public String getContextAnyFlag();\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.context;\r
-\r
-import java.util.Map;\r
-import java.util.TreeMap;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.core.structure.StructureAware;\r
-import org.argeo.slc.core.structure.StructureElement;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.structure.tree.TreeSRelated;\r
-import org.argeo.slc.core.test.SimpleResultPart;\r
-import org.argeo.slc.core.test.TestResult;\r
-import org.argeo.slc.core.test.TestStatus;\r
-\r
-public class ContextUtils {\r
- private final static Log log = LogFactory.getLog(ContextUtils.class);\r
-\r
- public static void compareReachedExpected(ContextAware contextAware,\r
- TestResult testResult, TreeSRelated treeSRelated) {\r
- for (String key : contextAware.getExpectedValues().keySet()) {\r
-\r
- // Compare expected values with reached ones\r
- Object expectedValue = contextAware.getExpectedValues().get(key);\r
-\r
- if (expectedValue.toString().equals(\r
- contextAware.getContextSkipFlag())) {\r
- if (log.isDebugEnabled())\r
- log.debug("Skipped check for key '" + key + "'");\r
- continue;\r
- }\r
-\r
- // Register in structure\r
- registerInStructure(testResult, treeSRelated, key);\r
-\r
- if (contextAware.getValues().containsKey(key)) {\r
- Object reachedValue = contextAware.getValues().get(key);\r
-\r
- if (expectedValue.equals(contextAware.getContextAnyFlag())) {\r
- testResult.addResultPart(new SimpleResultPart(\r
- TestStatus.PASSED, "Expected any value for key '"\r
- + key + "'"));\r
- } else if (expectedValue.equals(reachedValue)) {\r
- testResult.addResultPart(new SimpleResultPart(\r
- TestStatus.PASSED, "Values matched for key '" + key\r
- + "'"));\r
- } else {\r
- testResult.addResultPart(new SimpleResultPart(\r
- TestStatus.FAILED, "Mismatch for key '" + key\r
- + "': expected '" + expectedValue\r
- + "' but reached '" + reachedValue + "'"));\r
- }\r
- } else {\r
- testResult.addResultPart(new SimpleResultPart(\r
- TestStatus.FAILED, "No value reached for key '" + key\r
- + "'"));\r
- }\r
- resetStructure(testResult, treeSRelated);\r
- }\r
- }\r
-\r
- private static void registerInStructure(TestResult testResult,\r
- TreeSRelated treeSRelated, String key) {\r
- if (treeSRelated != null) {\r
- if (treeSRelated.getBasePath() != null) {\r
- TreeSPath path = treeSRelated.getBasePath().createChild(key);\r
- StructureRegistry<TreeSPath> registry = treeSRelated\r
- .getRegistry();\r
- final StructureElement element = treeSRelated\r
- .getStructureElement(key);\r
- registry.register(path, element);\r
- if (testResult instanceof StructureAware)\r
- ((StructureAware<TreeSPath>) testResult).notifyCurrentPath(\r
- registry, path);\r
-\r
- if (log.isDebugEnabled())\r
- log.debug("Checking key " + key + " for path " + path);\r
- }\r
- }\r
- }\r
-\r
- private static void resetStructure(TestResult testResult,\r
- TreeSRelated treeSRelated) {\r
- if (treeSRelated != null) {\r
- if (treeSRelated.getBasePath() != null) {\r
- if (testResult instanceof StructureAware) {\r
- ((StructureAware<TreeSPath>) testResult).notifyCurrentPath(\r
- treeSRelated.getRegistry(), treeSRelated\r
- .getBasePath());\r
- }\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * Makes sure that all children and sub-children of parent share the same\r
- * maps for values and expected values.\r
- */\r
- public static void synchronize(ParentContextAware parent) {\r
- Map<String, Object> expectedValuesCommon = new TreeMap<String, Object>(\r
- parent.getExpectedValues());\r
- synchronize(parent, expectedValuesCommon);\r
- if (log.isDebugEnabled())\r
- log.debug("Synchonized context " + parent);\r
-\r
- }\r
-\r
- private static void synchronize(ParentContextAware parent,\r
- Map<String, Object> expectedValuesCommon) {\r
- for (ContextAware child : parent.getChildContexts()) {\r
- // Values\r
- putNotContained(parent.getValues(), child.getValues());\r
- child.setValues(parent.getValues());\r
-\r
- // Expected Values\r
- // Expected values reference is not overridden: each child has its\r
- // own expected values map.\r
- overrideContained(expectedValuesCommon, child.getExpectedValues());\r
-\r
- // Creates a new Map in order not to disturb other context using the\r
- // same keys\r
- Map<String, Object> expectedValuesCommonChild = new TreeMap<String, Object>(\r
- expectedValuesCommon);\r
- putNotContained(expectedValuesCommonChild, child\r
- .getExpectedValues());\r
-\r
- if (child instanceof ParentContextAware) {\r
- // Recursive sync\r
- synchronize((ParentContextAware) child,\r
- expectedValuesCommonChild);\r
- }\r
- }\r
-\r
- }\r
-\r
- /**\r
- * Put into common map the values from child map which are not already\r
- * defined in common map.\r
- */\r
- public static void putNotContained(Map<String, Object> commonMap,\r
- Map<String, Object> childMap) {\r
- for (String key : childMap.keySet()) {\r
- if (!commonMap.containsKey(key)) {\r
- commonMap.put(key, childMap.get(key));\r
- }\r
- }\r
- }\r
-\r
- /** Overrides child map values with the values already set in common map */\r
- public static void overrideContained(Map<String, Object> commonMap,\r
- Map<String, Object> childMap) {\r
- for (String key : childMap.keySet()) {\r
- if (commonMap.containsKey(key)) {\r
- childMap.put(key, commonMap.get(key));\r
- }\r
- }\r
- }\r
-\r
- /** Makes sure this cannot be instantiated. */\r
- private ContextUtils() {\r
-\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.context;\r
-\r
-import org.argeo.slc.core.test.TestData;\r
-import org.argeo.slc.core.test.TestDataProvider;\r
-import org.argeo.slc.core.test.TestDataUtils;\r
-\r
-public class DefaultContextTestData extends SimpleContextAware implements\r
- TestData, TestDataProvider {\r
-\r
- public <T extends TestData> T getTestData(Class<T> clss, String key) {\r
- return TestDataUtils.getItSelf(clss, this);\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.context;\r
-\r
-import java.util.Collection;\r
-\r
-public interface ParentContextAware extends ContextAware {\r
- public Collection<ContextAware> getChildContexts();\r
- public void addChildContext(ContextAware contextAware);\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.context;\r
-\r
-import java.util.Map;\r
-import java.util.TreeMap;\r
-\r
-import org.springframework.beans.factory.InitializingBean;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-\r
-public class SimpleContextAware implements ContextAware, InitializingBean {\r
- private ParentContextAware parentContext;\r
-\r
- private Map<String, Object> values = new TreeMap<String, Object>();\r
- private Map<String, Object> expectedValues = new TreeMap<String, Object>();\r
-\r
- private String contextSkipFlag = DEFAULT_SKIP_FLAG;\r
- private String contextAnyFlag = DEFAULT_ANY_FLAG;\r
-\r
- public Map<String, Object> getValues() {\r
- return values;\r
- }\r
-\r
- public void setValues(Map<String, Object> values) {\r
- this.values = values;\r
- }\r
-\r
- public Map<String, Object> getExpectedValues() {\r
- return expectedValues;\r
- }\r
-\r
- public void setExpectedValues(Map<String, Object> expectedValues) {\r
- this.expectedValues = expectedValues;\r
- }\r
-\r
- /** Used to add this context as a child by setting a property. */\r
- public void setParentContext(ParentContextAware parentContextAware) {\r
- if (parentContext != null)\r
- throw new SlcException("Parent context already set");\r
- this.parentContext = parentContextAware;\r
- this.parentContext.addChildContext(this);\r
- }\r
-\r
- protected ParentContextAware getParentContext() {\r
- return parentContext;\r
- }\r
-\r
- public void afterPropertiesSet() throws Exception {\r
- if (parentContext != null) {\r
- ContextUtils.synchronize(parentContext);\r
- }\r
- }\r
-\r
- public String getContextSkipFlag() {\r
- return contextSkipFlag;\r
- }\r
-\r
- public void setContextSkipFlag(String contextSkipFlag) {\r
- this.contextSkipFlag = contextSkipFlag;\r
- }\r
-\r
- public String getContextAnyFlag() {\r
- return contextAnyFlag;\r
- }\r
-\r
- public void setContextAnyFlag(String contextAnyFlag) {\r
- this.contextAnyFlag = contextAnyFlag;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.context;\r
-\r
-import java.util.Collection;\r
-import java.util.List;\r
-import java.util.Vector;\r
-\r
-import org.springframework.beans.factory.InitializingBean;\r
-\r
-public class SimpleParentContextAware extends SimpleContextAware implements\r
- ParentContextAware, InitializingBean {\r
- private List<ContextAware> children = new Vector<ContextAware>();\r
-\r
- public Collection<ContextAware> getChildContexts() {\r
- return children;\r
- }\r
-\r
- public void addChildContext(ContextAware contextAware) {\r
- children.add(contextAware);\r
- }\r
-\r
- @Override\r
- public void afterPropertiesSet() throws Exception {\r
- if (getParentContext() != null) {\r
- // If has a parent, sync it.\r
- super.afterPropertiesSet();\r
- } else {\r
- if(children.size()>0){\r
- // No need to synchronize if no children\r
- ContextUtils.synchronize(this);\r
- }\r
- }\r
- }\r
-}\r
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-Context variables to be passed between parts of tests.\r
-</body>\r
-</html>
\ No newline at end of file
+++ /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
+++ /dev/null
-package org.argeo.slc.core.test.tree;\r
-\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
-\r
-import org.argeo.slc.core.structure.SimpleSElement;\r
-import org.argeo.slc.core.structure.StructureAware;\r
-import org.argeo.slc.core.structure.StructureElement;\r
-import org.argeo.slc.core.structure.StructureElementProvider;\r
-import org.argeo.slc.core.structure.StructurePath;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.test.TestDefinition;\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<TreeSPath> {\r
- private Log log = LogFactory.getLog(CompositeTreeTestDefinition.class);\r
-\r
- private List<TestDefinition> tasks = null;\r
- private List<TreeSPath> taskPaths = null;\r
- private TreeSPath path;\r
- private StructureRegistry<TreeSPath> registry;\r
-\r
- public void execute(TestRun testRun) {\r
- log.info("Execute sequence of test definitions...");\r
-\r
- int i = 0;\r
- for (TestDefinition task : tasks) {\r
- TestResult result = testRun.getTestResult();\r
- if (result instanceof StructureAware) {\r
- ((StructureAware) result).notifyCurrentPath(registry, taskPaths\r
- .get(i));\r
- }\r
-\r
- task.execute(testRun);\r
-\r
- // Reset current path in case it has been changed\r
- if (result instanceof StructureAware) {\r
- ((StructureAware) result).notifyCurrentPath(registry, path);\r
- }\r
- i++;\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
- taskPaths = new Vector<TreeSPath>();\r
- }\r
- }\r
-\r
- public void notifyCurrentPath(StructureRegistry<TreeSPath> registry,\r
- TreeSPath path) {\r
- this.path = path;\r
- this.registry = registry;\r
-\r
- // clear task paths\r
- taskPaths.clear();\r
-\r
- Integer count = 0;\r
- for (TestDefinition task : tasks) {\r
- final StructureElement element;\r
- if (task instanceof StructureElementProvider) {\r
- element = ((StructureElementProvider) task)\r
- .createStructureElement();\r
- } else {\r
- element = new SimpleSElement("[no desc]");\r
- }\r
- TreeSPath taskPath = this.path.createChild(count.toString());\r
- registry.register(taskPath, element);\r
- taskPaths.add(taskPath);\r
- if (task instanceof StructureAware) {\r
- ((StructureAware<TreeSPath>) task).notifyCurrentPath(registry,\r
- taskPath);\r
- }\r
- count++;\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.tree;\r
-\r
-import java.util.List;\r
-import java.util.Vector;\r
-\r
-import org.argeo.slc.core.test.TestResultPart;\r
-import org.argeo.slc.core.test.TestStatus;\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
- /** For ORM */\r
- private Long tid;\r
-\r
- private List<TestResultPart> parts = new Vector<TestResultPart>();\r
-\r
- /** Gets the result parts. */\r
- public List<TestResultPart> getParts() {\r
- return parts;\r
- }\r
-\r
- /** Sets the result parts. */\r
- public void setParts(List<TestResultPart> parts) {\r
- this.parts = parts;\r
- }\r
-\r
- Long getTid() {\r
- return tid;\r
- }\r
-\r
- void setTid(Long tid) {\r
- this.tid = tid;\r
- }\r
-\r
- public Boolean getIsPassed() {\r
- for (TestResultPart part : parts) {\r
- if (part.getStatus() != TestStatus.PASSED) {\r
- return false;\r
- }\r
- }\r
- return true;\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.tree;\r
-\r
-import java.util.Date;\r
-import java.util.List;\r
-import java.util.SortedMap;\r
-import java.util.TreeMap;\r
-import java.util.Vector;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-import org.argeo.slc.core.structure.StructureAware;\r
-import org.argeo.slc.core.structure.StructureElement;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.test.TestResult;\r
-import org.argeo.slc.core.test.TestResultListener;\r
-import org.argeo.slc.core.test.TestResultPart;\r
-import org.argeo.slc.core.test.TestRun;\r
-import org.argeo.slc.core.test.TestRunAware;\r
-\r
-/**\r
- * Complex implementation of a test result compatible with a tree based\r
- * structure.\r
- */\r
-public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,Comparable<TreeTestResult> {\r
- private Log log = LogFactory.getLog(TreeTestResult.class);\r
-\r
- private List<TestResultListener<TreeTestResult>> listeners = new Vector<TestResultListener<TreeTestResult>>();\r
-\r
- private TreeSPath currentPath;\r
- private TestRun currentTestRun;\r
-\r
- private Date closeDate;\r
-\r
- private boolean isClosed = false;\r
-\r
- private String uuid;\r
-\r
- private SortedMap<TreeSPath, PartSubList> resultParts = new TreeMap<TreeSPath, PartSubList>();\r
- private SortedMap<TreeSPath, StructureElement> elements = new TreeMap<TreeSPath, StructureElement>();\r
-\r
- /** Sets the list of listeners. */\r
- public void setListeners(List<TestResultListener<TreeTestResult>> listeners) {\r
- this.listeners = listeners;\r
- }\r
-\r
- public void addResultPart(TestResultPart part) {\r
- if (currentPath == null) {\r
- throw new SlcException("No current path set.");\r
- }\r
- PartSubList subList = resultParts.get(currentPath);\r
- if (subList == null) {\r
- subList = new PartSubList();\r
- resultParts.put(currentPath, subList);\r
- }\r
- if (part instanceof TestRunAware && currentTestRun != null) {\r
- ((TestRunAware) part).notifyTestRun(currentTestRun);\r
- }\r
- subList.getParts().add(part);\r
-\r
- // notify listeners\r
- synchronized (listeners) {\r
- for (TestResultListener<TreeTestResult> listener : listeners) {\r
- listener.resultPartAdded(this, part);\r
- }\r
- }\r
- }\r
-\r
- public void notifyCurrentPath(StructureRegistry<TreeSPath> registry,\r
- TreeSPath path) {\r
- if (registry != null) {\r
- for (TreeSPath p : path.getHierarchyAsList()) {\r
- if (!elements.containsKey(p)) {\r
- StructureElement elem = registry.getElement(p);\r
- if (elem != null) {\r
- elements.put(p, elem);\r
- }\r
- } else {\r
- if (log.isTraceEnabled())\r
- log.trace("An element is already registered for path "\r
- + p + " and was not updated");\r
- }\r
-\r
- }\r
- }\r
-\r
- currentPath = (TreeSPath) path;\r
- }\r
-\r
- /** Gets the current path. */\r
- public TreeSPath getCurrentPath() {\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 #" + getUuid()\r
- + " alredy closed.");\r
- }\r
- closeDate = new Date();\r
-\r
- synchronized (listeners) {\r
- for (TestResultListener<TreeTestResult> listener : listeners) {\r
- listener.close(this);\r
- }\r
- listeners.clear();\r
- }\r
- isClosed = true;\r
-\r
- log.info("Test Result #" + getUuid() + " closed.");\r
- }\r
-\r
- public Date getCloseDate() {\r
- return closeDate;\r
- }\r
-\r
- /** Sets the close date (for ORM) */\r
- public void setCloseDate(Date closeDate) {\r
- this.closeDate = closeDate;\r
- }\r
-\r
- public void notifyTestRun(TestRun testRun) {\r
- currentTestRun = testRun;\r
- }\r
-\r
- public SortedMap<TreeSPath, StructureElement> getElements() {\r
- return elements;\r
- }\r
-\r
- public void setElements(SortedMap<TreeSPath, StructureElement> pathNames) {\r
- this.elements = pathNames;\r
- }\r
-\r
- public String getUuid() {\r
- return uuid;\r
- }\r
-\r
- public void setUuid(String uuid) {\r
- this.uuid = uuid;\r
- }\r
-\r
- public SortedMap<TreeSPath, StructureElement> getRelatedElements(\r
- TreeSPath path) {\r
- SortedMap<TreeSPath, StructureElement> relatedElements = new TreeMap<TreeSPath, StructureElement>();\r
- List<TreeSPath> hierarchy = path.getHierarchyAsList();\r
- for (TreeSPath currPath : elements.keySet()) {\r
- if (hierarchy.contains(currPath)) {\r
- relatedElements.put(currPath, elements.get(currPath));\r
- }\r
- }\r
- return relatedElements;\r
- }\r
-\r
- public TestRun getCurrentTestRun() {\r
- return currentTestRun;\r
- }\r
-\r
- public int compareTo(TreeTestResult ttr2) {\r
- TreeTestResult ttr1 = this;\r
- if (ttr1.getCloseDate() != null && ttr2.getCloseDate() != null) {\r
- return -ttr1.getCloseDate().compareTo(ttr2.getCloseDate());\r
- } else if (ttr1.getCloseDate() != null && ttr2.getCloseDate() == null) {\r
- return 1;\r
- } else if (ttr1.getCloseDate() == null && ttr2.getCloseDate() != null) {\r
- return -1;\r
- } else {\r
- return ttr1.getUuid().compareTo(ttr2.getUuid());\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.tree;\r
-\r
-import java.util.SortedSet;\r
-import java.util.TreeSet;\r
-\r
-public class TreeTestResultCollection implements\r
- Comparable<TreeTestResultCollection> {\r
- private String id;\r
- private SortedSet<TreeTestResult> results = new TreeSet<TreeTestResult>();\r
-\r
- public TreeTestResultCollection() {\r
- }\r
-\r
- public TreeTestResultCollection(String id) {\r
- this.id = id;\r
- }\r
-\r
- public String getId() {\r
- return id;\r
- }\r
-\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
-\r
- public SortedSet<TreeTestResult> getResults() {\r
- return results;\r
- }\r
-\r
- public void setResults(SortedSet<TreeTestResult> results) {\r
- this.results = results;\r
- }\r
-\r
- public int compareTo(TreeTestResultCollection o) {\r
- return getId().compareTo(o.getId());\r
- }\r
-\r
- @Override\r
- public boolean equals(Object o) {\r
- if (o instanceof TreeTestResultCollection) {\r
- return getId().equals(((TreeTestResultCollection) o).getId());\r
- }\r
- return false;\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.tree;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.core.test.TestResultListener;\r
-import org.argeo.slc.core.test.TestResultPart;\r
-import org.argeo.slc.core.test.TestStatus;\r
-\r
-/**\r
- * Listener logging tree-based test results to the underlying logging system.\r
- * \r
- * @see TreeTestResult\r
- * \r
- */\r
-public class TreeTestResultLogger implements TestResultListener<TreeTestResult> {\r
-\r
- private static Log log = LogFactory.getLog(TreeTestResultLogger.class);\r
-\r
- public void resultPartAdded(TreeTestResult testResult,\r
- TestResultPart testResultPart) {\r
- String msg = testResultPart + " - " + testResult.getUuid() + ":"\r
- + testResult.getCurrentPath();\r
- if (testResultPart.getStatus().equals(TestStatus.PASSED)) {\r
- log.info(msg);\r
- } else if (testResultPart.getStatus().equals(TestStatus.FAILED)) {\r
- log.warn(msg);\r
- } else if (testResultPart.getStatus().equals(TestStatus.ERROR)) {\r
- log.error(msg + "\n" + testResultPart.getExceptionMessage());\r
- } else {\r
- log.error("Unknow test status: " + msg);\r
- }\r
- }\r
-\r
- public void close(TreeTestResult testResult) {\r
- log.info("Test result " + testResult.getUuid() + " closed.");\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.tree;\r
-\r
-import org.springframework.ws.client.WebServiceIOException;\r
-import org.springframework.ws.client.core.WebServiceTemplate;\r
-import org.springframework.ws.soap.client.SoapFaultClientException;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.core.test.TestResultListener;\r
-import org.argeo.slc.core.test.TestResultPart;\r
-import org.argeo.slc.msg.test.tree.CloseTreeTestResultRequest;\r
-import org.argeo.slc.msg.test.tree.CreateTreeTestResultRequest;\r
-import org.argeo.slc.msg.test.tree.ResultPartRequest;\r
-import org.argeo.slc.ws.client.WebServiceUtils;\r
-\r
-public class WebServiceTreeTestResultNotifier implements\r
- TestResultListener<TreeTestResult> {\r
- private WebServiceTemplate template;\r
- private Boolean onlyOnClose = false;\r
-\r
- private Log log = LogFactory.getLog(getClass());\r
-\r
- private Boolean cannotConnect = false;\r
-\r
- public void resultPartAdded(TreeTestResult testResult,\r
- TestResultPart testResultPart) {\r
- if (onlyOnClose)\r
- return;\r
-\r
- if (cannotConnect)\r
- return;\r
-\r
- try {\r
- if (testResult.getResultParts().size() == 1\r
- && testResult.getResultParts().values().iterator().next()\r
- .getParts().size() == 1) {\r
- CreateTreeTestResultRequest req = new CreateTreeTestResultRequest(\r
- testResult);\r
-\r
- if (log.isDebugEnabled())\r
- log.debug("Send create result request for result "\r
- + testResult.getUuid());\r
-\r
- WebServiceUtils.marshalSendAndReceive(template, req);\r
- } else {\r
- ResultPartRequest req = new ResultPartRequest(testResult);\r
-\r
- if (log.isDebugEnabled())\r
- log.debug("Send result parts for result "\r
- + testResult.getUuid());\r
-\r
- WebServiceUtils.marshalSendAndReceive(template, req);\r
- }\r
- } catch (SoapFaultClientException e) {\r
- WebServiceUtils.manageSoapException(e);\r
-\r
- } catch (WebServiceIOException e) {\r
- manageIoException(e);\r
- }\r
- }\r
-\r
- public void close(TreeTestResult testResult) {\r
- if (cannotConnect)\r
- return;\r
-\r
- try {\r
- if (onlyOnClose) {\r
- CreateTreeTestResultRequest req = new CreateTreeTestResultRequest(\r
- testResult);\r
-\r
- if (log.isDebugEnabled())\r
- log.debug("Send create result request for result "\r
- + testResult.getUuid());\r
-\r
- WebServiceUtils.marshalSendAndReceive(template, req);\r
- } else {\r
- CloseTreeTestResultRequest req = new CloseTreeTestResultRequest(\r
- testResult);\r
-\r
- if (log.isDebugEnabled())\r
- log.debug("Send close result request for result "\r
- + testResult.getUuid());\r
-\r
- WebServiceUtils.marshalSendAndReceive(template, req);\r
-\r
- }\r
- } catch (SoapFaultClientException e) {\r
- WebServiceUtils.manageSoapException(e);\r
- } catch (WebServiceIOException e) {\r
- manageIoException(e);\r
- }\r
- }\r
-\r
- public void setTemplate(WebServiceTemplate template) {\r
- this.template = template;\r
- }\r
-\r
- public void setOnlyOnClose(Boolean onlyOnClose) {\r
- this.onlyOnClose = onlyOnClose;\r
- }\r
-\r
- protected void manageIoException(WebServiceIOException e) {\r
- if (!cannotConnect) {\r
- log.error("Cannot connect to " + template.getDefaultUri()\r
- + ". Won't try again.", e);\r
- cannotConnect = true;\r
- }\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.tree;\r
-\r
-import java.io.File;\r
-import java.io.FileOutputStream;\r
-import java.io.InputStream;\r
-import java.io.OutputStream;\r
-\r
-import javax.xml.parsers.DocumentBuilder;\r
-import javax.xml.parsers.DocumentBuilderFactory;\r
-import javax.xml.transform.Templates;\r
-import javax.xml.transform.Transformer;\r
-import javax.xml.transform.TransformerFactory;\r
-import javax.xml.transform.dom.DOMResult;\r
-import javax.xml.transform.dom.DOMSource;\r
-import javax.xml.transform.stream.StreamResult;\r
-import javax.xml.transform.stream.StreamSource;\r
-\r
-import org.springframework.core.io.Resource;\r
-import org.springframework.oxm.Marshaller;\r
-import org.springframework.xml.transform.StringResult;\r
-import org.w3c.dom.Document;\r
-\r
-import org.apache.commons.io.IOUtils;\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-import org.argeo.slc.core.test.TestResultListener;\r
-import org.argeo.slc.core.test.TestResultPart;\r
-\r
-public class XsltReportGenerator implements TestResultListener<TreeTestResult> {\r
- private Log log = LogFactory.getLog(getClass());\r
-\r
- private DocumentBuilder documentBuilder = null;\r
-\r
- private Resource xsltStyleSheet;\r
-\r
- private Templates templates;\r
-\r
- private Marshaller marshaller;\r
-\r
- private String outputDir;\r
- private String outputFileExtension = "html";\r
-\r
- private Boolean logXml = false;\r
-\r
- public void init() {\r
- if (templates != null)\r
- return;\r
-\r
- if (xsltStyleSheet == null)\r
- throw new SlcException("XSLT style sheet not specified.");\r
-\r
- InputStream in = null;\r
- try {\r
- TransformerFactory transformerFactory = TransformerFactory\r
- .newInstance();\r
- in = xsltStyleSheet.getInputStream();\r
- StreamSource xsltSource = new StreamSource(in);\r
- templates = transformerFactory.newTemplates(xsltSource);\r
- } catch (Exception e) {\r
- throw new SlcException("Could not initialize templates", e);\r
- } finally {\r
- IOUtils.closeQuietly(in);\r
- }\r
- }\r
-\r
- public void resultPartAdded(TreeTestResult testResult,\r
- TestResultPart testResultPart) {\r
-\r
- }\r
-\r
- public void close(TreeTestResult testResult) {\r
- if (templates == null)\r
- throw new SlcException("XSLT template not initialized");\r
-\r
- File file = getFile(testResult);\r
- OutputStream out = null;\r
-\r
- try {\r
- Transformer transformer = templates.newTransformer();\r
-\r
- if (documentBuilder == null)\r
- documentBuilder = DocumentBuilderFactory.newInstance()\r
- .newDocumentBuilder();\r
-\r
- Document document = documentBuilder.newDocument();\r
- DOMResult marshallResult = new DOMResult(document);\r
- marshaller.marshal(testResult, marshallResult);\r
-\r
- if (logXml) {\r
- Transformer identityTransformer = TransformerFactory\r
- .newInstance().newTransformer();\r
- StringResult xmlResult = new StringResult();\r
- identityTransformer.transform(new DOMSource(marshallResult\r
- .getNode()), xmlResult);\r
- log.info("Marshalled XML:\n" + xmlResult);\r
- }\r
-\r
- DOMSource transfoSource = new DOMSource(marshallResult.getNode());\r
-\r
- if (outputDir != null) {\r
- File dir = new File(outputDir);\r
- dir.mkdirs();\r
- out = new FileOutputStream(file);\r
- StreamResult outputResult = new StreamResult(out);\r
- transformer.transform(transfoSource, outputResult);\r
- } else {\r
- // print on console if no output dir\r
- StringResult result = new StringResult();\r
- transformer.transform(transfoSource, result);\r
- log.info("Generated report:\n" + result);\r
- }\r
- } catch (Exception e) {\r
- throw new SlcException(\r
- "Could not transform test result to " + file, e);\r
- } finally {\r
- IOUtils.closeQuietly(out);\r
- }\r
- }\r
-\r
- public Resource getXsltStyleSheet() {\r
- return xsltStyleSheet;\r
- }\r
-\r
- public void setXsltStyleSheet(Resource xsltStyleSheet) {\r
- this.xsltStyleSheet = xsltStyleSheet;\r
- }\r
-\r
- public void setTemplates(Templates templates) {\r
- this.templates = templates;\r
- }\r
-\r
- public void setMarshaller(Marshaller marshaller) {\r
- this.marshaller = marshaller;\r
- }\r
-\r
- public void setOutputDir(String outputDir) {\r
- this.outputDir = outputDir;\r
- }\r
-\r
- public void setOutputFileExtension(String outputFileExtension) {\r
- this.outputFileExtension = outputFileExtension;\r
- }\r
-\r
- protected File getFile(TreeTestResult result) {\r
- Long time = System.currentTimeMillis();\r
- return new File(outputDir + File.separator + time + "-"\r
- + result.getUuid() + "." + outputFileExtension);\r
- }\r
-\r
- public void setLogXml(Boolean logXml) {\r
- this.logXml = logXml;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.tree.htmlreport;\r
-\r
-import java.io.File;\r
-import java.io.FileOutputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.text.SimpleDateFormat;\r
-import java.util.Comparator;\r
-import java.util.List;\r
-import java.util.SortedSet;\r
-import java.util.TreeSet;\r
-\r
-import org.apache.commons.io.IOUtils;\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-import org.argeo.slc.core.structure.StructureAware;\r
-import org.argeo.slc.core.structure.StructurePath;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.test.TestReport;\r
-import org.argeo.slc.core.test.TestResult;\r
-import org.argeo.slc.core.test.tree.TreeTestResult;\r
-import org.argeo.slc.dao.structure.tree.TreeSRegistryDao;\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 data is dumped, otherwise\r
- * only the passed <code>TestResult</code>.\r
- */\r
-public class FullHtmlTreeReport implements TestReport, StructureAware {\r
- private static final Log log = LogFactory.getLog(FullHtmlTreeReport.class);\r
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");\r
-\r
- private TestResultDao testResultDao;\r
- private TreeSRegistryDao treeSRegistryDao;\r
- private File reportDir;\r
-\r
- private StructureRegistry localRegistry;\r
-\r
- public void generateTestReport(TestResult testResult) {\r
-\r
- if (testResultDao == null) {\r
- if (testResult == null)\r
- throw new SlcException(\r
- "Cannot generate report without DAO or result instance.");\r
-\r
- TreeTestResult result = (TreeTestResult) testResult;\r
- ResultPage page = new ResultPage(this, result);\r
- page.generate(getRegistry(result));\r
- } else {\r
- if (reportDir.exists()) {\r
- // clean\r
- for (File file : reportDir.listFiles()) {\r
- file.delete();\r
- }\r
- }\r
- reportDir.mkdirs();\r
-\r
- resourceToFile("index.html");\r
-\r
- ResultsList index = new ResultsList(this);\r
- List<TestResult> list = testResultDao.listTestResults();\r
- SortedSet<TestResult> sortedSet = new TreeSet<TestResult>(\r
- new Comparator<TestResult>() {\r
-\r
- public int compare(TestResult o1, TestResult o2) {\r
- if (o1.getCloseDate() == null\r
- || o2.getCloseDate() == null)\r
- return 0;\r
- // inverse date order (last first)\r
- return o2.getCloseDate().compareTo(\r
- o1.getCloseDate());\r
- }\r
-\r
- });\r
- sortedSet.addAll(list);\r
- for (TestResult testRes : sortedSet) {\r
- TreeTestResult result = (TreeTestResult) testRes;\r
-\r
- index.addTestResult(result);\r
- ResultPage page = new ResultPage(this, result);\r
- page.generate(getRegistry(result));\r
- }\r
- index.close();\r
- }\r
- log.info("Generated HTML test result report to "+reportDir);\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 + "slc-result-"\r
- + result.getUuid() + ".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 tree structure registry DAO. */\r
- public void setTreeSRegistryDao(TreeSRegistryDao treeSRegistryDao) {\r
- this.treeSRegistryDao = treeSRegistryDao;\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
- private StructureRegistry getRegistry(TreeTestResult result) {\r
- StructureRegistry registry = null;\r
- if (treeSRegistryDao != null) {\r
- TreeSPath path = result.getResultParts().firstKey();\r
- registry = treeSRegistryDao.getActiveTreeSRegistry();\r
- }\r
- if (registry == null) {\r
- registry = localRegistry;\r
- }\r
- if (registry == null) {\r
- throw new SlcException("No structure registry available");\r
- }\r
- return registry;\r
- }\r
-\r
- public void notifyCurrentPath(StructureRegistry registry, StructurePath path) {\r
- this.localRegistry = registry;\r
- }\r
-\r
- File getReportDir() {\r
- return reportDir;\r
- }\r
-\r
- void addStyles(StringBuffer buf) {\r
- try {\r
- buf.append("<style type=\"text/css\">\n");\r
- InputStream in = FullHtmlTreeReport.class\r
- .getResourceAsStream("style.css");\r
- String styles = IOUtils.toString(in);\r
- IOUtils.closeQuietly(in);\r
- buf.append(styles);\r
- buf.append("\n</style>\n");\r
- } catch (IOException e) {\r
- throw new SlcException("Cannot load styles", e);\r
- }\r
- }\r
-\r
- private void resourceToFile(String resourceName) {\r
- try {\r
- File file = new File(getReportDir() + File.separator + resourceName);\r
- InputStream in = FullHtmlTreeReport.class\r
- .getResourceAsStream(resourceName);\r
- FileOutputStream out = new FileOutputStream(file);\r
- IOUtils.copy(in, out);\r
- IOUtils.closeQuietly(in);\r
- IOUtils.closeQuietly(out);\r
- } catch (Exception e) {\r
- throw new SlcException("Cannot load resource", e);\r
- }\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.tree.htmlreport;\r
-\r
-import java.io.IOException;\r
-import java.io.PrintWriter;\r
-import java.io.StringWriter;\r
-import java.util.Date;\r
-import java.util.SortedMap;\r
-import java.util.TreeMap;\r
-\r
-import org.apache.commons.io.FileUtils;\r
-import org.apache.commons.io.IOUtils;\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.core.structure.StructureElement;\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.test.SimpleResultPart;\r
-import org.argeo.slc.core.test.TestResultPart;\r
-import org.argeo.slc.core.test.TestStatus;\r
-import org.argeo.slc.core.test.tree.PartSubList;\r
-import org.argeo.slc.core.test.tree.TreeTestResult;\r
-\r
-class ResultPage {\r
- private final static Log log = LogFactory.getLog(ResultPage.class);\r
-\r
- private final FullHtmlTreeReport report;\r
- private final TreeTestResult result;\r
-\r
- ResultPage(FullHtmlTreeReport report, TreeTestResult result) {\r
- this.report = report;\r
- this.result = result;\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 generate(StructureRegistry<TreeSPath> registry) {\r
- StringBuffer buf = new StringBuffer("");\r
- buf.append("<html>\n");\r
- buf.append("<header>");\r
- buf.append("<title>Result #").append(result.getUuid());\r
- buf.append("</title>\n");\r
- report.addStyles(buf);\r
- buf.append("</header>\n");\r
-\r
- buf.append("<body>\n");\r
-\r
- // Header\r
- buf.append("<a name=\"top\"/>\n");\r
- buf.append("<h1>Result #").append(result.getUuid()).append("</h1>\n");\r
- Date closeDate = result.getCloseDate();\r
- if (closeDate == null) {\r
- buf.append("[Not closed]");\r
- } else {\r
- buf.append(report.sdf.format(closeDate));\r
- }\r
-\r
- // TOC\r
- generateToc(buf, registry);\r
-\r
- generatePartsList(buf, registry);\r
-\r
- buf.append("</body>");\r
- buf.append("</html>");\r
-\r
- try {\r
- FileUtils.writeStringToFile(report.getResultFile(result), buf\r
- .toString());\r
- } catch (IOException e) {\r
- log.error("Could not save result page.", e);\r
- }\r
- }\r
-\r
- private void generateToc(StringBuffer buf,\r
- StructureRegistry<TreeSPath> registry) {\r
- buf.append("<h2>Overview</h2>\n");\r
- SortedMap<TreeSPath, Integer> toc = new TreeMap<TreeSPath, Integer>();\r
- for (TreeSPath path : result.getResultParts().keySet()) {\r
- PartSubList subList = (PartSubList) result.getResultParts().get(\r
- path);\r
- boolean isFailed = false;\r
- for (TestResultPart part : subList.getParts()) {\r
- if (!part.getStatus().equals(TestStatus.PASSED)) {\r
- isFailed = true;\r
- break;\r
- }\r
- }\r
- fillToc(toc, path, isFailed);\r
- }\r
-\r
- buf.append("<table border=\"0\">\n");\r
- for (TreeSPath path : toc.keySet()) {\r
- boolean inResult = result.getResultParts().containsKey(path);\r
- boolean isFailed = !toc.get(path).equals(TestStatus.PASSED);\r
-\r
- buf.append("<tr><td class=\"").append(\r
- isFailed ? "failed" : "passed").append("\">");\r
- int depth = path.getDepth();\r
- for (int i = 0; i < depth; i++) {\r
- buf.append(" ");\r
- }\r
-\r
- if (inResult) {\r
- buf.append("<a href=\"#").append(anchor(path)).append(\r
- "\" class=\"").append(isFailed ? "failed" : "passed")\r
- .append("\"><b>");\r
- }\r
- if (registry != null) {\r
- StructureElement element = registry.getElement(path);\r
- if (element != null) {\r
- buf.append(element.getLabel());\r
- } else {\r
- buf.append(path.getName());\r
- }\r
- }\r
- if (inResult) {\r
- buf.append("</b></a>");\r
- }\r
- buf.append("</td></tr>\n");\r
- }\r
- buf.append("</table>\n");\r
- buf.append("<hr/>\n");\r
- }\r
-\r
- private void generatePartsList(StringBuffer buf,\r
- StructureRegistry<TreeSPath> registry) {\r
- for (TreeSPath path : result.getResultParts().keySet()) {\r
- buf.append("<p>\n");\r
- buf.append("<a name=\"").append(anchor(path)).append("\"></a>");\r
- buf.append("<h2>");\r
- describedPath(path, registry, buf);\r
- buf.append("</h2>");\r
-\r
- PartSubList subList = (PartSubList) result.getResultParts().get(\r
- path);\r
- buf.append("<table border=0>\n");\r
- int displayedIndex = 1;// for display only\r
- for (TestResultPart part : subList.getParts()) {\r
- SimpleResultPart sPart = (SimpleResultPart) part;\r
- buf.append("Related Test Run Id:").append(\r
- sPart.getTestRunUuid()).append("<br/>\n");\r
- String clss = "";\r
- if (sPart.getStatus().equals(TestStatus.PASSED)) {\r
- clss = "passed";\r
- } else {\r
- clss = "failed";\r
- }\r
- buf.append("<tr>");\r
- buf.append("<td><b>").append(displayedIndex)\r
- .append("</b></td>");\r
- buf.append("<td class=\"").append(clss).append("\">");\r
-\r
- buf.append(sPart.getMessage());\r
- if (sPart.getStatus().equals(TestStatus.ERROR)) {\r
- buf\r
- .append("<p><b>An unexpected error prevented the test to run properly.</b>");\r
- buf.append(sPart.getExceptionMessage());\r
- buf.append("</p>");\r
- }\r
- buf.append("</td>");\r
- buf.append("</tr>\n");\r
-\r
- displayedIndex++;\r
- }\r
- buf.append("</table>\n");\r
- buf.append("<a class=\"nav\" href=\"#top\">top</a>\n");\r
- buf.append("<hr/>\n");\r
- }\r
- }\r
-\r
- private void fillToc(SortedMap<TreeSPath, Integer> toc, TreeSPath path,\r
- boolean isFailed) {\r
- if (isFailed) {\r
- toc.put(path, TestStatus.FAILED);\r
- } else {\r
- if (!toc.containsKey(path)) {\r
- toc.put(path, TestStatus.PASSED);\r
- }\r
- }\r
-\r
- if (path.getParent() != null) {\r
- fillToc(toc, path.getParent(), isFailed);\r
- }\r
- }\r
-\r
- private String anchor(TreeSPath path) {\r
- return path.getAsUniqueString().replace(path.getSeparator(), '_');\r
- }\r
-\r
- private void describedPath(TreeSPath path,\r
- StructureRegistry<TreeSPath> registry, StringBuffer buf) {\r
- // StringBuffer buf = new StringBuffer("");\r
- if (path.getParent() != null) {\r
- describedPath(path.getParent(), registry, buf);\r
- }\r
- String description = path.getName();\r
- if (registry != null) {\r
- StructureElement element = registry.getElement(path);\r
- if (element != null) {\r
- description = element.getLabel();\r
- }\r
- }\r
- buf.append('/').append(description);\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.tree.htmlreport;\r
-\r
-import java.io.File;\r
-import java.io.FileWriter;\r
-import java.io.IOException;\r
-import java.util.Date;\r
-\r
-import org.argeo.slc.core.test.tree.TreeTestResult;\r
-\r
-class ResultsList {\r
- private final FullHtmlTreeReport report;\r
- private final StringBuffer buf = new StringBuffer("");\r
-\r
- ResultsList(FullHtmlTreeReport report) {\r
- this.report = report;\r
-\r
- buf.append("<html><header><title>Results</title></header><body>");\r
- buf.append("<header>");\r
- buf.append("<title>Results</title>\n");\r
- report.addStyles(buf);\r
- buf.append("</header>\n");\r
- buf.append("<body>\n");\r
-\r
- buf.append("<h1>Results</h1>\n");\r
- buf.append("<table border=\"0\" cellspacing=\"1\">\n");\r
- buf.append("<tr><th>Date</th><th>Result Id</th></tr>\n");\r
- }\r
-\r
- void addTestResult(TreeTestResult result) {\r
- buf.append("<tr>\n");\r
- // Date\r
- buf.append("<td>");\r
- Date closeDate = result.getCloseDate();\r
- if (closeDate == null) {\r
- buf.append("[Not closed]");\r
- } else {\r
- buf.append(report.sdf.format(closeDate));\r
- }\r
- buf.append("</td>\n");\r
- // Id and link\r
- buf.append("<td><a class=\"nav\" href=\"");\r
- buf.append(report.getResultFile(result).getName());\r
- buf.append("\" target=\"main\">#");\r
- buf.append(result.getUuid()).append("</a></td>\n");\r
-\r
- buf.append("</tr>\n");\r
- }\r
-\r
- void close() {\r
- buf.append("</table>\n</body></html>");\r
-\r
- try {\r
- FileWriter writer = new FileWriter(report.getReportDir().getPath()\r
- + File.separator + "slc-resultsList.html");\r
- writer.write(buf.toString());\r
- writer.close();\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- }\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-Static HTML report for tree based test results.\r
-</body>\r
-</html>
\ No newline at end of file
+++ /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
+++ /dev/null
-package org.argeo.slc.dao.process;\r
-\r
-import java.util.List;\r
-\r
-import org.argeo.slc.core.process.SlcExecution;\r
-\r
-public interface SlcExecutionDao {\r
- public void create(SlcExecution slcExecution);\r
- public void update(SlcExecution slcExecution);\r
- public SlcExecution getSlcExecution(String uuid);\r
- public List<SlcExecution> listSlcExecutions();\r
-}\r
+++ /dev/null
-package org.argeo.slc.dao.structure;\r
-\r
-public interface SimpleSElementDao {\r
-\r
-}\r
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-DAOs for the core structure objects.\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.dao.structure.tree;\r
-\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-\r
-public interface TreeSPathDao {\r
- public void create(TreeSPath path);\r
-\r
- public TreeSPath getTreeSPath(String pathString);\r
-\r
- public TreeSPath getOrCreate(TreeSPath pathTransient);\r
-}\r
+++ /dev/null
-package org.argeo.slc.dao.structure.tree;\r
-\r
-import org.argeo.slc.core.structure.StructureRegistry;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.structure.tree.TreeSRegistry;\r
-\r
-/**\r
- * DAO for tree-base structure registry.\r
- * \r
- * @see TreeSRegistry\r
- */\r
-public interface TreeSRegistryDao {\r
- /** Gets the TreeSRegistry which has the same root path as the provided path. */\r
- public TreeSRegistry getActiveTreeSRegistry();\r
-\r
- /** Creates a new registry. */\r
- public void create(TreeSRegistry registry);\r
-\r
- /** Updates an existing registry. */\r
- public void update(TreeSRegistry registry);\r
- \r
- /** Sync with local registry */\r
- public void syncPath(TreeSRegistry registry,\r
- StructureRegistry<TreeSPath> localRegistry, TreeSPath path);\r
-}\r
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-DAOs for the tree-based structure objects.\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.dao.test;\r
-\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-import org.argeo.slc.core.test.TestResult;\r
-\r
-/**\r
- * The dao for <code>TestResult</code>.\r
- * \r
- * @see TestResult\r
- */\r
-public interface TestResultDao<T extends TestResult> {\r
- /** Gets a test result based on its id. */\r
- public T getTestResult(String uuid);\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<T> listTestResults();\r
- \r
-\r
- public void close(String id, Date closeDate);\r
-}\r
+++ /dev/null
-package org.argeo.slc.dao.test;\r
-\r
-import org.argeo.slc.core.test.TestRunDescriptor;\r
-\r
-public interface TestRunDescriptorDao {\r
- public TestRunDescriptor getTestRunDescriptor(String id);\r
- public void saveOrUpdate(TestRunDescriptor testRunDescriptor);\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
+++ /dev/null
-package org.argeo.slc.dao.test.tree;\r
-\r
-import java.util.SortedSet;\r
-\r
-import org.argeo.slc.core.test.tree.TreeTestResultCollection;\r
-\r
-public interface TreeTestResultCollectionDao {\r
- public void create(TreeTestResultCollection ttrCollection);\r
-\r
- public void update(TreeTestResultCollection ttrCollection);\r
-\r
- public TreeTestResultCollection getTestResultCollection(String id);\r
-\r
- public SortedSet<TreeTestResultCollection> listCollections();\r
-}\r
+++ /dev/null
-package org.argeo.slc.dao.test.tree;\r
-\r
-import java.util.List;\r
-\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.test.tree.TreeTestResult;\r
-import org.argeo.slc.dao.test.TestResultDao;\r
-\r
-public interface TreeTestResultDao extends TestResultDao<TreeTestResult> {\r
- /** Lists results containing this path */\r
- public List<TreeTestResult> listResults(TreeSPath path);\r
-}\r
+++ /dev/null
-package org.argeo.slc.dao.test.tree;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.core.test.TestResultListener;\r
-import org.argeo.slc.core.test.TestResultPart;\r
-import org.argeo.slc.core.test.tree.TreeTestResult;\r
-\r
-/**\r
- * Listener persisting tree-based results.\r
- * \r
- * @see TreeTestResult\r
- */\r
-public class TreeTestResultPersister implements\r
- TestResultListener<TreeTestResult> {\r
- private static Log log = LogFactory.getLog(TreeTestResultPersister.class);\r
-\r
- private TreeTestResultDao testResultDao;\r
-\r
- public void resultPartAdded(TreeTestResult testResult,\r
- TestResultPart testResultPart) {\r
- try {\r
- TreeTestResult persistedResult = testResultDao\r
- .getTestResult(testResult.getUuid());\r
-\r
- if (persistedResult == null) {\r
- testResultDao.create(testResult);\r
- } else {\r
- testResultDao.update(testResult);\r
- }\r
- } catch (Exception e) {\r
- log.error("Could not persist result part " + testResultPart\r
- + " for result " + testResult.getUuid());\r
- }\r
- }\r
-\r
- public void close(TreeTestResult testResult) {\r
- TreeTestResult persistedResult = (TreeTestResult) testResultDao\r
- .getTestResult(testResult.getUuid());\r
-\r
- if (persistedResult != null) {\r
- persistedResult.setCloseDate(testResult.getCloseDate());\r
- testResultDao.update(persistedResult);\r
- }\r
- if (log.isDebugEnabled())\r
- log.debug("Closed result persister for result "\r
- + testResult.getUuid());\r
- }\r
-\r
- /** Sets the DAO to use in order to persist the results. */\r
- public void setTestResultDao(TreeTestResultDao testResultDao) {\r
- this.testResultDao = testResultDao;\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;\r
-\r
-/**\r
- * Converts data into a format better adapted for comparison. It is typically\r
- * used to convert <code>String</code> into typed format such as\r
- * <code>BigDecimal</code>\r
- */\r
-public interface DataInterpreter {\r
- /**\r
- * Converts data\r
- * \r
- * @param key\r
- * any object used to differentiate the type of data (e.g.\r
- * column, path)\r
- * @param value\r
- * the data to convert\r
- * @return the converted object\r
- */\r
- public Object convert(Object key, Object value);\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;\r
-\r
-import org.springframework.core.io.Resource;\r
-\r
-/** A comparator providing structured information about the differences found. */\r
-public interface Diff {\r
- /** Performs the comparison. */\r
- public DiffResult compare(Resource expected, Resource reached);\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;\r
-\r
-/** The root class for issues which happened during a diff. */\r
-public abstract class DiffIssue implements Comparable<DiffIssue> {\r
- /** The position of this issue. */\r
- protected final DiffPosition position;\r
-\r
- /** Constructor */\r
- public DiffIssue(DiffPosition position) {\r
- super();\r
- this.position = position;\r
- }\r
-\r
- public int compareTo(DiffIssue o) {\r
- return position.compareTo(o.position);\r
- }\r
-\r
- /** The position of this issue within the test file */\r
- public DiffPosition getPosition() {\r
- return position;\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;\r
-\r
-/**\r
- * Object able to uniquely identify an atomic diff part. Used to identify\r
- * missings and left-overs.\r
- */\r
-public interface DiffKey {\r
- public String toString();\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;\r
-\r
-/**\r
- * A value missing in one of the file. If its position is related to expected,\r
- * this means it is a left over in the reached, if its position is related to\r
- * the reached it means that it is missing from the reached. If the value is\r
- * null it means that the entire line is missing.\r
- */\r
-public class DiffMissing extends DiffIssue {\r
- private final DiffKey key;\r
-\r
- public DiffMissing(DiffPosition position, DiffKey key) {\r
- super(position);\r
- this.key = key;\r
- }\r
-\r
- public Object getKey() {\r
- return key;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- if (position.relatedFile == RelatedFile.EXPECTED) {\r
- return position + ": left over " + key;\r
- } else if (position.relatedFile == RelatedFile.REACHED) {\r
- return position + ": missing " + key;\r
- }\r
- return super.toString();\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;\r
-\r
-/**\r
- * <code>DiffMissing</code> using the XPath of the position as\r
- * <code>DiffKey</code>\r
- */\r
-public class DiffMissingXml extends DiffMissing {\r
-\r
- public DiffMissingXml(XPathDiffPosition position) {\r
- super(position, new DiffKeyXml(position.getXPath()));\r
- }\r
-\r
- /** Implementation of <code>DiffKey</code> based on an XPath string. */\r
- protected static class DiffKeyXml implements DiffKey {\r
- private final String xPath;\r
-\r
- public DiffKeyXml(String xPath) {\r
- this.xPath = xPath;\r
- }\r
-\r
- public String getXPath() {\r
- return xPath;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return xPath;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (!(obj instanceof DiffKeyXml))\r
- return false;\r
- return xPath.equals(((DiffKeyXml) obj).xPath);\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return xPath.hashCode();\r
- }\r
-\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;\r
-\r
-/** Diff issue where reached and expected values are different. */\r
-public class DiffNotMatched extends DiffIssue {\r
- private final Object expected;\r
- private final Object reached;\r
-\r
- public DiffNotMatched(DiffPosition position, Object expected, Object reached) {\r
- super(position);\r
- this.expected = expected;\r
- this.reached = reached;\r
- }\r
-\r
- public Object getExpected() {\r
- return expected;\r
- }\r
-\r
- public Object getReached() {\r
- return reached;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return position + ": not matched " + expected + " <> " + reached;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;\r
-\r
-/** The position of a diff issue within the test resource. */\r
-public abstract class DiffPosition implements Comparable<DiffPosition> {\r
- protected RelatedFile relatedFile;\r
-\r
- public DiffPosition(RelatedFile relatedFile) {\r
- super();\r
- this.relatedFile = relatedFile;\r
- }\r
-\r
- public RelatedFile getRelatedFile() {\r
- return relatedFile;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * The result of a diff. Can be subclassed to provided more structured\r
- * information.\r
- */\r
-public interface DiffResult {\r
- /** The list of issues, a zero size meaning that the diff succeeded. */\r
- public List<DiffIssue> getIssues();\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Parses a string as a vector of strings according to a separator, dealing
- * properly with missing values. This is intended to be used instead of the
- * standard StringTokenizer, which does not deal well with empty values.
- * Contrary to the StringTokenizer the provided String is parsed in the
- * constructor and the values stored as a property. This should therefore not be
- * used to parse long strings. No reference to the argument passed in
- * constructor is kept.
- */
-public class LineTokenizer {
- private final List<String> tokens;
-
- /** Complete constructor. */
- public LineTokenizer(String stringToParse, Character separator,
- String noValueString) {
- this.tokens = parse(stringToParse, separator, noValueString);
- }
-
- /**
- * Parse the string as a vector of strings. Can be overridden in order to
- * provide another implementation.
- */
- protected List<String> parse(final String stringToParse,
- final char separator, final String noValueString) {
- // Init
- final int NULL = -1;
- List<String> res = new ArrayList<String>();
- final char[] array = stringToParse.toCharArray();
- int lastSeparatorIndex = NULL;
-
- // Loop on chars
- for (int currIndex = 0; currIndex < array.length; currIndex++) {
- char c = array[currIndex];
- if (c == separator) {
- if (currIndex == 0) {
- // first char is a separator
- res.add(new String(noValueString));
- lastSeparatorIndex = 0;
- } else if (lastSeparatorIndex == NULL) {
- // first separator found
- res.add(new String(array, 0, currIndex));
- lastSeparatorIndex = currIndex;
- } else if (lastSeparatorIndex != NULL
- && (lastSeparatorIndex == (currIndex - 1))) {
- // consecutive separators
- res.add(new String(noValueString));
- lastSeparatorIndex = currIndex;
- } else {
- // simple case
- res.add(new String(array, lastSeparatorIndex + 1, currIndex
- - lastSeparatorIndex - 1));
- lastSeparatorIndex = currIndex;
- }
- }
- }
-
- // Finalize
- if (lastSeparatorIndex == NULL) {
- // no separator found
- res.add(new String(stringToParse));
- } else if (lastSeparatorIndex == (array.length - 1)) {
- // last char is a separator
- res.add(new String(noValueString));
- } else {
- // last token
- res.add(new String(array, lastSeparatorIndex + 1, array.length
- - lastSeparatorIndex - 1));
- }
- return res;
- }
-
- /** The tokens. */
- public List<String> getTokens() {
- return tokens;
- }
-
- /** Parse */
- public static List<String> tokenize(String stringToParse,
- Character separator, String noValueString) {
- LineTokenizer lt = new LineTokenizer(stringToParse, separator,
- noValueString);
- return lt.getTokens();
- }
-
- /** Parse, using the empty string as no value string. */
- public static List<String> tokenize(String stringToParse,
- Character separator) {
- return tokenize(stringToParse, separator, "");
- }
-
-}
+++ /dev/null
-package org.argeo.slc.diff;\r
-\r
-/** Enumeration of the types of resource tested. */\r
-public enum RelatedFile {\r
- /** The expected resource */\r
- EXPECTED,\r
- /** The reached resource */\r
- REACHED\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;\r
-\r
-import java.util.List;\r
-import java.util.Vector;\r
-\r
-/** A basic implementation of <code>DiffResult</code>. */\r
-public class SimpleDiffResult implements DiffResult {\r
- private List<DiffIssue> issues = new Vector<DiffIssue>();\r
-\r
- public List<DiffIssue> getIssues() {\r
- return issues;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;\r
-\r
-import org.argeo.slc.core.UnsupportedException;\r
-\r
-/**\r
- * A diff position within a table structure such a CSV file or an SQL result\r
- * set.\r
- */\r
-public class TableDiffPosition extends DiffPosition {\r
- private Integer line;\r
- /** Can be null */\r
- private Integer column;\r
- /** Can be null */\r
- private String columnName;\r
-\r
- public TableDiffPosition(RelatedFile relatedFile, Integer line,\r
- Integer column, String columnName) {\r
- super(relatedFile);\r
- this.line = line;\r
- this.column = column;\r
- this.columnName = columnName;\r
- }\r
-\r
- public Integer getLine() {\r
- return line;\r
- }\r
-\r
- public Integer getColumn() {\r
- return column;\r
- }\r
-\r
- public String getColumnName() {\r
- return columnName;\r
- }\r
-\r
- public int compareTo(DiffPosition dp) {\r
- if (!(dp instanceof TableDiffPosition))\r
- throw new UnsupportedException("position", dp);\r
-\r
- TableDiffPosition o = (TableDiffPosition) dp;\r
- if (relatedFile.equals(o.relatedFile)) {\r
- if (line == o.line) {\r
- return column.compareTo(o.column);\r
- } else {\r
- return line.compareTo(o.line);\r
- }\r
- } else {\r
- return relatedFile.compareTo(o.relatedFile);\r
- }\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- StringBuffer buf = new StringBuffer("");\r
- buf.append(relatedFile).append('[').append(line);\r
- if (column != null) {\r
- buf.append(',').append(column);\r
- if (columnName != null) {\r
- buf.append('-').append(columnName);\r
- }\r
- }\r
- buf.append(']');\r
- return buf.toString();\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;\r
-\r
-/** Compares objects, eventually using tolerance mechanisms. */\r
-public interface Tolerance {\r
- /**\r
- * Compares objects\r
- * \r
- * @param key\r
- * any object used to differentiate the type of data (e.g.\r
- * column, path)\r
- * @param expected\r
- * the expected value\r
- * @param reached\r
- * the reached value\r
- * @return the converted object\r
- */\r
- public Boolean compare(Object key, Object expected, Object reached);\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;\r
-\r
-import org.argeo.slc.core.UnsupportedException;\r
-\r
-/** A diff position within an Xml file. <b>NOT YET IMPLEMENTED</b>. */\r
-public class XPathDiffPosition extends DiffPosition {\r
-\r
- private String xPath;\r
-\r
- public XPathDiffPosition(RelatedFile relatedFile, String path) {\r
- super(relatedFile);\r
- xPath = path;\r
- }\r
-\r
- public int compareTo(DiffPosition dp) {\r
- if (!(dp instanceof XPathDiffPosition))\r
- throw new UnsupportedException("position", dp);\r
-\r
- XPathDiffPosition o = (XPathDiffPosition) dp;\r
- if (relatedFile.equals(o.relatedFile)) {\r
- return xPath.compareTo(o.xPath);\r
- } else {\r
- return relatedFile.compareTo(o.relatedFile);\r
- }\r
- }\r
-\r
- public String getXPath() {\r
- return xPath;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return xPath;\r
- }\r
-}\r
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-Abstraction of diff comparison with structured results.\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.maven;\r
-\r
-import org.argeo.slc.core.build.Distribution;\r
-import org.argeo.slc.core.deploy.DeploymentData;\r
-\r
-public class MavenFile implements Distribution, DeploymentData {\r
- private String groupId;\r
- private String artifactId;\r
- private String version;\r
- private String type;\r
- private String classifier;\r
-\r
- private String distributionId;\r
-\r
- public String getDistributionId() {\r
- return distributionId;\r
- }\r
-\r
- public void setDistributionId(String distributionId) {\r
- this.distributionId = distributionId;\r
- }\r
-\r
- public String getGroupId() {\r
- return groupId;\r
- }\r
-\r
- public void setGroupId(String groupId) {\r
- this.groupId = groupId;\r
- }\r
-\r
- public String getArtifactId() {\r
- return artifactId;\r
- }\r
-\r
- public void setArtifactId(String artifactId) {\r
- this.artifactId = artifactId;\r
- }\r
-\r
- public String getVersion() {\r
- return version;\r
- }\r
-\r
- public void setVersion(String version) {\r
- this.version = version;\r
- }\r
-\r
- public String getType() {\r
- return type;\r
- }\r
-\r
- public void setType(String type) {\r
- this.type = type;\r
- }\r
-\r
- public String getClassifier() {\r
- return classifier;\r
- }\r
-\r
- public void setClassifier(String classifier) {\r
- this.classifier = classifier;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.maven;\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
-import org.apache.maven.artifact.Artifact;\r
-import org.apache.maven.artifact.repository.ArtifactRepository;\r
-import org.apache.maven.embedder.MavenEmbedder;\r
-import org.apache.maven.embedder.MavenEmbedderException;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-\r
-public class MavenManager {\r
- private final Log log = LogFactory.getLog(getClass());\r
-\r
- private String repositoryId;\r
- private String repositoryUrl;\r
- private String localRepositoryPath;\r
-\r
- private ArtifactRepository localRepository;\r
- private List<ArtifactRepository> remoteRepositories;\r
-\r
- private MavenEmbedder mavenEmbedder;\r
-\r
- public void init() {\r
- try {\r
- mavenEmbedder = new MavenEmbedder();\r
- mavenEmbedder.setOffline(true);\r
- mavenEmbedder.setClassLoader(Thread.currentThread()\r
- .getContextClassLoader());\r
- mavenEmbedder.start();\r
-\r
- mavenEmbedder.setLocalRepositoryDirectory(new File(\r
- localRepositoryPath));\r
-\r
- localRepository = mavenEmbedder.getLocalRepository();\r
-\r
- // localRepository = mavenEmbedder.createLocalRepository(new File(\r
- // localRepositoryPath));\r
-\r
- ArtifactRepository repository = mavenEmbedder.createRepository(\r
- repositoryUrl, repositoryId);\r
-\r
- remoteRepositories = new Vector<ArtifactRepository>();\r
- remoteRepositories.add(repository);\r
- } catch (Exception e) {\r
- throw new SlcException("Cannot initialize Maven manager", e);\r
- }\r
- }\r
-\r
- private Artifact resolve(MavenFile mavenDistribution) {\r
- try {\r
- Artifact artifact;\r
- if (mavenDistribution.getClassifier() == null) {\r
- artifact = mavenEmbedder.createArtifact(mavenDistribution\r
- .getGroupId(), mavenDistribution.getArtifactId(),\r
- mavenDistribution.getVersion(),\r
- Artifact.SCOPE_PROVIDED, mavenDistribution.getType());\r
- } else {\r
- artifact = mavenEmbedder.createArtifactWithClassifier(\r
- mavenDistribution.getGroupId(), mavenDistribution\r
- .getArtifactId(), mavenDistribution\r
- .getVersion(), mavenDistribution.getType(),\r
- mavenDistribution.getClassifier());\r
- }\r
-\r
- mavenEmbedder\r
- .resolve(artifact, remoteRepositories, localRepository);\r
-\r
- return artifact;\r
- } catch (Exception e) {\r
- throw new SlcException("Cannot resolve artifact.", e);\r
- }\r
- }\r
-\r
- public File getPackageLocation(MavenFile mavenDistribution) {\r
- return resolve(mavenDistribution).getFile();\r
- }\r
-\r
- public void destroy() {\r
- try {\r
- if (mavenEmbedder != null) {\r
- mavenEmbedder.stop();\r
- }\r
- } catch (MavenEmbedderException e) {\r
- log.error("Cannot destroy Maven manager", e);\r
- }\r
- }\r
-\r
- public void setRepositoryId(String repositoryId) {\r
- this.repositoryId = repositoryId;\r
- }\r
-\r
- public void setRepositoryUrl(String repositoryUrl) {\r
- this.repositoryUrl = repositoryUrl;\r
- }\r
-\r
- public void setLocalRepositoryPath(String localRepositoryPath) {\r
- this.localRepositoryPath = localRepositoryPath;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.msg.process;
-
-import org.argeo.slc.core.process.SlcExecution;
-
-public class SlcExecutionRequest {
- private SlcExecution slcExecution;
-
- public SlcExecution getSlcExecution() {
- return slcExecution;
- }
-
- public void setSlcExecution(SlcExecution slcExecution) {
- this.slcExecution = slcExecution;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.msg.process;\r
-\r
-public class SlcExecutionStatusRequest {\r
- private String slcExecutionUuid;\r
- private String newStatus;\r
-\r
- public SlcExecutionStatusRequest() {\r
- }\r
-\r
- public SlcExecutionStatusRequest(String slcExecutionUuid, String newStatus) {\r
- this.slcExecutionUuid = slcExecutionUuid;\r
- this.newStatus = newStatus;\r
- }\r
-\r
- public String getSlcExecutionUuid() {\r
- return slcExecutionUuid;\r
- }\r
-\r
- public void setSlcExecutionUuid(String slcExecutionUuid) {\r
- this.slcExecutionUuid = slcExecutionUuid;\r
- }\r
-\r
- public String getNewStatus() {\r
- return newStatus;\r
- }\r
-\r
- public void setNewStatus(String newStatus) {\r
- this.newStatus = newStatus;\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.msg.process;\r
-\r
-import java.util.List;\r
-import java.util.Vector;\r
-\r
-import org.argeo.slc.core.process.SlcExecutionStep;\r
-\r
-public class SlcExecutionStepsRequest {\r
- private String slcExecutionUuid;\r
- private List<SlcExecutionStep> steps = new Vector<SlcExecutionStep>();\r
-\r
- public String getSlcExecutionUuid() {\r
- return slcExecutionUuid;\r
- }\r
-\r
- public void setSlcExecutionUuid(String slcExecutionUuid) {\r
- this.slcExecutionUuid = slcExecutionUuid;\r
- }\r
-\r
- public List<SlcExecutionStep> getSteps() {\r
- return steps;\r
- }\r
-\r
- public void setSteps(List<SlcExecutionStep> step) {\r
- this.steps = step;\r
- }\r
-\r
- public void addStep(SlcExecutionStep step) {\r
- steps.add(step);\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.msg.test.tree;\r
-\r
-import java.util.Date;\r
-\r
-import org.argeo.slc.core.test.tree.TreeTestResult;\r
-\r
-public class CloseTreeTestResultRequest {\r
- private String resultUuid;\r
- private Date closeDate;\r
-\r
- public CloseTreeTestResultRequest() {\r
-\r
- }\r
-\r
- public CloseTreeTestResultRequest(String resultUuid, Date closeDate) {\r
- this.resultUuid = resultUuid;\r
- this.closeDate = closeDate;\r
- }\r
-\r
- public CloseTreeTestResultRequest(TreeTestResult ttr) {\r
- this.resultUuid = ttr.getUuid();\r
- this.closeDate = ttr.getCloseDate();\r
- }\r
-\r
- public String getResultUuid() {\r
- return resultUuid;\r
- }\r
-\r
- public void setResultUuid(String id) {\r
- this.resultUuid = id;\r
- }\r
-\r
- public Date getCloseDate() {\r
- return closeDate;\r
- }\r
-\r
- public void setCloseDate(Date closeDate) {\r
- this.closeDate = closeDate;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.msg.test.tree;\r
-\r
-import org.argeo.slc.core.test.tree.TreeTestResult;\r
-\r
-public class CreateTreeTestResultRequest {\r
- private TreeTestResult treeTestResult;\r
-\r
- public CreateTreeTestResultRequest() {\r
-\r
- }\r
-\r
- public CreateTreeTestResultRequest(TreeTestResult treeTestResult) {\r
- this.treeTestResult = treeTestResult;\r
- }\r
-\r
- public TreeTestResult getTreeTestResult() {\r
- return treeTestResult;\r
- }\r
-\r
- public void setTreeTestResult(TreeTestResult treeTestResult) {\r
- this.treeTestResult = treeTestResult;\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.msg.test.tree;\r
-\r
-import java.util.Map;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-import org.argeo.slc.core.process.SlcExecution;\r
-import org.argeo.slc.core.structure.StructureElement;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.test.SimpleResultPart;\r
-import org.argeo.slc.core.test.TestRunDescriptor;\r
-import org.argeo.slc.core.test.tree.PartSubList;\r
-import org.argeo.slc.core.test.tree.TreeTestResult;\r
-\r
-public class ResultPartRequest {\r
- private String resultUuid;\r
- private SimpleResultPart resultPart;\r
- private TreeSPath path;\r
- private Map<TreeSPath, StructureElement> relatedElements;\r
- private TestRunDescriptor testRunDescriptor;\r
-\r
- public ResultPartRequest() {\r
-\r
- }\r
-\r
- public ResultPartRequest(TreeTestResult ttr, TreeSPath path,\r
- SimpleResultPart resultPart) {\r
- resultUuid = ttr.getUuid();\r
- this.resultPart = resultPart;\r
- this.path = path;\r
- relatedElements = ttr.getRelatedElements(path);\r
- if (ttr.getCurrentTestRun() != null)\r
- testRunDescriptor = new TestRunDescriptor(ttr.getCurrentTestRun());\r
- }\r
-\r
- public ResultPartRequest(TreeTestResult ttr) {\r
- resultUuid = ttr.getUuid();\r
- this.path = ttr.getCurrentPath();\r
-\r
- PartSubList lst = ttr.getResultParts().get(path);\r
- if (lst.getParts().size() < 1) {\r
- throw new SlcException("Cannot find part for path " + path\r
- + " in result " + resultUuid);\r
- }\r
-\r
- this.resultPart = (SimpleResultPart) lst.getParts().get(\r
- lst.getParts().size() - 1);\r
- relatedElements = ttr.getRelatedElements(path);\r
- if (ttr.getCurrentTestRun() != null)\r
- testRunDescriptor = new TestRunDescriptor(ttr.getCurrentTestRun());\r
- }\r
-\r
- public String getResultUuid() {\r
- return resultUuid;\r
- }\r
-\r
- public void setResultUuid(String resultUuid) {\r
- this.resultUuid = resultUuid;\r
- }\r
-\r
- public SimpleResultPart getResultPart() {\r
- return resultPart;\r
- }\r
-\r
- public void setResultPart(SimpleResultPart resultPart) {\r
- this.resultPart = resultPart;\r
- }\r
-\r
- public TreeSPath getPath() {\r
- return path;\r
- }\r
-\r
- public void setPath(TreeSPath path) {\r
- this.path = path;\r
- }\r
-\r
- public TestRunDescriptor getTestRunDescriptor() {\r
- return testRunDescriptor;\r
- }\r
-\r
- public void setTestRunDescriptor(TestRunDescriptor testRunDescriptor) {\r
- this.testRunDescriptor = testRunDescriptor;\r
- }\r
-\r
- public Map<TreeSPath, StructureElement> getRelatedElements() {\r
- return relatedElements;\r
- }\r
-\r
- public void setRelatedElements(\r
- Map<TreeSPath, StructureElement> relatedElements) {\r
- this.relatedElements = relatedElements;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.spring;\r
-\r
-import java.util.Map;\r
-\r
-import org.springframework.beans.factory.ListableBeanFactory;\r
-\r
-public class SpringUtils {\r
- public static <T> T loadSingleFromContext(ListableBeanFactory context,\r
- Class<T> clss) {\r
- Map<String, T> beans = context.getBeansOfType(clss);\r
- if (beans.size() == 1) {\r
- return beans.values().iterator().next();\r
- } else {\r
- return null;\r
- }\r
- }\r
-\r
- private SpringUtils() {\r
-\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.support.deploy;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.net.URL;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-import org.argeo.slc.core.build.Distribution;\r
-import org.springframework.core.io.Resource;\r
-\r
-public class ApacheHttpdServer implements WebServer {\r
- private Resource baseUrlRes;\r
- private File baseLocation;\r
-\r
- public URL getBaseUrl() {\r
- try {\r
- return baseUrlRes.getURL();\r
- } catch (IOException e) {\r
- throw new SlcException("Cannot get url from "+baseUrlRes,e);\r
- }\r
- }\r
-\r
- public void setBaseUrlRes(Resource baseUrlRes){\r
- this.baseUrlRes = baseUrlRes;\r
- }\r
- \r
- \r
- \r
- public File getBaseLocation() {\r
- return baseLocation;\r
- }\r
-\r
- public void setBaseLocation(File baseLocation) {\r
- this.baseLocation = baseLocation;\r
- }\r
-\r
- public String getDeployedSystemId() {\r
- // TODO Auto-generated method stub\r
- return null;\r
- }\r
-\r
- public Distribution getDistribution() {\r
- // TODO Auto-generated method stub\r
- return null;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.support.deploy;
-
-import java.io.File;
-import java.net.URL;
-import java.util.Map;
-import java.util.Properties;
-import java.util.UUID;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.slc.ant.AntRegistryUtil;
-import org.argeo.slc.core.SlcException;
-import org.argeo.slc.core.deploy.DeployEnvironment;
-import org.argeo.slc.maven.MavenFile;
-import org.argeo.slc.maven.MavenManager;
-
-public class BasicDeployEnvironment implements DeployEnvironment {
- private static final Log log = LogFactory
- .getLog(BasicDeployEnvironment.class);
- private MavenManager mavenManager;
-
- public void unpackTo(Object packg, File targetLocation,
- Map<String, String> filter) {
- File packageLocation;
- String type = null;
- String removeRootDir = "enabled";
- if (packg instanceof MavenFile) {
- packageLocation = mavenManager
- .getPackageLocation((MavenFile) packg);
- type = ((MavenFile) packg).getType();
- } else if (packg instanceof File) {
- packageLocation = (File) packg;
- // TODO: type based on extension
- } else {
- throw new SlcException("Unrecognized package type "
- + packg.getClass());
- }
- if (log.isDebugEnabled()) {
- log.debug("Unpack " + packageLocation + " of type " + type + " to "
- + targetLocation);
- }
-
- try {
- File tempDir = new File("/tmp/"+UUID.randomUUID().toString());
- tempDir.mkdirs();
- targetLocation.mkdirs();
- Properties props = new Properties();
- props.setProperty("dest", targetLocation.getAbsolutePath());
- props.setProperty("src", packageLocation.getAbsolutePath());
- props.setProperty("tempDir", tempDir.getAbsolutePath());
- props.setProperty("removeRootDir", removeRootDir);
-
- URL antUrl = getClass().getClassLoader().getResource(
- "org/argeo/slc/support/deploy/ant/build.xml");
-
- if (type == null || type.equals("zip")) {
- AntRegistryUtil.runAll(antUrl, "deployZip", props);
- } else if (type.equals("tar.gz")) {
- AntRegistryUtil.runAll(antUrl, "deployTarGz", props);
- } else {
- throw new SlcException("Unknow package type " + type);
- }
- } catch (SlcException e) {
- throw e;
- } catch (Exception e) {
- throw new SlcException("Cannot unpack package " + packg + " to "
- + targetLocation, e);
- }
- }
-
- public void setMavenManager(MavenManager mavenManager) {
- this.mavenManager = mavenManager;
- }
-
-}
+++ /dev/null
-package org.argeo.slc.support.deploy;\r
-\r
-import java.io.File;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.argeo.slc.core.SlcException;\r
-import org.argeo.slc.core.build.Distribution;\r
-import org.argeo.slc.core.deploy.DeployEnvironment;\r
-import org.argeo.slc.core.deploy.DeployedSystem;\r
-import org.argeo.slc.core.deploy.DeploymentData;\r
-import org.argeo.slc.core.deploy.ExecutableDeployment;\r
-import org.argeo.slc.core.deploy.TargetData;\r
-\r
-public class HttpdApplicationDeployment implements ExecutableDeployment {\r
- private static final Log log = LogFactory\r
- .getLog(HttpdApplicationDeployment.class);\r
-\r
- private HttpdApplicationTargetData targetData;\r
- private DeploymentData deploymentData;\r
- private SimpleHttpdApplication deployedSystem;\r
- private Distribution distribution;\r
-\r
- private DeployEnvironment deployEnvironment;\r
-\r
- public void execute() {\r
- try {\r
- deployEnvironment.unpackTo(getDistribution(), targetData\r
- .getTargetRootLocation(), null);\r
- \r
- // FIXME: make it generic\r
- String deployDataPath = targetData.getTargetRootLocation()\r
- .getCanonicalPath();\r
- \r
- deployEnvironment.unpackTo(getDeploymentData(), new File(\r
- deployDataPath), null);\r
- deployedSystem = new SimpleHttpdApplication();\r
- deployedSystem.setTargetData(targetData);\r
-\r
- } catch (Exception e) {\r
- throw new SlcException("Cannot deploy " + deploymentData + " to "\r
- + targetData, e);\r
- }\r
-\r
- }\r
-\r
- public void setTargetData(TargetData targetData) {\r
- this.targetData = (HttpdApplicationTargetData) targetData;\r
- }\r
-\r
- public void setDeploymentData(DeploymentData deploymentData) {\r
- this.deploymentData = deploymentData;\r
- }\r
-\r
- public DeployedSystem getDeployedSystem() {\r
- return deployedSystem;\r
- }\r
-\r
- public DeploymentData getDeploymentData() {\r
- return deploymentData;\r
- }\r
-\r
- public TargetData getTargetData() {\r
- return targetData;\r
- }\r
-\r
- public Distribution getDistribution() {\r
- return distribution;\r
- }\r
-\r
- public void setDistribution(Distribution distribution) {\r
- this.distribution = distribution;\r
- }\r
-\r
- public void setDeployEnvironment(DeployEnvironment deployEnvironment) {\r
- this.deployEnvironment = deployEnvironment;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.support.deploy;\r
-\r
-import java.io.File;\r
-import java.net.MalformedURLException;\r
-import java.net.URL;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-import org.argeo.slc.core.deploy.TargetData;\r
-\r
-public class HttpdApplicationTargetData implements TargetData {\r
- private ApacheHttpdServer webServer;\r
- private String relativePath;\r
-\r
- public ApacheHttpdServer getWebServer() {\r
- return webServer;\r
- }\r
-\r
- public void setWebServer(ApacheHttpdServer webServer) {\r
- this.webServer = webServer;\r
- }\r
-\r
- public String getRelativePath() {\r
- return relativePath;\r
- }\r
-\r
- public void setRelativePath(String relativePath) {\r
- this.relativePath = relativePath;\r
- }\r
-\r
- public URL getTargetBaseUrl() {\r
- try {\r
- URL wsUrl = getWebServer().getBaseUrl();\r
- return new URL(wsUrl, wsUrl.getFile() + '/' + relativePath);\r
- } catch (MalformedURLException e) {\r
- throw new SlcException("Cannot get base url for " + relativePath, e);\r
- }\r
- }\r
-\r
- public File getTargetRootLocation() {\r
- return new File(getWebServer().getBaseLocation().getPath()\r
- + File.separator + getRelativePath());\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.support.deploy;\r
-\r
-import java.io.File;\r
-import java.net.URL;\r
-\r
-import org.argeo.slc.core.build.Distribution;\r
-\r
-public class SimpleHttpdApplication implements WebApplication {\r
- private HttpdApplicationTargetData targetData;\r
- private Distribution distribution;\r
-\r
- public void setDistribution(Distribution distribution) {\r
- this.distribution = distribution;\r
- }\r
-\r
- public URL getBaseUrl() {\r
- return targetData.getTargetBaseUrl();\r
- }\r
-\r
- public File getRootLocation() {\r
- return targetData.getTargetRootLocation();\r
- }\r
-\r
- public String getDeployedSystemId() {\r
- // TODO Auto-generated method stub\r
- return null;\r
- }\r
-\r
- public HttpdApplicationTargetData getTargetData() {\r
- return targetData;\r
- }\r
-\r
- public void setTargetData(HttpdApplicationTargetData targetData) {\r
- this.targetData = targetData;\r
- }\r
-\r
- public Distribution getDistribution() {\r
- return distribution;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.support.deploy;\r
-\r
-import java.io.File;\r
-import java.net.URL;\r
-\r
-import org.argeo.slc.core.deploy.DeployedSystem;\r
-\r
-public interface WebApplication extends DeployedSystem{\r
- public URL getBaseUrl();\r
- public File getRootLocation();\r
-}\r
+++ /dev/null
-package org.argeo.slc.support.deploy;\r
-\r
-import java.net.URL;\r
-\r
-import org.argeo.slc.core.deploy.DeployedSystem;\r
-\r
-public interface WebServer extends DeployedSystem {\r
- public URL getBaseUrl();\r
-}\r
+++ /dev/null
-package org.argeo.slc.unit;\r
-\r
-import junit.framework.TestCase;\r
-\r
-import org.springframework.context.ApplicationContext;\r
-import org.springframework.context.support.ClassPathXmlApplicationContext;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-import org.argeo.slc.spring.SpringUtils;\r
-\r
-/** Helper for tests using a Spring application co,text. */\r
-public abstract class AbstractSpringTestCase extends TestCase {\r
- protected final Log log = LogFactory.getLog(getClass());\r
- private ApplicationContext context;\r
-\r
- /**\r
- * Gets (and create if necessary) the application context to use. Default\r
- * implementation uses a class path xml application context and calls\r
- * {@link #getApplicationContextLocation()}.\r
- */\r
- protected ApplicationContext getContext() {\r
- if (context == null) {\r
- context = new ClassPathXmlApplicationContext(\r
- getApplicationContextLocation());\r
- }\r
- return context;\r
- }\r
-\r
- /** Returns a bean from the underlying context */\r
- protected <T> T getBean(String beanId) {\r
- return (T) getContext().getBean(beanId);\r
- }\r
-\r
- protected <T> T getBean(Class<? extends T> clss) {\r
- T bean = SpringUtils.loadSingleFromContext(getContext(), clss);\r
- if (bean == null) {\r
- throw new SlcException("Cannot retrieve a unique bean of type "\r
- + clss);\r
- } else {\r
- return bean;\r
- }\r
- }\r
-\r
- /**\r
- * Th location of the application to load. The default implementation\r
- * returns <i>applicationContext.xml</i> found in the same package as the\r
- * test.\r
- */\r
- protected String getApplicationContextLocation() {\r
- return inPackage("applicationContext.xml");\r
- }\r
-\r
- /**\r
- * Prefixes the package of the class after converting the '.' to '/' in\r
- * order to have a resource path.\r
- */\r
- protected String inPackage(String suffix) {\r
- String prefix = getClass().getPackage().getName().replace('.', '/');\r
- return prefix + '/' + suffix;\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.unit;\r
-\r
-import java.sql.Connection;\r
-import java.util.List;\r
-import java.util.Properties;\r
-\r
-import org.hibernate.cfg.Configuration;\r
-import org.hibernate.cfg.Environment;\r
-import org.hibernate.tool.hbm2ddl.SchemaExport;\r
-\r
-/**\r
- * Creates a relational data model from Hibernate mapping files. The benefit of\r
- * this class is to be able to use Hibernate to have test data which are\r
- * independent from the type of database used.\r
- */\r
-public class DbModel {\r
- private String dialect;\r
- private List<String> mappings;\r
-\r
- /** Sets the Hibernate dialect to use. */\r
- public void setDialect(String dialect) {\r
- this.dialect = dialect;\r
- }\r
-\r
- /** Sets the list of mappings to consider. */\r
- public void setMappings(List<String> mappings) {\r
- this.mappings = mappings;\r
- }\r
-\r
- /**\r
- * Creates an Hibernate schema export tool, in order to create the\r
- * underlying datamodel.\r
- */\r
- public SchemaExport createSchemaExport(Connection connection) {\r
- Configuration configuration = new Configuration();\r
- Properties properties = new Properties();\r
- properties.setProperty(Environment.DIALECT, dialect);\r
- properties.setProperty(Environment.HBM2DDL_AUTO, "create");\r
- configuration.setProperties(properties);\r
-\r
- for (String mapping : mappings) {\r
- configuration.addResource(mapping.trim());\r
- }\r
-\r
- return new SchemaExport(configuration, connection);\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.unit;\r
-\r
-import java.io.InputStream;\r
-import java.sql.SQLException;\r
-\r
-import javax.sql.DataSource;\r
-\r
-import org.dbunit.DataSourceDatabaseTester;\r
-import org.dbunit.DatabaseUnitException;\r
-import org.dbunit.IDatabaseTester;\r
-import org.dbunit.database.IDatabaseConnection;\r
-import org.dbunit.dataset.IDataSet;\r
-import org.dbunit.dataset.ReplacementDataSet;\r
-import org.dbunit.dataset.xml.FlatXmlDataSet;\r
-import org.dbunit.operation.DatabaseOperation;\r
-import org.springframework.core.io.ClassPathResource;\r
-import org.springframework.core.io.Resource;\r
-\r
-import org.apache.commons.io.IOUtils;\r
-\r
-import org.hibernate.tool.hbm2ddl.SchemaExport;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-\r
-/**\r
- * Helper to make db vendor independent tests using DbUnit data sets. Based on\r
- * {@link DbModel}.\r
- */\r
-public abstract class IndependentDbTestCase extends AbstractSpringTestCase {\r
- private IDatabaseTester databaseTester;\r
-\r
- /** Creates the DDL of the data model and loads the data. */\r
- @Override\r
- protected void setUp() throws Exception {\r
- super.setUp();\r
-\r
- databaseTester = new DataSourceDatabaseTester(getDataSource());\r
- databaseTester.setSetUpOperation(new DatabaseOperation() {\r
-\r
- @Override\r
- public void execute(IDatabaseConnection connection, IDataSet dataSet)\r
- throws DatabaseUnitException, SQLException {\r
- DbModel dbModel = getDbModel();\r
- SchemaExport schemaExport = dbModel\r
- .createSchemaExport(connection.getConnection());\r
- schemaExport.create(true, true);\r
-\r
- DatabaseOperation.INSERT.execute(connection, dataSet);\r
- }\r
-\r
- });\r
- databaseTester.setDataSet(createDataSet());\r
- databaseTester.onSetup();\r
- }\r
-\r
- @Override\r
- protected void tearDown() throws Exception {\r
- if (databaseTester != null) {\r
- databaseTester.onTearDown();\r
- }\r
- super.tearDown();\r
- }\r
-\r
- /**\r
- * The data source to use. The default implementation returns a bean named\r
- * {@link #getDataSourceBeanName}\r
- */\r
- protected DataSource getDataSource() {\r
- return (DataSource) getContext().getBean(getDataSourceBeanName());\r
- }\r
-\r
- /**\r
- * The name of the data source bean to use. The default implementation\r
- * returns <i>dataSource</i>.\r
- */\r
- protected String getDataSourceBeanName() {\r
- return "slcDefault.dataSource.inMemoryTestHSQL";\r
- }\r
-\r
- /**\r
- * Creates the data set to use. The default implementation creates a\r
- * <code>FlatXmlDataSet</code> load from the resource defined in\r
- * {@link #getDataSetResource()}\r
- */\r
- protected IDataSet createDataSet() {\r
- InputStream in = null;\r
- try {\r
- in = getDataSetResource().getInputStream();\r
- String[] replaceStrings = getReplacementStrings();\r
- IDataSet dataSet;\r
- if (replaceStrings.length == 0) {\r
- dataSet = new FlatXmlDataSet(in);\r
- } else {\r
- dataSet = new ReplacementDataSet(new FlatXmlDataSet(in));\r
- for (String str : replaceStrings) {\r
- replace((ReplacementDataSet) dataSet, str);\r
- }\r
- }\r
- return dataSet;\r
- } catch (Exception e) {\r
- throw new SlcException("Cannot create data set", e);\r
- } finally {\r
- IOUtils.closeQuietly(in);\r
- }\r
- }\r
-\r
- /**\r
- * To be overridden. Return an empty array by default.\r
- * \r
- * @return the array of strings to replace in the dataset\r
- */\r
- protected String[] getReplacementStrings() {\r
- return new String[0];\r
- }\r
-\r
- /**\r
- * Set the object replacing the given string. To be overridden. Does nothing\r
- * by default.\r
- */\r
- protected void replace(ReplacementDataSet dataSet, String str)\r
- throws Exception {\r
-\r
- }\r
-\r
- /**\r
- * Replace the given string by the content of the resource with the same\r
- * name in the same package, as a byte array.\r
- */\r
- protected void replaceByRessource(ReplacementDataSet dataSet, String str)\r
- throws Exception {\r
- Resource zipResource = new ClassPathResource(inPackage(str));\r
-\r
- dataSet.addReplacementObject(str, IOUtils.toByteArray(zipResource\r
- .getInputStream()));\r
- }\r
-\r
- /**\r
- * The resource of the data set to load. The default implementation loads a\r
- * <code>ClassPathResource</code> located at\r
- * {@link #getDataSetResourceLocation()}.\r
- */\r
- protected Resource getDataSetResource() {\r
- return new ClassPathResource(getDataSetResourceLocation());\r
- }\r
-\r
- /**\r
- * The location of the data set to load. The default implementation loads\r
- * <i>dataSet.xml</i> found in the same package as the test.\r
- */\r
- protected String getDataSetResourceLocation() {\r
- return inPackage("dataSet.xml");\r
- }\r
-\r
- /**\r
- * The DB model to us to create the DDL of the testes database. The default\r
- * implementation loads a bean named after {@link #getDbModelBeanName()}.\r
- */\r
- protected DbModel getDbModel() {\r
- return (DbModel) getContext().getBean(getDbModelBeanName());\r
- }\r
-\r
- /**\r
- * The name of the bean to load. The default implementation returns\r
- * <i>dbModel</i>.\r
- */\r
- protected String getDbModelBeanName() {\r
- return "dbModel";\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.unit;\r
-\r
-import java.util.Calendar;\r
-import java.util.Date;\r
-import java.util.GregorianCalendar;\r
-\r
-import static junit.framework.Assert.assertEquals;\r
-import static junit.framework.Assert.assertNull;\r
-import static junit.framework.Assert.assertNotNull;\r
-\r
-public abstract class UnitUtils {\r
- public static void assertDateSec(Date expected, Date reached) {\r
- if (expected == null) {\r
- assertNull(reached);\r
- return;\r
- } else {\r
- assertNotNull(reached);\r
- }\r
-\r
- Calendar expectedCal = new GregorianCalendar();\r
- expectedCal.setTime(expected);\r
- Calendar reachedCal = new GregorianCalendar();\r
- reachedCal.setTime(reached);\r
- assertEquals(expectedCal.get(Calendar.YEAR), reachedCal\r
- .get(Calendar.YEAR));\r
- assertEquals(expectedCal.get(Calendar.MONTH), reachedCal\r
- .get(Calendar.MONTH));\r
- assertEquals(expectedCal.get(Calendar.DATE), reachedCal\r
- .get(Calendar.DATE));\r
- assertEquals(expectedCal.get(Calendar.HOUR_OF_DAY), reachedCal\r
- .get(Calendar.HOUR_OF_DAY));\r
- assertEquals(expectedCal.get(Calendar.MINUTE), reachedCal\r
- .get(Calendar.MINUTE));\r
- assertEquals(expectedCal.get(Calendar.SECOND), reachedCal\r
- .get(Calendar.SECOND));\r
- }\r
-\r
- private UnitUtils() {\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.unit;\r
-\r
-import java.io.IOException;\r
-\r
-import javax.xml.transform.Source;\r
-\r
-import junit.framework.TestCase;\r
-\r
-import org.springframework.xml.validation.XmlValidator;\r
-import org.springframework.xml.xsd.XsdSchema;\r
-import org.xml.sax.SAXParseException;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-public abstract class UnitXmlUtils {\r
- private final static Log log = LogFactory.getLog(UnitXmlUtils.class);\r
-\r
- public static void assertXsdSchemaValidation(XsdSchema schema, Source source)\r
- throws IOException {\r
- XmlValidator validator = schema.createValidator();\r
- assertXmlValidation(validator, source);\r
- }\r
-\r
- public static void assertXmlValidation(XmlValidator validator, Source source)\r
- throws IOException {\r
- SAXParseException[] exceptions = validator.validate(source);\r
- if (exceptions.length != 0) {\r
- for (SAXParseException ex : exceptions) {\r
- log.error(ex.getMessage());\r
- }\r
- TestCase.fail("Could not validate");\r
- }\r
- }\r
-\r
- private UnitXmlUtils() {\r
-\r
- }\r
-}\r
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-Helpers for unit tests.\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.unit.test.tree;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import static junit.framework.Assert.assertEquals;\r
-import static junit.framework.Assert.assertNotNull;\r
-import static junit.framework.Assert.assertNull;\r
-import static junit.framework.Assert.fail;\r
-import static org.argeo.slc.unit.UnitUtils.assertDateSec;\r
-\r
-import org.argeo.slc.core.structure.SimpleSElement;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.test.SimpleResultPart;\r
-import org.argeo.slc.core.test.TestResultPart;\r
-import org.argeo.slc.core.test.tree.PartSubList;\r
-import org.argeo.slc.core.test.tree.TreeTestResult;\r
-\r
-/** Utilities for unit tests. */\r
-public class UnitTestTreeUtil {\r
- private final static Log log = LogFactory.getLog(UnitTestTreeUtil.class);\r
-\r
- public static void assertTreeTestResult(TreeTestResult expected,\r
- TreeTestResult reached) {\r
- assertEquals(expected.getUuid(), reached.getUuid());\r
- assertDateSec(expected.getCloseDate(), reached.getCloseDate());\r
-\r
- assertEquals(expected.getResultParts().size(), reached.getResultParts()\r
- .size());\r
- for (TreeSPath path : expected.getResultParts().keySet()) {\r
- PartSubList lstExpected = expected.getResultParts().get(path);\r
- PartSubList lstReached = expected.getResultParts().get(path);\r
- if (lstReached == null) {\r
- fail("No result for path " + path);\r
- return;\r
- }\r
- assertPartSubList(lstExpected, lstReached);\r
- }\r
-\r
- assertEquals(expected.getElements().size(), reached.getElements()\r
- .size());\r
- for (TreeSPath path : expected.getElements().keySet()) {\r
- // String nameExpected = expected.getElements().get(path);\r
- // String nameReached = expected.getElements().get(path);\r
- SimpleSElement elemExpected = (SimpleSElement) expected\r
- .getElements().get(path);\r
- SimpleSElement elemReached = (SimpleSElement) expected\r
- .getElements().get(path);\r
- assertNotNull(elemReached);\r
- assertElements(elemExpected, elemReached);\r
- }\r
-\r
- }\r
-\r
- public static void assertElements(SimpleSElement expected,\r
- SimpleSElement reached) {\r
- assertEquals(expected.getLabel(), reached.getLabel());\r
- assertEquals(expected.getTags().size(), reached.getTags().size());\r
- for (String tagName : expected.getTags().keySet()) {\r
- String expectedTagValue = expected.getTags().get(tagName);\r
- String reachedTagValue = reached.getTags().get(tagName);\r
- assertNotNull(reachedTagValue);\r
- assertEquals(expectedTagValue, reachedTagValue);\r
- }\r
- }\r
-\r
- public static void assertPartSubList(PartSubList lstExpected,\r
- PartSubList lstReached) {\r
- assertEquals(lstExpected.getParts().size(), lstReached.getParts()\r
- .size());\r
- for (int i = 0; i < lstExpected.getParts().size(); i++) {\r
- assertPart(lstExpected.getParts().get(i), lstReached.getParts()\r
- .get(i));\r
- }\r
- }\r
-\r
- /** Asserts one part of a tree test result */\r
- public static void assertPart(TreeTestResult testResult, String pathStr,\r
- int index, Integer status, String message) {\r
- TreeSPath path = new TreeSPath(pathStr);\r
- PartSubList list = testResult.getResultParts().get(path);\r
- if (list == null) {\r
- fail("No result for path " + path);\r
- return;\r
- }\r
- if (index >= list.getParts().size()) {\r
- fail("Not enough parts.");\r
- }\r
- SimpleResultPart part = (SimpleResultPart) list.getParts().get(index);\r
- assertPart(part, status, message, null, part.getTestRunUuid(), true);\r
- }\r
-\r
- public static void assertPart(TestResultPart expected,\r
- TestResultPart reached) {\r
- String expectedTestRunUuid = null;\r
- if (expected instanceof SimpleResultPart) {\r
- expectedTestRunUuid = ((SimpleResultPart) expected)\r
- .getTestRunUuid();\r
- }\r
-\r
- assertPart(reached, expected.getStatus(), expected.getMessage(),\r
- expected.getExceptionMessage(), expectedTestRunUuid, false);\r
- }\r
-\r
- /** Assert one part of a tree test result. */\r
- private static void assertPart(TestResultPart part, Integer status,\r
- String message, String exceptionDescription,\r
- String expectedTestRunUuid, boolean skipExceptionMessage) {\r
- assertEquals(status, part.getStatus());\r
-\r
- if (log.isTraceEnabled()) {\r
- log.trace("Expected message:" + message);\r
- log.trace("Reached message:" + part.getMessage());\r
- }\r
- assertEquals(message, part.getMessage());\r
- if (!skipExceptionMessage) {\r
- if (exceptionDescription == null) {\r
- assertNull(part.getExceptionMessage());\r
- } else {\r
- if (log.isTraceEnabled()) {\r
- log.trace("Expected exception message:"\r
- + exceptionDescription);\r
- log.trace("Reached exception message:"\r
- + part.getExceptionMessage());\r
- }\r
-\r
- assertEquals(exceptionDescription, part.getExceptionMessage());\r
- }\r
- }\r
-\r
- if (expectedTestRunUuid != null) {\r
- SimpleResultPart reachedPart = (SimpleResultPart) part;\r
- assertNotNull(reachedPart.getTestRunUuid());\r
- assertEquals(expectedTestRunUuid, reachedPart.getTestRunUuid());\r
- } else {\r
- if (part instanceof SimpleResultPart) {\r
- assertNull(((SimpleResultPart) part).getTestRunUuid());\r
- }\r
-\r
- }\r
-\r
- }\r
-\r
- /** Makes sure this is a singleton */\r
- private UnitTestTreeUtil() {\r
-\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.ws.client;\r
-\r
-import java.io.IOException;\r
-\r
-import javax.xml.transform.Source;\r
-\r
-import org.springframework.ws.client.WebServiceClientException;\r
-import org.springframework.ws.client.WebServiceIOException;\r
-import org.springframework.ws.client.support.interceptor.ClientInterceptor;\r
-import org.springframework.ws.context.MessageContext;\r
-import org.springframework.xml.validation.XmlValidator;\r
-import org.xml.sax.SAXParseException;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-public class ValidatingClientInterceptor implements ClientInterceptor {\r
- private final static Log log = LogFactory\r
- .getLog(ValidatingClientInterceptor.class);\r
-\r
- private Boolean validateRequest = true;\r
- private Boolean validateResponse = false;\r
- private XmlValidator validator = null;\r
-\r
- public boolean handleFault(MessageContext messageContext)\r
- throws WebServiceClientException {\r
- return true;\r
- }\r
-\r
- public boolean handleRequest(MessageContext messageContext)\r
- throws WebServiceClientException {\r
- if (validateRequest) {\r
- if (messageContext.getRequest() == null)\r
- return true;\r
-\r
- Source source = messageContext.getRequest().getPayloadSource();\r
- try {\r
- return validate(source);\r
- } catch (IOException e) {\r
- throw new WebServiceIOException("Cannot validate request", e);\r
- }\r
- } else {\r
- return true;\r
- }\r
- }\r
-\r
- public boolean handleResponse(MessageContext messageContext)\r
- throws WebServiceClientException {\r
- if (validateResponse) {\r
- if (messageContext.getResponse() == null)\r
- return true;\r
- \r
- Source source = messageContext.getResponse().getPayloadSource();\r
- try {\r
- return validate(source);\r
- } catch (IOException e) {\r
- throw new WebServiceIOException("Cannot validate response", e);\r
- }\r
- } else {\r
- return true;\r
- }\r
- }\r
-\r
- protected boolean validate(Source source) throws IOException {\r
- SAXParseException[] exceptions = validator.validate(source);\r
- if (exceptions.length != 0) {\r
- for (SAXParseException ex : exceptions) {\r
- log.error(ex.getMessage());\r
- }\r
- return false;\r
- } else {\r
- return true;\r
- }\r
- }\r
-\r
- public void setValidateRequest(Boolean validateRequest) {\r
- this.validateRequest = validateRequest;\r
- }\r
-\r
- public void setValidateResponse(Boolean validateResponse) {\r
- this.validateResponse = validateResponse;\r
- }\r
-\r
- public void setValidator(XmlValidator validator) {\r
- this.validator = validator;\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.ws.client;\r
-\r
-import java.util.Iterator;\r
-\r
-import javax.xml.transform.Source;\r
-import javax.xml.transform.dom.DOMSource;\r
-\r
-import org.springframework.ws.client.core.WebServiceTemplate;\r
-import org.springframework.ws.soap.SoapFaultDetail;\r
-import org.springframework.ws.soap.SoapFaultDetailElement;\r
-import org.springframework.ws.soap.client.SoapFaultClientException;\r
-import org.springframework.xml.transform.StringResult;\r
-import org.w3c.dom.Node;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-public abstract class WebServiceUtils {\r
- private final static Log log = LogFactory.getLog(WebServiceUtils.class);\r
-\r
- public static Object marshalSendAndReceiveSafe(WebServiceTemplate template,\r
- Object req) {\r
- try {\r
- Object resp = marshalSendAndReceive(template, req);\r
- return resp;\r
- } catch (Exception e) {\r
- log.error("Cannot send web servicerequest: "+e.getMessage());\r
- if(log.isDebugEnabled()){\r
- log.debug("Webservice exception details: ",e);\r
- }\r
- return null;\r
- }\r
- }\r
-\r
- public static Object marshalSendAndReceive(\r
- WebServiceTemplate template, Object req) {\r
- if (log.isTraceEnabled()) {\r
- try {\r
- StringResult result = new StringResult();\r
- template.getMarshaller().marshal(req, result);\r
- log.trace("About to send " + result);\r
- } catch (Exception e) {\r
- log.error("Cannot marshall " + req + " for logging", e);\r
- }\r
- }\r
- Object resp = template.marshalSendAndReceive(req);\r
- return resp;\r
- }\r
-\r
- public static void manageSoapException(SoapFaultClientException e) {\r
- log\r
- .error("WS root cause: "\r
- + e.getSoapFault().getFaultStringOrReason());\r
- StringBuffer stack = new StringBuffer("");\r
- SoapFaultDetail detail = e.getSoapFault().getFaultDetail();\r
- if (detail != null) {\r
- Iterator<SoapFaultDetailElement> it = (Iterator<SoapFaultDetailElement>) detail\r
- .getDetailEntries();\r
- while (it.hasNext()) {\r
- SoapFaultDetailElement elem = it.next();\r
- if (elem.getName().getLocalPart().equals("StackElement")) {\r
- Source source = elem.getSource();\r
- if (source instanceof DOMSource) {\r
- Node node = ((DOMSource) source).getNode();\r
- stack.append(node.getTextContent()).append('\n');\r
- }\r
- }\r
- }\r
-\r
- if (stack.length() > 0 && log.isTraceEnabled())\r
- log.error("WS root cause stack: " + stack);\r
- }\r
- }\r
-\r
- private WebServiceUtils() {\r
-\r
- }\r
-}\r
+++ /dev/null
-# Tasks\r
-slc.test=org.argeo.slc.ant.test.SlcTestTask\r
-slc.deploy=org.argeo.slc.ant.deploy.SlcDeployTask\r
-slc.closeResult=org.argeo.slc.ant.test.SlcCloseTestResultTask\r
-slc.report=org.argeo.slc.ant.test.SlcReportTask\r
+++ /dev/null
-# Types\r
-slc.context=org.argeo.slc.ant.test.ParentContextType\r
+++ /dev/null
-<?xml version="1.0"?>\r
-\r
-<mapping>\r
- <description>Mapping of generic types</description>\r
-\r
- <class name="java.lang.Exception" auto-complete="false">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="message" type="string" set-method="%1"\r
- get-method="getMessage">\r
- <bind-xml node="attribute" />\r
- </field>\r
- <field name="stackTrace" collection="array"\r
- type="java.lang.StackTraceElement">\r
- <bind-xml auto-naming="deriveByClass"\r
- location="stack-trace" />\r
- </field>\r
- </class>\r
-\r
- <class name="java.lang.StackTraceElement" auto-complete="false"\r
- verify-constructable="false">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="declaringClass" type="string" set-method="%1"\r
- get-method="getClassName">\r
- <bind-xml node="attribute" />\r
- </field>\r
- <field name="methodName" type="string" set-method="%2"\r
- get-method="getMethodName">\r
- <bind-xml node="attribute" />\r
- </field>\r
- <field name="fileName" type="string" set-method="%3"\r
- get-method="getFileName">\r
- <bind-xml node="attribute" />\r
- </field>\r
- <field name="lineNumber" type="integer" set-method="%4"\r
- get-method="getLineNumber">\r
- <bind-xml node="attribute" />\r
- </field>\r
- </class>\r
-</mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-\r
-<mapping>\r
- <description>Message objects XML mapping</description>\r
-\r
- <!-- TESTS -->\r
- <class\r
- name="org.argeo.slc.msg.test.tree.CreateTreeTestResultRequest">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="treeTestResult"\r
- type="org.argeo.slc.core.test.tree.TreeTestResult" />\r
- </class>\r
-\r
- <class\r
- name="org.argeo.slc.msg.test.tree.CloseTreeTestResultRequest">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="resultUuid" />\r
- <field name="closeDate" />\r
- </class>\r
-\r
- <class name="org.argeo.slc.msg.test.tree.ResultPartRequest">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="resultUuid" />\r
- <field name="resultPart"\r
- type="org.argeo.slc.core.test.SimpleResultPart">\r
- <bind-xml auto-naming="deriveByClass" />\r
- </field>\r
-\r
- <field name="relatedElements" collection="map">\r
- <bind-xml name="element" location="related-elements">\r
- <class name="org.exolab.castor.mapping.MapItem">\r
- <map-to\r
- ns-uri="http://argeo.org/projects/slc/schemas" ns-prefix="slc" />\r
- <field name="key"\r
- type="org.argeo.slc.core.structure.tree.TreeSPath"\r
- handler="org.argeo.slc.castor.structure.tree.TreeSPathFieldHandler">\r
- <bind-xml name="path" node="attribute" />\r
- </field>\r
- <field name="value"\r
- type="org.argeo.slc.core.structure.SimpleSElement">\r
- <bind-xml auto-naming="deriveByClass" />\r
- </field>\r
- </class>\r
- </bind-xml>\r
- </field>\r
- <field name="path">\r
- <bind-xml auto-naming="deriveByClass" />\r
- </field>\r
- <field name="testRunDescriptor" />\r
- </class>\r
-\r
-\r
- <!-- PROCESS -->\r
- <class name="org.argeo.slc.msg.process.SlcExecutionStepsRequest">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="slcExecutionUuid" />\r
- <field name="steps" collection="vector"\r
- type="org.argeo.slc.core.process.SlcExecutionStep">\r
- <bind-xml auto-naming="deriveByClass" location="steps" />\r
- </field>\r
- </class>\r
-\r
- <class name="org.argeo.slc.msg.process.SlcExecutionStatusRequest">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="slcExecutionUuid" />\r
- <field name="newStatus"/>\r
- </class>\r
-\r
- <class name="org.argeo.slc.msg.process.SlcExecutionRequest">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="slcExecution"\r
- type="org.argeo.slc.core.process.SlcExecution" />\r
- </class>\r
-\r
-\r
-</mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-\r
-<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.org/mapping.dtd">\r
-\r
-<mapping>\r
- <description>Process objects XML mapping</description>\r
-\r
- <class name="org.argeo.slc.core.process.SlcExecution">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="uuid" identity="true">\r
- <bind-xml node="attribute" />\r
- </field>\r
- <field name="status" />\r
- <field name="type" />\r
- <field name="host" />\r
- <field name="user" />\r
- <field name="steps" collection="vector"\r
- type="org.argeo.slc.core.process.SlcExecutionStep">\r
- <bind-xml auto-naming="deriveByClass" location="steps" />\r
- </field>\r
- <field name="attributes" collection="map">\r
- <bind-xml name="attribute" location="attributes">\r
- <class name="org.exolab.castor.mapping.MapItem">\r
- <map-to\r
- ns-uri="http://argeo.org/projects/slc/schemas" ns-prefix="slc" />\r
- <field name="key" type="string">\r
- <bind-xml name="name" node="attribute" />\r
- </field>\r
- <field name="value" type="string">\r
- <bind-xml node="text" />\r
- </field>\r
- </class>\r
- </bind-xml>\r
- </field>\r
- </class>\r
-\r
- <class name="org.argeo.slc.core.process.SlcExecutionStep">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="uuid" identity="true">\r
- <bind-xml node="attribute" />\r
- </field>\r
- <field name="type" />\r
- <field name="begin" />\r
- <field name="logLines" collection="vector" type="string">\r
- <bind-xml name="log-line" location="log-lines" />\r
- </field>\r
- </class>\r
- \r
-</mapping>
\ No newline at end of file
+++ /dev/null
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
- default-lazy-init="true">\r
-\r
- <bean id="slcDefault.castor.marshaller"\r
- class="org.springframework.oxm.castor.CastorMarshaller">\r
- <property name="mappingLocations">\r
- <list>\r
- <value>\r
- classpath:org/argeo/slc/castor/msg/mapping.xml\r
- </value>\r
- <value>\r
- classpath:org/argeo/slc/castor/process/mapping.xml\r
- </value>\r
- <value>\r
- classpath:org/argeo/slc/castor/structure/mapping.xml\r
- </value>\r
- <value>\r
- classpath:org/argeo/slc/castor/test/mapping.xml\r
- </value>\r
- </list>\r
- </property>\r
- <property name="whitespacePreserve" value="true" />\r
- </bean>\r
-\r
- <bean id="slcDefault.castor.xsltReportGenerator"\r
- class="org.argeo.slc.core.test.tree.XsltReportGenerator"\r
- init-method="init">\r
- <property name="xsltStyleSheet"\r
- value="classpath:/org/argeo/slc/core/test/tree/basicReport.xslt" />\r
- <property name="marshaller" ref="slcDefault.castor.marshaller" />\r
- <property name="logXml" value="false" />\r
- <!-- \r
- <property name="outputDir" value="D:\dev\test\SLC\SlcReports" />\r
- -->\r
- </bean>\r
-\r
-\r
-</beans>\r
+++ /dev/null
-<?xml version="1.0"?>\r
-\r
-<mapping>\r
- <description>Structure related objects XML mapping</description>\r
-\r
- <class name="org.argeo.slc.core.structure.tree.TreeSPath"\r
- auto-complete="false">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="asUniqueString" type="string">\r
- <bind-xml node="attribute" />\r
- </field>\r
- </class>\r
-\r
- <class name="org.argeo.slc.core.structure.SimpleSElement"\r
- auto-complete="false">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="label" type="string" />\r
- <field name="tags" collection="map">\r
- <bind-xml name="tag" location="tags">\r
- <class name="org.exolab.castor.mapping.MapItem">\r
- <map-to\r
- ns-uri="http://argeo.org/projects/slc/schemas" ns-prefix="slc" />\r
- <field name="key" type="string">\r
- <bind-xml name="name" node="attribute" />\r
- </field>\r
- <field name="value" type="string">\r
- <bind-xml name="tag-value" />\r
- </field>\r
- </class>\r
- </bind-xml>\r
- </field>\r
- </class>\r
-</mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-\r
-<mapping>\r
- <description>Test objects XML mapping</description>\r
-\r
- <class name="org.argeo.slc.core.test.TestRunDescriptor"\r
- auto-complete="false">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="testRunUuid" />\r
- <field name="slcExecutionUuid" />\r
- <field name="slcExecutionStepUuid" />\r
- <field name="testResultUuid" />\r
- <field name="deployedSytemId" />\r
- </class>\r
-\r
- <class name="org.argeo.slc.core.test.tree.TreeTestResult"\r
- auto-complete="false">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="uuid" type="string">\r
- <bind-xml name="uuid" node="attribute" />\r
- </field>\r
- <field name="closeDate" />\r
- <field name="resultParts" collection="map">\r
- <bind-xml name="result-part" location="result-parts">\r
- <class name="org.exolab.castor.mapping.MapItem">\r
- <map-to\r
- ns-uri="http://argeo.org/projects/slc/schemas" ns-prefix="slc" />\r
- <field name="key"\r
- type="org.argeo.slc.core.structure.tree.TreeSPath"\r
- handler="org.argeo.slc.castor.structure.tree.TreeSPathFieldHandler">\r
- <bind-xml name="path" node="attribute" />\r
- </field>\r
- <field name="value"\r
- type="org.argeo.slc.core.test.tree.PartSubList">\r
- <bind-xml name="part-sub-list" />\r
- </field>\r
- </class>\r
- </bind-xml>\r
- </field>\r
- <field name="elements" collection="map">\r
- <bind-xml name="element" location="elements">\r
- <class name="org.exolab.castor.mapping.MapItem">\r
- <map-to\r
- ns-uri="http://argeo.org/projects/slc/schemas" ns-prefix="slc" />\r
- <field name="key"\r
- type="org.argeo.slc.core.structure.tree.TreeSPath"\r
- handler="org.argeo.slc.castor.structure.tree.TreeSPathFieldHandler">\r
- <bind-xml name="path" node="attribute" />\r
- </field>\r
- <field name="value"\r
- type="org.argeo.slc.core.structure.SimpleSElement">\r
- <bind-xml auto-naming="deriveByClass" />\r
- </field>\r
- </class>\r
- </bind-xml>\r
- </field>\r
- </class>\r
-\r
- <class name="org.argeo.slc.core.test.tree.PartSubList"\r
- auto-complete="false">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="parts" collection="arraylist"\r
- type="org.argeo.slc.core.test.SimpleResultPart">\r
- <bind-xml auto-naming="deriveByClass" location="parts" />\r
- </field>\r
- </class>\r
-\r
- <class name="org.argeo.slc.core.test.SimpleResultPart"\r
- auto-complete="false">\r
- <map-to ns-uri="http://argeo.org/projects/slc/schemas"\r
- ns-prefix="slc" />\r
- <field name="testRunUuid" type="string" />\r
- <field name="message" type="string"/>\r
- <field name="status" type="string"\r
- handler="org.argeo.slc.castor.test.tree.StatusFieldHandler" />\r
- <field name="exceptionMessage" type="string"/>\r
- </class>\r
-\r
-</mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
- default-lazy-init="true">\r
-\r
- <bean id="slcDefault.test.resultLogger"\r
- class="org.argeo.slc.core.test.tree.TreeTestResultLogger">\r
- </bean>\r
-\r
- <bean name="slcDefault.test.testRun"\r
- class="org.argeo.slc.core.test.SimpleTestRun">\r
- </bean>\r
-\r
- <bean name="slcDefault.test.uuid" class="java.util.UUID"\r
- factory-method="randomUUID" scope="prototype">\r
- </bean>\r
-\r
- <bean id="slcDefault.test.basicTreeTestResult"\r
- class="org.argeo.slc.core.test.tree.TreeTestResult" abstract="true">\r
- <property name="uuid">\r
- <bean factory-bean="slcDefault.test.uuid" factory-method="toString"></bean>\r
- </property>\r
- <property name="listeners">\r
- <list>\r
- <ref bean="slcDefault.test.resultLogger" />\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="slcDefault.test.basicSimpleTestResult"\r
- class="org.argeo.slc.core.test.SimpleTestResult" abstract="true">\r
- <property name="uuid">\r
- <bean factory-bean="slcDefault.test.uuid" factory-method="toString"></bean>\r
- </property>\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<xsl:stylesheet version="1.0"\r
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
- xmlns:slc="http://argeo.org/projects/slc/schemas"\r
- exclude-result-prefixes="slc">\r
-\r
- <xsl:output method="html" omit-xml-declaration="yes" />\r
-\r
- <xsl:template match="/">\r
- <html>\r
- <head>\r
- <title>Result</title>\r
- </head>\r
- <body style="font-family: sans-serif">\r
- <h1>\r
- Result\r
- <xsl:value-of select="slc:tree-test-result/@uuid" />\r
- </h1>\r
- <xsl:for-each\r
- select="slc:tree-test-result/slc:result-parts/slc:result-part">\r
- <h2>\r
- <xsl:value-of select="@path" />\r
- </h2>\r
- <table>\r
- <xsl:for-each\r
- select="slc:part-sub-list/slc:parts/slc:simple-result-part">\r
- <tr>\r
- <xsl:choose>\r
- <xsl:when\r
- test="slc:status = 'PASSED' ">\r
- <td style="color:green">\r
- <xsl:value-of\r
- select="slc:message" />\r
- </td>\r
- </xsl:when>\r
- <xsl:otherwise>\r
- <td style="color:red">\r
- <xsl:value-of\r
- select="slc:message" />\r
- </td>\r
- </xsl:otherwise>\r
- </xsl:choose>\r
- </tr>\r
- </xsl:for-each>\r
- </table>\r
- </xsl:for-each>\r
- </body>\r
- </html>\r
- </xsl:template>\r
-</xsl:stylesheet>
\ No newline at end of file
+++ /dev/null
-<html>\r
-<head>\r
-<META http-equiv="Content-Type" content="text/html; charset=US-ASCII">\r
-<title>SLC test results</title>\r
-</head>\r
-<frameset cols="30%,70%">\r
- <frame src="slc-resultsList.html" name="navigation">\r
- <frame src="about:blank" name="main">\r
- <noframes>\r
- <h2>Frame Alert</h2>\r
- <p>This document is designed to be viewed using the frames feature.\r
- If you see this message, you are using a non-frame-capable web client.\r
- </p>\r
- </noframes>\r
-</frameset>\r
-</html>\r
+++ /dev/null
-body {\r
- font-family: sans-serif;\r
- font-size: 12px;\r
- color: black;\r
- background-color: white;\r
-}\r
-\r
-h1 {\r
- font-family: sans-serif;\r
- font-size: 16px;\r
- font-weight: bold;\r
- color: #000000;\r
- padding: 0px 0px 5px 0px;\r
- margin: 0px;\r
-}\r
-\r
-h2 {\r
- font-family: sans-serif;\r
- font-size: 14px;\r
- font-weight: bold;\r
- color: #000000;\r
- padding: 5px 0px 5px 0px;\r
- margin: 0px;\r
- margin-top: 5px;\r
-}\r
-\r
-table,form {\r
- margin: 0px;\r
-}\r
-\r
-th {\r
- font-size: 12px;\r
- padding: 2px 20px 2px 2px;\r
- vertical-align: top;\r
- text-align: left;\r
-}\r
-\r
-td {\r
- font-size: 12px;\r
- padding: 1px;\r
- vertical-align: top;\r
- text-align: left;\r
-}\r
-\r
-.passed {\r
- color: green;\r
-}\r
-\r
-.failed {\r
- color: red;\r
-}\r
-\r
-a {\r
- text-decoration: none;\r
-}\r
-\r
-a.nav {\r
- color: #0066CC;\r
- text-decoration: none;\r
-}\r
-\r
-a:hover {\r
- text-decoration: underline;\r
-}
\ No newline at end of file
+++ /dev/null
-<project>\r
-\r
- <target name="deployZip">
- <unzip src="${src}" dest="${tempDir}" />
- <copyFromTemp />
- </target>
-
- <target name="deployTarGz">
- <untar src="${src}" dest="${tempDir}" compression="gzip" />
- <copyFromTemp />
- </target>
-
- <macrodef name="copyFromTemp">
- <sequential>
- <copy todir="${dest}" includeemptydirs="true">
- <fileset dir="${tempDir}">
- <include name="**/*" />
- </fileset>
- <mapper classname="org.argeo.slc.ant.RemoveRootDirMapper" to="${removeRootDir}" />
- </copy>
- </sequential>
- </macrodef>
-</project>
\ No newline at end of file
+++ /dev/null
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
- default-lazy-init="true">\r
-\r
- <import\r
- resource="classpath:/org/argeo/slc/castor/spring/applicationContext.xml" />\r
- <import\r
- resource="classpath:/org/argeo/slc/xml/spring/applicationContext.xml" />\r
-\r
- <bean id="slcDefault.ws.client.webServiceTemplate"\r
- class="org.springframework.ws.client.core.WebServiceTemplate">\r
- <constructor-arg ref="slcDefault.ws.client.messageFactory" />\r
- <property name="marshaller" ref="slcDefault.castor.marshaller" />\r
- <property name="unmarshaller"\r
- ref="slcDefault.castor.marshaller" />\r
- <property name="defaultUri"\r
- value="http://localhost:8080/org.argeo.slc.webapp/slcService/" />\r
- <property name="interceptors">\r
- <list>\r
- <bean\r
- class="org.argeo.slc.ws.client.ValidatingClientInterceptor">\r
- <property name="validator"\r
- ref="slcDefault.xml.xsdValidator" />\r
- </bean>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="slcDefault.ws.client.messageFactory"\r
- class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" />\r
-\r
- <bean name="slcDefault.ws.client.treeTestResultWsNotfier"\r
- class="org.argeo.slc.core.test.tree.WebServiceTreeTestResultNotifier">\r
- <property name="template"\r
- ref="slcDefault.ws.client.webServiceTemplate" />\r
- <property name="onlyOnClose" value="false" />\r
- </bean>\r
-\r
-</beans>\r
+++ /dev/null
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"\r
- xmlns:slc="http://argeo.org/projects/slc/schemas"\r
- elementFormDefault="qualified"\r
- targetNamespace="http://argeo.org/projects/slc/schemas">\r
- <!-- TREE TEST RESULT -->\r
- <xs:element name="tree-test-result" type="slc:TreeTestResultType" />\r
- <xs:complexType name="TreeTestResultType">\r
- <xs:all>\r
- <xs:element name="close-date" type="xs:dateTime"\r
- minOccurs="0" />\r
- <xs:element name="result-parts" minOccurs="0"\r
- type="slc:ResultPartsType" />\r
- <xs:element name="elements" minOccurs="0"\r
- type="slc:ElementsType" />\r
- </xs:all>\r
- <xs:attribute name="uuid" use="required" />\r
- </xs:complexType>\r
- <xs:complexType name="ResultPartsType">\r
- <xs:sequence>\r
- <xs:element name="result-part" type="slc:ResultPartType"\r
- minOccurs="0" maxOccurs="unbounded">\r
- </xs:element>\r
- </xs:sequence>\r
- </xs:complexType>\r
- <xs:complexType name="ResultPartType">\r
- <xs:all>\r
- <xs:element name="part-sub-list" type="slc:PartSubListType" />\r
- </xs:all>\r
- <xs:attribute name="path" type="xs:string" use="required" />\r
- </xs:complexType>\r
- <xs:complexType name="PartSubListType">\r
- <xs:all>\r
- <xs:element name="parts" minOccurs="0" type="slc:PartsType" />\r
- </xs:all>\r
- </xs:complexType>\r
- <xs:complexType name="PartsType">\r
- <xs:sequence>\r
- <xs:element name="simple-result-part"\r
- type="slc:SimpleResultPartType" maxOccurs="unbounded">\r
- </xs:element>\r
- </xs:sequence>\r
- </xs:complexType>\r
- <xs:complexType name="SimpleResultPartType">\r
- <xs:all>\r
- <xs:element name="status">\r
- <xs:simpleType>\r
- <xs:restriction base="xs:string">\r
- <xs:enumeration value="PASSED" />\r
- <xs:enumeration value="FAILED" />\r
- <xs:enumeration value="ERROR" />\r
- </xs:restriction>\r
- </xs:simpleType>\r
- </xs:element>\r
- <xs:element name="message" type="xs:string" />\r
- <xs:element name="exception-message" minOccurs="0"\r
- type="xs:string" />\r
- <xs:element name="stack-lines" minOccurs="0"\r
- type="slc:StackLinesType" />\r
- <xs:element name="test-run-uuid" type="xs:string"\r
- minOccurs="0" />\r
- </xs:all>\r
- </xs:complexType>\r
- <xs:complexType name="StackLinesType">\r
- <xs:sequence>\r
- <xs:element name="stack-line" maxOccurs="unbounded"\r
- type="xs:string" />\r
- </xs:sequence>\r
- <xs:attribute name="message" type="xs:string" />\r
- </xs:complexType>\r
- <xs:complexType name="ElementsType">\r
- <xs:sequence>\r
- <xs:element name="element" type="slc:ElementType"\r
- minOccurs="0" maxOccurs="unbounded">\r
- </xs:element>\r
- </xs:sequence>\r
- </xs:complexType>\r
- <xs:complexType name="ElementType">\r
- <xs:all>\r
- <xs:element name="simple-sElement"\r
- type="slc:SimpleSElementType" />\r
- </xs:all>\r
- <xs:attribute name="path" type="xs:string" use="required" />\r
- </xs:complexType>\r
- <xs:complexType name="SimpleSElementType">\r
- <xs:all>\r
- <xs:element name="label" type="xs:string" />\r
- <xs:element name="tags" type="slc:TagsType" minOccurs="0" />\r
- </xs:all>\r
- </xs:complexType>\r
- <xs:complexType name="TagsType">\r
- <xs:sequence>\r
- <xs:element name="tag" type="slc:TagType" minOccurs="0"\r
- maxOccurs="unbounded">\r
- </xs:element>\r
- </xs:sequence>\r
- </xs:complexType>\r
- <xs:complexType name="TagType">\r
- <xs:all>\r
- <xs:element name="tag-value" type="xs:string" />\r
- </xs:all>\r
- <xs:attribute name="name" type="xs:string" use="required" />\r
- </xs:complexType>\r
- <xs:complexType name="TreeSPathType">\r
- <xs:attribute name="as-unique-string" type="xs:string"\r
- use="required" />\r
- </xs:complexType>\r
- <xs:complexType name="TestRunDescriptorType">\r
- <xs:all>\r
- <xs:element name="test-run-uuid" type="xs:string" />\r
- <xs:element name="slc-execution-uuid" type="xs:string"\r
- minOccurs="0" />\r
- <xs:element name="slc-execution-step-uuid" type="xs:string"\r
- minOccurs="0" />\r
- <xs:element name="deployed-sytem-id" type="xs:string"\r
- minOccurs="0" />\r
- <xs:element name="test-result-uuid" type="xs:string"\r
- minOccurs="0" />\r
- </xs:all>\r
- </xs:complexType>\r
-\r
- <!-- TREE TEST RESULT REQUESTS -->\r
- <xs:element name="create-tree-test-result-request">\r
- <xs:complexType>\r
- <xs:all>\r
- <xs:element name="tree-test-result"\r
- type="slc:TreeTestResultType" />\r
- </xs:all>\r
- </xs:complexType>\r
- </xs:element>\r
-\r
- <xs:element name="close-tree-test-result-request">\r
- <xs:complexType>\r
- <xs:all>\r
- <xs:element name="result-uuid" type="xs:string" />\r
- <xs:element name="close-date" type="xs:dateTime" />\r
- </xs:all>\r
- </xs:complexType>\r
- </xs:element>\r
-\r
- <xs:element name="result-part-request">\r
- <xs:complexType>\r
- <xs:all>\r
- <xs:element name="result-uuid" type="xs:string" />\r
- <xs:element name="simple-result-part"\r
- type="slc:SimpleResultPartType" />\r
- <xs:element name="related-elements"\r
- type="slc:ElementsType" />\r
- <xs:element name="tree-sPath" type="slc:TreeSPathType" />\r
- <xs:element name="test-run-descriptor"\r
- type="slc:TestRunDescriptorType" />\r
- </xs:all>\r
- </xs:complexType>\r
- </xs:element>\r
-\r
- <!-- SLC EXECUTION -->\r
- <xs:element name="slc-execution" type="slc:SlcExecutionType" />\r
- <xs:complexType name="SlcExecutionType">\r
- <xs:all>\r
- <xs:element name="status" type="xs:string" />\r
- <xs:element name="type" type="xs:string" />\r
- <xs:element name="host" type="xs:string" />\r
- <xs:element name="user" type="xs:string" />\r
- <xs:element name="steps" minOccurs="0"\r
- type="slc:SlcExecutionStepsType" />\r
- <xs:element name="attributes" minOccurs="0"\r
- type="slc:AttributesType" />\r
- </xs:all>\r
- <xs:attribute name="uuid" type="xs:string" use="required" />\r
- </xs:complexType>\r
- <xs:complexType name="SlcExecutionStepsType">\r
- <xs:sequence>\r
- <xs:element name="slc-execution-step"\r
- type="slc:SlcExecutionStepType" maxOccurs="unbounded">\r
- </xs:element>\r
- </xs:sequence>\r
- </xs:complexType>\r
- <xs:complexType name="SlcExecutionStepType">\r
- <xs:all>\r
- <xs:element name="type" type="xs:string" />\r
- <xs:element name="begin" type="xs:dateTime" />\r
- <xs:element name="log-lines" minOccurs="0">\r
- <xs:complexType>\r
- <xs:sequence>\r
- <xs:element name="log-line" type="xs:string"\r
- maxOccurs="unbounded" />\r
- </xs:sequence>\r
- </xs:complexType>\r
- </xs:element>\r
- </xs:all>\r
- <xs:attribute name="uuid" type="xs:string" use="required" />\r
- </xs:complexType>\r
- <xs:complexType name="AttributesType">\r
- <xs:sequence>\r
- <xs:element name="attribute" type="slc:AttributeType"\r
- maxOccurs="unbounded">\r
- </xs:element>\r
- </xs:sequence>\r
- </xs:complexType>\r
- <xs:complexType name="AttributeType">\r
- <xs:simpleContent>\r
- <xs:extension base="xs:string">\r
- <xs:attribute name="name" type="xs:string"\r
- use="required" />\r
- </xs:extension>\r
- </xs:simpleContent>\r
- </xs:complexType>\r
-\r
- <!-- SLC EXECUTION REQUESTS-->\r
- <xs:element name="slc-execution-request">\r
- <xs:complexType>\r
- <xs:all>\r
- <xs:element name="slc-execution"\r
- type="slc:SlcExecutionType" />\r
- </xs:all>\r
- </xs:complexType>\r
- </xs:element>\r
- <xs:element name="slc-execution-steps-request">\r
- <xs:complexType>\r
- <xs:all>\r
- <xs:element name="slc-execution-uuid" type="xs:string" />\r
- <xs:element name="steps"\r
- type="slc:SlcExecutionStepsType" />\r
- </xs:all>\r
- </xs:complexType>\r
- </xs:element>\r
- <xs:element name="slc-execution-status-request">\r
- <xs:complexType>\r
- <xs:all>\r
- <xs:element name="slc-execution-uuid" type="xs:string" />\r
- <xs:element name="new-status" type="xs:string" />\r
- </xs:all>\r
- </xs:complexType>\r
- </xs:element>\r
-\r
-</xs:schema>
\ No newline at end of file
+++ /dev/null
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
- default-lazy-init="true">\r
-\r
- <bean id="slcDefault.xml.xsdValidator"\r
- factory-bean="slcDefault.xml.xsdSchema" factory-method="createValidator" />\r
-\r
- <bean id="slcDefault.xml.xsdSchema"\r
- class="org.springframework.xml.xsd.SimpleXsdSchema">\r
- <property name="xsd"\r
- value="classpath:/org/argeo/slc/xml/slc.xsd" />\r
- </bean>\r
-</beans>\r
+++ /dev/null
-package org.argeo.slc.ant;\r
-\r
-import java.net.URL;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.unit.AbstractSpringTestCase;\r
-\r
-public class SlcAntTest extends AbstractSpringTestCase {\r
- private Log log = LogFactory.getLog(getClass());\r
-\r
- public void testSimpleRun() {\r
- // AntRegistryUtil.runAll(getClass().getResource(\r
- // "/org/argeo/slc/ant/build.xml"), "test", null);\r
-\r
- URL url = getClass().getResource("/org/argeo/slc/ant/build.xml");\r
- log.info("Run Ant file from URL: " + url);\r
- AntRunner antRunner = new AntRunner(getContext(), url, "test");\r
-\r
- antRunner.run();\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.process;\r
-\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.io.StringReader;\r
-import java.io.StringWriter;\r
-import java.text.SimpleDateFormat;\r
-import java.util.UUID;\r
-\r
-import javax.xml.transform.stream.StreamResult;\r
-import javax.xml.transform.stream.StreamSource;\r
-\r
-import org.apache.commons.io.IOUtils;\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.argeo.slc.msg.process.SlcExecutionRequest;\r
-import org.argeo.slc.msg.process.SlcExecutionStepsRequest;\r
-import org.argeo.slc.unit.AbstractSpringTestCase;\r
-import org.argeo.slc.unit.UnitXmlUtils;\r
-\r
-import org.springframework.oxm.Marshaller;\r
-import org.springframework.oxm.Unmarshaller;\r
-import org.springframework.xml.transform.StringResult;\r
-import org.springframework.xml.transform.StringSource;\r
-import org.springframework.xml.validation.XmlValidator;\r
-import org.springframework.xml.xsd.XsdSchema;\r
-\r
-public class SlcExecutionCastorTest extends AbstractSpringTestCase {\r
- private Log log = LogFactory.getLog(getClass());\r
-\r
- private Marshaller marshaller;\r
- private Unmarshaller unmarshaller;\r
-\r
- @Override\r
- public void setUp() {\r
- marshaller = getBean(Marshaller.class);\r
- unmarshaller = getBean(Unmarshaller.class);\r
- }\r
-\r
- public void testMarshalling() throws Exception {\r
- SlcExecution slcExec = SlcExecutionTestUtils.createSimpleSlcExecution();\r
-\r
- SlcExecutionRequest msgSave = new SlcExecutionRequest();\r
- msgSave.setSlcExecution(slcExec);\r
-\r
- String msgSaveXml = marshallAndLog(marshaller, msgSave);\r
-\r
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");\r
- SlcExecutionStep step0 = new SlcExecutionStep();\r
- step0.setUuid(UUID.randomUUID().toString());\r
- step0.setBegin(sdf.parse("2008-04-17 18:21"));\r
- step0.setType("LOG");\r
- step0.addLog("A log message\nand another line");\r
-\r
- SlcExecutionStep step1 = new SlcExecutionStep();\r
- step1.setUuid(UUID.randomUUID().toString());\r
- step1.setBegin(sdf.parse("2008-04-17 18:25"));\r
- step1.setType("LOG");\r
- step1.addLog("A nother log message");\r
-\r
- SlcExecutionStepsRequest msgNotif = new SlcExecutionStepsRequest();\r
- msgNotif.addStep(step0);\r
- msgNotif.addStep(step1);\r
- msgNotif.setSlcExecutionUuid(slcExec.getUuid());\r
-\r
- String msgNotifXml = marshallAndLog(marshaller, msgNotif);\r
-\r
- SlcExecutionRequest msgSaveUnm = unmarshall(unmarshaller, msgSaveXml);\r
- assertNotNull(msgSaveUnm);\r
- SlcExecutionTestUtils.assertSlcExecution(slcExec, msgSaveUnm\r
- .getSlcExecution());\r
-\r
- SlcExecutionStepsRequest msgNotifUnm = unmarshall(unmarshaller,\r
- msgNotifXml);\r
- assertNotNull(msgNotifUnm);\r
- assertEquals(slcExec.getUuid(), msgNotifUnm.getSlcExecutionUuid());\r
- assertEquals(2, msgNotifUnm.getSteps().size());\r
- SlcExecutionTestUtils.assertSlcExecutionStep(step0, msgNotifUnm\r
- .getSteps().get(0));\r
- SlcExecutionTestUtils.assertSlcExecutionStep(step1, msgNotifUnm\r
- .getSteps().get(1));\r
-\r
- SlcExecution slcExecUnm = msgSaveUnm.getSlcExecution();\r
- slcExecUnm.getSteps().addAll(msgNotifUnm.getSteps());\r
-\r
- SlcExecutionRequest msgUpdate = new SlcExecutionRequest();\r
- msgUpdate.setSlcExecution(slcExecUnm);\r
- String msgUpdateXml = marshallAndLog(marshaller, msgUpdate);\r
-\r
- SlcExecutionRequest msgUpdateUnm = unmarshall(unmarshaller,\r
- msgUpdateXml);\r
- assertNotNull(msgUpdateUnm);\r
- }\r
-\r
- private String marshallAndLog(Marshaller marshaller, Object obj)\r
- throws IOException {\r
- StringResult xml = new StringResult();\r
- marshaller.marshal(obj, xml);\r
- log.info("Marshalled object: " + xml);\r
-\r
- UnitXmlUtils.assertXmlValidation(getBean(XmlValidator.class),\r
- new StringSource(xml.toString()));\r
-\r
- return xml.toString();\r
- }\r
-\r
- private <T> T unmarshall(Unmarshaller unmarshaller, String xml)\r
- throws IOException {\r
- StringReader reader = new StringReader(xml);\r
- Object obj = unmarshaller.unmarshal(new StreamSource(reader));\r
- IOUtils.closeQuietly(reader);\r
- return (T) obj;\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.process;\r
-\r
-import java.util.UUID;\r
-\r
-import static junit.framework.Assert.assertEquals;\r
-import static junit.framework.Assert.assertNotNull;\r
-import static org.argeo.slc.unit.UnitUtils.assertDateSec;\r
-\r
-public abstract class SlcExecutionTestUtils {\r
-\r
- public static SlcExecution createSimpleSlcExecution() {\r
- SlcExecution slcExec = new SlcExecution();\r
- slcExec.setUuid(UUID.randomUUID().toString());\r
- slcExec.setHost("localhost");\r
- slcExec.setUser("user");\r
- slcExec.setType("slcAnt");\r
- slcExec.setStatus("STARTED");\r
- slcExec.getAttributes().put("ant.file", "/test");\r
- return slcExec;\r
- }\r
-\r
- public static void assertSlcExecution(SlcExecution expected,\r
- SlcExecution reached) {\r
- assertNotNull(reached);\r
- assertEquals(expected.getHost(), reached.getHost());\r
- assertEquals(expected.getUser(), reached.getUser());\r
- assertEquals(expected.getType(), reached.getType());\r
- assertEquals(expected.getStatus(), reached.getStatus());\r
- assertEquals(expected.getAttributes().size(), reached.getAttributes()\r
- .size());\r
- for (String key : expected.getAttributes().keySet()) {\r
- String expectedValue = expected.getAttributes().get(key);\r
- String reachedValue = reached.getAttributes().get(key);\r
- assertNotNull(reachedValue);\r
- assertEquals(expectedValue, reachedValue);\r
- }\r
- }\r
-\r
- public static void assertSlcExecutionStep(SlcExecutionStep expected,\r
- SlcExecutionStep reached) {\r
- assertNotNull(reached);\r
- assertEquals(expected.getUuid(), reached.getUuid());\r
- assertEquals(expected.getType(), reached.getType());\r
- assertEquals(expected.logAsString(), reached.logAsString());\r
- assertDateSec(expected.getBegin(), reached.getBegin());\r
- }\r
-\r
- private SlcExecutionTestUtils() {\r
-\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.structure.tree;\r
-\r
-import junit.framework.TestCase;\r
-\r
-public class TreeSPathTest extends TestCase {\r
-\r
- public void testNew() {\r
- TreeSPath path = new TreeSPath("/test");\r
- assertEquals("test", path.getName());\r
- assertNull(path.getParent());\r
-\r
- path = new TreeSPath("/root/subdir");\r
- assertEquals("subdir", path.getName());\r
- assertEquals(new TreeSPath("/root"), path.getParent());\r
- }\r
-\r
- public void testEquals() {\r
- TreeSPath path1 = new TreeSPath("/test");\r
- TreeSPath path2 = new TreeSPath("/test");\r
- assertEquals(path1, path2);\r
- \r
- path1 = new TreeSPath("/test/subdir/anotherdir");\r
- path2 = new TreeSPath("/test/subdir/anotherdir");\r
- assertEquals(path1, path2);\r
- \r
- path1 = new TreeSPath("/test/subdir/anotherd");\r
- path2 = new TreeSPath("/test/subdir/anotherdir");\r
- assertNotSame(path1, path2);\r
- \r
- path1 = new TreeSPath("/test/subdir");\r
- path2 = new TreeSPath("/test/subdir/anotherdir");\r
- assertNotSame(path1, path2);\r
- \r
- path1 = new TreeSPath("/test/subd/anotherdir");\r
- path2 = new TreeSPath("/test/subdir/anotherdir");\r
- assertNotSame(path1, path2);\r
- }\r
- \r
- public void testCheckFormat(){\r
- try{\r
- new TreeSPath("hello");\r
- fail("Bad format should be rejected");\r
- }catch(Exception e){\r
- // exception expected\r
- }\r
- \r
- try{\r
- new TreeSPath("/");\r
- fail("Bad format should be rejected");\r
- }catch(Exception e){\r
- // exception expected\r
- }\r
- \r
- assertEquals(new TreeSPath("/test"), new TreeSPath("/test/"));\r
- assertEquals(new TreeSPath("/test/dir"), new TreeSPath("//test///dir////"));\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.context;\r
-\r
-import java.util.List;\r
-\r
-import org.argeo.slc.core.test.SimpleTestResult;\r
-import org.argeo.slc.core.test.TestResultPart;\r
-import org.argeo.slc.core.test.TestStatus;\r
-import org.argeo.slc.unit.AbstractSpringTestCase;\r
-\r
-public class ContextTest extends AbstractSpringTestCase {\r
-\r
- public void testComplexContext() {\r
- SimpleTestResult testResult = new SimpleTestResult();\r
- ContextUtils.compareReachedExpected(\r
- (ContextAware) getBean("context.c1"), testResult, null);\r
- ContextUtils.compareReachedExpected(\r
- (ContextAware) getBean("context.c2"), testResult, null);\r
- ContextUtils.compareReachedExpected(\r
- (ContextAware) getBean("context.c3"), testResult, null);\r
-\r
- List<TestResultPart> parts = testResult.getParts();\r
- assertEquals(6, parts.size());\r
- assertEquals(TestStatus.PASSED, parts.get(0).getStatus());\r
- assertEquals(TestStatus.PASSED, parts.get(1).getStatus());\r
- assertEquals(TestStatus.PASSED, parts.get(2).getStatus());\r
- assertEquals(TestStatus.FAILED, parts.get(3).getStatus());\r
- assertEquals(TestStatus.PASSED, parts.get(4).getStatus());\r
- assertEquals(TestStatus.PASSED, parts.get(5).getStatus());\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.tree;\r
-\r
-import org.springframework.oxm.Marshaller;\r
-import org.springframework.oxm.Unmarshaller;\r
-import org.springframework.xml.transform.StringResult;\r
-import org.springframework.xml.transform.StringSource;\r
-import org.springframework.xml.validation.XmlValidator;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import static org.argeo.slc.core.test.tree.TreeTestResultTestUtils.createCompleteTreeTestResult;\r
-import static org.argeo.slc.core.test.tree.TreeTestResultTestUtils.createSimpleResultPartRequest;\r
-import static org.argeo.slc.unit.UnitUtils.assertDateSec;\r
-\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.test.SimpleResultPart;\r
-import org.argeo.slc.msg.test.tree.CloseTreeTestResultRequest;\r
-import org.argeo.slc.msg.test.tree.CreateTreeTestResultRequest;\r
-import org.argeo.slc.msg.test.tree.ResultPartRequest;\r
-import org.argeo.slc.unit.AbstractSpringTestCase;\r
-import org.argeo.slc.unit.UnitXmlUtils;\r
-import org.argeo.slc.unit.test.tree.UnitTestTreeUtil;\r
-\r
-public class TreeTestResultCastorTest extends AbstractSpringTestCase {\r
- private Log log = LogFactory.getLog(getClass());\r
-\r
- private Marshaller marshaller;\r
- private Unmarshaller unmarshaller;\r
-\r
- @Override\r
- public void setUp() {\r
- marshaller = getBean(Marshaller.class);\r
- unmarshaller = getBean(Unmarshaller.class);\r
- }\r
-\r
- public void testMarshUnmarsh() throws Exception {\r
- TreeTestResult ttr = createCompleteTreeTestResult();\r
-\r
- StringResult xml = marshallAndValidate(ttr);\r
-\r
- TreeTestResult ttrUnm = (TreeTestResult) unmarshaller\r
- .unmarshal(new StringSource(xml.toString()));\r
-\r
- UnitTestTreeUtil.assertTreeTestResult(ttr, ttrUnm);\r
- }\r
-\r
- public void testCreateTreeTestResultRequest() throws Exception {\r
- CreateTreeTestResultRequest req = new CreateTreeTestResultRequest();\r
- req.setTreeTestResult(createCompleteTreeTestResult());\r
-\r
- StringResult xml = marshallAndValidate(req);\r
-\r
- CreateTreeTestResultRequest reqUnm = (CreateTreeTestResultRequest) unmarshaller\r
- .unmarshal(new StringSource(xml.toString()));\r
-\r
- UnitTestTreeUtil.assertTreeTestResult(req.getTreeTestResult(), reqUnm\r
- .getTreeTestResult());\r
- }\r
-\r
- public void testResultPartRequest() throws Exception {\r
- TreeTestResult ttr = createCompleteTreeTestResult();\r
- ResultPartRequest req = createSimpleResultPartRequest(ttr);\r
-\r
- StringResult xml = marshallAndValidate(req);\r
-\r
- ResultPartRequest reqUnm = (ResultPartRequest) unmarshaller\r
- .unmarshal(new StringSource(xml.toString()));\r
-\r
- UnitTestTreeUtil\r
- .assertPart(req.getResultPart(), reqUnm.getResultPart());\r
- }\r
-\r
- public void testCloseTreeTestResultRequest() throws Exception {\r
- TreeTestResult ttr = createCompleteTreeTestResult();\r
- ttr.close();\r
-\r
- CloseTreeTestResultRequest req = new CloseTreeTestResultRequest(ttr\r
- .getUuid(), ttr.getCloseDate());\r
-\r
- StringResult xml = marshallAndValidate(req);\r
-\r
- CloseTreeTestResultRequest reqUnm = (CloseTreeTestResultRequest) unmarshaller\r
- .unmarshal(new StringSource(xml.toString()));\r
-\r
- assertEquals(ttr.getUuid(), reqUnm.getResultUuid());\r
- assertDateSec(ttr.getCloseDate(), ttr.getCloseDate());\r
- }\r
-\r
- private StringResult marshallAndValidate(Object obj) throws Exception {\r
- StringResult xml = new StringResult();\r
- marshaller.marshal(obj, xml);\r
-\r
- log.info("Marshalled ResultPart Request: " + xml);\r
-\r
- UnitXmlUtils.assertXmlValidation(getBean(XmlValidator.class),\r
- new StringSource(xml.toString()));\r
- return xml;\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.core.test.tree;\r
-\r
-import java.util.Date;\r
-import java.util.UUID;\r
-\r
-import org.argeo.slc.core.build.Distribution;\r
-import org.argeo.slc.core.deploy.DeployedSystem;\r
-import org.argeo.slc.core.process.SlcExecution;\r
-import org.argeo.slc.core.process.SlcExecutionStep;\r
-import org.argeo.slc.core.process.SlcExecutionTestUtils;\r
-import org.argeo.slc.core.structure.SimpleSElement;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.structure.tree.TreeSRegistry;\r
-import org.argeo.slc.core.test.SimpleResultPart;\r
-import org.argeo.slc.core.test.SimpleTestRun;\r
-import org.argeo.slc.core.test.TestStatus;\r
-import org.argeo.slc.msg.test.tree.ResultPartRequest;\r
-\r
-public abstract class TreeTestResultTestUtils {\r
-\r
- public static TreeTestResult createSimpleTreeTestResult() {\r
- TreeTestResult treeTestResult = new TreeTestResult();\r
- treeTestResult.setUuid(UUID.randomUUID().toString());\r
- return treeTestResult;\r
- }\r
-\r
- public static TreeTestResult createCompleteTreeTestResult() {\r
- SlcExecution slcExecution = SlcExecutionTestUtils\r
- .createSimpleSlcExecution();\r
- SlcExecutionStep step = new SlcExecutionStep("LOG", "JUnit step");\r
- slcExecution.getSteps().add(step);\r
-\r
- SimpleTestRun testRun = new SimpleTestRun();\r
- testRun.setUuid(UUID.randomUUID().toString());\r
-\r
- String pathStr = "/test";\r
- TreeSPath path = new TreeSPath(pathStr);\r
-\r
- TreeSRegistry registry = new TreeSRegistry();\r
- SimpleSElement elem = new SimpleSElement("Unit Test");\r
- elem.getTags().put("myTag", "myTagValue");\r
- registry.register(path, elem);\r
-\r
- TreeTestResult ttr = createSimpleTreeTestResult();\r
- ttr.notifyCurrentPath(registry, path);\r
- ttr.notifyTestRun(testRun);\r
- testRun.setTestResult(ttr);\r
- testRun.setDeployedSystem(new DeployedSystem() {\r
- private String uuid = UUID.randomUUID().toString();\r
-\r
- public String getDeployedSystemId() {\r
- return uuid;\r
- }\r
-\r
- public Distribution getDistribution() {\r
- return null;\r
- }\r
- });\r
- testRun.notifySlcExecution(slcExecution);\r
-\r
- ttr.addResultPart(createSimpleResultPartPassed());\r
- ttr.addResultPart(createSimpleResultPartFailed());\r
- ttr.addResultPart(createSimpleResultPartError());\r
- return ttr;\r
- }\r
-\r
- public static SimpleResultPart createSimpleResultPartPassed() {\r
- SimpleResultPart partPassed = new SimpleResultPart();\r
- String msgPassed = "message\nnew line";\r
- partPassed.setStatus(TestStatus.PASSED);\r
- partPassed.setMessage(msgPassed);\r
- return partPassed;\r
- }\r
-\r
- public static SimpleResultPart createSimpleResultPartFailed() {\r
- SimpleResultPart partFailed = new SimpleResultPart();\r
- String msgFailed = "too bad";\r
- partFailed.setStatus(TestStatus.FAILED);\r
- partFailed.setMessage(msgFailed);\r
- return partFailed;\r
- }\r
-\r
- public static SimpleResultPart createSimpleResultPartError() {\r
- SimpleResultPart partFailed = new SimpleResultPart();\r
- String msgFailed = "crashed\nanother line";\r
- partFailed.setStatus(TestStatus.ERROR);\r
- partFailed.setMessage(msgFailed);\r
- partFailed.setException(new Exception("Test Exception"));\r
- return partFailed;\r
- }\r
-\r
- public static ResultPartRequest createSimpleResultPartRequest(TreeTestResult ttr) {\r
- TreeSPath path = ttr.getCurrentPath();\r
- PartSubList lst = ttr.getResultParts().get(path);\r
- SimpleResultPart part = (SimpleResultPart) lst.getParts().get(2);\r
-\r
- ResultPartRequest req = new ResultPartRequest(ttr, path, part);\r
- req.setPath(ttr.getCurrentPath());\r
-\r
- return req;\r
- }\r
-\r
- private TreeTestResultTestUtils() {\r
-\r
- }\r
-}\r
+++ /dev/null
-package org.argeo.slc.diff;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-public class LineTokenizerTest extends TestCase {
- public void testSimple() throws Exception {
- testAndAssert("a,b,c", new String[] { "a", "b", "c" });
- testAndAssert("hello,bonjour,hallo,priviet", new String[] { "hello",
- "bonjour", "hallo", "priviet" });
- }
-
- public void testTricky() throws Exception {
- testAndAssert("alone", new String[] { "alone" });
- testAndAssert("", new String[] { "" });
-
- testAndAssert(",hello,bonjour,hallo,priviet", new String[] { "",
- "hello", "bonjour", "hallo", "priviet" });
- testAndAssert("hello,bonjour,,hallo,priviet", new String[] { "hello",
- "bonjour", "", "hallo", "priviet" });
- testAndAssert("hello,bonjour,hallo,priviet,", new String[] { "hello",
- "bonjour", "hallo", "priviet", "" });
- testAndAssert(",hello,,bonjour,hallo,,,,priviet,", new String[] { "",
- "hello", "", "bonjour", "hallo", "", "", "", "priviet", "" });
-
- testAndAssert(",,,", new String[] { "", "", "", "" });
- }
-
- public void testComplex() throws Exception {
- testAndAssert("a#b#c", '#', "", new String[] { "a", "b", "c" });
- testAndAssert("hello!bonjour!hallo!priviet", '!', "", new String[] {
- "hello", "bonjour", "hallo", "priviet" });
-
- testAndAssert("hello,,bonjour,,hallo,priviet", ',', "<EMPTY>",
- new String[] { "hello", "<EMPTY>", "bonjour", "<EMPTY>",
- "hallo", "priviet" });
- }
-
- private void testAndAssert(String str, String[] expected) {
- testAndAssert(str, ',', "", expected);
- }
-
- private void testAndAssert(String str, Character sep, String noValueStr,
- String[] expected) {
- List<String> res = LineTokenizer.tokenize(str, sep, noValueStr);
- assertEquals("Size", expected.length, res.size());
- for (int i = 0; i < res.size(); i++) {
- String token = res.get(i);
- assertEquals("Value@" + i, expected[i], token);
- }
- }
-}
\r
import org.argeo.slc.core.process.SlcExecution;\r
import org.argeo.slc.core.process.SlcExecutionStep;\r
-import org.argeo.slc.core.process.SlcExecutionTestUtils;\r
import org.argeo.slc.dao.process.SlcExecutionDao;\r
import org.argeo.slc.unit.AbstractSpringTestCase;\r
+import org.argeo.slc.unit.process.SlcExecutionTestUtils;\r
\r
public class SlcExecutionHibernateTest extends AbstractSpringTestCase {\r
\r
package org.argeo.slc.hibernate.test.tree;\r
\r
-import org.springframework.oxm.Marshaller;\r
-import org.springframework.oxm.Unmarshaller;\r
-import org.springframework.xml.transform.StringResult;\r
-import org.springframework.xml.transform.StringSource;\r
-\r
import org.argeo.slc.core.structure.tree.TreeSPath;\r
import org.argeo.slc.core.test.tree.TreeTestResult;\r
-import org.argeo.slc.core.test.tree.TreeTestResultTestUtils;\r
import org.argeo.slc.dao.test.tree.TreeTestResultDao;\r
import org.argeo.slc.unit.AbstractSpringTestCase;\r
+import org.argeo.slc.unit.test.tree.TreeTestResultTestUtils;\r
import org.argeo.slc.unit.test.tree.UnitTestTreeUtil;\r
+import org.springframework.oxm.Marshaller;\r
+import org.springframework.oxm.Unmarshaller;\r
+import org.springframework.xml.transform.StringResult;\r
+import org.springframework.xml.transform.StringSource;\r
\r
public class CastorTestResultDaoHibernateTest extends AbstractSpringTestCase {\r
\r
\r
import org.argeo.slc.core.test.tree.TreeTestResult;\r
import org.argeo.slc.core.test.tree.TreeTestResultCollection;\r
-import org.argeo.slc.core.test.tree.TreeTestResultTestUtils;\r
import org.argeo.slc.dao.test.tree.TreeTestResultCollectionDao;\r
import org.argeo.slc.dao.test.tree.TreeTestResultDao;\r
import org.argeo.slc.unit.AbstractSpringTestCase;\r
+import org.argeo.slc.unit.test.tree.TreeTestResultTestUtils;\r
import org.argeo.slc.unit.test.tree.UnitTestTreeUtil;\r
\r
public class TreeTestResultCollectionDaoHibernateTest extends\r
package org.argeo.slc.hibernate.test.tree;\r
\r
-import static org.argeo.slc.core.test.tree.TreeTestResultTestUtils.createCompleteTreeTestResult;\r
-import static org.argeo.slc.core.test.tree.TreeTestResultTestUtils.createSimpleTreeTestResult;\r
-\r
-import java.util.Date;\r
-\r
import org.argeo.slc.core.structure.SimpleSElement;\r
import org.argeo.slc.core.structure.tree.TreeSPath;\r
import org.argeo.slc.core.structure.tree.TreeSRegistry;\r
import org.argeo.slc.core.test.SimpleResultPart;\r
import org.argeo.slc.core.test.TestStatus;\r
import org.argeo.slc.core.test.tree.TreeTestResult;\r
-import org.argeo.slc.core.test.tree.TreeTestResultTestUtils;\r
import org.argeo.slc.dao.test.tree.TreeTestResultDao;\r
import org.argeo.slc.unit.AbstractSpringTestCase;\r
+import org.argeo.slc.unit.test.tree.TreeTestResultTestUtils;\r
import org.argeo.slc.unit.test.tree.UnitTestTreeUtil;\r
\r
public class TreeTestResultDaoHibernateTest extends AbstractSpringTestCase {\r
\r
public void testCreate() {\r
\r
- TreeTestResult ttr = createCompleteTreeTestResult();\r
+ TreeTestResult ttr = TreeTestResultTestUtils\r
+ .createCompleteTreeTestResult();\r
testResultDao.create(ttr);\r
\r
TreeTestResult ttrPersisted = (TreeTestResult) testResultDao\r
}\r
\r
public void testUpdate() {\r
- TreeTestResult ttr = createCompleteTreeTestResult();\r
+ TreeTestResult ttr = TreeTestResultTestUtils\r
+ .createCompleteTreeTestResult();\r
testResultDao.create(ttr);\r
\r
TreeTestResult ttrUpdated = (TreeTestResult) testResultDao\r
UnitTestTreeUtil.assertTreeTestResult(ttrRetrieved, ttrUpdated);\r
}\r
\r
- public void testMultipleUpdateScenario() throws Exception{\r
+ public void testMultipleUpdateScenario() throws Exception {\r
TreeSRegistry registry = new TreeSRegistry();\r
\r
TreeSPath path = new TreeSPath("/root/test");\r
SimpleSElement elem = new SimpleSElement("Unit Test");\r
elem.getTags().put("myTag", "myTagValue");\r
registry.register(path, elem);\r
- \r
- TreeTestResult ttr = createSimpleTreeTestResult();\r
+\r
+ TreeTestResult ttr = TreeTestResultTestUtils\r
+ .createSimpleTreeTestResult();\r
ttr.notifyCurrentPath(registry, path);\r
- ttr.addResultPart(new SimpleResultPart(TestStatus.PASSED,"First test"));\r
- \r
+ ttr\r
+ .addResultPart(new SimpleResultPart(TestStatus.PASSED,\r
+ "First test"));\r
+\r
testResultDao.create(ttr);\r
- \r
+\r
path = new TreeSPath("/root/test2/subtest");\r
elem = new SimpleSElement("Sub Test");\r
elem.getTags().put("myTag", "myTagValue");\r
registry.register(path, elem);\r
- \r
+\r
ttr.notifyCurrentPath(registry, path);\r
- ttr.addResultPart(new SimpleResultPart(TestStatus.PASSED,"Second test"));\r
- \r
+ ttr\r
+ .addResultPart(new SimpleResultPart(TestStatus.PASSED,\r
+ "Second test"));\r
+\r
testResultDao.update(ttr);\r
- \r
+\r
ttr.notifyCurrentPath(registry, path);\r
- ttr.addResultPart(new SimpleResultPart(TestStatus.PASSED,"Third test with same path"));\r
- \r
+ ttr.addResultPart(new SimpleResultPart(TestStatus.PASSED,\r
+ "Third test with same path"));\r
+\r
testResultDao.update(ttr);\r
- \r
+\r
ttr.close();\r
- \r
+\r
testResultDao.close(ttr.getUuid(), ttr.getCloseDate());\r
}\r
\r
--- /dev/null
+package org.argeo.slc.hibernate.unit;\r
+\r
+import java.sql.Connection;\r
+import java.util.List;\r
+import java.util.Properties;\r
+\r
+import org.hibernate.cfg.Configuration;\r
+import org.hibernate.cfg.Environment;\r
+import org.hibernate.tool.hbm2ddl.SchemaExport;\r
+\r
+/**\r
+ * Creates a relational data model from Hibernate mapping files. The benefit of\r
+ * this class is to be able to use Hibernate to have test data which are\r
+ * independent from the type of database used.\r
+ */\r
+public class DbModel {\r
+ private String dialect;\r
+ private List<String> mappings;\r
+\r
+ /** Sets the Hibernate dialect to use. */\r
+ public void setDialect(String dialect) {\r
+ this.dialect = dialect;\r
+ }\r
+\r
+ /** Sets the list of mappings to consider. */\r
+ public void setMappings(List<String> mappings) {\r
+ this.mappings = mappings;\r
+ }\r
+\r
+ /**\r
+ * Creates an Hibernate schema export tool, in order to create the\r
+ * underlying datamodel.\r
+ */\r
+ public SchemaExport createSchemaExport(Connection connection) {\r
+ Configuration configuration = new Configuration();\r
+ Properties properties = new Properties();\r
+ properties.setProperty(Environment.DIALECT, dialect);\r
+ properties.setProperty(Environment.HBM2DDL_AUTO, "create");\r
+ configuration.setProperties(properties);\r
+\r
+ for (String mapping : mappings) {\r
+ configuration.addResource(mapping.trim());\r
+ }\r
+\r
+ return new SchemaExport(configuration, connection);\r
+ }\r
+}\r
--- /dev/null
+package org.argeo.slc.hibernate.unit;\r
+\r
+import java.io.InputStream;\r
+import java.sql.SQLException;\r
+\r
+import javax.sql.DataSource;\r
+\r
+import org.apache.commons.io.IOUtils;\r
+import org.argeo.slc.core.SlcException;\r
+import org.argeo.slc.unit.AbstractSpringTestCase;\r
+import org.dbunit.DataSourceDatabaseTester;\r
+import org.dbunit.DatabaseUnitException;\r
+import org.dbunit.IDatabaseTester;\r
+import org.dbunit.database.IDatabaseConnection;\r
+import org.dbunit.dataset.IDataSet;\r
+import org.dbunit.dataset.ReplacementDataSet;\r
+import org.dbunit.dataset.xml.FlatXmlDataSet;\r
+import org.dbunit.operation.DatabaseOperation;\r
+import org.hibernate.tool.hbm2ddl.SchemaExport;\r
+import org.springframework.core.io.ClassPathResource;\r
+import org.springframework.core.io.Resource;\r
+\r
+/**\r
+ * Helper to make db vendor independent tests using DbUnit data sets. Based on\r
+ * {@link DbModel}.\r
+ */\r
+public abstract class IndependentDbTestCase extends AbstractSpringTestCase {\r
+ private IDatabaseTester databaseTester;\r
+\r
+ /** Creates the DDL of the data model and loads the data. */\r
+ @Override\r
+ protected void setUp() throws Exception {\r
+ super.setUp();\r
+\r
+ databaseTester = new DataSourceDatabaseTester(getDataSource());\r
+ databaseTester.setSetUpOperation(new DatabaseOperation() {\r
+\r
+ @Override\r
+ public void execute(IDatabaseConnection connection, IDataSet dataSet)\r
+ throws DatabaseUnitException, SQLException {\r
+ DbModel dbModel = getDbModel();\r
+ SchemaExport schemaExport = dbModel\r
+ .createSchemaExport(connection.getConnection());\r
+ schemaExport.create(true, true);\r
+\r
+ DatabaseOperation.INSERT.execute(connection, dataSet);\r
+ }\r
+\r
+ });\r
+ databaseTester.setDataSet(createDataSet());\r
+ databaseTester.onSetup();\r
+ }\r
+\r
+ @Override\r
+ protected void tearDown() throws Exception {\r
+ if (databaseTester != null) {\r
+ databaseTester.onTearDown();\r
+ }\r
+ super.tearDown();\r
+ }\r
+\r
+ /**\r
+ * The data source to use. The default implementation returns a bean named\r
+ * {@link #getDataSourceBeanName}\r
+ */\r
+ protected DataSource getDataSource() {\r
+ return (DataSource) getContext().getBean(getDataSourceBeanName());\r
+ }\r
+\r
+ /**\r
+ * The name of the data source bean to use. The default implementation\r
+ * returns <i>dataSource</i>.\r
+ */\r
+ protected String getDataSourceBeanName() {\r
+ return "slcDefault.dataSource.inMemoryTestHSQL";\r
+ }\r
+\r
+ /**\r
+ * Creates the data set to use. The default implementation creates a\r
+ * <code>FlatXmlDataSet</code> load from the resource defined in\r
+ * {@link #getDataSetResource()}\r
+ */\r
+ protected IDataSet createDataSet() {\r
+ InputStream in = null;\r
+ try {\r
+ in = getDataSetResource().getInputStream();\r
+ String[] replaceStrings = getReplacementStrings();\r
+ IDataSet dataSet;\r
+ if (replaceStrings.length == 0) {\r
+ dataSet = new FlatXmlDataSet(in);\r
+ } else {\r
+ dataSet = new ReplacementDataSet(new FlatXmlDataSet(in));\r
+ for (String str : replaceStrings) {\r
+ replace((ReplacementDataSet) dataSet, str);\r
+ }\r
+ }\r
+ return dataSet;\r
+ } catch (Exception e) {\r
+ throw new SlcException("Cannot create data set", e);\r
+ } finally {\r
+ IOUtils.closeQuietly(in);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * To be overridden. Return an empty array by default.\r
+ * \r
+ * @return the array of strings to replace in the dataset\r
+ */\r
+ protected String[] getReplacementStrings() {\r
+ return new String[0];\r
+ }\r
+\r
+ /**\r
+ * Set the object replacing the given string. To be overridden. Does nothing\r
+ * by default.\r
+ */\r
+ protected void replace(ReplacementDataSet dataSet, String str)\r
+ throws Exception {\r
+\r
+ }\r
+\r
+ /**\r
+ * Replace the given string by the content of the resource with the same\r
+ * name in the same package, as a byte array.\r
+ */\r
+ protected void replaceByRessource(ReplacementDataSet dataSet, String str)\r
+ throws Exception {\r
+ Resource zipResource = new ClassPathResource(inPackage(str));\r
+\r
+ dataSet.addReplacementObject(str, IOUtils.toByteArray(zipResource\r
+ .getInputStream()));\r
+ }\r
+\r
+ /**\r
+ * The resource of the data set to load. The default implementation loads a\r
+ * <code>ClassPathResource</code> located at\r
+ * {@link #getDataSetResourceLocation()}.\r
+ */\r
+ protected Resource getDataSetResource() {\r
+ return new ClassPathResource(getDataSetResourceLocation());\r
+ }\r
+\r
+ /**\r
+ * The location of the data set to load. The default implementation loads\r
+ * <i>dataSet.xml</i> found in the same package as the test.\r
+ */\r
+ protected String getDataSetResourceLocation() {\r
+ return inPackage("dataSet.xml");\r
+ }\r
+\r
+ /**\r
+ * The DB model to us to create the DDL of the testes database. The default\r
+ * implementation loads a bean named after {@link #getDbModelBeanName()}.\r
+ */\r
+ protected DbModel getDbModel() {\r
+ return (DbModel) getContext().getBean(getDbModelBeanName());\r
+ }\r
+\r
+ /**\r
+ * The name of the bean to load. The default implementation returns\r
+ * <i>dbModel</i>.\r
+ */\r
+ protected String getDbModelBeanName() {\r
+ return "dbModel";\r
+ }\r
+}\r
+++ /dev/null
-package org.argeo.slc.ws;\r
-\r
-import java.net.URL;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.ant.AntRunner;\r
-import org.argeo.slc.unit.AbstractSpringTestCase;\r
-\r
-public class SlcAntWsIntegrationTest extends AbstractSpringTestCase {\r
- private Log log = LogFactory.getLog(getClass());\r
-\r
- public void testSimpleRun() {\r
- // AntRegistryUtil.runAll(getClass().getResource(\r
- // "/org/argeo/slc/ant/build.xml"), "test", null);\r
-\r
- URL url = getClass().getResource("/org/argeo/slc/ant/build.xml");\r
- log.info("Run Ant file from URL: " + url);\r
- AntRunner antRunner = new AntRunner(getContext(), url, "test");\r
-\r
- antRunner.run();\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.ws;
-
-import org.springframework.ws.client.core.WebServiceTemplate;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.argeo.slc.core.process.SlcExecution;
-import org.argeo.slc.core.process.SlcExecutionTestUtils;
-import org.argeo.slc.msg.process.SlcExecutionRequest;
-import org.argeo.slc.unit.AbstractSpringTestCase;
-
-public class SlcExecutionWsIntegrationTest extends AbstractSpringTestCase {
- private Log log = LogFactory.getLog(getClass());
-
- public void testSendSlcExecutionrequest() {
- WebServiceTemplate template = getBean(WebServiceTemplate.class);
- SlcExecution slcExec = SlcExecutionTestUtils.createSimpleSlcExecution();
-
- SlcExecutionRequest req = new SlcExecutionRequest();
- req.setSlcExecution(slcExec);
-
- log.info("Send SlcExecutionRequest for SlcExecution "
- + slcExec.getUuid());
-
- Object resp = template.marshalSendAndReceive(req);
- log.info("Resp: " + resp);
- }
-}
+++ /dev/null
-package org.argeo.slc.ws;
-
-import org.springframework.ws.client.core.WebServiceTemplate;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import static org.argeo.slc.core.test.tree.TreeTestResultTestUtils.createCompleteTreeTestResult;
-import static org.argeo.slc.core.test.tree.TreeTestResultTestUtils.createSimpleResultPartRequest;
-
-import org.argeo.slc.core.test.tree.TreeTestResult;
-import org.argeo.slc.msg.test.tree.CloseTreeTestResultRequest;
-import org.argeo.slc.msg.test.tree.CreateTreeTestResultRequest;
-import org.argeo.slc.msg.test.tree.ResultPartRequest;
-import org.argeo.slc.unit.AbstractSpringTestCase;
-
-public class TreeTestResultWsIntegrationTest extends AbstractSpringTestCase {
- private Log log = LogFactory.getLog(getClass());
-
- public void testCreateTreeTestResultRequest() {
- WebServiceTemplate template = getBean(WebServiceTemplate.class);
- CreateTreeTestResultRequest req = new CreateTreeTestResultRequest(
- createCompleteTreeTestResult());
- req.getTreeTestResult().close();// in order to avoid unclosed in test db
-
- log.info("Send CreateTreeTestResultRequest for result "
- + req.getTreeTestResult().getUuid());
-
- Object resp = template.marshalSendAndReceive(req);
- log.info("Resp: " + resp);
- }
-
- public void testResultPartRequest() {
- WebServiceTemplate template = getBean(WebServiceTemplate.class);
- TreeTestResult ttr = createCompleteTreeTestResult();
- ttr.close();// in order to avoid unclosed in test db
- CreateTreeTestResultRequest reqCreate = new CreateTreeTestResultRequest(
- ttr);
- log.info("Send CreateTreeTestResultRequest for result "
- + reqCreate.getTreeTestResult().getUuid());
- template.marshalSendAndReceive(reqCreate);
-
- ResultPartRequest req = createSimpleResultPartRequest(ttr);
-
- log.info("Send ResultPartRequest for result " + req.getResultUuid());
- Object resp = template.marshalSendAndReceive(req);
- log.info("Resp: " + resp);
- }
-
- public void testCloseTreeTestResultRequest() {
- WebServiceTemplate template = getBean(WebServiceTemplate.class);
-
- TreeTestResult ttr = createCompleteTreeTestResult();
- CreateTreeTestResultRequest reqCreate = new CreateTreeTestResultRequest(
- ttr);
- log.info("Send CreateTreeTestResultRequest for result "
- + reqCreate.getTreeTestResult().getUuid());
- template.marshalSendAndReceive(reqCreate);
-
- ttr.close();
- CloseTreeTestResultRequest req = new CloseTreeTestResultRequest(ttr
- .getUuid(), ttr.getCloseDate());
-
- log.info("Send CloseTreeTestResultRequest for result "
- + req.getResultUuid());
-
- Object resp = template.marshalSendAndReceive(req);
- log.info("Resp: " + resp);
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <import resource="classpath:/org/argeo/slc/ant/nonDepContext.xml" />\r
-\r
- <bean id="testResult"\r
- parent="slcDefault.test.basicTreeTestResult">\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<project default="test">\r
-\r
- <target name="test">\r
- <echo message="Hello World!" />\r
- \r
- <slc.test path="/testRoot/testPath">\r
- <testDefinition bean="testDef"/>\r
- <testData bean="testData1"/>\r
- </slc.test>\r
- \r
- <slc.test path="/testRoot/testContext">\r
- <testDefinition bean="testDef"/>\r
- <testData bean="testData.context1"/>\r
- </slc.test>\r
- \r
- <slc.closeResult result="testResult" />\r
- </target>\r
-</project>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <import\r
- resource="classpath:/org/argeo/slc/core/test/spring/applicationContext.xml" />\r
-\r
- <bean name="testDef"\r
- class="org.argeo.slc.core.test.BasicTestDefinition" scope="prototype" />\r
-\r
- <bean name="testData1"\r
- class="org.argeo.slc.core.test.BasicTestData">\r
- <property name="expected">\r
- <value>toto</value>\r
- </property>\r
- <property name="reached">\r
- <value>toto</value>\r
- </property>\r
- </bean>\r
-\r
- <bean id="testData.context1" parent="context.template">\r
- <property name="values">\r
- <map>\r
- <entry key="reference" value="20" />\r
- <entry key="varIntern" value="60" />\r
- </map>\r
- </property>\r
- <property name="expectedValues">\r
- <map>\r
- <entry key="reference" value="21" />\r
- <entry key="varIntern" value="60" />\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="context.template"\r
- class="org.argeo.slc.core.test.context.DefaultContextTestData"\r
- abstract="true">\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
-<!-- TODO: remove this file\r
- <import\r
- resource="classpath:/org/argeo/slc/castor/spring/applicationContext.xml" />\r
- <import\r
- resource="classpath:/org/argeo/slc/ws/client/spring/applicationContext.xml" />\r
--->\r
-</beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
-\r
- <import\r
- resource="classpath:/org/argeo/slc/xml/spring/applicationContext.xml" />\r
- <import\r
- resource="classpath:/org/argeo/slc/castor/spring/applicationContext.xml" />\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <bean id="parentContext.pc1" parent="parentContext.template">\r
- <property name="values">\r
- <map>\r
- <entry key="rootvar" value="text" />\r
- </map>\r
- </property>\r
- <property name="expectedValues">\r
- <map>\r
- <entry key="reference" value="20" />\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="context.c1" parent="context.template">\r
- <property name="parentContext" ref="parentContext.pc1" />\r
- <property name="values">\r
- <map>\r
- <entry key="reference" value="20" />\r
- <entry key="any" value="999" />\r
- <entry key="skipped" value="999" />\r
- </map>\r
- </property>\r
- <property name="expectedValues">\r
- <map>\r
- <entry key="reference" value="21" />\r
- <entry key="any" value="*" />\r
- <entry key="skipped" value="!" />\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="context.c2" parent="context.template">\r
- <property name="parentContext" ref="parentContext.pc1" />\r
- <property name="values">\r
- <map>\r
- <entry key="var" value="37" />\r
- <entry key="bad" value="56" />\r
- </map>\r
- </property>\r
- <property name="expectedValues">\r
- <map>\r
- <entry key="var" value="37" />\r
- <entry key="bad" value="57" />\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="parentContext.pc2" parent="parentContext.template">\r
- <property name="parentContext" ref="parentContext.pc1" />\r
- <property name="expectedValues">\r
- <map>\r
- <entry key="reference" value="40" />\r
- </map>\r
- </property>\r
- </bean>\r
-\r
- <bean id="context.c3" parent="context.template">\r
- <property name="parentContext" ref="parentContext.pc2" />\r
- <property name="values">\r
- <map>\r
- <entry key="reference" value="41" />\r
- <entry key="rootvar" value="textX" />\r
- </map>\r
- </property>\r
- <property name="expectedValues">\r
- <map>\r
- <entry key="reference" value="40" />\r
- <entry key="rootvar" value="text" />\r
- </map>\r
- </property>\r
- </bean>\r
-\r
-\r
- <bean id="parentContext.template"\r
- class="org.argeo.slc.core.test.context.SimpleParentContextAware"\r
- abstract="true">\r
- </bean>\r
-\r
- <bean id="context.template"\r
- class="org.argeo.slc.core.test.context.SimpleContextAware"\r
- abstract="true">\r
- </bean>\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <import\r
- resource="classpath:/org/argeo/slc/xml/spring/applicationContext.xml" />\r
- <import\r
- resource="classpath:/org/argeo/slc/castor/spring/applicationContext.xml" />\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <import\r
- resource="classpath:/org/argeo/slc/ws/client/spring/applicationContext.xml" />\r
- <import resource="classpath:/org/argeo/slc/ant/nonDepContext.xml" />\r
- <import resource="execution.xml" />\r
- <import resource="result.xml" />\r
-\r
-</beans>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <import\r
- resource="classpath:/org/argeo/slc/ws/client/spring/applicationContext.xml" />\r
-\r
- <bean name="executionBuildListener"\r
- class="org.argeo.slc.ant.SlcExecutionBuildListener">\r
- <property name="notifiers">\r
- <list>\r
- <ref bean="webServiceNotifier" />\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean name="fileNotifier"\r
- class="org.argeo.slc.core.process.FileSlcExecutionNotifier">\r
- <property name="basePath" value="${slc.workDir}/process" />\r
- <property name="marshaller" ref="slcDefault.castor.marshaller" />\r
- </bean>\r
-\r
- <bean name="webServiceNotifier"\r
- class="org.argeo.slc.core.process.WebServiceSlcExecutionNotifier">\r
- <property name="template"\r
- ref="slcDefault.ws.client.webServiceTemplate" />\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans xmlns="http://www.springframework.org/schema/beans"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
- <import\r
- resource="classpath:/org/argeo/slc/ws/client/spring/applicationContext.xml" />\r
-\r
- <bean id="testResult"\r
- parent="slcDefault.test.basicTreeTestResult">\r
- <property name="listeners">\r
- <list merge="true">\r
- <ref\r
- bean="slcDefault.ws.client.treeTestResultWsNotfier" />\r
- <ref bean="slcDefault.castor.xsltReportGenerator" />\r
- </list>\r
- </property>\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file