<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
- <dependency>
- <groupId>org.springframework.ws</groupId>
- <artifactId>spring-ws-core</artifactId>
- </dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-oxm</artifactId>
<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>
<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.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.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.maven;
-
-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;
-
-public class MavenDeployEnvironment implements DeployEnvironment {
- private static final Log log = LogFactory
- .getLog(MavenDeployEnvironment.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.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.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
-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.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.msg.process.SlcExecutionRequest;
-import org.argeo.slc.unit.AbstractSpringTestCase;
-import org.argeo.slc.unit.process.SlcExecutionTestUtils;
-
-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.unit.test.tree.TreeTestResultTestUtils.createCompleteTreeTestResult;
-import static org.argeo.slc.unit.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);
- }
-}