</plugins>
</build>
<dependencies>
- <dependency>
- <groupId>javax.transaction</groupId>
- <artifactId>jta</artifactId>
- </dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</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>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jdbc</artifactId>
- </dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- </dependency>
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
+++ /dev/null
-package org.argeo.slc.hibernate.process;\r
-\r
-import java.util.List;\r
-\r
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;\r
-\r
-import org.argeo.slc.core.process.SlcExecution;\r
-import org.argeo.slc.dao.process.SlcExecutionDao;\r
-\r
-public class SlcExecutionDaoHibernate extends HibernateDaoSupport implements\r
- SlcExecutionDao {\r
-\r
- public void create(SlcExecution slcExecution) {\r
- getHibernateTemplate().save(slcExecution);\r
- }\r
-\r
- public void update(SlcExecution slcExecution) {\r
- getHibernateTemplate().update(slcExecution);\r
- }\r
-\r
- public SlcExecution getSlcExecution(String uuid) {\r
- return (SlcExecution) getHibernateTemplate().get(SlcExecution.class,\r
- uuid);\r
- }\r
-\r
- public List<SlcExecution> listSlcExecutions() {\r
- return (List<SlcExecution>) getHibernateTemplate().loadAll(\r
- SlcExecution.class);\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.hibernate.structure.tree;\r
-\r
-import java.util.List;\r
-\r
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.dao.structure.tree.TreeSPathDao;\r
-\r
-/**\r
- * The Hibernate implementation for tree-based result of the test result dao.\r
- * \r
- * @see TreeTestResult\r
- */\r
-public class TreeSPathDaoHibernate extends HibernateDaoSupport implements\r
- TreeSPathDao {\r
-\r
- private static Log log = LogFactory.getLog(TreeSPathDaoHibernate.class);\r
-\r
- public void create(TreeSPath path) {\r
- createImpl(path);\r
- }\r
-\r
- private void createImpl(TreeSPath path) {\r
- if (path.getParent() != null) {\r
- TreeSPath parent = getTreeSPath(path.getParent()\r
- .getAsUniqueString());\r
- if (parent == null) {\r
- createImpl(path.getParent());\r
- }\r
- }\r
- getHibernateTemplate().save(path);\r
- if (log.isTraceEnabled())\r
- log.trace("Saved TreeSPath " + path.getAsUniqueString());\r
- }\r
-\r
- public TreeSPath getTreeSPath(String pathString) {\r
- List<?> list = getHibernateTemplate().find(\r
- "from TreeSPath where asUniqueString=?", pathString);\r
- if (list.size() == 0) {\r
- return null;\r
- } else {\r
- return (TreeSPath) list.get(0);\r
- }\r
- }\r
-\r
- public TreeSPath getOrCreate(TreeSPath pathTransient) {\r
- TreeSPath path = getTreeSPath(pathTransient.getAsUniqueString());\r
- if (path != null) {\r
- return path;\r
- } else {\r
- create(pathTransient);\r
- // TODO: optimize\r
- return getTreeSPath(pathTransient.getAsUniqueString());\r
- }\r
-\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.hibernate.structure.tree;\r
-\r
-import java.util.List;\r
-\r
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;\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.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.TreeSRegistry;\r
-import org.argeo.slc.dao.structure.tree.TreeSPathDao;\r
-import org.argeo.slc.dao.structure.tree.TreeSRegistryDao;\r
-import org.hibernate.Session;\r
-\r
-/**\r
- * The Hibernate implementation for tree-based structure registry.\r
- * \r
- * @see TreeSRegistry\r
- */\r
-public class TreeSRegistryDaoHibernate extends HibernateDaoSupport implements\r
- TreeSRegistryDao {\r
-\r
- private TreeSPathDao treeSPathDao;\r
-\r
- private static Log log = LogFactory.getLog(TreeSRegistryDaoHibernate.class);\r
-\r
- public void create(TreeSRegistry registry) {\r
- getHibernateTemplate().save(registry);\r
- }\r
-\r
- public void update(TreeSRegistry registryArg) {\r
- Session session = getSession();\r
- session.beginTransaction();\r
- TreeSRegistry registry = (TreeSRegistry)session.merge(registryArg);\r
- session.update(registry);\r
- session.getTransaction().commit();\r
- }\r
-\r
- public TreeSRegistry getActiveTreeSRegistry() {\r
- List<?> list = getHibernateTemplate().find(\r
- "from TreeSRegistry where status=?",\r
- TreeSRegistry.STATUS_ACTIVE);\r
- if (list.size() == 0) {\r
- return null;\r
- } else {\r
- return (TreeSRegistry) list.get(0);\r
- }\r
- }\r
-\r
- public void syncPath(TreeSRegistry registryArg,\r
- StructureRegistry<TreeSPath> localRegistry, TreeSPath pathArg) {\r
- Session session = getSession();\r
- session.beginTransaction();\r
- TreeSRegistry registry = (TreeSRegistry)session.merge(registryArg);\r
- TreeSPath path = (TreeSPath)session.merge(pathArg);\r
- if (log.isTraceEnabled())\r
- log.trace("Session#" + session.hashCode() + " " + session);\r
- syncPathImpl(registry, localRegistry, path, session);\r
- session.update(registry);\r
- session.getTransaction().commit();\r
- }\r
-\r
- private void syncPathImpl(TreeSRegistry registry,\r
- StructureRegistry<TreeSPath> localRegistry, TreeSPath path,\r
- Session session) {\r
- if (path.getParent() != null) {\r
- TreeSPath parent = treeSPathDao.getOrCreate(path.getParent());\r
- syncPathImpl(registry, localRegistry, parent, session);\r
- }\r
-\r
- if (log.isTraceEnabled())\r
- log.trace("Synchronize path " + path);\r
-\r
- if (registry.getElement(path) == null) {\r
- final StructureElement element = getElement(registry,\r
- localRegistry, path, session);\r
- StructureElement elementPersisted = (StructureElement) session\r
- .merge(element);\r
- registry.register(path, elementPersisted);\r
- // update(registry);\r
-\r
- if (log.isTraceEnabled())\r
- log.trace("No element in persisted structure for " + path\r
- + ", merged to " + elementPersisted);\r
- } else {\r
- if (localRegistry != null) {\r
- StructureElement element = getElement(registry, localRegistry,\r
- path, session);\r
-\r
- if (element != null) {\r
- StructureElement elementPersisted = (StructureElement) session\r
- .merge(element);\r
- registry.register(path, elementPersisted);\r
- // update(registry);\r
- if (log.isTraceEnabled())\r
- log\r
- .trace("Update existing element in persisted structure for "\r
- + path\r
- + ", merged to "\r
- + elementPersisted);\r
- }\r
- }\r
- }\r
-\r
- }\r
-\r
- public void setTreeSPathDao(TreeSPathDao treeSPathDao) {\r
- this.treeSPathDao = treeSPathDao;\r
- }\r
-\r
- protected StructureElement getElement(TreeSRegistry registry,\r
- StructureRegistry<TreeSPath> localRegistry, TreeSPath path,\r
- Session session) {\r
- StructureElement element;\r
- if (localRegistry != null) {\r
- element = localRegistry.getElement(path);\r
- if (session.getSessionFactory()\r
- .getClassMetadata(element.getClass()) == null) {\r
- if (log.isTraceEnabled())\r
- log.trace("Replace non-hibernate element " + element\r
- + " by a simple element.");\r
- element = new SimpleSElement(element.getLabel());\r
- }\r
- } else {\r
- element = new SimpleSElement(path.getName());\r
- }\r
- return element;\r
- }\r
-}\r
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-Hibernate based DAO implementations for tree-based structure objects.\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.hibernate.test;\r
-\r
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;\r
-\r
-import org.argeo.slc.core.test.TestRunDescriptor;\r
-import org.argeo.slc.dao.test.TestRunDescriptorDao;\r
-\r
-public class TestRunDescriptorDaoHibernate extends HibernateDaoSupport\r
- implements TestRunDescriptorDao {\r
-\r
- public TestRunDescriptor getTestRunDescriptor(String id) {\r
- return (TestRunDescriptor) getHibernateTemplate().get(\r
- TestRunDescriptor.class, id);\r
- }\r
-\r
- public void saveOrUpdate(TestRunDescriptor testRunDescriptor) {\r
- getHibernateTemplate().saveOrUpdate(testRunDescriptor);\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.hibernate.test.tree;\r
-\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;\r
-\r
-import org.argeo.slc.core.SlcException;\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.core.test.NumericTRId;\r
-import org.argeo.slc.core.test.TestResult;\r
-import org.argeo.slc.core.test.TestResultId;\r
-import org.argeo.slc.core.test.tree.TreeTestResult;\r
-import org.argeo.slc.dao.test.tree.TreeTestResultDao;\r
-\r
-/**\r
- * The Hibernate implementation for tree-based result of the test result dao.\r
- * \r
- * @see TreeTestResult\r
- */\r
-public class TestResultDaoHibernate extends HibernateDaoSupport implements\r
- TreeTestResultDao {\r
-\r
- public void create(TestResult testResult) {\r
- getHibernateTemplate().save(testResult);\r
- }\r
-\r
- public void update(TestResult testResult) {\r
- getHibernateTemplate().saveOrUpdate(testResult);\r
- }\r
-\r
- public TreeTestResult getTestResult(String uuid) {\r
- List<?> list = getHibernateTemplate().find(\r
- "from TreeTestResult where uuid=?", uuid);\r
- if (list.size() == 0) {\r
- return null;\r
- } else {\r
- return (TreeTestResult) list.get(0);\r
- }\r
-\r
- }\r
-\r
- public List<TreeTestResult> listTestResults() {\r
- return (List<TreeTestResult>) getHibernateTemplate().find(\r
- "from TreeTestResult");\r
- }\r
-\r
- public List<TreeTestResult> listResults(TreeSPath path) {\r
- List<TreeTestResult> list = getHibernateTemplate().find(\r
- "from TreeTestResult res where ? in indices(res.resultParts)",\r
- path.getAsUniqueString());\r
- return list;\r
- }\r
-\r
- public void close(String id, Date closeDate) {\r
-// TreeTestResult ttr = (TreeTestResult) getHibernateTemplate().load(\r
-// TreeTestResult.class, id);\r
- TreeTestResult ttr = getTestResult(id);\r
- if (ttr != null) {\r
- ttr.setCloseDate(closeDate);\r
- getHibernateTemplate().update(ttr);\r
- } else {\r
- throw new SlcException("Result with id " + id\r
- + " could not be closed because it was not found.");\r
- }\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.hibernate.test.tree;\r
-\r
-import java.util.SortedSet;\r
-import java.util.TreeSet;\r
-\r
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;\r
-\r
-import org.argeo.slc.core.test.tree.TreeTestResultCollection;\r
-import org.argeo.slc.dao.test.tree.TreeTestResultCollectionDao;\r
-\r
-public class TreeTestResultCollectionDaoHibernate extends HibernateDaoSupport\r
- implements TreeTestResultCollectionDao {\r
-\r
- public void create(TreeTestResultCollection ttrCollection) {\r
- getHibernateTemplate().save(ttrCollection);\r
- }\r
-\r
- public TreeTestResultCollection getTestResultCollection(String id) {\r
- return (TreeTestResultCollection) getHibernateTemplate().get(\r
- TreeTestResultCollection.class, id);\r
- }\r
-\r
- public void update(TreeTestResultCollection ttrCollection) {\r
- getHibernateTemplate().update(ttrCollection);\r
- }\r
-\r
- public SortedSet<TreeTestResultCollection> listCollections() {\r
- return new TreeSet<TreeTestResultCollection>(getHibernateTemplate()\r
- .find("from TreeTestResultCollection"));\r
- }\r
-\r
-}\r
+++ /dev/null
-<html>\r
-<head></head>\r
-<body>\r
-Hibernate based DAO implementations for tree-based SLC Test.\r
-</body>\r
-</html>
\ No newline at end of file
+++ /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.process;\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
+import java.util.UUID;\r
+\r
+import org.argeo.slc.core.process.SlcExecution;\r
+import org.argeo.slc.core.process.SlcExecutionStep;\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.unit.test.tree;\r
+\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.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.core.test.tree.PartSubList;\r
+import org.argeo.slc.core.test.tree.TreeTestResult;\r
+import org.argeo.slc.msg.test.tree.ResultPartRequest;\r
+import org.argeo.slc.unit.process.SlcExecutionTestUtils;\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
-<?xml version="1.0"?>\r
-<!DOCTYPE hibernate-mapping PUBLIC\r
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
-<hibernate-mapping package="org.argeo.slc.core.process">\r
- <class name="SlcExecution" table="SLC_EXECUTION">\r
- <id name="uuid" column="UUID" />\r
- <property name="host" column="HOST" />\r
- <property name="user" column="USER" />\r
- <property name="type" column="TYPE" />\r
- <property name="status" column="STATUS" />\r
-\r
- <list name="steps" cascade="all" lazy="false"\r
- table="SLC_EXECUTIONS_STEPS">\r
- <key column="SLC_EXECUTION_ID" />\r
- <list-index column="INDX" />\r
- <one-to-many\r
- class="org.argeo.slc.core.process.SlcExecutionStep" />\r
- </list>\r
-\r
- <map name="attributes" table="SLC_EXEC_ATTRS_MAP" cascade="all"\r
- lazy="false" sort="natural">\r
- <key column="PARENT_ID" />\r
- <map-key type="string" column="ATTR_NAME" />\r
- <element column="NAME" type="string" />\r
- </map>\r
-\r
- </class>\r
-</hibernate-mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<!DOCTYPE hibernate-mapping PUBLIC\r
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
-<hibernate-mapping package="org.argeo.slc.core.process">\r
- <class name="SlcExecutionStep" table="SLC_EXECUTION_STEP">\r
- <id name="uuid" column="UUID" />\r
- <property name="type" column="TYPE" />\r
- <property name="begin" column="BEGIN" />\r
-\r
- <list name="logLines" cascade="all" lazy="false"\r
- table="SLC_EXECUTION_STEP_LOG_LINE">\r
- <key column="SLC_EXECUTION_STEP_ID" />\r
- <list-index column="INDX" />\r
- <element column="LOG_LINE" type="string" />\r
- </list>\r
- </class>\r
-</hibernate-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.dataSource.inMemoryTestHSQL"\r
- class="org.springframework.jdbc.datasource.SingleConnectionDataSource"\r
- destroy-method="destroy">\r
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />\r
- <property name="url" value="jdbc:hsqldb:mem:test" />\r
- <property name="username" value="sa" />\r
- <property name="password" value="" />\r
- <property name="suppressClose" value="true" />\r
- </bean>\r
-\r
- <bean id="slcTemplates.sessionFactory.hibernateBasic"\r
- abstract="true"\r
- class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">\r
- <property name="mappingResources">\r
- <list>\r
- <value>\r
- org/argeo/slc/hibernate/structure/SimpleSElement.hbm.xml\r
- </value>\r
- <value>\r
- org/argeo/slc/hibernate/structure/tree/TreeSPath.hbm.xml\r
- </value>\r
- <value>\r
- org/argeo/slc/hibernate/structure/tree/TreeSRegistry.hbm.xml\r
- </value>\r
- <value>\r
- org/argeo/slc/hibernate/test/NumericTRId.hbm.xml\r
- </value>\r
- <value>\r
- org/argeo/slc/hibernate/test/SimpleResultPart.hbm.xml\r
- </value>\r
- <value>\r
- org/argeo/slc/hibernate/test/tree/TreeTestResult.hbm.xml\r
- </value>\r
- <value>\r
- org/argeo/slc/hibernate/test/tree/TreeTestResultCollection.hbm.xml\r
- </value>\r
- <value>\r
- org/argeo/slc/hibernate/test/tree/PartSubList.hbm.xml\r
- </value>\r
- <value>\r
- org/argeo/slc/hibernate/test/TestRunDescriptor.hbm.xml\r
- </value>\r
- <value>\r
- org/argeo/slc/hibernate/process/SlcExecution.hbm.xml\r
- </value>\r
- <value>\r
- org/argeo/slc/hibernate/process/SlcExecutionStep.hbm.xml\r
- </value>\r
- </list>\r
- </property>\r
- </bean>\r
-\r
- <bean id="slcDefault.sessionFactory.hibernateTestHSQL"\r
- parent="slcTemplates.sessionFactory.hibernateBasic">\r
- <property name="dataSource"\r
- ref="slcDefault.dataSource.inMemoryTestHSQL" />\r
- <property name="hibernateProperties">\r
- <value><![CDATA[\r
- hibernate.dialect=org.hibernate.dialect.HSQLDialect\r
- hibernate.hbm2ddl.auto=create\r
- hibernate.current_session_context_class=thread\r
- ]]></value>\r
- </property>\r
- </bean>\r
-\r
- <bean id="slcTemplates.dao.treeSPathDao"\r
- class="org.argeo.slc.hibernate.structure.tree.TreeSPathDaoHibernate"\r
- abstract="true">\r
- </bean>\r
-\r
- <bean id="slcTemplates.dao.treeSRegistryDao"\r
- class="org.argeo.slc.hibernate.structure.tree.TreeSRegistryDaoHibernate"\r
- abstract="true">\r
- </bean>\r
-\r
- <bean id="slcTemplates.dao.testResultDao"\r
- class="org.argeo.slc.hibernate.test.tree.TestResultDaoHibernate"\r
- abstract="true">\r
- </bean>\r
-\r
- <bean id="slcTemplates.dao.testResultCollectionDao"\r
- class="org.argeo.slc.hibernate.test.tree.TreeTestResultCollectionDaoHibernate"\r
- abstract="true">\r
- </bean>\r
-\r
- <bean id="slcTemplates.dao.testRunDescriptorDao"\r
- class="org.argeo.slc.hibernate.test.TestRunDescriptorDaoHibernate"\r
- abstract="true">\r
- </bean>\r
-\r
- <bean id="slcTemplates.dao.slcExecutionDao"\r
- class="org.argeo.slc.hibernate.process.SlcExecutionDaoHibernate"\r
- abstract="true">\r
- </bean>\r
-\r
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<!DOCTYPE hibernate-mapping PUBLIC\r
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
-<hibernate-mapping package="org.argeo.slc.core.structure">\r
- <class name="SimpleSElement" table="SIMPLE_SELEMENT">\r
- <id name="tid" column="T_ID">\r
- <generator class="native" />\r
- </id>\r
- <property name="label" column="LABEL" not-null="true" />\r
- <map name="tags" table="SIMPLE_SELEMENT_TAGS" cascade="all"\r
- lazy="false" sort="natural">\r
- <key column="PARENT_ID" />\r
- <map-key type="string" column="NAME" />\r
- <element type="string" column="VALUE" />\r
- </map>\r
- </class>\r
-</hibernate-mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<!DOCTYPE hibernate-mapping PUBLIC\r
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
-<hibernate-mapping package="org.argeo.slc.core.structure.tree">\r
- <class name="TreeSPath" table="TREE_SPATH">\r
- <id name="tid" column="T_ID">\r
- <generator class="native" />\r
- </id>\r
- <property name="asUniqueString" column="PATH" not-null="true"\r
- unique="true" />\r
- </class>\r
-</hibernate-mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<!DOCTYPE hibernate-mapping PUBLIC\r
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
-<hibernate-mapping package="org.argeo.slc.core.structure.tree">\r
- <class name="TreeSRegistry" table="TREE_SREGISTRY">\r
- <id name="tid" column="T_ID">\r
- <generator class="native" />\r
- </id>\r
-\r
- <property name="status" column="STATUS" not-null="true"\r
- unique="true" />\r
-\r
- <map name="elements" table="REGISTRY_ELEMENTS" cascade="all"\r
- lazy="false" sort="natural">\r
- <key column="PARENT_ID" />\r
- <map-key-many-to-many class="TreeSPath" column="PATH" />\r
-\r
- <many-to-many\r
- class="org.argeo.slc.core.structure.SimpleSElement"\r
- column="ELEMENT_ID" unique="true" lazy="false" />\r
- </map>\r
-\r
- </class>\r
-</hibernate-mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<!DOCTYPE hibernate-mapping PUBLIC\r
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
-<hibernate-mapping package="org.argeo.slc.core.test">\r
- <class name="NumericTRId" table="NUMERIC_TR_ID">\r
-\r
- <id name="tid" column="T_ID">\r
- <generator class="native" />\r
- </id>\r
- <property name="value" column="VALUE" not-null="true"\r
- unique="true" />\r
- </class>\r
-</hibernate-mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<!DOCTYPE hibernate-mapping PUBLIC\r
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
-<hibernate-mapping package="org.argeo.slc.core.test">\r
- <class name="SimpleResultPart" table="SIMPLE_RESULT_PART">\r
- <id name="tid" column="T_ID">\r
- <generator class="native" />\r
- </id>\r
- <property name="status" column="STATUS" not-null="true" />\r
- <property name="message" column="MESSAGE" not-null="true" />\r
- <property name="exceptionMessage" column="EXCEPTION_MESSAGE"\r
- not-null="false" />\r
- </class>\r
-</hibernate-mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<!DOCTYPE hibernate-mapping PUBLIC\r
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
-<hibernate-mapping package="org.argeo.slc.core.test">\r
- <class name="TestResultId" table="TEST_RESULT_ID">\r
- <id name="tid" column="T_ID">\r
- <generator class="native" />\r
- </id>\r
- </class>\r
-</hibernate-mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<!DOCTYPE hibernate-mapping PUBLIC\r
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
-<hibernate-mapping package="org.argeo.slc.core.test">\r
- <class name="TestRunDescriptor" table="TEST_RUN_DESCRIPTOR">\r
- <id name="testRunUuid" column="TEST_RUN_UUID" />\r
- <property name="slcExecutionUuid" column="SLC_EXEC_UUID"\r
- not-null="false" />\r
- <property name="slcExecutionStepUuid"\r
- column="SLC_EXEC_STEP_UUID" not-null="false" />\r
- <property name="testResultUuid" column="TEST_RESULT_UUID"\r
- not-null="false" />\r
- <property name="deployedSytemId" column="DEPLOYED_SYSTEM_ID"\r
- not-null="false" />\r
- </class>\r
-</hibernate-mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<!DOCTYPE hibernate-mapping PUBLIC\r
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
-<hibernate-mapping package="org.argeo.slc.core.test.tree">\r
- <class name="PartSubList" table="PART_SUB_LIST">\r
- <id name="tid" column="T_ID">\r
- <generator class="native" />\r
- </id>\r
- <list name="parts" cascade="all" lazy="false">\r
- <key column="PART_SUBLIST_ID" />\r
- <list-index column="INDX" />\r
- <composite-element\r
- class="org.argeo.slc.core.test.SimpleResultPart">\r
- <property name="status" column="STATUS" not-null="true" />\r
- <property name="message" column="MESSAGE"\r
- not-null="true" />\r
- <property name="exceptionMessage"\r
- column="EXCEPTION_MESSAGE" not-null="false" />\r
- <property name="testRunUuid" column="TEST_RUN_UUID"\r
- not-null="false" />\r
- </composite-element>\r
- </list>\r
- </class>\r
-</hibernate-mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<!DOCTYPE hibernate-mapping PUBLIC\r
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
-<hibernate-mapping package="org.argeo.slc.core.test.tree">\r
- <class name="TreeTestResult" table="TREE_TEST_RESULT">\r
- <id name="uuid" column="UUID"/>\r
-\r
- <property name="closeDate" column="CLOSE_DATE" type="timestamp"\r
- not-null="false" />\r
-\r
- <map name="resultParts" table="RESULT_PARTS_MAP" cascade="all"\r
- lazy="false" sort="natural">\r
- <key column="PARENT_ID" />\r
- <composite-map-key\r
- class="org.argeo.slc.core.structure.tree.TreeSPath">\r
- <key-property name="asUniqueString" column="PATH" />\r
- </composite-map-key>\r
- <many-to-many class="PartSubList" column="PART_SUB_LIST_ID"\r
- unique="true" lazy="false" />\r
- </map>\r
-\r
- <map name="elements" table="RESULT_ELEMENTS_MAP"\r
- cascade="all" lazy="false" sort="natural">\r
- <key column="PARENT_ID" />\r
- <composite-map-key\r
- class="org.argeo.slc.core.structure.tree.TreeSPath">\r
- <key-property name="asUniqueString" column="PATH" />\r
- </composite-map-key>\r
- <many-to-many class="org.argeo.slc.core.structure.SimpleSElement" column="ELEMENT_ID"\r
- unique="true" lazy="false" />\r
- </map>\r
- </class>\r
-</hibernate-mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<!DOCTYPE hibernate-mapping PUBLIC\r
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
-<hibernate-mapping package="org.argeo.slc.core.test.tree">\r
- <class name="TreeTestResultCollection"\r
- table="TREE_TEST_RESULT_COLLECTION">\r
- <id name="id" column="ID" />\r
-\r
- <set name="results" table="TTR_COLLECTION_RESULTS"\r
- sort="natural" lazy="false">\r
- <key column="PARENT_ID" />\r
- <many-to-many class="TreeTestResult" />\r
- </set>\r
- </class>\r
-</hibernate-mapping>
\ No newline at end of file
import org.argeo.slc.msg.process.SlcExecutionStepsRequest;\r
import org.argeo.slc.unit.AbstractSpringTestCase;\r
import org.argeo.slc.unit.UnitXmlUtils;\r
+import org.argeo.slc.unit.process.SlcExecutionTestUtils;\r
\r
import org.springframework.oxm.Marshaller;\r
import org.springframework.oxm.Unmarshaller;\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
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
+import static org.argeo.slc.unit.test.tree.TreeTestResultTestUtils.createCompleteTreeTestResult;\r
+import static org.argeo.slc.unit.test.tree.TreeTestResultTestUtils.createSimpleResultPartRequest;\r
\r
import org.argeo.slc.core.structure.tree.TreeSPath;\r
import org.argeo.slc.core.test.SimpleResultPart;\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.hibernate.process;\r
-\r
-import java.util.List;\r
-\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
-\r
-public class SlcExecutionHibernateTest extends AbstractSpringTestCase {\r
-\r
- public void testSave() {\r
- SlcExecutionDao dao = getBean(SlcExecutionDao.class);\r
-\r
- SlcExecution slcExec = SlcExecutionTestUtils.createSimpleSlcExecution();\r
- slcExec.getSteps().add(new SlcExecutionStep("LOG", "A log line"));\r
- slcExec.getSteps().add(new SlcExecutionStep("LOG", "Two log\nlines"));\r
-\r
- dao.create(slcExec);\r
-\r
- SlcExecution slcExecPersisted = dao.getSlcExecution(slcExec.getUuid());\r
- SlcExecutionTestUtils.assertSlcExecution(slcExec, slcExecPersisted);\r
- assertEquals(2, slcExecPersisted.getSteps().size());\r
- SlcExecutionTestUtils.assertSlcExecutionStep(slcExec.getSteps().get(0),\r
- slcExecPersisted.getSteps().get(0));\r
- SlcExecutionTestUtils.assertSlcExecutionStep(slcExec.getSteps().get(1),\r
- slcExecPersisted.getSteps().get(1));\r
- }\r
-\r
- public void testModify() {\r
- SlcExecutionDao dao = getBean(SlcExecutionDao.class);\r
-\r
- // slcExecution Creation\r
- SlcExecution slcExec = SlcExecutionTestUtils.createSimpleSlcExecution();\r
- slcExec.getSteps().add(new SlcExecutionStep("LOG", "A log line"));\r
- slcExec.getSteps().add(new SlcExecutionStep("LOG", "Two log\nlines"));\r
-\r
- dao.create(slcExec);\r
-\r
- // slcExecution retrieval and update\r
- SlcExecution slcExecRetrieved = dao.getSlcExecution(slcExec.getUuid());\r
-\r
- List<String> logLineListStep0 = slcExecRetrieved.getSteps().get(0)\r
- .getLogLines();\r
- for (String logLine : logLineListStep0)\r
- logLine = logLine + "appended Log text";\r
-\r
- slcExecRetrieved.getSteps().get(0).setLogLines(logLineListStep0);\r
- slcExecRetrieved.getSteps().add(\r
- new SlcExecutionStep("LOG", "Three \n log \n lines"));\r
-\r
- dao.update(slcExecRetrieved);\r
-\r
- // updated slcExecution retrieval and comparison\r
- SlcExecution slcExecUpdated = dao.getSlcExecution(slcExec.getUuid());\r
-\r
- SlcExecutionTestUtils.assertSlcExecution(slcExecRetrieved,\r
- slcExecUpdated);\r
- assertEquals(3, slcExecUpdated.getSteps().size());\r
- SlcExecutionTestUtils.assertSlcExecutionStep(slcExecUpdated.getSteps()\r
- .get(0), slcExecRetrieved.getSteps().get(0));\r
- SlcExecutionTestUtils.assertSlcExecutionStep(slcExecUpdated.getSteps()\r
- .get(1), slcExecRetrieved.getSteps().get(1));\r
- SlcExecutionTestUtils.assertSlcExecutionStep(slcExecUpdated.getSteps()\r
- .get(2), slcExecRetrieved.getSteps().get(2));\r
- }\r
-\r
- @Override\r
- protected String getApplicationContextLocation() {\r
- return "org/argeo/slc/hibernate/applicationContext.xml";\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.hibernate.structure.tree;\r
-\r
-import org.argeo.slc.core.structure.tree.TreeSPath;\r
-import org.argeo.slc.dao.structure.tree.TreeSPathDao;\r
-import org.argeo.slc.unit.AbstractSpringTestCase;\r
-\r
-public class TreeSPathDaoHibernateTest extends AbstractSpringTestCase {\r
-\r
- public void testCreate() {\r
- TreeSPathDao treeSPathDao = getBean(TreeSPathDao.class);\r
-\r
- String pathParentStr = "/root/testParent";\r
- String pathStr = pathParentStr + "/test";\r
- TreeSPath path = TreeSPath.parseToCreatePath(pathStr);\r
- treeSPathDao.create(path);\r
-\r
- TreeSPath pathChild = treeSPathDao.getTreeSPath(pathStr);\r
- assertEquals(path, pathChild);\r
-\r
- TreeSPath pathParent = treeSPathDao.getTreeSPath(pathParentStr);\r
- assertEquals(path.getParent(), pathParent);\r
- }\r
-\r
- @Override\r
- protected String getApplicationContextLocation() {\r
- return "org/argeo/slc/hibernate/applicationContext.xml";\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.hibernate.structure.tree;\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.dao.structure.tree.TreeSPathDao;\r
-import org.argeo.slc.dao.structure.tree.TreeSRegistryDao;\r
-import org.argeo.slc.unit.AbstractSpringTestCase;\r
-\r
-public class TreeSRegistryDaoHibernateTest extends AbstractSpringTestCase {\r
-\r
- public void testCreate() {\r
- TreeSRegistryDao treeSRegistryDao = getBean(TreeSRegistryDao.class);\r
-\r
- TreeSPathDao treeSPathDao = (TreeSPathDao) getContext().getBean(\r
- "treeSPathDao");\r
-\r
- TreeSPath root = TreeSPath.parseToCreatePath("/root");\r
- TreeSPath path = root.createChild("test");\r
-\r
- treeSPathDao.create(root);\r
- treeSPathDao.create(path);\r
-\r
- TreeSRegistry registry = new TreeSRegistry();\r
- registry.setStatus(TreeSRegistry.STATUS_ACTIVE);\r
- String desc = "desc";\r
- registry.register(path, new SimpleSElement(desc));\r
-\r
- treeSRegistryDao.create(registry);\r
-\r
- TreeSRegistry registry2 = treeSRegistryDao.getActiveTreeSRegistry();\r
- SimpleSElement element = registry2.getElements().get(path);\r
- assertEquals(desc, element.getLabel());\r
- }\r
-\r
- @Override\r
- protected String getApplicationContextLocation() {\r
- return "org/argeo/slc/hibernate/applicationContext.xml";\r
- }\r
-\r
-}\r
+++ /dev/null
-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.UnitTestTreeUtil;\r
-\r
-public class CastorTestResultDaoHibernateTest extends AbstractSpringTestCase {\r
-\r
- public void testUnmarshallAndCreate() throws Exception {\r
- TreeTestResult ttr = TreeTestResultTestUtils\r
- .createCompleteTreeTestResult();\r
-\r
- StringResult result = new StringResult();\r
- getBean(Marshaller.class).marshal(ttr, result);\r
-\r
- StringSource source = new StringSource(result.toString());\r
- TreeTestResult ttrUnm = (TreeTestResult) getBean(Unmarshaller.class)\r
- .unmarshal(source);\r
-\r
- for (TreeSPath path : ttrUnm.getResultParts().keySet()) {\r
- log.debug("Path: " + path.getClass() + ": " + path);\r
- }\r
-\r
- TreeTestResultDao ttrDao = getBean(TreeTestResultDao.class);\r
- ttrDao.create(ttrUnm);\r
- TreeTestResult ttrPersist = ttrDao.getTestResult(ttr.getUuid());\r
-\r
- UnitTestTreeUtil.assertTreeTestResult(ttr, ttrPersist);\r
- }\r
-\r
- @Override\r
- protected String getApplicationContextLocation() {\r
- return "org/argeo/slc/hibernate/withCastor.xml";\r
- }\r
-\r
-}\r
+++ /dev/null
-package org.argeo.slc.hibernate.test.tree;\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.UnitTestTreeUtil;\r
-\r
-public class TreeTestResultCollectionDaoHibernateTest extends\r
- AbstractSpringTestCase {\r
-\r
- public void testScenario() {\r
- TreeTestResultDao ttrDao = getBean(TreeTestResultDao.class);\r
- TreeTestResultCollectionDao ttrcDao = getBean(TreeTestResultCollectionDao.class);\r
-\r
- String ttrcName = "testCollection";\r
-\r
- TreeTestResult ttr1 = TreeTestResultTestUtils\r
- .createCompleteTreeTestResult();\r
- ttrDao.create(ttr1);\r
-\r
- TreeTestResultCollection ttrc = new TreeTestResultCollection(ttrcName);\r
- ttrcDao.create(ttrc);\r
-\r
- ttrc.getResults().add(ttr1);\r
- ttrcDao.update(ttrc);\r
-\r
- TreeTestResult ttr2 = TreeTestResultTestUtils\r
- .createCompleteTreeTestResult();\r
- ttrDao.create(ttr2);\r
-\r
- ttrc.getResults().add(ttr2);\r
- ttrcDao.update(ttrc);\r
-\r
- ttrc.getResults().remove(ttr1);\r
- ttrcDao.update(ttrc);\r
-\r
- TreeTestResultCollection ttrcPersist = ttrcDao\r
- .getTestResultCollection(ttrcName);\r
- assertEquals(1, ttrcPersist.getResults().size());\r
- UnitTestTreeUtil.assertTreeTestResult(ttr2, ttrcPersist.getResults()\r
- .iterator().next());\r
- }\r
-\r
- @Override\r
- protected String getApplicationContextLocation() {\r
- return "org/argeo/slc/hibernate/applicationContext.xml";\r
- }\r
-\r
-}\r
+++ /dev/null
-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.UnitTestTreeUtil;\r
-\r
-public class TreeTestResultDaoHibernateTest extends AbstractSpringTestCase {\r
- private TreeTestResultDao testResultDao = null;\r
-\r
- @Override\r
- public void setUp() {\r
- testResultDao = (TreeTestResultDao) getContext().getBean(\r
- "testResultDao");\r
- }\r
-\r
- public void testCreate() {\r
-\r
- TreeTestResult ttr = createCompleteTreeTestResult();\r
- testResultDao.create(ttr);\r
-\r
- TreeTestResult ttrPersisted = (TreeTestResult) testResultDao\r
- .getTestResult(ttr.getUuid());\r
-\r
- UnitTestTreeUtil.assertTreeTestResult(ttr, ttrPersisted);\r
- }\r
-\r
- public void testUpdate() {\r
- TreeTestResult ttr = createCompleteTreeTestResult();\r
- testResultDao.create(ttr);\r
-\r
- TreeTestResult ttrUpdated = (TreeTestResult) testResultDao\r
- .getTestResult(ttr.getUuid());\r
-\r
- // Modifying ttrUpdated\r
-\r
- /**\r
- * this closeDate update commented because the assertTreeTestResult will\r
- * find a unexpected discrepancy in the date.\r
- * ttrUpdated.setCloseDate(new Date());\r
- */\r
-\r
- String pathStr = "/test";\r
- TreeSPath path = TreeSPath.parseToCreatePath(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
- ttrUpdated.notifyCurrentPath(registry, path);\r
-\r
- ttrUpdated.addResultPart(TreeTestResultTestUtils\r
- .createSimpleResultPartPassed());\r
- ttrUpdated.addResultPart(TreeTestResultTestUtils\r
- .createSimpleResultPartFailed());\r
- ttrUpdated.addResultPart(TreeTestResultTestUtils\r
- .createSimpleResultPartError());\r
-\r
- testResultDao.update(ttrUpdated);\r
-\r
- // comparison of ttrUpdated and ttrRetrieved\r
- TreeTestResult ttrRetrieved = (TreeTestResult) testResultDao\r
- .getTestResult(ttr.getUuid());\r
-\r
- UnitTestTreeUtil.assertTreeTestResult(ttrRetrieved, ttrUpdated);\r
- }\r
-\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
- ttr.notifyCurrentPath(registry, path);\r
- ttr.addResultPart(new SimpleResultPart(TestStatus.PASSED,"First test"));\r
- \r
- testResultDao.create(ttr);\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
- ttr.notifyCurrentPath(registry, path);\r
- ttr.addResultPart(new SimpleResultPart(TestStatus.PASSED,"Second test"));\r
- \r
- testResultDao.update(ttr);\r
- \r
- ttr.notifyCurrentPath(registry, path);\r
- ttr.addResultPart(new SimpleResultPart(TestStatus.PASSED,"Third test with same path"));\r
- \r
- testResultDao.update(ttr);\r
- \r
- ttr.close();\r
- \r
- testResultDao.close(ttr.getUuid(), ttr.getCloseDate());\r
- }\r
-\r
- @Override\r
- protected String getApplicationContextLocation() {\r
- return "org/argeo/slc/hibernate/applicationContext.xml";\r
- }\r
-\r
-}\r
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;
+import org.argeo.slc.unit.process.SlcExecutionTestUtils;
public class SlcExecutionWsIntegrationTest extends AbstractSpringTestCase {
private Log log = LogFactory.getLog(getClass());
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 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;
+++ /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/hibernate/spring/applicationContext.xml" />\r
-\r
- <bean id="sessionFactory"\r
- parent="slcDefault.sessionFactory.hibernateTestHSQL">\r
- </bean>\r
-\r
- <bean id="testResultDao"\r
- parent="slcTemplates.dao.testResultDao">\r
- <property name="sessionFactory" ref="sessionFactory" />\r
- </bean>\r
- <bean id="testResultCollectionDao"\r
- parent="slcTemplates.dao.testResultCollectionDao">\r
- <property name="sessionFactory" ref="sessionFactory" />\r
- </bean>\r
-\r
- <bean id="slcExecutionDao"\r
- parent="slcTemplates.dao.slcExecutionDao">\r
- <property name="sessionFactory" ref="sessionFactory" />\r
- </bean>\r
- \r
- <bean id="treeSPathDao"\r
- parent="slcTemplates.dao.treeSPathDao">\r
- <property name="sessionFactory" ref="sessionFactory" />\r
- </bean>\r
-\r
- <bean id="treeSRegistryDao"\r
- parent="slcTemplates.dao.treeSRegistryDao">\r
- <property name="sessionFactory" ref="sessionFactory" />\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 resource="applicationContext.xml" />\r
- <import\r
- resource="classpath:/org/argeo/slc/castor/spring/applicationContext.xml" />\r
-</beans>
\ No newline at end of file