From: Mathieu Baudier Date: Wed, 5 Sep 2012 14:37:56 +0000 (+0000) Subject: Remove deprecated APIs X-Git-Tag: argeo-slc-2.1.7~627 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=a0a151ee3a0aed29a3cb03d81e35d540ca9fdb03;p=gpl%2Fargeo-slc.git Remove deprecated APIs git-svn-id: https://svn.argeo.org/slc/trunk@5557 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/modules/org.argeo.slc.agent.jcr/META-INF/spring/jcr-osgi.xml b/modules/org.argeo.slc.agent.jcr/META-INF/spring/jcr-osgi.xml index 62fca103c..71891d599 100644 --- a/modules/org.argeo.slc.agent.jcr/META-INF/spring/jcr-osgi.xml +++ b/modules/org.argeo.slc.agent.jcr/META-INF/spring/jcr-osgi.xml @@ -20,10 +20,6 @@ interface="org.argeo.slc.execution.ExecutionModulesManager" /> - - - - - - - diff --git a/modules/org.argeo.slc.agent/pom.xml b/modules/org.argeo.slc.agent/pom.xml index 03fdcb0b3..22de3849f 100644 --- a/modules/org.argeo.slc.agent/pom.xml +++ b/modules/org.argeo.slc.agent/pom.xml @@ -17,7 +17,6 @@ *, - org.argeo.slc.core.test.tree diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlow.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlow.java index 237d05c96..20c3c7c4a 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlow.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/DefaultExecutionFlow.java @@ -23,14 +23,9 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.slc.SlcException; -import org.argeo.slc.core.structure.tree.TreeSPath; -import org.argeo.slc.core.structure.tree.TreeSRegistry; import org.argeo.slc.execution.ExecutionFlow; import org.argeo.slc.execution.ExecutionSpec; import org.argeo.slc.execution.ExecutionSpecAttribute; -import org.argeo.slc.structure.StructureAware; -import org.argeo.slc.structure.StructureRegistry; -import org.springframework.aop.scope.ScopedObject; import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.validation.MapBindingResult; @@ -47,7 +42,6 @@ public class DefaultExecutionFlow implements ExecutionFlow, InitializingBean, private List executables = new ArrayList(); private String path; - private StructureRegistry registry = new TreeSRegistry(); private Boolean failOnError = true; @@ -142,7 +136,6 @@ public class DefaultExecutionFlow implements ExecutionFlow, InitializingBean, runnable.run(); } - @SuppressWarnings(value = { "unchecked" }) public void afterPropertiesSet() throws Exception { if (path == null) { if (name.charAt(0) == '/') { @@ -152,11 +145,7 @@ public class DefaultExecutionFlow implements ExecutionFlow, InitializingBean, if (path != null) { for (Runnable executable : executables) { - if (executable instanceof StructureAware - && !(executable instanceof ScopedObject)) { - ((StructureAware) executable).notifyCurrentPath( - registry, new TreeSPath(path)); - } else if (executable instanceof DefaultExecutionFlow) { + if (executable instanceof DefaultExecutionFlow) { // so we don't need to have DefaultExecutionFlow // implementing StructureAware // FIXME: probably has side effects @@ -240,10 +229,6 @@ public class DefaultExecutionFlow implements ExecutionFlow, InitializingBean, this.path = path; } - public void setRegistry(StructureRegistry registry) { - this.registry = registry; - } - public Boolean getFailOnError() { return failOnError; } diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/tasks/SlcManager.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/tasks/SlcManager.java deleted file mode 100644 index adf65ed2d..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/tasks/SlcManager.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.core.execution.tasks; - -import java.lang.reflect.Method; -import java.util.UUID; - -import org.argeo.slc.SlcException; -import org.argeo.slc.deploy.DeployedSystem; -import org.argeo.slc.deploy.DeployedSystemManager; -import org.argeo.slc.process.SlcExecution; -import org.argeo.slc.process.SlcExecutionRelated; -import org.argeo.slc.process.SlcExecutionStep; -import org.argeo.slc.structure.StructureRegistry; - -/** Use {@link MethodCall} instead. */ -@Deprecated -public class SlcManager implements Runnable, SlcExecutionRelated { - private String uuid; - private String slcExecutionUuid; - private String slcExecutionStepUuid; - - private String action; - private DeployedSystemManager manager; - - public final void run() { - uuid = UUID.randomUUID().toString(); - executeActions(StructureRegistry.ALL); - } - - protected void executeActions(String mode) { - try { - Class[] argClasses = null; - Method method = manager.getClass().getMethod(action, argClasses); - Object[] argObjects = null; - method.invoke(manager, argObjects); - } catch (Exception e) { - throw new SlcException("Cannot execute action " + action - + " for manager " + manager, e); - } - } - - public void setAction(String action) { - this.action = action; - } - - public void setManager(DeployedSystemManager manager) { - this.manager = manager; - } - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public String getSlcExecutionUuid() { - return slcExecutionUuid; - } - - public void setSlcExecutionUuid(String slcExecutionUuid) { - this.slcExecutionUuid = slcExecutionUuid; - } - - public String getSlcExecutionStepUuid() { - return slcExecutionStepUuid; - } - - public void setSlcExecutionStepUuid(String slcExecutionStepUuid) { - this.slcExecutionStepUuid = slcExecutionStepUuid; - } - - public void notifySlcExecution(SlcExecution slcExecution) { - if (slcExecution != null) { - slcExecutionUuid = slcExecution.getUuid(); - SlcExecutionStep step = slcExecution.currentStep(); - if (step != null) { - slcExecutionStepUuid = step.getUuid(); - } - } - } -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/SimpleSElement.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/SimpleSElement.java deleted file mode 100644 index f04e982bc..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/SimpleSElement.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.core.structure; - -import java.io.Serializable; -import java.util.Map; -import java.util.TreeMap; - -import org.argeo.slc.core.structure.tree.TreeSPath; -import org.argeo.slc.structure.StructureElement; - -/** - * Basic implementation of StructureElement. - * - * @see TreeSPath - */ -public class SimpleSElement implements StructureElement, Serializable { - private static final long serialVersionUID = -7012193125005818900L; - /** For ORM */ - private Long tid; - private String label; - private Map tags = new TreeMap(); - - /** For ORM */ - public SimpleSElement() { - } - - /** Constructor */ - public SimpleSElement(String label) { - this.label = label; - } - - /** Constructor */ - public SimpleSElement(String label, String defaultLabel) { - this(label != null ? label : defaultLabel); - } - - /** Constructor */ - public SimpleSElement(SimpleSElement sElement) { - setLabel(sElement.getLabel()); - setTags(new TreeMap(sElement.getTags())); - } - - public String getLabel() { - return label; - } - - /** Sets the label. */ - public void setLabel(String label) { - this.label = label; - } - - public Long getTid() { - return tid; - } - - void setTid(Long tid) { - this.tid = tid; - } - - public Map getTags() { - return tags; - } - - public void setTags(Map tags) { - this.tags = tags; - } - - @Override - public SimpleSElement clone() { - return new SimpleSElement(this); - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/package.html b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/package.html deleted file mode 100644 index d9bab8a55..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/package.html +++ /dev/null @@ -1,6 +0,0 @@ - - - -SLC Structure framework allowing to uniquely reference actions. - - \ No newline at end of file diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSPath.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSPath.java deleted file mode 100644 index 69492b240..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSPath.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.core.structure.tree; - -import java.io.Serializable; -import java.util.List; -import java.util.StringTokenizer; -import java.util.Vector; - -import org.argeo.slc.SlcException; -import org.argeo.slc.structure.StructurePath; -import org.argeo.slc.structure.StructureRegistry; - -/** - * Path for tree based StructureRegistry implementations. - */ -public class TreeSPath implements StructurePath, Comparable, - Serializable { - private static final long serialVersionUID = -110121029180848183L; - - /** Default character to use a separator: /. */ - private static Character DEFAULT_SEPARATOR = '/'; - - private Character separator = DEFAULT_SEPARATOR; - - private String asUniqueString; - - /** For ORM */ - private Long tid; - - public TreeSPath() { - - } - - public TreeSPath(String asUniqueString) { - this.asUniqueString = checkAndFormatPath(asUniqueString); - } - - public String getAsUniqueString() { - return asUniqueString; - } - - /** - * Sets all the required data from a string. ATTENTION: the path is - * not checked for performance reason. This method should be used only by - * ORM/OXM frameworks. Use constructor to create immutable tree structure - * paths. - */ - public void setAsUniqueString(String str) { - this.asUniqueString = str; - } - - /** The separator actually used by this path. */ - public Character getSeparator() { - return separator; - } - - /** Gets the parent path. */ - public TreeSPath getParent() { - int lastSep = getAsUniqueString().lastIndexOf(separator); - if (lastSep < 1) { - return null; - } - String parentUniqueString = getAsUniqueString().substring(0, lastSep); - return new TreeSPath(parentUniqueString); - } - - /** Gets the name part of the path. */ - public String getName() { - int lastSep = getAsUniqueString().lastIndexOf(separator); - return getAsUniqueString().substring(lastSep + 1); - } - - /** Create a path without parent. */ - public static TreeSPath createRootPath(String name) { - if (name.indexOf(DEFAULT_SEPARATOR) >= 0) { - throw new SlcException("Name cannot contain " + DEFAULT_SEPARATOR); - } - return new TreeSPath('/' + name); - } - - /** Create a child . */ - public TreeSPath createChild(String name) { - if (name.indexOf(separator) > -1) { - throw new SlcException("Tree path name '" + name - + "' contains separator character " + separator); - } - return new TreeSPath(getAsUniqueString() + '/' + name); - } - - /** - * Parses a string to a path. - * - * @deprecated use constructor instead - */ - public static TreeSPath parseToCreatePath(String path) { - return parseToCreatePath(path, DEFAULT_SEPARATOR); - } - - protected String checkAndFormatPath(String str) { - if (str.length() < 2) { - throw new SlcException("Path " + str + " is not short"); - } - if (str.charAt(0) != separator) { - throw new SlcException("Path " + str + " have to start with " - + separator); - } - - StringBuffer buf = new StringBuffer(str.length() + 5); - StringTokenizer st = new StringTokenizer(str, separator.toString()); - while (st.hasMoreTokens()) { - buf.append(separator).append(st.nextToken()); - } - return buf.toString(); - } - - /** - * Parses a string to a path. - * - * @deprecated use constructor instead - */ - public static TreeSPath parseToCreatePath(String path, Character separator) { - return new TreeSPath(path); - } - - /** Lists the children from a registry. */ - public List listChildren(StructureRegistry registry) { - return listChildrenPaths(registry, this); - } - - /** Lists the children from a given path from a registry. */ - public static List listChildrenPaths( - StructureRegistry registry, TreeSPath path) { - List paths = new Vector(); - List allPaths = registry.listPaths(); - for (TreeSPath pathT : allPaths) { - if (pathT.getParent() != null && pathT.getParent().equals(path)) { - paths.add(pathT); - } - } - return paths; - } - - /** Gets the root tree path of this path. */ - public TreeSPath getRoot() { - TreeSPath root = this; - while (root.getParent() != null) { - root = root.getParent(); - } - return root; - } - - /** Depth of this path. */ - public Integer getDepth() { - return depthImpl(this); - } - - protected int depthImpl(TreeSPath path) { - if (path.getParent() == null) { - return 1; - } else { - return depthImpl(path.getParent()) + 1; - } - } - - public List getHierarchyAsList() { - List lst = new Vector(); - addParentToList(lst, this); - lst.add(this); - return lst; - } - - protected void addParentToList(List lst, TreeSPath current) { - TreeSPath parent = current.getParent(); - if (parent != null) { - addParentToList(lst, parent); - lst.add(parent); - } - } - - @Override - public String toString() { - return getAsUniqueString(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof StructurePath) { - StructurePath path = (StructurePath) obj; - return getAsUniqueString().equals(path.getAsUniqueString()); - } - return false; - } - - @Override - public int hashCode() { - return getAsUniqueString().hashCode(); - } - - public int compareTo(StructurePath o) { - return getAsUniqueString().compareTo(o.getAsUniqueString()); - } - - public Long getTid() { - return tid; - } - - void setTid(Long tid) { - this.tid = tid; - } -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSRegistry.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSRegistry.java deleted file mode 100644 index 9553d9909..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSRegistry.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.core.structure.tree; - -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.Vector; - -import org.argeo.slc.UnsupportedException; -import org.argeo.slc.core.structure.SimpleSElement; -import org.argeo.slc.structure.StructureElement; -import org.argeo.slc.structure.StructureRegistry; - -/** Tree based implementation of a structure registry. */ -public class TreeSRegistry implements StructureRegistry { - /** For ORM */ - private Long tid; - private Map elements = new TreeMap(); - - private String mode = StructureRegistry.ALL; - - private List activePaths; - - @SuppressWarnings("unchecked") - public T getElement(TreeSPath path) { - return (T) elements.get(path); - } - - public List listElements() { - return new Vector(elements.values()); - } - - public List listPaths() { - return new Vector(elements.keySet()); - } - - public void register(TreeSPath path, StructureElement element) { - if (path == null) - throw new UnsupportedException("Cannot register under a null path."); - if (element == null) - throw new UnsupportedException( - "Cannot register null element for path " + path); - if (element.getLabel() == null) - throw new UnsupportedException( - "Cannot register an element with null label for path " - + path); - - final SimpleSElement simpleSElement; - if (element instanceof SimpleSElement) { - simpleSElement = (SimpleSElement) element; - } else { - simpleSElement = new SimpleSElement(element.getLabel()); - } - - elements.put(path, simpleSElement); - } - - public String getMode() { - return mode; - } - - public void setMode(String mode) { - this.mode = mode; - } - - public List getActivePaths() { - return activePaths; - } - - public void setActivePaths(List activePaths) { - this.activePaths = activePaths; - } - - /** Gets the elements. */ - public Map getElements() { - return elements; - } - - /** Sets the elements (for ORM). */ - public void setElements(Map elements) { - this.elements = elements; - } - - Long getTid() { - return tid; - } - - void setTid(Long tid) { - this.tid = tid; - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSRelated.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSRelated.java deleted file mode 100644 index 4179a5088..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSRelated.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.core.structure.tree; - -import org.argeo.slc.structure.StructureAware; -import org.argeo.slc.structure.StructureElement; -import org.argeo.slc.structure.StructureRegistry; - -public interface TreeSRelated extends StructureAware { - public TreeSPath getBasePath(); - - public StructureRegistry getRegistry(); - - public StructureElement getStructureElement(String key); -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSRelatedHelper.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSRelatedHelper.java deleted file mode 100644 index acd4dbffc..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSRelatedHelper.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.core.structure.tree; - -import org.argeo.slc.core.structure.SimpleSElement; -import org.argeo.slc.structure.StructureAware; -import org.argeo.slc.structure.StructureElement; -import org.argeo.slc.structure.StructureRegistry; - -/** - * Provides default implementations of some methods of TreeSRelated - * . - */ -public abstract class TreeSRelatedHelper implements TreeSRelated { - private TreeSPath basePath; - private StructureRegistry registry; - - // private ThreadLocal basePath = new ThreadLocal(); - // private ThreadLocal> registry = new - // ThreadLocal>(); - - public TreeSPath getBasePath() { - return basePath; - } - - public StructureRegistry getRegistry() { - return registry; - } - - public void notifyCurrentPath(StructureRegistry registry, - TreeSPath path) { - this.basePath = path; - this.registry = registry; - } - - public StructureElement getStructureElement(String key) { - return new SimpleSElement(key); - } - - /** - * Checks wether the object is {@link StructureAware} and forward path and - * registry. null safe for both arguments. - */ - @SuppressWarnings(value = { "unchecked" }) - protected void forwardPath(Object obj, String childName) { - if (obj == null) - return; - - if (obj instanceof StructureAware && basePath != null) { - TreeSPath path; - if (childName != null) - path = basePath.createChild(childName); - else - path = basePath; - - ((StructureAware) obj).notifyCurrentPath(registry, path); - } - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/package.html b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/package.html deleted file mode 100644 index a2a51e4d9..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/package.html +++ /dev/null @@ -1,6 +0,0 @@ - - - -Tree-based implementation of the SLC structure framework. - - \ No newline at end of file diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/BasicTestDefinition.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/BasicTestDefinition.java index d44a0be3c..b4963a0ee 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/BasicTestDefinition.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/BasicTestDefinition.java @@ -16,7 +16,6 @@ package org.argeo.slc.core.test; import org.argeo.slc.SlcException; -import org.argeo.slc.core.structure.tree.TreeSRelatedHelper; import org.argeo.slc.core.test.context.ContextUtils; import org.argeo.slc.test.IncompatibleTestDataException; import org.argeo.slc.test.TestData; @@ -27,8 +26,7 @@ import org.argeo.slc.test.TestStatus; import org.argeo.slc.test.context.ContextAware; /** Understands basic test data and context aware test data. */ -public class BasicTestDefinition extends TreeSRelatedHelper implements - TestDefinition { +public class BasicTestDefinition implements TestDefinition { public void execute(TestRun testRun) { if (testRun. getTestData() instanceof BasicTestData) { @@ -55,7 +53,7 @@ public class BasicTestDefinition extends TreeSRelatedHelper implements } else if (testRun. getTestData() instanceof ContextAware) { TestData testData = testRun.getTestData(); ContextUtils.compareReachedExpected((ContextAware) testData, - testRun.getTestResult(), this); + testRun.getTestResult()); } else { throw new IncompatibleTestDataException(testRun); } diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestResult.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestResult.java index b3c69f737..812caef2d 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestResult.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestResult.java @@ -97,4 +97,8 @@ public class SimpleTestResult implements TestResult { return attributes; } + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + } diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestRun.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestRun.java index e9b83995b..a4d396638 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestRun.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/SimpleTestRun.java @@ -17,13 +17,7 @@ package org.argeo.slc.core.test; import java.util.UUID; -import org.argeo.slc.core.structure.tree.TreeSPath; import org.argeo.slc.deploy.DeployedSystem; -import org.argeo.slc.process.SlcExecution; -import org.argeo.slc.process.SlcExecutionRelated; -import org.argeo.slc.process.SlcExecutionStep; -import org.argeo.slc.structure.StructureAware; -import org.argeo.slc.structure.StructureRegistry; import org.argeo.slc.test.ExecutableTestRun; import org.argeo.slc.test.TestData; import org.argeo.slc.test.TestDefinition; @@ -34,39 +28,23 @@ import org.argeo.slc.test.WritableTestRun; * A basic bean implementation of a WritableTestRun, holding * references to the various parts of a test run. */ -@SuppressWarnings("deprecation") -public class SimpleTestRun implements WritableTestRun, ExecutableTestRun, - SlcExecutionRelated, StructureAware { +public class SimpleTestRun implements WritableTestRun, ExecutableTestRun { private String uuid; private String slcExecutionUuid; private String slcExecutionStepUuid; - private TreeSPath path; - private StructureRegistry registry; - private DeployedSystem deployedSystem; private TestData testData; private TestDefinition testDefinition; private TestResult testResult; /** Executes the underlying test definition. */ - @SuppressWarnings("unchecked") public void run() { uuid = UUID.randomUUID().toString(); if (testResult != null) testResult.notifyTestRun(this); - // Structure - if (testResult != null && path != null - && testResult instanceof StructureAware) - ((StructureAware) testResult).notifyCurrentPath( - registry, path); - - if (path != null && testDefinition instanceof StructureAware) - ((StructureAware) testDefinition).notifyCurrentPath( - registry, path); - testDefinition.execute(this); } @@ -129,22 +107,4 @@ public class SimpleTestRun implements WritableTestRun, ExecutableTestRun, public void setSlcExecutionStepUuid(String slcExecutionStepUuid) { this.slcExecutionStepUuid = slcExecutionStepUuid; } - - @Deprecated - public void notifySlcExecution(SlcExecution slcExecution) { - if (slcExecution != null) { - slcExecutionUuid = slcExecution.getUuid(); - SlcExecutionStep step = slcExecution.currentStep(); - if (step != null) { - slcExecutionStepUuid = step.getUuid(); - } - } - } - - public void notifyCurrentPath(StructureRegistry registry, - TreeSPath path) { - this.registry = registry; - this.path = path; - } - } diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/context/ContextUtils.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/context/ContextUtils.java index 0d4ab6034..ce1b000f3 100644 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/context/ContextUtils.java +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/context/ContextUtils.java @@ -20,13 +20,7 @@ import java.util.TreeMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - -import org.argeo.slc.core.structure.tree.TreeSPath; -import org.argeo.slc.core.structure.tree.TreeSRelated; import org.argeo.slc.core.test.SimpleResultPart; -import org.argeo.slc.structure.StructureAware; -import org.argeo.slc.structure.StructureElement; -import org.argeo.slc.structure.StructureRegistry; import org.argeo.slc.test.TestResult; import org.argeo.slc.test.TestStatus; import org.argeo.slc.test.context.ContextAware; @@ -36,7 +30,7 @@ public class ContextUtils { private final static Log log = LogFactory.getLog(ContextUtils.class); public static void compareReachedExpected(ContextAware contextAware, - TestResult testResult, TreeSRelated treeSRelated) { + TestResult testResult) { for (String key : contextAware.getExpectedValues().keySet()) { // Compare expected values with reached ones @@ -49,9 +43,6 @@ public class ContextUtils { continue; } - // Register in structure - registerInStructure(testResult, treeSRelated, key); - if (contextAware.getValues().containsKey(key)) { Object reachedValue = contextAware.getValues().get(key); @@ -74,42 +65,6 @@ public class ContextUtils { TestStatus.FAILED, "No value reached for key '" + key + "'")); } - resetStructure(testResult, treeSRelated); - } - } - - @SuppressWarnings("unchecked") - private static void registerInStructure(TestResult testResult, - TreeSRelated treeSRelated, String key) { - if (treeSRelated != null) { - if (treeSRelated.getBasePath() != null) { - TreeSPath path = treeSRelated.getBasePath().createChild(key); - StructureRegistry registry = treeSRelated - .getRegistry(); - final StructureElement element = treeSRelated - .getStructureElement(key); - registry.register(path, element); - if (testResult instanceof StructureAware) - ((StructureAware) testResult).notifyCurrentPath( - registry, path); - - if (log.isDebugEnabled()) - log.debug("Checking key " + key + " for path " + path); - } - } - } - - @SuppressWarnings("unchecked") - private static void resetStructure(TestResult testResult, - TreeSRelated treeSRelated) { - if (treeSRelated != null) { - if (treeSRelated.getBasePath() != null) { - if (testResult instanceof StructureAware) { - ((StructureAware) testResult).notifyCurrentPath( - treeSRelated.getRegistry(), treeSRelated - .getBasePath()); - } - } } } diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/CompositeTreeTestDefinition.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/CompositeTreeTestDefinition.java deleted file mode 100644 index cdc7846a5..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/CompositeTreeTestDefinition.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.core.test.tree; - -import java.util.List; -import java.util.Vector; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.slc.core.structure.SimpleSElement; -import org.argeo.slc.core.structure.tree.TreeSPath; -import org.argeo.slc.structure.StructureAware; -import org.argeo.slc.structure.StructureElement; -import org.argeo.slc.structure.StructureElementProvider; -import org.argeo.slc.structure.StructureRegistry; -import org.argeo.slc.test.TestDefinition; -import org.argeo.slc.test.TestResult; -import org.argeo.slc.test.TestRun; - -/** - * Collection of test definitions propagating tree structure information to its - * children. - */ -public class CompositeTreeTestDefinition implements TestDefinition, - StructureAware { - private Log log = LogFactory.getLog(CompositeTreeTestDefinition.class); - - private List tasks = null; - private List taskPaths = null; - private TreeSPath path; - private StructureRegistry registry; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void execute(TestRun testRun) { - if (log.isTraceEnabled()) - log.trace("Execute sequence of test definitions..."); - - int i = 0; - for (TestDefinition task : tasks) { - TestResult result = testRun.getTestResult(); - if (result instanceof StructureAware) { - ((StructureAware) result).notifyCurrentPath(registry, - taskPaths.get(i)); - } - - task.execute(testRun); - - // Reset current path in case it has been changed - if (result instanceof StructureAware) { - ((StructureAware) result).notifyCurrentPath(registry, path); - } - i++; - } - } - - /** Sets the list of children test definitions */ - public void setTasks(List tasks) { - this.tasks = tasks; - if (tasks != null) { - taskPaths = new Vector(); - } - } - - @SuppressWarnings("unchecked") - public void notifyCurrentPath(StructureRegistry registry, - TreeSPath path) { - this.path = path; - this.registry = registry; - - // clear task paths - taskPaths.clear(); - - Integer count = 0; - for (TestDefinition task : tasks) { - final StructureElement element; - if (task instanceof StructureElementProvider) { - element = ((StructureElementProvider) task) - .createStructureElement(); - } else { - element = new SimpleSElement("[no desc]"); - } - TreeSPath taskPath = this.path.createChild(count.toString()); - registry.register(taskPath, element); - taskPaths.add(taskPath); - if (task instanceof StructureAware) { - ((StructureAware) task).notifyCurrentPath(registry, - taskPath); - } - count++; - } - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/PartSubList.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/PartSubList.java deleted file mode 100644 index b2f6a7af7..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/PartSubList.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.core.test.tree; - -import java.io.Serializable; -import java.util.List; -import java.util.Vector; - -import org.argeo.slc.test.TestResultPart; -import org.argeo.slc.test.TestStatus; - -/** - * List of TestResultPart. It can be used to build complex - * TestResult affording the possibility to a - * TestDefinition to add a list of result part under the same - * StructurePath. - * - * @see TreeTestResult - */ -public class PartSubList implements Serializable { - private static final long serialVersionUID = -5308754827565759844L; - - /** For ORM */ - private Long tid; - - private List parts = new Vector(); - - /** Gets the result parts. */ - public List getParts() { - return parts; - } - - /** Sets the result parts. */ - public void setParts(List parts) { - this.parts = parts; - } - - Long getTid() { - return tid; - } - - void setTid(Long tid) { - this.tid = tid; - } - - public Boolean getIsPassed() { - for (TestResultPart part : parts) { - if (part.getStatus() != TestStatus.PASSED) { - return false; - } - } - return true; - } -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/ResultAttributes.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/ResultAttributes.java deleted file mode 100644 index 1795708fa..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/ResultAttributes.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.core.test.tree; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; - -import org.argeo.slc.core.attachment.SimpleAttachment; - -public class ResultAttributes implements Serializable { - private static final long serialVersionUID = 1L; - - private String uuid = null; - private Date closeDate = null; - private Map attributes = new Hashtable(); - private List attachments = new ArrayList(); - - public ResultAttributes() { - super(); - } - - public ResultAttributes(TreeTestResult ttr) { - super(); - this.uuid = ttr.getUuid(); - this.attributes = ttr.getAttributes(); - this.closeDate = ttr.getCloseDate(); - this.attachments = ttr.getAttachments(); - } - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public Map getAttributes() { - return attributes; - } - - public void setAttributes(Map attributes) { - this.attributes = attributes; - } - - public Date getCloseDate() { - return closeDate; - } - - public void setCloseDate(Date closeDate) { - this.closeDate = closeDate; - } - - public List getAttachments() { - return attachments; - } - - public void setAttachments(List attachments) { - this.attachments = attachments; - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java deleted file mode 100644 index f102ae6ab..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResult.java +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.core.test.tree; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.SortedMap; -import java.util.TreeMap; -import java.util.UUID; -import java.util.Vector; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.slc.SlcException; -import org.argeo.slc.core.attachment.Attachment; -import org.argeo.slc.core.attachment.AttachmentsEnabled; -import org.argeo.slc.core.attachment.SimpleAttachment; -import org.argeo.slc.core.structure.tree.TreeSPath; -import org.argeo.slc.structure.StructureAware; -import org.argeo.slc.structure.StructureElement; -import org.argeo.slc.structure.StructureRegistry; -import org.argeo.slc.test.TestResult; -import org.argeo.slc.test.TestResultListener; -import org.argeo.slc.test.TestResultPart; -import org.argeo.slc.test.TestRun; -import org.argeo.slc.test.TestRunAware; - -/** - * Complex implementation of a test result compatible with a tree based - * structure. - */ -public class TreeTestResult implements TestResult, StructureAware, - Comparable, AttachmentsEnabled, Serializable { - - private static final long serialVersionUID = 1L; - private final static Log log = LogFactory.getLog(TreeTestResult.class); - - // Persistence data - private String uuid = UUID.randomUUID().toString(); - private Date closeDate; - - private SortedMap resultParts = new TreeMap(); - private SortedMap elements = new TreeMap(); - private List attachments = new ArrayList(); - - // Headers. Used to accelerate request on a specific test result. - private SortedMap attributes = new TreeMap(); - - // Runtime Data - private TreeSPath currentPath; - private transient TestRun currentTestRun; - private Boolean warnIfAlreadyClosed = true; - private Boolean strictChecks = false; - // TODO is it really necessary closeDate == null ? - private Boolean isClosed = false; - - private Boolean cache = true; - - private transient List> listeners = new Vector>(); - - /** Sets the list of listeners. */ - public void setListeners(List> listeners) { - this.listeners = listeners; - } - - public void addResultPart(TestResultPart part) { - if (isClosed) - notifyIssue( - "Trying to add result parts to an already closed result," - + " consider changing the scope of this test result:" - + " you are referencing the same stored data with each new call.", - null); - - if (currentPath == null) - throw new SlcException("No current path set."); - - if (cache) { - PartSubList subList = resultParts.get(currentPath); - if (subList == null) { - subList = new PartSubList(); - resultParts.put(currentPath, subList); - } - subList.getParts().add(part); - } - - if (part instanceof TestRunAware && currentTestRun != null) { - ((TestRunAware) part).notifyTestRun(currentTestRun); - } - - // notify listeners - synchronized (listeners) { - for (TestResultListener listener : listeners) { - listener.resultPartAdded(this, part); - } - } - } - - protected void notifyIssue(String msg, Exception e) { - if (strictChecks) - throw new SlcException(msg, e); - else - log.error(msg, e); - } - - public void notifyCurrentPath(StructureRegistry registry, - TreeSPath path) { - if (!cache) - return; - - if (registry != null) { - for (TreeSPath p : path.getHierarchyAsList()) { - if (!elements.containsKey(p)) { - StructureElement elem = registry.getElement(p); - if (elem != null) { - elements.put(p, elem); - } - } else { - if (log.isTraceEnabled()) - log.trace("An element is already registered for path " - + p + " and was not updated"); - } - - } - } - - currentPath = path; - } - - /** Gets the current path. */ - public TreeSPath getCurrentPath() { - return currentPath; - } - - /** Gets all the results structured as a map of PartSubLists. */ - public SortedMap getResultParts() { - return resultParts; - } - - /** - * Used by ORM systems. Changed to public in order to enable jcr persistence - */ - public void setResultParts(SortedMap resultParts) { - this.resultParts = resultParts; - } - - public void close() { - if (resultParts.size() == 0) { - if (log.isTraceEnabled()) - log.trace("Test Result #" + getUuid() - + " contains no results, no need to close it."); - return; - } - - if (isClosed) { - if (warnIfAlreadyClosed) - log.warn("Test Result #" + getUuid() - + " already closed. Doing nothing."); - return; - } - - closeDate = new Date(); - - synchronized (listeners) { - for (TestResultListener listener : listeners) { - listener.close(this); - } - } - isClosed = true; - - if (log.isTraceEnabled()) - log.trace("Test Result " + getUuid() + " closed."); - } - - public Date getCloseDate() { - return closeDate; - } - - /** Sets the close date (for ORM) */ - public void setCloseDate(Date closeDate) { - this.closeDate = closeDate; - } - - public void notifyTestRun(TestRun testRun) { - currentTestRun = testRun; - } - - public SortedMap getElements() { - return elements; - } - - public void setElements(SortedMap pathNames) { - this.elements = pathNames; - } - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public SortedMap getRelatedElements( - TreeSPath path) { - if (path == null) - throw new SlcException( - "Cannot retrieve element for a null path in result #" - + uuid); - - SortedMap relatedElements = new TreeMap(); - List hierarchy = path.getHierarchyAsList(); - for (TreeSPath currPath : elements.keySet()) { - if (hierarchy.contains(currPath)) { - relatedElements.put(currPath, elements.get(currPath)); - } - } - return relatedElements; - } - - public TestRun getCurrentTestRun() { - return currentTestRun; - } - - public int compareTo(TreeTestResult ttr2) { - TreeTestResult ttr1 = this; - if (ttr1.getCloseDate() != null && ttr2.getCloseDate() != null) { - if (ttr1.getCloseDate().equals(ttr2.getCloseDate())) - return compareUuid(ttr1, ttr2); - else - return -ttr1.getCloseDate().compareTo(ttr2.getCloseDate()); - } else if (ttr1.getCloseDate() != null && ttr2.getCloseDate() == null) { - return 1; - } else if (ttr1.getCloseDate() == null && ttr2.getCloseDate() != null) { - return -1; - } else { - return compareUuid(ttr1, ttr2); - } - } - - protected int compareUuid(TestResult ttr1, TestResult ttr2) { - if (ttr1.getUuid() == null || ttr2.getUuid() == null) - throw new SlcException( - "Cannot compare tree test result with null uuid"); - else { - if (ttr1.getUuid().equals(ttr2.getUuid())) - return 0; - return ttr1.getUuid().compareTo(ttr2.getUuid()); - } - } - - public boolean equals(Object obj) { - if (obj instanceof TestResult) - return compareUuid(this, ((TestResult) obj)) == 0; - else - return false; - } - - public int hashCode() { - if (uuid != null) - return uuid.hashCode(); - else - return super.hashCode(); - } - - public SortedMap getAttributes() { - return attributes; - } - - public void setAttributes(SortedMap attributes) { - this.attributes = attributes; - } - - public void setWarnIfAlreadyClosed(Boolean warnIfAlreadyClosed) { - this.warnIfAlreadyClosed = warnIfAlreadyClosed; - } - - public List getAttachments() { - return attachments; - } - - public void setAttachments(List attachments) { - this.attachments = attachments; - } - - public void addAttachment(Attachment attachment) { - attachments.add((SimpleAttachment) attachment); - synchronized (listeners) { - for (TestResultListener listener : listeners) { - if (listener instanceof TreeTestResultListener) - ((TreeTestResultListener) listener).addAttachment(this, - attachment); - } - } - } - - public void setStrictChecks(Boolean strictChecks) { - this.strictChecks = strictChecks; - } - - /** - * Whether information should be stored in thsi object or simply forwarded - * to teh listeners. - */ - public void setCache(Boolean cache) { - this.cache = cache; - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultCollection.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultCollection.java deleted file mode 100644 index 7e88c82d3..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultCollection.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.core.test.tree; - -import java.util.SortedSet; -import java.util.TreeSet; - -public class TreeTestResultCollection implements - Comparable { - private String id; - private SortedSet results = new TreeSet(); - - public TreeTestResultCollection() { - } - - public TreeTestResultCollection(String id) { - this.id = id; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public SortedSet getResults() { - return results; - } - - public void setResults(SortedSet results) { - this.results = results; - } - - public int compareTo(TreeTestResultCollection o) { - return getId().compareTo(o.getId()); - } - - @Override - public boolean equals(Object o) { - if (o instanceof TreeTestResultCollection) { - return getId().equals(((TreeTestResultCollection) o).getId()); - } - return false; - } -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultListener.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultListener.java deleted file mode 100644 index 709dd6194..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.core.test.tree; - -import org.argeo.slc.core.attachment.Attachment; -import org.argeo.slc.test.TestResultListener; - -public interface TreeTestResultListener extends - TestResultListener { - public void addAttachment(TreeTestResult testResult, - Attachment attachment); -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultLogger.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultLogger.java deleted file mode 100644 index d8ab7fc36..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/TreeTestResultLogger.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.core.test.tree; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.slc.core.attachment.Attachment; -import org.argeo.slc.test.TestResultPart; -import org.argeo.slc.test.TestStatus; - -/** - * Listener logging tree-based test results to the underlying logging system. - * - * @see TreeTestResult - * - */ -public class TreeTestResultLogger implements TreeTestResultListener { - - private static Log log = LogFactory.getLog(TreeTestResultLogger.class); - - private Boolean logExceptionMessages = false; - - public void resultPartAdded(TreeTestResult testResult, - TestResultPart testResultPart) { - String msg = testResultPart + " - " + testResult.getUuid() + ":" - + testResult.getCurrentPath(); - if (testResultPart.getStatus().equals(TestStatus.PASSED)) { - log.info(msg); - } else if (testResultPart.getStatus().equals(TestStatus.FAILED)) { - log.warn(msg); - } else if (testResultPart.getStatus().equals(TestStatus.ERROR)) { - if (logExceptionMessages) - msg = msg + "\n" + testResultPart.getExceptionMessage(); - - log.error(msg); - - if (!logExceptionMessages || log.isDebugEnabled()) - log.debug(testResultPart.getExceptionMessage()); - - } else { - log.error("Unknow test status: " + msg); - } - } - - public void close(TreeTestResult testResult) { - log.info("Test result " + testResult.getUuid() + " closed."); - } - - public void setLogExceptionMessages(Boolean logExceptionMessages) { - this.logExceptionMessages = logExceptionMessages; - } - - public void addAttachment(TreeTestResult treeTestResult, - Attachment attachment) { - if (log.isDebugEnabled()) - log.debug("Attachment " + attachment + " added to " - + treeTestResult.getUuid()); - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/package.html b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/package.html deleted file mode 100644 index 8ad12037e..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/test/tree/package.html +++ /dev/null @@ -1,6 +0,0 @@ - - - -Extension of SLC Test integrating tree-based structure. - - \ No newline at end of file diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/dao/test/tree/TreeTestResultCollectionDao.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/dao/test/tree/TreeTestResultCollectionDao.java deleted file mode 100644 index 0469138a6..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/dao/test/tree/TreeTestResultCollectionDao.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.dao.test.tree; - -import java.util.List; -import java.util.Map; -import java.util.SortedSet; - -import org.argeo.slc.core.test.tree.ResultAttributes; -import org.argeo.slc.core.test.tree.TreeTestResult; -import org.argeo.slc.core.test.tree.TreeTestResultCollection; - -/** Collections DAO */ -public interface TreeTestResultCollectionDao { - public void create(TreeTestResultCollection ttrCollection); - - public void update(TreeTestResultCollection ttrCollection); - - public void delete(TreeTestResultCollection ttrCollection); - - public TreeTestResultCollection getTestResultCollection(String id); - - /** Lists all collections */ - public SortedSet listCollections(); - - /** - * Lists only result ids and attributes of the results belonging to these - * collection, or all results if id is null. - */ - public List listResultAttributes(String collectionId); - - /** Lists results filtering based on the arguments. */ - public List listResults(String collectionId, - Map attributes); - - /** Adds a result to a collection. */ - public void addResultToCollection(TreeTestResultCollection ttrc, - String resultUuid); - - /** Removes a result from a collection. */ - public void removeResultFromCollection(TreeTestResultCollection ttrc, - String resultUuid); - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/dao/test/tree/TreeTestResultDao.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/dao/test/tree/TreeTestResultDao.java deleted file mode 100644 index 7399e8a1f..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/dao/test/tree/TreeTestResultDao.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.dao.test.tree; - -import java.util.List; -import java.util.Map; -import java.util.SortedMap; - -import org.argeo.slc.core.attachment.SimpleAttachment; -import org.argeo.slc.core.structure.tree.TreeSPath; -import org.argeo.slc.core.test.SimpleResultPart; -import org.argeo.slc.core.test.tree.TreeTestResult; -import org.argeo.slc.dao.test.TestResultDao; -import org.argeo.slc.structure.StructureElement; - -/** - * Adds DAO features specific to tree test result. - * - * @see TreeTestResult - */ -@Deprecated -public interface TreeTestResultDao extends TestResultDao { - /** Lists results containing this path */ - public List listResults(TreeSPath path); - - /** Adds a result part related to this path */ - public void addResultPart(String testResultId, TreeSPath path, - SimpleResultPart resultPart, - Map relatedElements); - - /** Update attributes */ - public void updateAttributes(String testResultId, - SortedMap attributes); - - public void addAttachment(String testResultId, SimpleAttachment attachment); -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/dao/test/tree/TreeTestResultPersister.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/dao/test/tree/TreeTestResultPersister.java deleted file mode 100644 index 06edee59a..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/dao/test/tree/TreeTestResultPersister.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.dao.test.tree; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.argeo.slc.core.test.tree.TreeTestResult; -import org.argeo.slc.test.TestResultListener; -import org.argeo.slc.test.TestResultPart; - -/** - * Listener persisting tree-based results. - * - * @see TreeTestResult - */ -@Deprecated -public class TreeTestResultPersister implements - TestResultListener { - private static Log log = LogFactory.getLog(TreeTestResultPersister.class); - - private TreeTestResultDao testResultDao; - - public void resultPartAdded(TreeTestResult testResult, - TestResultPart testResultPart) { - try { - TreeTestResult persistedResult = testResultDao - .getTestResult(testResult.getUuid()); - - if (persistedResult == null) { - testResultDao.create(testResult); - } else { - testResultDao.update(testResult); - } - } catch (Exception e) { - log.error("Could not persist result part " + testResultPart - + " for result " + testResult.getUuid()); - } - } - - public void close(TreeTestResult testResult) { - TreeTestResult persistedResult = (TreeTestResult) testResultDao - .getTestResult(testResult.getUuid()); - - if (persistedResult != null) { - persistedResult.setCloseDate(testResult.getCloseDate()); - testResultDao.update(persistedResult); - } - if (log.isDebugEnabled()) - log.debug("Closed result persister for result " - + testResult.getUuid()); - } - - /** Sets the DAO to use in order to persist the results. */ - public void setTestResultDao(TreeTestResultDao testResultDao) { - this.testResultDao = testResultDao; - } -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/ExecutionAnswer.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/ExecutionAnswer.java deleted file mode 100644 index 0297354c9..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/ExecutionAnswer.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg; - -import java.io.PrintWriter; -import java.io.Serializable; -import java.io.StringWriter; - -import org.apache.commons.io.IOUtils; -import org.argeo.slc.SlcException; - -/** Answer to an execution of a remote service which performed changes. */ -public class ExecutionAnswer implements Serializable { - private static final long serialVersionUID = -3268867743181316160L; - public final static String OK = "OK"; - public final static String ERROR = "ERROR"; - - private String status = OK; - private String message = ""; - - /** Canonical constructor */ - public ExecutionAnswer(String status, String message) { - setStatus(status); - if (message == null) - throw new SlcException("Message cannot be null"); - this.message = message; - } - - /** Empty constructor */ - public ExecutionAnswer() { - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - if (status == null || (!status.equals(OK) && !status.equals(ERROR))) - throw new SlcException("Bad status format: " + status); - this.status = status; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public Boolean isOk() { - return status.equals(OK); - } - - public Boolean isError() { - return status.equals(ERROR); - } - - public static ExecutionAnswer error(String message) { - return new ExecutionAnswer(ERROR, message); - } - - public static ExecutionAnswer error(Throwable e) { - StringWriter writer = new StringWriter(); - try { - e.printStackTrace(new PrintWriter(writer)); - return new ExecutionAnswer(ERROR, writer.toString()); - } finally { - IOUtils.closeQuietly(writer); - } - } - - public static ExecutionAnswer ok(String message) { - return new ExecutionAnswer(OK, message); - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/MsgConstants.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/MsgConstants.java deleted file mode 100644 index fe14f7710..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/MsgConstants.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg; - -public class MsgConstants { - - public final static String PROPERTY_SLC_AGENT_ID = "slc_agentId"; - public final static String PROPERTY_SLC_EXECUTION_ID = "slc_executionId"; - public final static String PROPERTY_SLC_EXECUTION_STATUS = "slc_executionStatus"; - - /** Force singleton */ - private MsgConstants() { - - } -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/MsgHandler.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/MsgHandler.java deleted file mode 100644 index 2d6f27e64..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/MsgHandler.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg; - -public interface MsgHandler { - public Object handleMsg(Object msg); -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/ObjectList.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/ObjectList.java deleted file mode 100644 index cd9ef4518..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/ObjectList.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class ObjectList implements Serializable{ - private static final long serialVersionUID = -7200599279369084551L; - private List objects = new ArrayList(); - - public ObjectList() { - } - - public ObjectList(Collection objects) { - this.objects.addAll(objects); - } - - @SuppressWarnings(value = { "unchecked" }) - public void fill(List objects) { - for (Serializable o : this.objects){ - objects.add((T) o); - } - } - - public List getObjects() { - return objects; - } - - public void setObjects(List objects) { - this.objects = objects; - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/ReferenceList.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/ReferenceList.java deleted file mode 100644 index 990140811..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/ReferenceList.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -public class ReferenceList implements Serializable{ - private static final long serialVersionUID = -6852393203700925723L; - private List references = new ArrayList(); - - public ReferenceList() { - } - - public ReferenceList(List references) { - this.references = references; - } - - public List getReferences() { - return references; - } - - public void setReferences(List refs) { - this.references = refs; - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/build/ModularDistributionDescriptor.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/build/ModularDistributionDescriptor.java deleted file mode 100644 index e6dc41a75..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/build/ModularDistributionDescriptor.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg.build; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.argeo.slc.BasicNameVersion; - -/** Describes a distribution of modules. */ -public class ModularDistributionDescriptor extends BasicNameVersion implements - Serializable { - private static final long serialVersionUID = 6076494586594591185L; - /** key is type, value the URL */ - private Map modulesDescriptors = new HashMap(); - - public Map getModulesDescriptors() { - return modulesDescriptors; - } - - public void setModulesDescriptors(Map urls) { - this.modulesDescriptors = urls; - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEvent.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEvent.java deleted file mode 100644 index af003d24b..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg.event; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -public class SlcEvent implements Serializable { - private static final long serialVersionUID = 1566174832839931036L; - public final static String EVENT_TYPE = "slc_eventType"; - public final static String EVENT_FILTER = "slc_eventFilter"; - - private Map headers = new HashMap(); - - public SlcEvent() { - } - - public SlcEvent(String eventType) { - headers.put(EVENT_TYPE, eventType); - } - - public Map getHeaders() { - return headers; - } - - public void setHeaders(Map headers) { - this.headers = headers; - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEventListener.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEventListener.java deleted file mode 100644 index 1fc1e0fe7..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEventListener.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg.event; - -import java.util.List; - -public interface SlcEventListener { - /** - * Blocks until an event is received or timeout is reached - * - * @return the event received or null if timeout was reached before - * receiving one - */ - public SlcEvent listen(String subscriberId, - List descriptors, Long timeout); -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEventListenerDescriptor.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEventListenerDescriptor.java deleted file mode 100644 index 1cecb411a..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEventListenerDescriptor.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg.event; - -import java.io.Serializable; - -public class SlcEventListenerDescriptor implements Serializable { - static final long serialVersionUID = 1l; - - private final String eventType; - private final String filter; - - public SlcEventListenerDescriptor(String eventType, String filter) { - super(); - this.eventType = eventType; - this.filter = filter; - } - - public String getEventType() { - return eventType; - } - - public String getFilter() { - return filter; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof SlcEventListenerDescriptor) { - SlcEventListenerDescriptor eventListenerDescriptor = (SlcEventListenerDescriptor) obj; - return eventListenerDescriptor.getEventType() - .equals(getEventType()); - } - return false; - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEventListenerRegister.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEventListenerRegister.java deleted file mode 100644 index 7bc7bc94d..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEventListenerRegister.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg.event; - -import java.util.List; - -public interface SlcEventListenerRegister { - public void addEventListenerDescriptor( - SlcEventListenerDescriptor eventListenerDescriptor); - - public void removeEventListenerDescriptor( - SlcEventListenerDescriptor eventListenerDescriptor); - - public List getDescriptorsCopy(); - - public String getId(); - - // public SlcEvent listen(SlcEventListener eventListener, Long timeout); -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEventPublisher.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEventPublisher.java deleted file mode 100644 index b6dd6ce62..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/event/SlcEventPublisher.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg.event; - -public interface SlcEventPublisher { - public void publish(SlcEvent event); -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/process/SlcExecutionRequest.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/process/SlcExecutionRequest.java deleted file mode 100644 index fbcd2ea95..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/process/SlcExecutionRequest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg.process; - -import java.io.Serializable; - -import org.argeo.slc.process.SlcExecution; - -@Deprecated -public class SlcExecutionRequest implements Serializable { - private static final long serialVersionUID = 4448081961875614441L; - private SlcExecution slcExecution; - - public SlcExecutionRequest() { - } - - public SlcExecutionRequest(SlcExecution slcExecution) { - this.slcExecution = slcExecution; - } - - public SlcExecution getSlcExecution() { - return slcExecution; - } - - public void setSlcExecution(SlcExecution slcExecution) { - this.slcExecution = slcExecution; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "#" + slcExecution.getUuid(); - } -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/process/SlcExecutionStatusRequest.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/process/SlcExecutionStatusRequest.java deleted file mode 100644 index f8fb953c8..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/process/SlcExecutionStatusRequest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg.process; - -import java.io.Serializable; - -@Deprecated -public class SlcExecutionStatusRequest implements Serializable { - private static final long serialVersionUID = -6495004680978575999L; - private String slcExecutionUuid; - private String newStatus; - - public SlcExecutionStatusRequest() { - } - - public SlcExecutionStatusRequest(String slcExecutionUuid, String newStatus) { - this.slcExecutionUuid = slcExecutionUuid; - this.newStatus = newStatus; - } - - public String getSlcExecutionUuid() { - return slcExecutionUuid; - } - - public void setSlcExecutionUuid(String slcExecutionUuid) { - this.slcExecutionUuid = slcExecutionUuid; - } - - public String getNewStatus() { - return newStatus; - } - - public void setNewStatus(String newStatus) { - this.newStatus = newStatus; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "#" + slcExecutionUuid; - } -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/process/SlcExecutionStepsRequest.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/process/SlcExecutionStepsRequest.java deleted file mode 100644 index f1cd5b125..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/process/SlcExecutionStepsRequest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg.process; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import org.argeo.slc.execution.ExecutionStep; -import org.argeo.slc.process.SlcExecutionStep; - -@Deprecated -public class SlcExecutionStepsRequest implements Serializable { - private static final long serialVersionUID = 6243880315234605390L; - private String slcExecutionUuid; - private List steps = new ArrayList(); - - public SlcExecutionStepsRequest() { - - } - - public SlcExecutionStepsRequest(String slcExecutionUuid, - List steps) { - this.slcExecutionUuid = slcExecutionUuid; - for (ExecutionStep step : steps) { - this.steps.add((SlcExecutionStep) step); - } - } - - public SlcExecutionStepsRequest(String slcExecutionUuid, ExecutionStep step) { - this.slcExecutionUuid = slcExecutionUuid; - List steps = new ArrayList(); - steps.add((SlcExecutionStep) step); - this.steps = steps; - } - - public String getSlcExecutionUuid() { - return slcExecutionUuid; - } - - public void setSlcExecutionUuid(String slcExecutionUuid) { - this.slcExecutionUuid = slcExecutionUuid; - } - - public List getSteps() { - return steps; - } - - public void setSteps(List step) { - this.steps = step; - } - - public void addStep(SlcExecutionStep step) { - steps.add(step); - } - - @Override - public String toString() { - return getClass().getSimpleName() + "#" + slcExecutionUuid + " " - + steps; - } -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/AddTreeTestResultAttachmentRequest.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/AddTreeTestResultAttachmentRequest.java deleted file mode 100644 index 1376dcf05..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/AddTreeTestResultAttachmentRequest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg.test.tree; - -import java.io.Serializable; - -import org.argeo.slc.core.attachment.SimpleAttachment; - -public class AddTreeTestResultAttachmentRequest implements Serializable { - private static final long serialVersionUID = -3193110972587429882L; - private String resultUuid; - private SimpleAttachment attachment; - - public String getResultUuid() { - return resultUuid; - } - - public void setResultUuid(String resultUuid) { - this.resultUuid = resultUuid; - } - - public SimpleAttachment getAttachment() { - return attachment; - } - - public void setAttachment(SimpleAttachment attachment) { - this.attachment = attachment; - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/CloseTreeTestResultRequest.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/CloseTreeTestResultRequest.java deleted file mode 100644 index 8a5e1ec92..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/CloseTreeTestResultRequest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg.test.tree; - -import java.io.Serializable; -import java.util.Date; - -import org.argeo.slc.core.test.tree.TreeTestResult; - -public class CloseTreeTestResultRequest implements Serializable { - private static final long serialVersionUID = 7384136025920047977L; - private String resultUuid; - private Date closeDate; - - public CloseTreeTestResultRequest() { - - } - - public CloseTreeTestResultRequest(String resultUuid, Date closeDate) { - this.resultUuid = resultUuid; - this.closeDate = closeDate; - } - - public CloseTreeTestResultRequest(TreeTestResult ttr) { - this.resultUuid = ttr.getUuid(); - this.closeDate = ttr.getCloseDate(); - } - - public String getResultUuid() { - return resultUuid; - } - - public void setResultUuid(String id) { - this.resultUuid = id; - } - - public Date getCloseDate() { - return closeDate; - } - - public void setCloseDate(Date closeDate) { - this.closeDate = closeDate; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "#" + resultUuid; - } - -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/CreateTreeTestResultRequest.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/CreateTreeTestResultRequest.java deleted file mode 100644 index d829d2945..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/CreateTreeTestResultRequest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg.test.tree; - -import java.io.Serializable; - -import org.argeo.slc.core.test.tree.TreeTestResult; -import org.argeo.slc.test.TestRunDescriptor; - -public class CreateTreeTestResultRequest implements Serializable { - private static final long serialVersionUID = 7443906609434527687L; - private TreeTestResult treeTestResult; - private TestRunDescriptor testRunDescriptor; - - public CreateTreeTestResultRequest() { - - } - - public CreateTreeTestResultRequest(TreeTestResult treeTestResult) { - this.treeTestResult = treeTestResult; - if (treeTestResult.getCurrentTestRun() != null) - testRunDescriptor = new TestRunDescriptor(treeTestResult - .getCurrentTestRun()); - } - - public TreeTestResult getTreeTestResult() { - return treeTestResult; - } - - public void setTreeTestResult(TreeTestResult treeTestResult) { - this.treeTestResult = treeTestResult; - } - - public TestRunDescriptor getTestRunDescriptor() { - return testRunDescriptor; - } - - public void setTestRunDescriptor(TestRunDescriptor testRunDescriptor) { - this.testRunDescriptor = testRunDescriptor; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "#" + treeTestResult.getUuid(); - } -} diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/ResultPartRequest.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/ResultPartRequest.java deleted file mode 100644 index 9d7d91c84..000000000 --- a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/msg/test/tree/ResultPartRequest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.msg.test.tree; - -import java.io.Serializable; -import java.util.Map; -import java.util.SortedMap; - -import org.argeo.slc.SlcException; -import org.argeo.slc.core.structure.tree.TreeSPath; -import org.argeo.slc.core.test.SimpleResultPart; -import org.argeo.slc.core.test.tree.PartSubList; -import org.argeo.slc.core.test.tree.TreeTestResult; -import org.argeo.slc.structure.StructureElement; -import org.argeo.slc.test.TestRunDescriptor; - -public class ResultPartRequest implements Serializable { - private static final long serialVersionUID = -6430135988577074226L; - private String resultUuid; - private SimpleResultPart resultPart; - private TreeSPath path; - private Map relatedElements; - private TestRunDescriptor testRunDescriptor; - private Map attributes; - - public ResultPartRequest() { - - } - - public ResultPartRequest(TreeTestResult ttr, TreeSPath path, - SimpleResultPart resultPart) { - resultUuid = ttr.getUuid(); - this.resultPart = resultPart; - this.path = (path != null ? path : ttr.getCurrentPath()); - relatedElements = ttr.getRelatedElements(this.path); - if (ttr.getCurrentTestRun() != null) - testRunDescriptor = new TestRunDescriptor(ttr.getCurrentTestRun()); - attributes = ttr.getAttributes(); - } - - public ResultPartRequest(TreeTestResult ttr) { - resultUuid = ttr.getUuid(); - this.path = ttr.getCurrentPath(); - - PartSubList lst = ttr.getResultParts().get(path); - if (lst.getParts().size() < 1) { - throw new SlcException("Cannot find part for path " + path - + " in result " + resultUuid); - } - - this.resultPart = (SimpleResultPart) lst.getParts().get( - lst.getParts().size() - 1); - relatedElements = ttr.getRelatedElements(path); - if (ttr.getCurrentTestRun() != null) - testRunDescriptor = new TestRunDescriptor(ttr.getCurrentTestRun()); - } - - public String getResultUuid() { - return resultUuid; - } - - public void setResultUuid(String resultUuid) { - this.resultUuid = resultUuid; - } - - public SimpleResultPart getResultPart() { - return resultPart; - } - - public void setResultPart(SimpleResultPart resultPart) { - this.resultPart = resultPart; - } - - public TreeSPath getPath() { - return path; - } - - public void setPath(TreeSPath path) { - this.path = path; - } - - public TestRunDescriptor getTestRunDescriptor() { - return testRunDescriptor; - } - - public void setTestRunDescriptor(TestRunDescriptor testRunDescriptor) { - this.testRunDescriptor = testRunDescriptor; - } - - public Map getRelatedElements() { - return relatedElements; - } - - public void setRelatedElements( - Map relatedElements) { - this.relatedElements = relatedElements; - } - - public Map getAttributes() { - return attributes; - } - - public void setAttributes(SortedMap attributes) { - this.attributes = attributes; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "#" + resultUuid + " " + path; - } -} diff --git a/runtime/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/test/spring.xml b/runtime/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/test/spring.xml index 729b948f6..37604b29f 100644 --- a/runtime/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/test/spring.xml +++ b/runtime/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/test/spring.xml @@ -21,10 +21,6 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" default-lazy-init="true"> - - - @@ -34,21 +30,6 @@ factory-method="randomUUID" scope="prototype"> - - - - - - - - - - - - diff --git a/runtime/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/test/spring/applicationContext.xml b/runtime/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/test/spring/applicationContext.xml deleted file mode 100644 index c385b27aa..000000000 --- a/runtime/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/test/spring/applicationContext.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - Deprecated - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/runtime/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/test/tree/basicReport.xslt b/runtime/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/test/tree/basicReport.xslt deleted file mode 100644 index 37d76295c..000000000 --- a/runtime/org.argeo.slc.core/src/main/resources/org/argeo/slc/core/test/tree/basicReport.xslt +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - Result - - -

- Result - -

-

Conf dir:

- -

- -

- - - - - - - - - - - - - -
- - - -
-
- - -
-
\ No newline at end of file diff --git a/runtime/org.argeo.slc.core/src/test/java/org/argeo/slc/core/structure/tree/TreeSPathTest.java b/runtime/org.argeo.slc.core/src/test/java/org/argeo/slc/core/structure/tree/TreeSPathTest.java deleted file mode 100644 index 7a1fb2a47..000000000 --- a/runtime/org.argeo.slc.core/src/test/java/org/argeo/slc/core/structure/tree/TreeSPathTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.core.structure.tree; - -import junit.framework.TestCase; - -public class TreeSPathTest extends TestCase { - - public void testNew() { - TreeSPath path = new TreeSPath("/test"); - assertEquals("test", path.getName()); - assertNull(path.getParent()); - - path = new TreeSPath("/root/subdir"); - assertEquals("subdir", path.getName()); - assertEquals(new TreeSPath("/root"), path.getParent()); - } - - public void testEquals() { - TreeSPath path1 = new TreeSPath("/test"); - TreeSPath path2 = new TreeSPath("/test"); - assertEquals(path1, path2); - - path1 = new TreeSPath("/test/subdir/anotherdir"); - path2 = new TreeSPath("/test/subdir/anotherdir"); - assertEquals(path1, path2); - - path1 = new TreeSPath("/test/subdir/anotherd"); - path2 = new TreeSPath("/test/subdir/anotherdir"); - assertNotSame(path1, path2); - - path1 = new TreeSPath("/test/subdir"); - path2 = new TreeSPath("/test/subdir/anotherdir"); - assertNotSame(path1, path2); - - path1 = new TreeSPath("/test/subd/anotherdir"); - path2 = new TreeSPath("/test/subdir/anotherdir"); - assertNotSame(path1, path2); - } - - public void testCheckFormat() { - try { - new TreeSPath("hello"); - fail("Bad format should be rejected"); - } catch (Exception e) { - // exception expected - } - - try { - new TreeSPath("/"); - fail("Bad format should be rejected"); - } catch (Exception e) { - // exception expected - } - - assertEquals(new TreeSPath("/test"), new TreeSPath("/test/")); - assertEquals(new TreeSPath("/test/dir"), new TreeSPath( - "//test///dir////")); - } -} diff --git a/runtime/org.argeo.slc.core/src/test/java/org/argeo/slc/core/test/context/ContextTest.java b/runtime/org.argeo.slc.core/src/test/java/org/argeo/slc/core/test/context/ContextTest.java index d72a9b47a..dbfa9f956 100644 --- a/runtime/org.argeo.slc.core/src/test/java/org/argeo/slc/core/test/context/ContextTest.java +++ b/runtime/org.argeo.slc.core/src/test/java/org/argeo/slc/core/test/context/ContextTest.java @@ -27,11 +27,11 @@ public class ContextTest extends AbstractInternalSpringTestCase { public void testComplexContext() { SimpleTestResult testResult = new SimpleTestResult(); ContextUtils.compareReachedExpected( - (ContextAware) getBean("context.c1"), testResult, null); + (ContextAware) getBean("context.c1"), testResult); ContextUtils.compareReachedExpected( - (ContextAware) getBean("context.c2"), testResult, null); + (ContextAware) getBean("context.c2"), testResult); ContextUtils.compareReachedExpected( - (ContextAware) getBean("context.c3"), testResult, null); + (ContextAware) getBean("context.c3"), testResult); List parts = testResult.getParts(); assertEquals(6, parts.size()); diff --git a/runtime/org.argeo.slc.core/src/test/resources/org/argeo/slc/core/execution/imports.xml b/runtime/org.argeo.slc.core/src/test/resources/org/argeo/slc/core/execution/imports.xml index bd9b56f98..2ffaef153 100644 --- a/runtime/org.argeo.slc.core/src/test/resources/org/argeo/slc/core/execution/imports.xml +++ b/runtime/org.argeo.slc.core/src/test/resources/org/argeo/slc/core/execution/imports.xml @@ -1,21 +1,11 @@ - + - - + \ No newline at end of file diff --git a/runtime/org.argeo.slc.core/src/test/resources/org/argeo/slc/core/execution/xml/tests.xml b/runtime/org.argeo.slc.core/src/test/resources/org/argeo/slc/core/execution/xml/tests.xml index f7489a63f..a36141c6d 100644 --- a/runtime/org.argeo.slc.core/src/test/resources/org/argeo/slc/core/execution/xml/tests.xml +++ b/runtime/org.argeo.slc.core/src/test/resources/org/argeo/slc/core/execution/xml/tests.xml @@ -37,7 +37,7 @@ - + diff --git a/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/DetachedExecutionServerImpl.java b/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/DetachedExecutionServerImpl.java index 4a8565457..cd502ea72 100644 --- a/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/DetachedExecutionServerImpl.java +++ b/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/DetachedExecutionServerImpl.java @@ -223,16 +223,6 @@ public class DetachedExecutionServerImpl implements DetachedExecutionServer, log.warn(msg); } - // Check paths - if (!previousRequest.getPath().equals(request.getPath())) { - String msg = "New request is not consistent with previous path. previousPath=" - + previousRequest.getPath() - + ", newPath=" - + request.getPath() + "\n"; - skippedLog.append(msg); - log.warn(msg); - } - if (previousAnswer.getStatus() != DetachedAnswer.ERROR) { // if no error occurred in the replayedSession, // skip the step diff --git a/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/DetachedRequest.java b/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/DetachedRequest.java index cb7f09131..8b296d426 100644 --- a/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/DetachedRequest.java +++ b/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/DetachedRequest.java @@ -24,7 +24,6 @@ public class DetachedRequest implements DetachedCommunication { private String uuid; private Properties properties = new Properties(); private String ref; - private String path = ""; private Object cachedObject = null; @@ -57,15 +56,6 @@ public class DetachedRequest implements DetachedCommunication { this.ref = stepRef; } - /** A path identifying the request within its source context. */ - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - /** The unique identifier of this request. */ public String getUuid() { return uuid; @@ -80,7 +70,6 @@ public class DetachedRequest implements DetachedCommunication { buf.append(ref); buf.append(" #").append(uuid); buf.append(" cachedObject=").append((cachedObject != null)); - buf.append(" path=").append(path); buf.append(" properties=").append(properties); return buf.toString(); } diff --git a/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/DetachedXmlConverterCompat.java b/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/DetachedXmlConverterCompat.java index 68bb2bbda..6cba2ba8d 100644 --- a/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/DetachedXmlConverterCompat.java +++ b/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/DetachedXmlConverterCompat.java @@ -103,9 +103,6 @@ public class DetachedXmlConverterCompat implements DetachedXmlConverter { .setRef(root.getElementsByTagNameNS( SLC_DETACHED_NAMESPACE_URI, "ref").item(0) .getTextContent()); - request.setPath(root.getElementsByTagNameNS( - SLC_DETACHED_NAMESPACE_URI, "path").item(0) - .getTextContent()); Element propertiesElement = (Element) root.getElementsByTagNameNS( SLC_DETACHED_NAMESPACE_URI, "properties").item(0); NodeList propElements = propertiesElement.getElementsByTagNameNS( @@ -177,8 +174,6 @@ public class DetachedXmlConverterCompat implements DetachedXmlConverter { "uuid").item(0).getTextContent()); request.setRef(node.getElementsByTagNameNS(SLC_DETACHED_NAMESPACE_URI, "ref").item(0).getTextContent()); - request.setPath(node.getElementsByTagNameNS(SLC_DETACHED_NAMESPACE_URI, - "path").item(0).getTextContent()); Element propertiesElement = (Element) node.getElementsByTagNameNS( SLC_DETACHED_NAMESPACE_URI, "properties").item(0); NodeList propElements = propertiesElement.getElementsByTagNameNS( diff --git a/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/MirrorStep.java b/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/MirrorStep.java index 36a6a23e3..80deaa584 100644 --- a/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/MirrorStep.java +++ b/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/MirrorStep.java @@ -31,7 +31,6 @@ public class MirrorStep implements DetachedStep { DetachedRequest req) { log.debug(" uuid=" + req.getUuid()); log.debug(" ref=" + req.getRef()); - log.debug(" path=" + req.getPath()); log.debug(" properties=" + req.getProperties()); DetachedAnswer answer = new DetachedAnswer(req, "Mirror"); diff --git a/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/drivers/FileDriver.java b/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/drivers/FileDriver.java index 06475f46a..4e1cef4c3 100644 --- a/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/drivers/FileDriver.java +++ b/runtime/org.argeo.slc.detached/src/main/java/org/argeo/slc/detached/drivers/FileDriver.java @@ -71,12 +71,12 @@ public class FileDriver implements DetachedClient, DetachedDriver, // Counters to avoid naming files with same prefix private long lastSentTime = 0; private int counter = 0; - - private DetachedXmlConverter xmlConverter = null; - + + private DetachedXmlConverter xmlConverter = null; + private long receiveAnswerTimeout = 10000l; - - private boolean active = true; + + private boolean active = true; public synchronized DetachedRequest receiveRequest() throws Exception { DetachedRequest request = (DetachedRequest) receiveFile(requestsDir, @@ -84,8 +84,7 @@ public class FileDriver implements DetachedClient, DetachedDriver, if (request != null) if (log.isTraceEnabled()) log.trace("Received detached request #" + request.getUuid() - + " for ref '" + request.getRef() + "', path=" - + request.getPath()); + + " for ref '" + request.getRef()); return request; } @@ -109,8 +108,7 @@ public class FileDriver implements DetachedClient, DetachedDriver, sendFile(requestsDir, request); if (log.isTraceEnabled()) log.trace("Sent detached request #" + request.getUuid() - + " for ref '" + request.getRef() + "', path=" - + request.getPath()); + + " for ref '" + request.getRef()); } protected synchronized void sendFile(File dir, DetachedCommunication detCom) @@ -132,8 +130,8 @@ public class FileDriver implements DetachedClient, DetachedDriver, // Create file path StringBuffer filePath = new StringBuffer(dir.getPath()); - filePath.append(File.separatorChar).append(sdf.format(nowDate)).append( - '-'); + filePath.append(File.separatorChar).append(sdf.format(nowDate)) + .append('-'); filePath.append(mf.format(new Object[] { new Long(counter) })).append( '-'); filePath.append(detCom.getUuid()).append(ext); @@ -225,13 +223,13 @@ public class FileDriver implements DetachedClient, DetachedDriver, FileUtils.moveFileToDirectory(file, processedDir, false); return detCom; } - + public synchronized void stop() { log.debug("Stopping Detached Driver"); active = false; notifyAll(); - } - + } + private synchronized boolean isActive() { return active; } diff --git a/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/cli/SlcMain.java b/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/cli/SlcMain.java index f3fce2b52..2df18bf24 100644 --- a/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/cli/SlcMain.java +++ b/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/cli/SlcMain.java @@ -28,7 +28,6 @@ import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.io.IOUtils; import org.argeo.slc.SlcException; -import org.argeo.slc.server.client.impl.SlcServerHttpClientImpl; @SuppressWarnings("static-access") public class SlcMain { @@ -44,18 +43,20 @@ public class SlcMain { // "classpath:org/argeo/slc/cli/spring-agent-default.xml"; private final static Option typeOpt = OptionBuilder.withLongOpt("mode") - .withArgName("mode").hasArg().withDescription( - "Execution type, one of: " + listTypeValues()).create('t'); + .withArgName("mode").hasArg() + .withDescription("Execution type, one of: " + listTypeValues()) + .create('t'); - private final static Option propertyOpt = OptionBuilder.withLongOpt( - "property").withArgName("prop1=val1,prop2=val2").hasArgs() - .withValueSeparator(',').withDescription( - "use value for given property").create('p'); + private final static Option propertyOpt = OptionBuilder + .withLongOpt("property").withArgName("prop1=val1,prop2=val2") + .hasArgs().withValueSeparator(',') + .withDescription("use value for given property").create('p'); - private final static Option propertiesOpt = OptionBuilder.withLongOpt( - "properties").withArgName("properties file").hasArgs() - .withValueSeparator(',').withDescription( - "load properties from file (-p has priority)").create('P'); + private final static Option propertiesOpt = OptionBuilder + .withLongOpt("properties").withArgName("properties file").hasArgs() + .withValueSeparator(',') + .withDescription("load properties from file (-p has priority)") + .create('P'); private final static Option moduleOpt = OptionBuilder.withLongOpt("module") .withArgName("module").hasArg().withDescription("Execution module") @@ -65,9 +66,9 @@ public class SlcMain { .withArgName("flows").hasArg().withDescription("Flows to execute") .create('f'); - private final static Option runtimeOpt = OptionBuilder.withLongOpt( - "runtime").withArgName("runtime").hasArg().withDescription( - "Runtime URL").create('r'); + private final static Option runtimeOpt = OptionBuilder + .withLongOpt("runtime").withArgName("runtime").hasArg() + .withDescription("Runtime URL").create('r'); private final static Options options; @@ -168,11 +169,6 @@ public class SlcMain { // Agent else if (type.equals(Type.agent)) { } - // Server - else if (type.equals(Type.server)) { - SlcServerHttpClientImpl slcServerHttpClient = new SlcServerHttpClientImpl(); - slcServerHttpClient.setBaseUrl(urlStr); - } } public static void printUsage() { diff --git a/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/server/client/HttpServicesClient.java b/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/server/client/HttpServicesClient.java deleted file mode 100644 index 9ed02184c..000000000 --- a/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/server/client/HttpServicesClient.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.server.client; - -import java.util.Map; - -import org.argeo.slc.Condition; - -/** Abstraction of the access to HTTP services . */ -public interface HttpServicesClient { - /** Call service, failing if it is not available. */ - public T callService(String path, Map parameters); - - /** - * Call service, waiting and retrying until the timeout is reached if it is - * not immediately available. - * - * @param path - * service path - * @param condition - * if not null, a condition to be applied on received object, - * keep trying if it returns false. - * @param timeout - * timeout after which an exception is thrown - */ - public T callServiceSafe(String path, Map parameters, - Condition condition, Long timeout); - -} diff --git a/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/server/client/SlcServerHttpClient.java b/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/server/client/SlcServerHttpClient.java deleted file mode 100644 index 98d78907c..000000000 --- a/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/server/client/SlcServerHttpClient.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.server.client; - -import java.util.List; -import java.util.Map; - -import org.argeo.slc.execution.ExecutionModuleDescriptor; -import org.argeo.slc.msg.ExecutionAnswer; -import org.argeo.slc.msg.event.SlcEvent; -import org.argeo.slc.process.RealizedFlow; -import org.argeo.slc.process.SlcExecution; -import org.argeo.slc.runtime.SlcAgentDescriptor; -import org.argeo.slc.server.HttpServices; - -/** Abstraction of the access to HTTP services of an SLC Server. */ -public interface SlcServerHttpClient extends HttpServicesClient,HttpServices { - /** Wait for the provided SlcExecution to be finished. */ - public void waitForSlcExecutionFinished(SlcExecution slcExecution, - Long timeout); - - /** Block until one of the registered event is finished. */ - public SlcEvent pollEvent(Long timeout); - - /** Register an event type. */ - public ExecutionAnswer addEventListener(String eventType, String eventFilter); - - /** Unregister an event type. */ - public ExecutionAnswer removeEventListener(String eventType, - String eventFilter); - - /** Wait for one agent to be available. */ - public SlcAgentDescriptor waitForOneAgent(); - - /** Wait for the http server to be ready. */ - public void waitForServerToBeReady(); - - /** Start an execution flow on the given agent. */ - public SlcExecution startFlow(String agentId, RealizedFlow realizedFlow); - - /** Assume one agent and one version per module. */ - public SlcExecution startFlowDefault(String moduleName, String flowName, - Map args); - - /** List execution modules descriptors. */ - public List listModuleDescriptors(String agentId); - - /** Retrieve a single execution module descriptor. */ - public ExecutionModuleDescriptor getModuleDescriptor(String agentId, - String moduleName, String version); - -} diff --git a/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/server/client/impl/AbstractHttpServicesClient.java b/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/server/client/impl/AbstractHttpServicesClient.java deleted file mode 100644 index 94f9c68fa..000000000 --- a/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/server/client/impl/AbstractHttpServicesClient.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.server.client.impl; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.Reader; -import java.io.Writer; -import java.net.Authenticator; -import java.net.HttpURLConnection; -import java.net.PasswordAuthentication; -import java.net.URL; -import java.net.URLEncoder; -import java.util.Map; - -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.slc.Condition; -import org.argeo.slc.SlcException; -import org.argeo.slc.server.client.HttpServicesClient; -import org.springframework.oxm.Marshaller; -import org.springframework.oxm.Unmarshaller; -import org.springframework.util.Assert; - -public abstract class AbstractHttpServicesClient implements HttpServicesClient { - private final static Log log = LogFactory - .getLog(AbstractHttpServicesClient.class); - - private String user; - private String password; - - private Unmarshaller unmarshaller; - private Marshaller marshaller; - private String baseUrl; - private String encoding = "UTF-8"; - - private Long retryPeriod = 1000l; - private Long defaultTimeout = 30 * 1000l; - - public void init() { - if (user != null && password != null) - Authenticator.setDefault(new Authenticator() { - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(user, password - .toCharArray()); - } - }); - } - - @SuppressWarnings(value = { "unchecked" }) - public T callService(String path, Map parameters) { - return (T) callService(path, parameters, null); - } - - @SuppressWarnings(value = { "unchecked" }) - public T callService(String path, Map parameters, - Object body) { - try { - return (T) callServiceLowLevel(path, parameters, body); - } catch (Exception e) { - throw new SlcException("Cannot call service " + path + " on " - + baseUrl, e); - } - } - - @SuppressWarnings(value = { "unchecked" }) - public T callServiceSafe(String path, Map parameters, - Condition condition, Long timeout) { - - long begin = System.currentTimeMillis(); - try { - Object obj = null; - while (System.currentTimeMillis() - begin < timeout(timeout)) { - try { - obj = callServiceLowLevel(path, parameters, null); - } catch (IOException e) { - if (log.isTraceEnabled()) - log.trace("Exception when calling service " + path - + " on " + baseUrl, e); - } - - if (obj != null) { - if (condition == null) - break; - else { - if (condition.check((T) obj)) - break; - } - } - // wait a bit - try { - Thread.sleep(retryPeriod); - } catch (InterruptedException e) { - // silent - } - } - - if (obj == null) - throw new SlcException( - "Service " - + path - + " on " - + baseUrl - + " did not return an answer after calling it safely for " - + timeout(timeout) + " ms."); - return (T) obj; - } catch (Exception e) { - throw new SlcException( - "Unexpected exception when safely calling service " + path - + " on " + baseUrl, e); - } - } - - protected Object callServiceLowLevel(String path, - Map parameters, Object body) throws IOException { - - Assert.notNull(baseUrl, "base url"); - HttpURLConnection connection = null; - Writer writer = null; - Reader reader = null; - try { - URL url = createUrl(path, parameters); - connection = (HttpURLConnection) url.openConnection(); - - if (body != null) { - connection.setRequestMethod("POST"); - connection.setDoOutput(true); - connection.setDoInput(true); - connection.setUseCaches(false); - connection.setAllowUserInteraction(false); - connection.setRequestProperty("Content-type", - "text/xml; charset=" + encoding); - } - - // Establish the connection - connection.connect(); - - if (body != null) { - writer = new OutputStreamWriter(connection.getOutputStream(), - encoding); - StreamResult result = new StreamResult(writer); - marshaller.marshal(body, result); - writer.flush(); - IOUtils.closeQuietly(writer); - } - - // Read answer - reader = new InputStreamReader(connection.getInputStream(), - encoding); - Source source = new StreamSource(reader); - Object obj = unmarshaller.unmarshal(source); - return obj; - } finally { - IOUtils.closeQuietly(reader); - IOUtils.closeQuietly(writer); - if (connection != null) { - connection.disconnect(); - } - } - } - - protected URL createUrl(String service, Map parameters) { - // URL encoded with UTF-8, as recommended by W3C - final String urlEncoding = "UTF-8"; - - StringBuffer buf = new StringBuffer(baseUrl + service); - try { - if (parameters != null && parameters.size() != 0) { - buf.append('?'); - boolean first = true; - for (String key : parameters.keySet()) { - String value = parameters.get(key); - if (value != null) { - if (first) - first = false; - else - buf.append('&'); - String keyEncoded = URLEncoder.encode(key, urlEncoding); - String valueEncoded = URLEncoder.encode(value, - urlEncoding); - buf.append(keyEncoded).append('=').append(valueEncoded); - } - } - } - - return new URL(buf.toString()); - } catch (Exception e) { - throw new SlcException("Cannot create URL: " + buf, e); - } - } - - public Long timeout(Long timeout) { - if (timeout == null) - timeout = getDefaultTimeout(); - return timeout; - } - - public void setUnmarshaller(Unmarshaller unmarshaller) { - this.unmarshaller = unmarshaller; - } - - public void setBaseUrl(String baseUrl) { - this.baseUrl = baseUrl; - } - - public Long getRetryPeriod() { - return retryPeriod; - } - - /** Retry period in ms when accessing service safely. Default is 1000 ms. */ - public void setRetryPeriod(Long retryPeriod) { - this.retryPeriod = retryPeriod; - } - - public void setMarshaller(Marshaller marshaller) { - this.marshaller = marshaller; - } - - /** Default is UTF-8. */ - public void setEncoding(String encoding) { - this.encoding = encoding; - } - - /** Default is 30s */ - public void setDefaultTimeout(Long defaultTimeout) { - this.defaultTimeout = defaultTimeout; - } - - public Long getDefaultTimeout() { - return defaultTimeout; - } - - public void setUser(String user) { - this.user = user; - } - - public void setPassword(String password) { - this.password = password; - } - -} diff --git a/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/server/client/impl/SlcServerHttpClientImpl.java b/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/server/client/impl/SlcServerHttpClientImpl.java deleted file mode 100644 index 73aa3012d..000000000 --- a/runtime/org.argeo.slc.launcher/src/main/java/org/argeo/slc/server/client/impl/SlcServerHttpClientImpl.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.server.client.impl; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.slc.Condition; -import org.argeo.slc.SlcException; -import org.argeo.slc.execution.ExecutionFlowDescriptor; -import org.argeo.slc.execution.ExecutionModuleDescriptor; -import org.argeo.slc.msg.ExecutionAnswer; -import org.argeo.slc.msg.MsgConstants; -import org.argeo.slc.msg.ObjectList; -import org.argeo.slc.msg.event.SlcEvent; -import org.argeo.slc.process.RealizedFlow; -import org.argeo.slc.process.SlcExecution; -import org.argeo.slc.runtime.SlcAgentDescriptor; -import org.argeo.slc.server.client.SlcServerHttpClient; - -public class SlcServerHttpClientImpl extends AbstractHttpServicesClient - implements SlcServerHttpClient { - - protected final static String PARAM_AGENT_ID = "agentId"; - - private final static Log log = LogFactory - .getLog(SlcServerHttpClientImpl.class); - - private Long serverReadyTimeout = 120 * 1000l; - - public void waitForSlcExecutionFinished(SlcExecution slcExecution, - Long timeout) { - if (slcExecution.getStatus().equals(SlcExecution.COMPLETED)) - return; - - long begin = System.currentTimeMillis(); - while (System.currentTimeMillis() - begin < timeout(timeout)) { - SlcEvent event = pollEvent(timeout); - String slcExecutionId = event.getHeaders().get( - MsgConstants.PROPERTY_SLC_EXECUTION_ID); - String status = event.getHeaders().get( - MsgConstants.PROPERTY_SLC_EXECUTION_STATUS); - if (slcExecutionId.equals(slcExecution.getUuid()) - && status.equals(SlcExecution.COMPLETED)) { - return; - } - } - throw new SlcException("SLC Execution not completed after timeout " - + timeout(timeout) + " elapsed."); - } - - public SlcEvent pollEvent(Long timeout) { - long begin = System.currentTimeMillis(); - while (System.currentTimeMillis() - begin < timeout(timeout)) { - Object obj = callService(POLL_EVENT, null); - if (obj instanceof ExecutionAnswer) { - ExecutionAnswer answer = (ExecutionAnswer) obj; - if (answer.isError()) - throw new SlcException( - "Unexpected exception when polling event: " - + answer.getMessage()); - } else { - return (SlcEvent) obj; - } - } - throw new SlcException("No event received after timeout " - + timeout(timeout) + " elapsed."); - } - - public ExecutionAnswer addEventListener(String eventType, String eventFilter) { - Map parameters = new HashMap(); - parameters.put(SlcEvent.EVENT_TYPE, eventType); - parameters.put(SlcEvent.EVENT_FILTER, eventFilter); - return callService(ADD_EVENT_LISTENER, parameters); - } - - public ExecutionAnswer removeEventListener(String eventType, - String eventFilter) { - Map parameters = new HashMap(); - parameters.put(SlcEvent.EVENT_TYPE, eventType); - parameters.put(SlcEvent.EVENT_FILTER, eventFilter); - return callService(REMOVE_EVENT_LISTENER, parameters); - } - - public SlcExecution startFlow(String agentId, RealizedFlow realizedFlow) { - SlcExecution slcExecution = new SlcExecution(); - slcExecution.setUuid(UUID.randomUUID().toString()); - - slcExecution.getRealizedFlows().add(realizedFlow); - - Map parameters = new HashMap(); - parameters.put(MsgConstants.PROPERTY_SLC_AGENT_ID, agentId); - ExecutionAnswer answer = callService(NEW_SLC_EXECUTION, parameters, - slcExecution); - if (!answer.isOk()) - throw new SlcException("Could not start flow on agent " + agentId - + ": " + answer.getMessage()); - return slcExecution; - } - - public SlcExecution startFlowDefault(String moduleName, String flowName, - Map args) { - SlcAgentDescriptor agentDescriptor = waitForOneAgent(); - List lst = listModuleDescriptors(agentDescriptor - .getUuid()); - ExecutionModuleDescriptor moduleDescMinimal = findModule(lst, - moduleName); - if (moduleDescMinimal == null) - throw new SlcException("Cannot find module " + moduleName); - String moduleVersion = moduleDescMinimal.getVersion(); - - ExecutionModuleDescriptor moduleDesc = getModuleDescriptor( - agentDescriptor.getUuid(), moduleName, moduleVersion); - - RealizedFlow realizedFlow = new RealizedFlow(); - realizedFlow.setModuleName(moduleName); - realizedFlow.setModuleVersion(moduleDesc.getVersion()); - - ExecutionFlowDescriptor flowDescriptor = findFlow(moduleDesc, flowName); - if (args != null) { - for (String key : args.keySet()) { - if (flowDescriptor.getValues().containsKey(key)) { - flowDescriptor.getValues().put(key, args.get(key)); - } - } - } - realizedFlow.setFlowDescriptor(flowDescriptor); - - return startFlow(agentDescriptor.getUuid(), realizedFlow); - - // FIXME: polling not working when called from test: no unique - // session is created on server side - // SlcExecution slcExecutionFinished = null; - // try { - // addEventListener( - // EventPublisherAspect.EVT_UPDATE_SLC_EXECUTION_STATUS, null); - // SlcExecution slcExecution = startFlow(agentDescriptor.getUuid(), - // realizedFlow); - // - // waitForSlcExecutionFinished(slcExecution, null); - // - // ObjectList ol = callService(LIST_SLC_EXECUTIONS, null); - // for (Serializable sr : ol.getObjects()) { - // SlcExecution se = (SlcExecution) sr; - // if (se.getUuid().equals(slcExecution.getUuid())) { - // slcExecutionFinished = se; - // break; - // } - // } - // - // } finally { - // removeEventListener( - // EventPublisherAspect.EVT_UPDATE_SLC_EXECUTION_STATUS, null); - // } - // - // if (slcExecutionFinished == null) - // throw new SlcException("No finished SLC Execution."); - // return slcExecutionFinished; - } - - public static ExecutionModuleDescriptor findModule( - List lst, String moduleName) { - ExecutionModuleDescriptor moduleDesc = null; - for (ExecutionModuleDescriptor desc : lst) { - if (desc.getName().equals(moduleName)) { - if (moduleDesc != null) - throw new SlcException( - "There is more than one module named " + moduleName - + " (versions: " + moduleDesc + " and " - + desc.getVersion() + ")"); - moduleDesc = desc; - } - } - return moduleDesc; - } - - public static ExecutionFlowDescriptor findFlow( - ExecutionModuleDescriptor moduleDesc, String flowName) { - ExecutionFlowDescriptor flowDesc = null; - for (ExecutionFlowDescriptor desc : moduleDesc.getExecutionFlows()) { - if (desc.getName().equals(flowName)) { - flowDesc = desc; - } - } - return flowDesc; - } - - public List listModuleDescriptors(String agentId) { - Map parameters = new HashMap(); - parameters.put(PARAM_AGENT_ID, agentId); - - List moduleDescriptors = new ArrayList(); - ObjectList ol = callService(LIST_MODULE_DESCRIPTORS, parameters); - ol.fill(moduleDescriptors); - return moduleDescriptors; - } - - public ExecutionModuleDescriptor getModuleDescriptor(String agentId, - String moduleName, String version) { - Map parameters = new HashMap(); - parameters.put(PARAM_AGENT_ID, agentId); - parameters.put("moduleName", moduleName); - parameters.put("version", version); - ExecutionModuleDescriptor moduleDescriptor = callService( - GET_MODULE_DESCRIPTOR, parameters); - return moduleDescriptor; - } - - public SlcAgentDescriptor waitForOneAgent() { - ObjectList objectList = callServiceSafe(LIST_AGENTS, null, - new Condition() { - public Boolean check(ObjectList obj) { - int size = obj.getObjects().size(); - if (log.isTraceEnabled()) - log.trace("Object list size: " + size); - return size == 1; - } - }, null); - return (SlcAgentDescriptor) objectList.getObjects().get(0); - } - - public void waitForServerToBeReady() { - ExecutionAnswer answer = callServiceSafe(IS_SERVER_READY, null, null, - serverReadyTimeout); - if (!answer.isOk()) - throw new SlcException("Server is not ready: " + answer); - } - - /** - * Timeout in ms after which the client will stop waiting for the server to - * be ready and throw an exception. Default is 120s. - */ - public void setServerReadyTimeout(Long serverReadyTimeout) { - this.serverReadyTimeout = serverReadyTimeout; - } - -} diff --git a/runtime/org.argeo.slc.lib.detached/src/main/java/org/argeo/slc/lib/detached/DetachedTestDefinition.java b/runtime/org.argeo.slc.lib.detached/src/main/java/org/argeo/slc/lib/detached/DetachedTestDefinition.java index 1fe333956..bac4819ef 100644 --- a/runtime/org.argeo.slc.lib.detached/src/main/java/org/argeo/slc/lib/detached/DetachedTestDefinition.java +++ b/runtime/org.argeo.slc.lib.detached/src/main/java/org/argeo/slc/lib/detached/DetachedTestDefinition.java @@ -22,7 +22,6 @@ import java.util.UUID; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.argeo.slc.SlcException; -import org.argeo.slc.core.structure.tree.TreeSRelatedHelper; import org.argeo.slc.core.test.SimpleResultPart; import org.argeo.slc.core.test.context.ContextUtils; import org.argeo.slc.core.test.context.DefaultContextTestData; @@ -46,8 +45,8 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanReference; import org.springframework.beans.factory.support.BeanDefinitionRegistry; -public class DetachedTestDefinition extends TreeSRelatedHelper implements - TestDefinition, BeanNameAware, BeanFactoryAware, InitializingBean { +public class DetachedTestDefinition implements TestDefinition, BeanNameAware, + BeanFactoryAware, InitializingBean { private final static Log log = LogFactory .getLog(DetachedTestDefinition.class); @@ -81,7 +80,6 @@ public class DetachedTestDefinition extends TreeSRelatedHelper implements // Execute DetachedRequest request = new DetachedRequest(); - request.setPath(getBasePath().toString()); request.setUuid(UUID.randomUUID().toString()); request.setRef(stepBeanNameT); @@ -106,8 +104,8 @@ public class DetachedTestDefinition extends TreeSRelatedHelper implements } catch (Exception e) { throw new SlcException("Could not receive answer #" + request.getUuid() + " for step " + stepBeanNameT, e); - } - + } + if (answer.getStatus() == DetachedAnswer.ERROR) throw new SlcException("Error when executing step " + answer.getUuid() + ": " + answer.getLog()); @@ -122,14 +120,13 @@ public class DetachedTestDefinition extends TreeSRelatedHelper implements outputParameters.get(key)); } - if (testData != null) { - ContextUtils.compareReachedExpected(testData, testRun - .getTestResult(), this); + ContextUtils.compareReachedExpected(testData, + testRun.getTestResult()); } else { - ((TestResult)testRun.getTestResult()).addResultPart( - new SimpleResultPart(TestStatus.PASSED, "Step " - + stepBeanNameT + " executed successfully")); + ((TestResult) testRun.getTestResult()) + .addResultPart(new SimpleResultPart(TestStatus.PASSED, + "Step " + stepBeanNameT + " executed successfully")); } } diff --git a/runtime/org.argeo.slc.lib.detached/src/main/resources/org/argeo/slc/lib/detached/castor.xml b/runtime/org.argeo.slc.lib.detached/src/main/resources/org/argeo/slc/lib/detached/castor.xml index 5f29f28c4..5d16111be 100644 --- a/runtime/org.argeo.slc.lib.detached/src/main/resources/org/argeo/slc/lib/detached/castor.xml +++ b/runtime/org.argeo.slc.lib.detached/src/main/resources/org/argeo/slc/lib/detached/castor.xml @@ -29,7 +29,6 @@ ns-prefix="&slc-detached-namespace-prefix;" /> - diff --git a/runtime/org.argeo.slc.lib.detached/src/test/java/org/argeo/slc/lib/detached/DetachedCastorTest.java b/runtime/org.argeo.slc.lib.detached/src/test/java/org/argeo/slc/lib/detached/DetachedCastorTest.java index f46bac508..e9d9a097b 100644 --- a/runtime/org.argeo.slc.lib.detached/src/test/java/org/argeo/slc/lib/detached/DetachedCastorTest.java +++ b/runtime/org.argeo.slc.lib.detached/src/test/java/org/argeo/slc/lib/detached/DetachedCastorTest.java @@ -100,7 +100,6 @@ public class DetachedCastorTest extends AbstractSpringTestCase { public static DetachedRequest createTestRequest() { DetachedRequest request = new DetachedRequest(); request.setUuid("12345"); - request.setPath("/root/test"); request.setRef("testRef"); Properties properties = new Properties(); properties.setProperty("key1", "value1"); @@ -124,7 +123,6 @@ public class DetachedCastorTest extends AbstractSpringTestCase { public static void assertDetachedRequest(DetachedRequest expected, DetachedRequest reached) { assertEquals(expected.getUuid(), reached.getUuid()); - assertEquals(expected.getPath(), reached.getPath()); assertEquals(expected.getRef(), reached.getRef()); Properties expectedProps = expected.getProperties(); Properties reachedProps = reached.getProperties(); diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/SlcAgentDescriptorDao.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/SlcAgentDescriptorDao.java deleted file mode 100644 index c63b160de..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/SlcAgentDescriptorDao.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.dao; - -import java.util.List; - -import org.argeo.slc.runtime.SlcAgentDescriptor; - -@SuppressWarnings("deprecation") -public interface SlcAgentDescriptorDao extends - org.argeo.slc.dao.runtime.SlcAgentDescriptorDao { - public void create(SlcAgentDescriptor slcAgentDescriptor); - - public void delete(SlcAgentDescriptor slcAgentDescriptor); - - public void delete(String agentId); - - public List listSlcAgentDescriptors(); - - public SlcAgentDescriptor getAgentDescriptor(String agentId); -} diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/SlcExecutionDao.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/SlcExecutionDao.java deleted file mode 100644 index 6067d6db2..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/SlcExecutionDao.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.dao; - -import java.util.List; - -import org.argeo.slc.process.SlcExecution; -import org.argeo.slc.process.SlcExecutionStep; - -@SuppressWarnings("deprecation") -public interface SlcExecutionDao extends - org.argeo.slc.dao.process.SlcExecutionDao { - public void create(SlcExecution slcExecution); - - public void update(SlcExecution slcExecution); - - public SlcExecution getSlcExecution(String uuid); - - public List listSlcExecutions(); - - public void addSteps(String slcExecutionId, - List additionalSteps); - - public List tailSteps(final String slcExecutionId, - final Integer nbrOfSteps); - - public List tailSteps(final String slcExecutionId, - final String slcExecutionStepId); -} diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/TestResultDao.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/TestResultDao.java deleted file mode 100644 index 1b67910b4..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/TestResultDao.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.dao; - -import java.util.Date; -import java.util.List; - -import org.argeo.slc.test.TestResult; - -/** - * The dao for TestResult. - * - * @see TestResult - */ -@SuppressWarnings("deprecation") -public interface TestResultDao extends - org.argeo.slc.dao.test.TestResultDao { - /** Gets a test result based on its id. */ - public T getTestResult(String uuid); - - /** Persists a new test result. */ - public void create(TestResult testResult); - - /** Updates an already persisted test result. */ - public void update(TestResult testResult); - - /** Lists all test results. */ - public List listTestResults(); - - public void close(String id, Date closeDate); -} diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/TestRunDescriptorDao.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/TestRunDescriptorDao.java deleted file mode 100644 index 6a2b8f142..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/TestRunDescriptorDao.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.dao; - -import org.argeo.slc.test.TestRunDescriptor; - -@SuppressWarnings("deprecation") -public interface TestRunDescriptorDao extends - org.argeo.slc.dao.test.TestRunDescriptorDao { - public TestRunDescriptor getTestRunDescriptor(String id); - - public void saveOrUpdate(TestRunDescriptor testRunDescriptor); -} diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/process/SlcExecutionDao.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/process/SlcExecutionDao.java deleted file mode 100644 index 65464c7b9..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/process/SlcExecutionDao.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.dao.process; - -import java.util.List; - -import org.argeo.slc.process.SlcExecution; -import org.argeo.slc.process.SlcExecutionStep; - -/** - * @deprecated will be removed in SLC 2.x, use - * {@link org.argeo.slc.dao.SlcExecutionDao} - */ -public interface SlcExecutionDao { - public void create(SlcExecution slcExecution); - - public void update(SlcExecution slcExecution); - - public SlcExecution getSlcExecution(String uuid); - - public List listSlcExecutions(); - - public void addSteps(String slcExecutionId, - List additionalSteps); - - public List tailSteps(final String slcExecutionId, - final Integer nbrOfSteps); - - public List tailSteps(final String slcExecutionId, - final String slcExecutionStepId); -} diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/runtime/SlcAgentDescriptorDao.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/runtime/SlcAgentDescriptorDao.java deleted file mode 100644 index 2b83e7354..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/runtime/SlcAgentDescriptorDao.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.dao.runtime; - -import java.util.List; - -import org.argeo.slc.runtime.SlcAgentDescriptor; - -/** - * @deprecated will be removed in SLC 2.0, use - * {@link org.argeo.slc.dao.SlcAgentDescriptorDao} instead. - */ -public interface SlcAgentDescriptorDao { - public void create(SlcAgentDescriptor slcAgentDescriptor); - - public void delete(SlcAgentDescriptor slcAgentDescriptor); - - public void delete(String agentId); - - public List listSlcAgentDescriptors(); - - public SlcAgentDescriptor getAgentDescriptor(String agentId); -} diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/test/TestResultDao.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/test/TestResultDao.java deleted file mode 100644 index 0f30bc9f4..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/test/TestResultDao.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.dao.test; - -import java.util.Date; -import java.util.List; - -import org.argeo.slc.test.TestResult; - -/** - * @deprecated will be removed in SLC 2.0, use - * {@link org.argeo.slc.dao.TestResultDao} instead. The dao for - * TestResult. - * - * @see TestResult - */ -public interface TestResultDao { - /** Gets a test result based on its id. */ - public T getTestResult(String uuid); - - /** Persists a new test result. */ - public void create(TestResult testResult); - - /** Updates an already persisted test result. */ - public void update(TestResult testResult); - - /** Lists all test results. */ - public List listTestResults(); - - public void close(String id, Date closeDate); -} diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/test/TestRunDescriptorDao.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/test/TestRunDescriptorDao.java deleted file mode 100644 index 13f1f265d..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/test/TestRunDescriptorDao.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.dao.test; - -import org.argeo.slc.dao.TestResultDao; -import org.argeo.slc.test.TestRunDescriptor; - -/** @deprecated will be removed in SLC 2.0, use {@link TestResultDao} instead. */ -public interface TestRunDescriptorDao { - public TestRunDescriptor getTestRunDescriptor(String id); - - public void saveOrUpdate(TestRunDescriptor testRunDescriptor); -} diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/test/package.html b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/test/package.html deleted file mode 100644 index 38ae2b5bf..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/dao/test/package.html +++ /dev/null @@ -1,6 +0,0 @@ - - - -Data Access Objects for SLC Test. - - \ No newline at end of file diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/server/HttpServices.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/server/HttpServices.java deleted file mode 100644 index aaeafb540..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/server/HttpServices.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.server; - -public interface HttpServices { - public final static String LIST_AGENTS = "listAgents.service"; - public final static String IS_SERVER_READY = "isServerReady.service"; - public final static String NEW_SLC_EXECUTION = "newSlcExecution.service"; - public final static String LIST_SLC_EXECUTIONS = "listSlcExecutions.service"; - public final static String GET_MODULE_DESCRIPTOR = "getExecutionDescriptor.service"; - public final static String LIST_MODULE_DESCRIPTORS = "listModulesDescriptors.service"; - public final static String LIST_RESULTS = "listResults.service"; - public final static String ADD_EVENT_LISTENER = "addEventListener.service"; - public final static String REMOVE_EVENT_LISTENER = "removeEventListener.service"; - public final static String POLL_EVENT = "pollEvent.service"; - -} diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructureAware.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructureAware.java deleted file mode 100644 index 78855644d..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructureAware.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.structure; - -/** - * Wrapper for an element, which is able to propagate registration to - * sub-elements. - */ -public interface StructureAware { - /** Called after registration. */ - public void notifyCurrentPath(StructureRegistry registry, T path); -} diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructureElement.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructureElement.java deleted file mode 100644 index 3c340029b..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructureElement.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.structure; - -import java.util.Map; - -/** - * Atomic element holding metadata such as description about the element which - * registered. - */ -public interface StructureElement { - /** Label of this element. */ - public String getLabel(); - - /** tags attached to this element*/ - public Map getTags(); - - -} diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructureElementProvider.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructureElementProvider.java deleted file mode 100644 index 86b8b55dd..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructureElementProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.structure; - -public interface StructureElementProvider { - public StructureElement createStructureElement(); -} diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructurePath.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructurePath.java deleted file mode 100644 index 5d7f696d8..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructurePath.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.structure; - -/** - * Path allowing to uniquely identify a StructureElement within a - * registry. - * - * @see StructureElement - * @see StructurePath - */ -public interface StructurePath { - /** - * Unique representation as a string. Most implementation will also provide - * a mean to interpret this string. - */ - public String getAsUniqueString(); -} diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructureRegistry.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructureRegistry.java deleted file mode 100644 index 499582454..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/StructureRegistry.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.structure; - -import java.util.List; - -/** Registry where the whole structure is stored. */ -public interface StructureRegistry

{ - /** Read mode: the structure is only read. */ - public static String READ = "READ"; - /** All mode: everything is executed regardless of the active paths. */ - public static String ALL = "ALL"; - /** Active mode: only the active paths are executed. */ - public static String ACTIVE = "ACTIVE"; - - /** Adds an element to the registry. */ - public void register(P path, StructureElement element); - - /** Lists all registered elements. */ - public List listElements(); - - /** Lists all registered elements. */ - public List

listPaths(); - - /** Gets a element based on its path. */ - public T getElement(P path); - - /** - * Set the interpreter mode: read, all or active. - * - * @see #READ - * @see #ALL - * @see #STATUS_ACTIVE - */ - public void setMode(String mode); - - /** - * Gets the current interpreter mode. - * - * @see #READ - * @see #ALL - * @see #STATUS_ACTIVE - */ - public String getMode(); - - /** - * Gets the list of active paths, which will be run if executed in - * STATUS_ACTIVE mode. - */ - public List

getActivePaths(); - - /** - * Sets the list of active path, which will be run if executed in - * STATUS_ACTIVE mode. - */ - public void setActivePaths(List

activePaths); -} diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/package.html b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/package.html deleted file mode 100644 index d9bab8a55..000000000 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/structure/package.html +++ /dev/null @@ -1,6 +0,0 @@ - - - -SLC Structure framework allowing to uniquely reference actions. - - \ No newline at end of file diff --git a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/test/TestRun.java b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/test/TestRun.java index 15a37846b..a9d2232f9 100644 --- a/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/test/TestRun.java +++ b/runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/test/TestRun.java @@ -20,7 +20,7 @@ import org.argeo.slc.process.SlcExecutionAware; /** The actual run of a test */ @SuppressWarnings("deprecation") -public interface TestRun extends SlcExecutionAware { +public interface TestRun { /** Gets UUID */ public String getUuid(); diff --git a/runtime/org.argeo.slc.support.jcr/pom.xml b/runtime/org.argeo.slc.support.jcr/pom.xml index 8d49c645e..c79debc77 100644 --- a/runtime/org.argeo.slc.support.jcr/pom.xml +++ b/runtime/org.argeo.slc.support.jcr/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 org.argeo.slc @@ -19,7 +20,12 @@ org.argeo.slc.jcr.* - org.springframework.context,javax.jcr.nodetype,* + + org.springframework.context, + javax.jcr.nodetype, + org.springframework.beans.factory, + * + diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/AbstractSlcJcrDao.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/AbstractSlcJcrDao.java deleted file mode 100644 index 08c99c6a0..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/AbstractSlcJcrDao.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.jcr.dao; - -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; - -import javax.jcr.NamespaceRegistry; -import javax.jcr.RepositoryException; -import javax.jcr.Session; -import javax.jcr.query.Query; - -import org.argeo.ArgeoException; -import org.argeo.jcr.JcrUtils; -import org.argeo.jcr.NodeMapper; -import org.argeo.jcr.NodeMapperProvider; -import org.argeo.slc.runtime.SlcAgentDescriptor; -import org.argeo.slc.test.TestResult; -import org.argeo.slc.test.TestRunDescriptor; - -public abstract class AbstractSlcJcrDao { - - private Session session; - - // protected Workspace workspace; - // protected QueryManager queryManager; - protected NodeMapper nodeMapper; - - // We inject the nodeMapperProvider that define a default node mapper as an - // entry point of the NodeMapper - private NodeMapperProvider nodeMapperProvider; - - public void init() { - nodeMapper = getNodeMapperProvider().findNodeMapper(null); - // JcrUtils.registerNamespaceSafely(session, "slc", - // "http://www.argeo.org/slc/0.12"); - - } - - public void setSession(Session session) { - this.session = session; - } - - protected Session getSession() { - return session; - } - - // IoC - public void setNodeMapperProvider(NodeMapperProvider nodeMapperProvider) { - this.nodeMapperProvider = nodeMapperProvider; - } - - // TODO : define a strategy to define basePathes - protected String basePath(TestResult testResult) { - Calendar cal = new GregorianCalendar(); - cal.setTime(new Date()); - return "/slc/testresults/" + JcrUtils.dateAsPath(cal) + "testresult"; - } - - protected String basePath(SlcAgentDescriptor slcAgentDescriptor) { - return "/slc/agents/" - + JcrUtils.hostAsPath(slcAgentDescriptor.getHost()) + "/agent"; - } - - protected String basePath(TestRunDescriptor testRunDescriptor) { - return "/slc/testruns/" + testRunDescriptor.getSlcExecutionUuid() - + "/testrun"; - } - - protected NodeMapperProvider getNodeMapperProvider() { - return this.nodeMapperProvider; - } - - protected Query createQuery(String query, String type) { - try { - return getSession().getWorkspace().getQueryManager().createQuery( - query, type); - } catch (RepositoryException e) { - throw new ArgeoException("Cannot create query " + query, e); - } - } -} diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/SlcAgentDescriptorDaoJcr.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/SlcAgentDescriptorDaoJcr.java deleted file mode 100644 index 863dfb93c..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/SlcAgentDescriptorDaoJcr.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.jcr.dao; - -import java.util.ArrayList; -import java.util.List; - -import javax.jcr.Node; -import javax.jcr.NodeIterator; -import javax.jcr.RepositoryException; -import javax.jcr.query.Query; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.jcr.JcrUtils; -import org.argeo.slc.SlcException; -import org.argeo.slc.dao.runtime.SlcAgentDescriptorDao; -import org.argeo.slc.runtime.SlcAgentDescriptor; - -public class SlcAgentDescriptorDaoJcr extends AbstractSlcJcrDao implements - SlcAgentDescriptorDao { - private final static Log log = LogFactory - .getLog(SlcAgentDescriptorDaoJcr.class); - - public void create(SlcAgentDescriptor slcAgentDescriptor) { - try { - nodeMapper.save(getSession(), basePath(slcAgentDescriptor), - slcAgentDescriptor); - getSession().save(); - } catch (RepositoryException e) { - throw new SlcException("Cannot import " + slcAgentDescriptor, e); - } - } - - public SlcAgentDescriptor getAgentDescriptor(String agentId) { - // TODO: optimize query - String queryString = "//agent[@uuid='" + agentId + "']"; - Query query = createQuery(queryString, Query.XPATH); - Node node = JcrUtils.querySingleNode(query); - if (node == null) - return null; - return (SlcAgentDescriptor) nodeMapper.load(node); - } - - public void delete(SlcAgentDescriptor slcAgentDescriptor) { - try { - String queryString = "//agent[@uuid='" - + slcAgentDescriptor.getUuid() + "']"; - Query query = createQuery(queryString, Query.XPATH); - Node node = JcrUtils.querySingleNode(query); - if (node != null) { - node.remove(); - getSession().save(); - } else - log.warn("No node found for agent descriptor: " - + slcAgentDescriptor); - } catch (RepositoryException e) { - throw new SlcException("Cannot delete " + slcAgentDescriptor, e); - } - - } - - public void delete(String agentId) { - try { - // TODO: optimize query - String queryString = "//agent[@uuid='" + agentId + "']"; - Query query = createQuery(queryString, Query.XPATH); - Node node = JcrUtils.querySingleNode(query); - if (node != null) - node.remove(); - } catch (RepositoryException e) { - throw new SlcException("Cannot find AgentDescriptor" + agentId, e); - } - - } - - public List listSlcAgentDescriptors() { - try { - String queryString = "//agent"; - Query query = createQuery(queryString, Query.XPATH); - - List listSad = new ArrayList(); - - NodeIterator ni = query.execute().getNodes(); - while (ni.hasNext()) { - Node curNode = (Node) ni.next(); - // JcrUtils.debug(curNode); - listSad.add((SlcAgentDescriptor) nodeMapper.load(curNode)); - } - - return listSad; - } catch (Exception e) { - throw new SlcException("Cannot load AgentDescriptorList", e); - } - } - -} diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/SlcExecutionDaoJcr.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/SlcExecutionDaoJcr.java deleted file mode 100644 index 1189c3aac..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/SlcExecutionDaoJcr.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.jcr.dao; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; - -import javax.jcr.Node; -import javax.jcr.NodeIterator; -import javax.jcr.RepositoryException; -import javax.jcr.query.Query; -import javax.jcr.query.QueryResult; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.jcr.JcrUtils; -import org.argeo.slc.SlcException; -import org.argeo.slc.dao.process.SlcExecutionDao; -import org.argeo.slc.process.SlcExecution; -import org.argeo.slc.process.SlcExecutionStep; - -public class SlcExecutionDaoJcr extends AbstractSlcJcrDao implements - SlcExecutionDao { - private final static Log log = LogFactory.getLog(SlcExecutionDaoJcr.class); - - public void addSteps(String slcExecutionId, - List additionalSteps) { - // TODO: optimize, do one single query - SlcExecution slcExecution = getSlcExecution(slcExecutionId); - slcExecution.getSteps().addAll(additionalSteps); - update(slcExecution); - - } - - public void create(SlcExecution slcExecution) { - try { - nodeMapper.save(getSession(), basePath(slcExecution), slcExecution); - getSession().save(); - } catch (RepositoryException e) { - throw new SlcException("Cannot create slcExecution" + slcExecution, - e); - } - } - - protected String basePath(SlcExecution slcExecution) { - Calendar cal = new GregorianCalendar(); - cal.setTime(new Date()); - // cal.setTime(slcExecution.getStartDate()); - String host = slcExecution.getHost(); - if (host == null) - host = "UNKOWNHOST"; - return "/slc/processes/" + JcrUtils.hostAsPath(host) + '/' - + JcrUtils.dateAsPath(cal) + "process"; - } - - public SlcExecution getSlcExecution(String uuid) { - // TODO: optimize query - String queryString = "//process[@uuid='" + uuid + "']"; - Query query = createQuery(queryString, Query.XPATH); - Node node = JcrUtils.querySingleNode(query); - if (node == null) - return null; - return (SlcExecution) nodeMapper.load(node); - } - - public List listSlcExecutions() { - List res = new ArrayList(); - // TODO: optimize query - String queryString = "//process"; - try { - Query query = createQuery(queryString, Query.XPATH); - QueryResult qr = query.execute(); - NodeIterator iterator = qr.getNodes(); - while (iterator.hasNext()) { - Node node = iterator.nextNode(); - SlcExecution slcExecution = (SlcExecution) nodeMapper - .load(node); - res.add(slcExecution); - } - return res; - } catch (RepositoryException e) { - throw new SlcException("Cannot list SLC executions", e); - } - } - - public void merge(SlcExecution slcExecution) { - throw new UnsupportedOperationException(); - } - - public void update(SlcExecution slcExecution) { - // TODO: optimize query - String queryString = "//process[@uuid='" + slcExecution.getUuid() - + "']"; - try { - Query query = createQuery(queryString, Query.XPATH); - Node node = JcrUtils.querySingleNode(query); - nodeMapper.update(node, slcExecution); - getSession().save(); - } catch (RepositoryException e) { - throw new SlcException("Cannot update " + slcExecution, e); - } - } - - public List tailSteps(String slcExecutionId, - Integer nbrOfSteps) { - log.error("Method not implemented, returning an empty list."); - return new ArrayList(); - } - - public List tailSteps(String slcExecutionId, - String slcExecutionStepId) { - log.error("Method not implemented, returning an empty list."); - return new ArrayList(); - } - -} diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/SlcNodeMapperProvider.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/SlcNodeMapperProvider.java deleted file mode 100644 index 2a7af450a..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/SlcNodeMapperProvider.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.jcr.dao; - -import javax.jcr.Node; -import javax.jcr.RepositoryException; - -import org.argeo.ArgeoException; -import org.argeo.jcr.NodeMapper; -import org.argeo.jcr.NodeMapperProvider; - -public class SlcNodeMapperProvider implements NodeMapperProvider { -// private final static Log log = LogFactory -// .getLog(SlcNodeMapperProvider.class); - - private NodeMapper defaultNodeMapper; - private NodeMapper treeTestResultNodeMapper; - - public void init() { - defaultNodeMapper.setNodeMapperProvider(this); - treeTestResultNodeMapper.setNodeMapperProvider(this); - } - - public NodeMapper findNodeMapper(Node node) { - try { - // useful to initialize recursivity - if (node == null) - return defaultNodeMapper; - - if ("testresult".equals(node.getName())) - return treeTestResultNodeMapper; - else - return defaultNodeMapper; - - } catch (RepositoryException re) { - throw new ArgeoException("Cannot find NodeMapper for node " + node, - re); - } - } - - public void setTreeTestResultNodeMapper(NodeMapper treeTestResultNodeMapper) { - this.treeTestResultNodeMapper = treeTestResultNodeMapper; - } - - public void setDefaultNodeMapper(NodeMapper defaultNodeMapper) { - this.defaultNodeMapper = defaultNodeMapper; - } - -} diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TestRunDescriptorDaoJcr.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TestRunDescriptorDaoJcr.java deleted file mode 100644 index 8cafb1777..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TestRunDescriptorDaoJcr.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.jcr.dao; - -import javax.jcr.Node; -import javax.jcr.RepositoryException; -import javax.jcr.query.Query; - -import org.argeo.jcr.JcrUtils; -import org.argeo.slc.SlcException; -import org.argeo.slc.dao.test.TestRunDescriptorDao; -import org.argeo.slc.test.TestRunDescriptor; - -public class TestRunDescriptorDaoJcr extends AbstractSlcJcrDao implements - TestRunDescriptorDao { - - public TestRunDescriptor getTestRunDescriptor(String id) { - // TODO: optimize query - String queryString = "//testrun[@testRunUuid='" + id + "']"; - Query query = createQuery(queryString, Query.XPATH); - Node node = JcrUtils.querySingleNode(query); - if (node == null) - return null; - return (TestRunDescriptor) nodeMapper.load(node); - } - - public void saveOrUpdate(TestRunDescriptor testRunDescriptor) { - try { - nodeMapper.save(getSession(), basePath(testRunDescriptor), - testRunDescriptor); - getSession().save(); - } catch (RepositoryException e) { - throw new SlcException("Cannot import " + testRunDescriptor, e); - } - } - -} diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TreeTestResultCollectionDaoJcr.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TreeTestResultCollectionDaoJcr.java deleted file mode 100644 index 0004bad93..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TreeTestResultCollectionDaoJcr.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.jcr.dao; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedSet; -import java.util.TreeSet; - -import javax.jcr.Node; -import javax.jcr.NodeIterator; -import javax.jcr.RepositoryException; -import javax.jcr.query.Query; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.jcr.JcrUtils; -import org.argeo.slc.SlcException; -import org.argeo.slc.core.test.tree.ResultAttributes; -import org.argeo.slc.core.test.tree.TreeTestResult; -import org.argeo.slc.core.test.tree.TreeTestResultCollection; -import org.argeo.slc.dao.test.tree.TreeTestResultCollectionDao; - -/** JCR implementation of collections DAO. */ -public class TreeTestResultCollectionDaoJcr extends AbstractSlcJcrDao implements - TreeTestResultCollectionDao { - - // FIXME : we handle testResultCollection by adding a property called - // "TestResultCollectionId " - final private String ttrColProp = "collectionId"; - - private final static Log log = LogFactory - .getLog(TreeTestResultCollectionDaoJcr.class); - - public void create(TreeTestResultCollection ttrCollection) { - try { - Node curNode; - String colId = ttrCollection.getId(); - for (TreeTestResult ttr : ttrCollection.getResults()) { - curNode = nodeMapper.save(getSession(), basePath(ttr), ttr); - curNode.setProperty(ttrColProp, colId); - } - getSession().save(); - } catch (RepositoryException e) { - throw new SlcException("Cannot create TreeTestResultCollection " - + ttrCollection, e); - } - } - - public TreeTestResultCollection getTestResultCollection(String id) { - TreeTestResultCollection res = new TreeTestResultCollection(); - res.setId(id); - NodeIterator ni = resultNodesInCollection(id); - while (ni.hasNext()) { - res.getResults().add( - (TreeTestResult) nodeMapper.load(ni.nextNode())); - } - return res; - } - - /** - * - * FIXME : validate what this method must really do ? what happen if one of - * the TreeTestResult of the collection is not found in the jcr repository? - * Now we create ttr that are not found and update existing ones. - * FurtherMore if a TreeTestResult is persisted as member the collection but - * is not in the object passed, it is removed. - */ - public void update(TreeTestResultCollection ttrCollection) { - try { - log.debug("Update "); - String colId = ttrCollection.getId(); - // We add or update existing ones - for (TreeTestResult ttr : ttrCollection.getResults()) { - String queryString = "//testresult[@uuid='" + ttr.getUuid() - + "']"; - Node curNode = singleNode(queryString, Query.XPATH); - if (curNode == null) { - curNode = nodeMapper.save(getSession(), basePath(ttr), ttr); - log.debug("New Node added"); - } else { - nodeMapper.update(curNode, ttr); - log.debug("Node updated"); - } - log - .debug("-----------------------------------------------------------------"); - curNode.setProperty(ttrColProp, colId); - JcrUtils.debug(curNode.getSession().getRootNode()); - } - // We remove those who are not part of the collection anymore - String queryString = "//*[@" + ttrColProp + "='" + colId + "']"; - Query query = createQuery(queryString, Query.XPATH); - log.debug("Query :" + queryString); - NodeIterator ni = query.execute().getNodes(); - int i = 0; - while (ni.hasNext()) { - log.debug("Node " + (++i)); - Node curNode = ni.nextNode(); - String uuid = curNode.getProperty("uuid").getString(); - boolean isPartOfTheSet = false; - for (TreeTestResult ttr : ttrCollection.getResults()) { - if (uuid.equals(ttr.getUuid())) { - isPartOfTheSet = true; - log.debug("Node " + i + " found"); - break; - } - } - if (!isPartOfTheSet) { - log.debug("Node " + i + " not found. trying to remove"); - curNode.getProperty(ttrColProp).remove(); - } - } - getSession().save(); - } catch (RepositoryException e) { - throw new SlcException("Cannot update TreeTestResultCollection " - + ttrCollection, e); - } - } - - public void delete(TreeTestResultCollection ttrCollection) { - try { - // FIXME: should not delete sub nodes - Node curNode; - String colId = ttrCollection.getId(); - NodeIterator ni = resultNodesInCollection(colId); - while (ni.hasNext()) { - curNode = ni.nextNode(); - curNode.remove(); - } - getSession().save(); - } catch (Exception e) { - throw new SlcException("Cannot delete TreeTestResultCollection " - + ttrCollection, e); - } - } - - public SortedSet listCollections() { - // FIXME: optimize - Map lst = new HashMap(); - NodeIterator nodeIterator = query("//testresult"); - while (nodeIterator.hasNext()) { - Node node = nodeIterator.nextNode(); - String colId = property(node, ttrColProp); - if (colId != null) { - if (!lst.containsKey(colId)) - lst.put(colId, new TreeTestResultCollection(colId)); - TreeTestResultCollection ttrc = lst.get(colId); - ttrc.getResults().add((TreeTestResult) nodeMapper.load(node)); - } - } - return new TreeSet(lst.values()); - } - - public void addResultToCollection(final TreeTestResultCollection ttrc, - final String resultUuid) { - try { - String queryString; - Node curNode; - String colId = ttrc.getId(); - queryString = "//testresult[@uuid='" + resultUuid + "']"; - curNode = singleNode(queryString, Query.XPATH); - if (curNode == null) { - throw new SlcException("Cannot find test result #" + resultUuid); - } else - curNode.setProperty(ttrColProp, colId); - getSession().save(); - } catch (Exception e) { - throw new SlcException("Cannot add TreeTestResult of Id " - + resultUuid + " to collection " + ttrc, e); - } - - } - - public void removeResultFromCollection(final TreeTestResultCollection ttrc, - final String resultUuid) { - try { - String queryString; - Node curNode; - queryString = "//testresult[@uuid='" + resultUuid + "' and " - + ttrColProp + "='" + ttrc.getId() + "']"; - Query query = createQuery(queryString, Query.XPATH); - curNode = JcrUtils.querySingleNode(query); - if (curNode == null) { - throw new SlcException("Cannot find test result #" + resultUuid); - } else { - curNode.getProperty(ttrColProp).remove(); - } - getSession().save(); - } catch (RepositoryException e) { - throw new SlcException("Cannot remove TreeTestResult of Id " - + resultUuid + " from collection " + ttrc, e); - } - } - - // FIXME specify and implement this method - public List listResultAttributes(String collectionId) { - // FIXME: optimize - List list = new ArrayList(); - if (collectionId == null) { - List results = asTreeTestResultList(resultNodes( - null, null)); - - for (TreeTestResult ttr : results) { - list.add(new ResultAttributes(ttr)); - } - } else { - NodeIterator nodeIterator = resultNodesInCollection(collectionId); - while (nodeIterator.hasNext()) { - list.add(new ResultAttributes((TreeTestResult) nodeMapper - .load(nodeIterator.nextNode()))); - } - } - - return list; - } - - public List listResults(String collectionId, - Map attributes) { - List list; - - if (collectionId == null) { - if (attributes == null || attributes.size() == 0) - list = asTreeTestResultList(resultNodes(null, null)); - else if (attributes.size() == 1) { - Map.Entry entry = attributes.entrySet() - .iterator().next(); - list = asTreeTestResultList(resultNodes(entry.getKey(), entry - .getValue())); - } else { - throw new SlcException( - "Multiple attributes filter are currently not supported."); - } - } else { - if (attributes == null || attributes.size() == 0) - list = asTreeTestResultList(resultNodesInCollection(collectionId)); - else if (attributes.size() == 1) { - Map.Entry entry = attributes.entrySet() - .iterator().next(); - list = asTreeTestResultList(resultNodesInCollection( - collectionId, entry.getKey(), entry.getValue())); - } else { - throw new SlcException( - "Multiple attributes filter are currently not supported."); - } - } - return list; - } - - // UTILITIES - - protected NodeIterator resultNodesInCollection(String collectionId, - String attributeKey, String attributeValue) { - String queryString = "//testresult[@" + ttrColProp + "='" - + collectionId + "' and @" + attributeKey + "='" - + attributeValue + "']"; - return query(queryString); - } - - protected NodeIterator resultNodesInCollection(String collectionId) { - String queryString = "//testresult[@" + ttrColProp + "='" - + collectionId + "']"; - return query(queryString); - } - - protected NodeIterator resultNodes(String attributeKey, - String attributeValue) { - String queryString; - if (attributeKey != null) - queryString = "//testresult[@" + attributeKey + "='" - + attributeValue + "']"; - else - queryString = "//testresult"; - return query(queryString); - } - - protected List asTreeTestResultList( - NodeIterator nodeIterator) { - List lst = new ArrayList(); - while (nodeIterator.hasNext()) { - lst.add((TreeTestResult) nodeMapper.load(nodeIterator.nextNode())); - } - return lst; - } - - private NodeIterator query(String query) { - try { - if (log.isDebugEnabled()) - log.debug("Retrieve nodes from query: " + query); - Query q = createQuery(query, Query.XPATH); - return q.execute().getNodes(); - } catch (RepositoryException e) { - throw new SlcException("Cannot load nodes from query: " + query); - } - } - - private String property(Node node, String key) { - try { - return node.getProperty(key).getString(); - } catch (RepositoryException e) { - log.warn("Cannot retrieve property " + key + " of node " + node, e); - return null; - } - } - - private Node singleNode(String query, String queryType) { - Query q = createQuery(query, queryType); - return JcrUtils.querySingleNode(q); - } - -} diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TreeTestResultDaoJcr.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TreeTestResultDaoJcr.java deleted file mode 100644 index 154c3c7bc..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TreeTestResultDaoJcr.java +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.jcr.dao; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; - -import javax.jcr.Node; -import javax.jcr.NodeIterator; -import javax.jcr.RepositoryException; -import javax.jcr.Session; -import javax.jcr.query.Query; -import javax.jcr.query.QueryManager; -import javax.jcr.query.QueryResult; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.jcr.JcrUtils; -import org.argeo.slc.SlcException; -import org.argeo.slc.core.attachment.SimpleAttachment; -import org.argeo.slc.core.structure.tree.TreeSPath; -import org.argeo.slc.core.test.SimpleResultPart; -import org.argeo.slc.core.test.tree.TreeTestResult; -import org.argeo.slc.dao.test.tree.TreeTestResultDao; -import org.argeo.slc.structure.StructureElement; -import org.argeo.slc.test.TestResult; - -/** - * The JCR implementation for tree-based result of the test result dao. - * - * @see TreeTestResult - */ - -public class TreeTestResultDaoJcr extends AbstractSlcJcrDao implements - TreeTestResultDao { - - private final static Log log = LogFactory - .getLog(TreeTestResultDaoJcr.class); - - public synchronized void create(TestResult testResult) { - try { - nodeMapper.save(getSession(), basePath(testResult), testResult); - getSession().save(); - } catch (Exception e) { - throw new SlcException("Cannot create testResult " + testResult, e); - } - } - - public synchronized void update(TestResult testResult) { - try { - nodeMapper.save(getSession(), basePath(testResult), testResult); - getSession().save(); - } catch (Exception e) { - throw new SlcException("Cannot update testResult" + testResult, e); - } - } - - public TreeTestResult getTestResult(String uuid) { - String queryString = "//testresult[@uuid='" + uuid + "']"; - Query query = createQuery(queryString, Query.XPATH); - Node node = JcrUtils.querySingleNode(query); - if (node == null) - return null; - return (TreeTestResult) nodeMapper.load(node); - - } - - public List listTestResults() { - try { - // TODO: optimize query - String queryString = "//testresult"; - Query query = createQuery(queryString, Query.XPATH); - QueryResult queryResult = query.execute(); - NodeIterator nodeIterator = queryResult.getNodes(); - if (nodeIterator.hasNext()) { - List list = new ArrayList(); - nodes: while (nodeIterator.hasNext()) { - Node curNode = (Node) nodeIterator.next(); - - // TODO improve architecture and get rid of this hack - if ("slc".equals(curNode.getParent().getName())) - continue nodes; - - list.add((TreeTestResult) nodeMapper.load(curNode)); - } - return list; - } else - return null; - - } catch (RepositoryException e) { - throw new SlcException("Cannot load list of TestResult ", e); - } - } - - public List listResults(TreeSPath path) { - try { - // TODO: optimize query - String queryString = "//testresult" + path.getAsUniqueString(); - Query query = createQuery(queryString, Query.XPATH); - QueryResult queryResult = query.execute(); - NodeIterator nodeIterator = queryResult.getNodes(); - if (nodeIterator.hasNext()) { - List list = new ArrayList(); - while (nodeIterator.hasNext()) { - list.add((TreeTestResult) nodeMapper - .load((Node) nodeIterator.next())); - } - return list; - } else - return null; - - } catch (RepositoryException e) { - throw new SlcException("Cannot load list of TestResult ", e); - } - } - - public synchronized void close(final String testResultId, - final Date closeDate) { - try { - // TODO: optimize query - String queryString = "//testresult[@uuid='" + testResultId + "']"; - Query query = createQuery(queryString, Query.XPATH); - Node resNode = JcrUtils.querySingleNode(query); - Calendar cal = new GregorianCalendar(); - cal.setTime(closeDate); - if (resNode != null) - resNode.setProperty("closeDate", cal); - else if (log.isDebugEnabled()) - log.debug("Cannot close because a node for test result # " - + testResultId + " was not found"); - getSession().save(); - } catch (RepositoryException e) { - throw new SlcException("Cannot close TestResult " + testResultId, e); - } - - } - - /** - * Add a SimpleResultPart to the TreeTestResult of ID testResultId at - * treeSPath path - * - * May also add some relatedElements - * - */ - // TODO do we load objects, do treatment and persist them or do we work - // directly in JCR - public synchronized void addResultPart(final String testResultId, - final TreeSPath path, final SimpleResultPart resultPart, - final Map relatedElements) { - - try { - // TODO: optimize query - String queryString = "//testresult[@uuid='" + testResultId + "']"; - Query query = createQuery(queryString, Query.XPATH); - Node resNode = JcrUtils.querySingleNode(query); - - Node curNode; - String usedPath = path.getAsUniqueString().substring(1) - + "/partsublist"; - - if (resNode.hasNode(usedPath)) - curNode = resNode.getNode(usedPath); - else { - - // TODO Factorize that - Node tmpNode = resNode; - String[] pathes = usedPath.split("/"); - for (int i = 0; i < pathes.length; i++) { - if (tmpNode.hasNode(pathes[i])) - tmpNode = tmpNode.getNode(pathes[i]); - else - tmpNode = tmpNode.addNode(pathes[i]); - } - curNode = tmpNode; - } - - nodeMapper.update(curNode.addNode("resultPart"), resultPart); - - if (relatedElements != null) { - for (TreeSPath key : relatedElements.keySet()) { - String relPath = key.getAsUniqueString().substring(1); - - // check if already exists. - if (!resNode.hasNode(relPath)) { - - // TODO Factorize that - Node tmpNode = resNode; - String[] pathes = usedPath.split("/"); - for (int i = 0; i < pathes.length; i++) { - if (tmpNode.hasNode(pathes[i])) - tmpNode = tmpNode.getNode(pathes[i]); - else - tmpNode = tmpNode.addNode(pathes[i]); - } - curNode = tmpNode; - } else - curNode = resNode.getNode(relPath); - - curNode.setProperty("label", relatedElements.get(key) - .getLabel()); - // We add the tags - Map tags = relatedElements.get(key) - .getTags(); - - for (String tag : tags.keySet()) { - NodeIterator tagIt = curNode.getNodes("tag"); - Node tagNode = null; - while (tagIt.hasNext()) { - Node n = tagIt.nextNode(); - if (n.getProperty("name").getString().equals(tag)) { - tagNode = n; - } - } - - if (tagNode == null) { - tagNode = curNode.addNode("tag"); - tagNode.setProperty("name", tag); - } - - tagNode.setProperty("value", tags.get(tag)); - - // remove forbidden characters - // String cleanTag = - // JcrUtils.removeForbiddenCharacters(tag); - // if (!cleanTag.equals(tag)) - // log.warn("Tag '" + tag + "' persisted as '" + - // cleanTag - // + "'"); - // childNode.setProperty(cleanTag, tags.get(tag)); - } - // for (String tag : tags.keySet()) { - // String cleanTag = JcrUtils - // .removeForbiddenCharacters(tag); - // if (!cleanTag.equals(tag)) - // log.warn("Tag '" + tag + "' persisted as '" - // + cleanTag + "'"); - // curNode.setProperty(cleanTag, tags.get(tag)); - // } - - // We set the class in order to be able to retrieve - curNode.setProperty("class", StructureElement.class - .getName()); - } - } - getSession().save(); - - } catch (RepositoryException e) { - throw new SlcException("Cannot add resultPart", e); - } - } - - public synchronized void addAttachment(final String testResultId, - final SimpleAttachment attachment) { - - try { - // TODO: optimize query - // Might not be OK. - // Do we have a notion of "currentNode" when we call JCRUtils one - // more time. - - // Check if attachment already exists - String queryString = "//testresult[@uuid='" + testResultId + "']"; - Query query = createQuery(queryString, Query.XPATH); - Node resNode = JcrUtils.querySingleNode(query); - - queryString = ".//*[@uuid='" + attachment.getUuid() + "']"; - query = createQuery(queryString, Query.XPATH); - Node atNode = JcrUtils.querySingleNode(query); - - if (atNode != null) { - if (log.isDebugEnabled()) - log.debug("Attachement already There "); - } else { - if (resNode.hasNode("attachments")) - atNode = resNode.getNode("attachments"); - else { - atNode = resNode.addNode("attachments"); - } - Node attachNode; - attachNode = atNode.addNode(attachment.getName()); - attachNode.setProperty("uuid", attachment.getUuid()); - attachNode.setProperty("contentType", attachment - .getContentType()); - getSession().save(); - } - - } catch (RepositoryException e) { - throw new SlcException("Cannot Add Attachment to " + testResultId, - e); - } - } - - protected TreeTestResult getTreeTestResult(Session session, - String testResultId) { - try { - String queryString = "//testresult[@uuid='" + testResultId + "']"; - QueryManager qm = session.getWorkspace().getQueryManager(); - Query query = qm.createQuery(queryString, Query.XPATH); - Node node = JcrUtils.querySingleNode(query); - if (node == null) - return null; - return (TreeTestResult) nodeMapper.load(node); - - } catch (RepositoryException e) { - throw new SlcException("Cannot load TestResult with ID " - + testResultId + " For Session " + session, e); - } - } - - public synchronized void updateAttributes(final String testResultId, - final SortedMap attributes) { - try { - String queryString = "//testresult[@uuid='" + testResultId + "']"; - Query query = createQuery(queryString, Query.XPATH); - Node node = JcrUtils.querySingleNode(query); - - for (String key : attributes.keySet()) { - node.setProperty(key, attributes.get(key)); - } - getSession().save(); - } catch (RepositoryException e) { - throw new SlcException( - "Cannot update Attributes on TestResult with ID " - + testResultId, e); - } - } - -} diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TreeTestResultNodeMapper.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TreeTestResultNodeMapper.java deleted file mode 100644 index d27157b7c..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/dao/TreeTestResultNodeMapper.java +++ /dev/null @@ -1,369 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.jcr.dao; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; -import java.util.Vector; - -import javax.jcr.Node; -import javax.jcr.NodeIterator; -import javax.jcr.Property; -import javax.jcr.PropertyIterator; -import javax.jcr.RepositoryException; -import javax.jcr.query.Query; -import javax.jcr.query.QueryManager; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.jcr.spring.BeanNodeMapper; -import org.argeo.slc.core.attachment.SimpleAttachment; -import org.argeo.slc.core.structure.SimpleSElement; -import org.argeo.slc.core.structure.tree.TreeSPath; -import org.argeo.slc.core.test.tree.PartSubList; -import org.argeo.slc.core.test.tree.TreeTestResult; -import org.argeo.slc.structure.StructureElement; -import org.argeo.slc.test.TestResultPart; -import org.springframework.beans.BeanWrapper; - -public class TreeTestResultNodeMapper extends BeanNodeMapper { - private final static Log log = LogFactory - .getLog(TreeTestResultNodeMapper.class); - - /** - * Transforms a TreeTestResult to the specified jcr Node in order to persist - * it. - * - * @param beanWrapper - * @param node - * @throws RepositoryException - */ - protected void beanToNode(BeanWrapper beanWrapper, Node node) - throws RepositoryException { - - if (log.isTraceEnabled()) - log.debug("Map TreeTestResult to node " + node.getPath()); - - // We know we are mapping a TreeTestResult so we cast it - TreeTestResult ttr = (TreeTestResult) beanWrapper.getWrappedInstance(); - - // First we persist the class - node.setProperty(getClassProperty(), ttr.getClass().getName()); - - // Then we persist String uuid, Date closeDate - node.setProperty("uuid", ttr.getUuid()); - if (ttr.getCloseDate() != null) { - Calendar cal = new GregorianCalendar(); - cal.setTime(ttr.getCloseDate()); - node.setProperty("closeDate", cal); - } - - Node childNode; - - // Elements & resultParts are merged, we use treeSPath to build the tree - // Element label is stored as a property of the vertice - // ResultParts are stored as childNode named resultpart[xx]. - - SortedMap elements = ttr.getElements(); - - for (TreeSPath key : elements.keySet()) { - String relPath = key.getAsUniqueString(); - // We remove the first separator - relPath = relPath.substring(1); - - // check if already exists. - if (!node.hasNode(relPath)) { - // TODO Factorize that - Node tmpNode = node; - String[] pathes = relPath.split("/"); - for (int i = 0; i < pathes.length; i++) { - if (tmpNode.hasNode(pathes[i])) - tmpNode = tmpNode.getNode(pathes[i]); - else - tmpNode = tmpNode.addNode(pathes[i]); - } - childNode = tmpNode; - } else - childNode = node.getNode(relPath); - - childNode.setProperty("label", elements.get(key).getLabel()); - // We add the tags - Map tags = elements.get(key).getTags(); - for (String tag : tags.keySet()) { - NodeIterator tagIt = childNode.getNodes("tag"); - Node tagNode = null; - while (tagIt.hasNext()) { - Node n = tagIt.nextNode(); - if (n.getProperty("name").getString().equals(tag)) { - tagNode = n; - } - } - - if (tagNode == null) { - tagNode = childNode.addNode("tag"); - tagNode.setProperty("name", tag); - } - - tagNode.setProperty("value", tags.get(tag)); - - // remove forbidden characters - // String cleanTag = JcrUtils.removeForbiddenCharacters(tag); - // if (!cleanTag.equals(tag)) - // log.warn("Tag '" + tag + "' persisted as '" + cleanTag - // + "'"); - // childNode.setProperty(cleanTag, tags.get(tag)); - } - - // We set the class in order to be able to retrieve - childNode.setProperty(getClassProperty(), StructureElement.class - .getName()); - } - - SortedMap resultParts = ttr.getResultParts(); - - for (TreeSPath key : resultParts.keySet()) { - String relPath = key.getAsUniqueString(); - - // we get rid of the '/' that begins every TreeSPath Unique string - // and add the partsublist level - relPath = relPath.substring(1) + "/partsublist"; - - // check if already exists. - if (!node.hasNode(relPath)) { - // TODO Factorize that - Node tmpNode = node; - String[] pathes = relPath.split("/"); - for (int i = 0; i < pathes.length; i++) { - if (tmpNode.hasNode(pathes[i])) - tmpNode = tmpNode.getNode(pathes[i]); - else - tmpNode = tmpNode.addNode(pathes[i]); - } - childNode = tmpNode; - //log.debug("Node created " + childNode.getPath()); - } else { - childNode = node.getNode(relPath); - //log.debug("Node already existing " + childNode.getPath()); - } - - List list = resultParts.get(key).getParts(); - - Node listNode; - int i; - for (i = 0; i < list.size(); i++) { - // TestResultPart trp = list.get(i); - // FIXME : ResultParts are systematicaly added. - // There no check to see if already exists. - listNode = childNode.addNode("resultpart"); - update(listNode, list.get(i)); - } - } - - // TODO : store files in the graph - // As for now, we only store on a vertice called after the name value of - // the SimpleAttachment Object - // and uuid & contentType as property - - List attachments = ttr.getAttachments(); - if (attachments.size() != 0) { - if (node.hasNode("attachments")) - childNode = node.getNode("attachments"); - else { - if (getPrimaryNodeType() != null) - childNode = node.addNode("attachments", - getPrimaryNodeType()); - else - childNode = node.addNode("attachments"); - } - Node attachNode; - for (int i = 0; i < attachments.size(); i++) { - attachNode = childNode.addNode(attachments.get(i).getName()); - attachNode.setProperty("uuid", attachments.get(i).getUuid()); - attachNode.setProperty("contentType", attachments.get(i) - .getContentType()); - } - } - - // attributes are stored as properties of the testResult node - for (String key : ttr.getAttributes().keySet()) { - String mapValue = ttr.getAttributes().get(key); - node.setProperty(key, mapValue); - } - - } - - /** - * Transforms a node into a TreeTestResult Instance - */ - @SuppressWarnings("unchecked") - protected Object nodeToBean(Node node) throws RepositoryException { - // method variables - String uuid; - String clssName = node.getProperty(getClassProperty()).getString(); - QueryManager qm = node.getSession().getWorkspace().getQueryManager(); - Query query; - - if (log.isTraceEnabled()) - log.debug("Map node " + node.getPath() + " to bean " + clssName); - - // It's a very specific implementation, - // We don't need to use a bean wrapper. - TreeTestResult ttr = new TreeTestResult(); - - // RESULTPART PARAMETERS - uuid = node.getProperty("uuid").getString(); - ttr.setUuid(uuid); - - if (node.hasProperty("closeDate")) { - ttr.setCloseDate((node.getProperty("closeDate").getDate()) - .getTime()); - } - - // ATTRIBUTES - SortedMap attributes = new TreeMap(); - PropertyIterator propIt = node.getProperties(); - props: while (propIt.hasNext()) { - Property prop = propIt.nextProperty(); - - // TODO Define a rule to generalize it (Namespace ??) - // Get rid of specific case. mainly uuid - if ("uuid".equals(prop.getName()) - || prop.getName().equals(getClassProperty()) - || prop.getName().startsWith("jcr")) { - continue props; - } - - // else it's an attribute, we retrieve it - attributes.put(prop.getName(), prop.getString()); - } - ttr.setAttributes(attributes); - - // ATTACHMENTS - NodeIterator ni; - if (node.hasNode("attachments")) { - List attachments = new ArrayList(); - - ni = node.getNode("attachments").getNodes(); - while (ni.hasNext()) { - Node curNode = ni.nextNode(); - attachments.add(new SimpleAttachment(curNode - .getProperty("uuid").getString(), curNode.getName(), - curNode.getProperty("contentType").getString())); - } - ttr.setAttachments(attachments); - } - - // STRUCTURED ELEMENTS - - String basePath = node.getPath(); - SortedMap resultParts = new TreeMap(); - SortedMap elements = new TreeMap(); - - // We have to add the uuid of the current node to be sure that we are in - // its sub tree - String queryString = "//testresult[@uuid='" + uuid + "']"; - - // Business part of the current query - queryString = queryString + "//*[@" + getClassProperty() + "='" - + StructureElement.class.getName() + "']"; - - query = qm.createQuery(queryString, Query.XPATH); - ni = query.execute().getNodes(); - - while (ni.hasNext()) { - Node curNode = ni.nextNode(); - String curPath = curNode.getPath().substring(basePath.length()); - TreeSPath tsp = new TreeSPath(); - - // We must add the "/" at the begining of the jcr path to have a - // TreeSPath string - tsp.setAsUniqueString(tsp.getSeparator() + curPath); - - SimpleSElement se = new SimpleSElement(); - se.setLabel(curNode.getProperty("label").getString()); - - Map tagMap = new TreeMap(); - NodeIterator tagIt = node.getNodes("tag"); - while (tagIt.hasNext()) { - Node tagNode = tagIt.nextNode(); - tagMap.put(tagNode.getProperty("name").getString(), tagNode - .getProperty("value").getString()); - - } - // PropertyIterator tagIt = curNode.getProperties(); - // tags: while (tagIt.hasNext()) { - // Property prop = tagIt.nextProperty(); - // //log.debug("Handling property named : " + prop.getName()); - // - // // TODO Define a rule to generalize it - // // Specific case. mainly uuid - // if ("uuid".equals(prop.getName()) - // || prop.getName().equals(getClassProperty()) - // || prop.getName().startsWith("jcr")) { - // continue tags; - // } - // - // // else it's an attribute, we retrieve it - // tagMap.put(prop.getName(), prop.getString()); - // } - - se.setTags(tagMap); - elements.put(tsp, se); - } - //log.debug("We added " + elements.size() + " elements"); - - ttr.setElements(elements); - - // RESULTPARTS - - // We have to had the uuid of the current node to be sure that we are in - // its sub tree - queryString = "//testresult[@uuid='" + uuid + "']"; - - // Business part of the current query - queryString = queryString + "//partsublist"; - query = qm.createQuery(queryString, Query.XPATH); - ni = query.execute().getNodes(); - while (ni.hasNext()) { - Node curNode = ni.nextNode(); - String curPath = curNode.getParent().getPath().substring( - basePath.length()); - - TreeSPath tsp = new TreeSPath(); - // We must add the "/" at the begining of the jcr path to have a - // TreeSPath string - tsp.setAsUniqueString(tsp.getSeparator() + curPath); - - NodeIterator ni2 = curNode.getNodes("resultpart"); - List parts = new Vector(); - while (ni2.hasNext()) { - parts.add((TestResultPart) load(ni2.nextNode())); - } - PartSubList psl = new PartSubList(); - psl.setParts(parts); - resultParts.put(tsp, psl); - } - - ttr.setResultParts(resultParts); - - return ttr; - } -} diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrResultListener.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrResultListener.java deleted file mode 100644 index ce5dbf76c..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrResultListener.java +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.jcr.execution; - -import java.util.Collections; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.Map; - -import javax.jcr.Node; -import javax.jcr.NodeIterator; -import javax.jcr.Property; -import javax.jcr.PropertyIterator; -import javax.jcr.RepositoryException; -import javax.jcr.Session; -import javax.jcr.query.Query; -import javax.jcr.query.QueryManager; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.jcr.JcrUtils; -import org.argeo.slc.SlcException; -import org.argeo.slc.core.attachment.Attachment; -import org.argeo.slc.core.structure.SimpleSElement; -import org.argeo.slc.core.structure.tree.TreeSPath; -import org.argeo.slc.core.test.SimpleResultPart; -import org.argeo.slc.core.test.tree.PartSubList; -import org.argeo.slc.core.test.tree.TreeTestResult; -import org.argeo.slc.core.test.tree.TreeTestResultListener; -import org.argeo.slc.jcr.SlcJcrUtils; -import org.argeo.slc.jcr.SlcNames; -import org.argeo.slc.jcr.SlcTypes; -import org.argeo.slc.test.TestResultPart; -import org.argeo.slc.test.TestStatus; - -/** - * Persists results in JCR by listening to {@link TreeTestResult}. This is to - * facilitate transition from legacy approaches and should not be used in new - * implementations. - */ -public class JcrResultListener implements TreeTestResultListener, SlcNames { - private final static Log log = LogFactory.getLog(JcrResultListener.class); - - private Session session; - - /** Caches the mapping between SLC uuids and internal JCR identifiers */ - private Map uuidToIdentifier = Collections - .synchronizedMap(new HashMap()); - - public void resultPartAdded(TreeTestResult testResult, - TestResultPart testResultPart) { - try { - String uuid = testResult.getUuid(); - Node resultNode = getResultNode(uuid); - if (resultNode == null) { - resultNode = createResultNode(testResult); - // session.save(); - } - String partParentPath; - TreeSPath currentPath = testResult.getCurrentPath(); - if (currentPath != null) { - String subPath = currentPath.getAsUniqueString(); - partParentPath = resultNode.getPath() + subPath; - } else { - partParentPath = resultNode.getPath(); - // TODO create some depth? - } - - Node partParentNode; - if (session.itemExists(partParentPath)) { - partParentNode = session.getNode(partParentPath); - } else { - partParentNode = JcrUtils.mkdirs(session, partParentPath); - // session.save(); - } - // create part node - SimpleSElement element = null; - if (testResult.getElements().containsKey(currentPath)) { - element = (SimpleSElement) testResult.getElements().get( - currentPath); - } - - String elementLabel = element != null && element.getLabel() != null - && !element.getLabel().trim().equals("") ? element - .getLabel() : null; - String partNodeName = elementLabel != null ? JcrUtils - .replaceInvalidChars(elementLabel, '_') : Long - .toString(System.currentTimeMillis()); - - Node resultPartNode = partParentNode.addNode(partNodeName, - SlcTypes.SLC_CHECK); - resultPartNode.setProperty(SLC_SUCCESS, - testResultPart.getStatus() == TestStatus.PASSED); - if (elementLabel != null) - resultPartNode.setProperty(Property.JCR_TITLE, elementLabel); - if (testResultPart.getMessage() != null) - resultPartNode.setProperty(SLC_MESSAGE, - testResultPart.getMessage()); - if (testResultPart.getExceptionMessage() != null) - resultPartNode.setProperty(SLC_ERROR_MESSAGE, - testResultPart.getExceptionMessage()); - // JcrUtils.debug(resultPartNode); - - JcrUtils.updateLastModified(resultNode); - - if (element != null) { - element = (SimpleSElement) testResult.getElements().get( - currentPath); - if (log.isTraceEnabled()) - log.trace(" Path= " + currentPath + ", part=" - + testResultPart.getMessage()); - for (Map.Entry tag : element.getTags() - .entrySet()) { - String tagNodeName = JcrUtils.replaceInvalidChars( - tag.getKey(), '_'); - // log.debug("key=" + tag.getKey() + ", tagNodeName=" - // + tagNodeName); - Node tagNode = resultPartNode.addNode(tagNodeName, - SlcTypes.SLC_PROPERTY); - tagNode.setProperty(SLC_NAME, tag.getKey()); - tagNode.setProperty(SLC_VALUE, tag.getValue()); - } - } - - session.save(); - } catch (RepositoryException e) { - JcrUtils.discardQuietly(session); - log.error("Cannot add result part " + testResultPart + " to " - + testResult, e); - // throw new SlcException("Cannot add result part " + testResultPart - // + " to " + testResult, e); - } - - } - - /** @return null if does not exist */ - protected Node getResultNode(String uuid) throws RepositoryException { - Node resultNode; - if (uuidToIdentifier.containsKey(uuid)) { - return session.getNodeByIdentifier(uuidToIdentifier.get(uuid)); - } else { - Query q = session - .getWorkspace() - .getQueryManager() - .createQuery( - "select * from [slc:result] where [slc:uuid]='" - + uuid + "'", Query.JCR_SQL2); - resultNode = JcrUtils.querySingleNode(q); - if (resultNode != null) - uuidToIdentifier.put(uuid, resultNode.getIdentifier()); - } - return resultNode; - } - - protected Node createResultNode(TreeTestResult testResult) - throws RepositoryException { - String uuid = testResult.getUuid(); - String path = SlcJcrUtils.createResultPath(session, uuid); - Node resultNode = JcrUtils.mkdirs(session, path, SlcTypes.SLC_TEST_RESULT); - resultNode.setProperty(SLC_UUID, uuid); - for (Map.Entry entry : testResult.getAttributes() - .entrySet()) { - resultNode.setProperty(entry.getKey(), entry.getValue()); - } - - uuidToIdentifier.put(uuid, resultNode.getIdentifier()); - return resultNode; - } - - public void close(TreeTestResult testResult) { - try { - String uuid = testResult.getUuid(); - Node resultNode = getResultNode(uuid); - if (resultNode == null) - resultNode = createResultNode(testResult); - JcrUtils.updateLastModified(resultNode); - GregorianCalendar closeDate = new GregorianCalendar(); - closeDate.setTime(testResult.getCloseDate()); - resultNode.setProperty(SLC_COMPLETED, closeDate); - - uuidToIdentifier.remove(uuid); - session.save(); - - if (log.isDebugEnabled()) - log.debug("Closed test result " + uuid); - } catch (RepositoryException e) { - JcrUtils.discardQuietly(session); - log.error("Cannot close result " + testResult, e); - // throw new SlcException("Cannot close result " + testResult, e); - } - - } - - public void addAttachment(TreeTestResult testResult, Attachment attachment) { - - } - - public void setSession(Session session) { - this.session = session; - } - - /** - * Creates and populates a {@link TreeTestResult} from the related result - * node. Meant to simplify migration of legacy applications. This is no - * stable API. - */ - public static TreeTestResult nodeToTreeTestResult(Node resultNode) { - try { - String resultPath = resultNode.getPath(); - TreeTestResult ttr = new TreeTestResult(); - // base properties - ttr.setUuid(resultNode.getProperty(SLC_UUID).getString()); - if (resultNode.hasProperty(SLC_COMPLETED)) - ttr.setCloseDate(resultNode.getProperty(SLC_COMPLETED) - .getDate().getTime()); - // attributes - for (PropertyIterator pit = resultNode.getProperties(); pit - .hasNext();) { - Property p = pit.nextProperty(); - if (p.getName().indexOf(':') < 0) { - ttr.getAttributes().put(p.getName(), p.getString()); - } - } - - QueryManager qm = resultNode.getSession().getWorkspace() - .getQueryManager(); - String statement = "SELECT * FROM [" + SlcTypes.SLC_CHECK - + "] WHERE ISDESCENDANTNODE(['" + resultPath + "'])"; - NodeIterator nit = qm.createQuery(statement, Query.JCR_SQL2) - .execute().getNodes(); - while (nit.hasNext()) { - Node checkNode = nit.nextNode(); - String relPath = checkNode.getPath().substring( - resultPath.length()); - TreeSPath tsp = new TreeSPath(relPath); - - // result part - SimpleResultPart srp = new SimpleResultPart(); - if (checkNode.getProperty(SLC_SUCCESS).getBoolean()) - srp.setStatus(TestStatus.PASSED); - else if (checkNode.hasProperty(SLC_ERROR_MESSAGE)) - srp.setStatus(TestStatus.ERROR); - else - srp.setStatus(TestStatus.FAILED); - if (checkNode.hasProperty(SLC_MESSAGE)) - srp.setMessage(checkNode.getProperty(SLC_MESSAGE) - .getString()); - if (!ttr.getResultParts().containsKey(tsp)) - ttr.getResultParts().put(tsp, new PartSubList()); - ttr.getResultParts().get(tsp).getParts().add(srp); - - // element - SimpleSElement elem = new SimpleSElement(); - if (checkNode.hasProperty(Property.JCR_TITLE)) - elem.setLabel(checkNode.getProperty(Property.JCR_TITLE) - .getString()); - else - elem.setLabel("");// some legacy code expect it to be set - for (NodeIterator tagIt = checkNode.getNodes(); tagIt.hasNext();) { - Node tagNode = tagIt.nextNode(); - elem.getTags().put( - tagNode.getProperty(SLC_NAME).getString(), - tagNode.getProperty(SLC_VALUE).getString()); - } - ttr.getElements().put(tsp, elem); - } - return ttr; - } catch (RepositoryException e) { - throw new SlcException("Cannot generate tree test result from " - + resultNode, e); - } - } -} diff --git a/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/SlcAgentDescriptorDaoJcrTest.java b/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/SlcAgentDescriptorDaoJcrTest.java deleted file mode 100644 index 7af874373..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/SlcAgentDescriptorDaoJcrTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.jcr.dao; - -import java.io.ByteArrayOutputStream; -import java.net.InetAddress; -import java.util.UUID; - -import javax.jcr.Session; - -import org.argeo.slc.dao.runtime.SlcAgentDescriptorDao; -import org.argeo.slc.runtime.SlcAgentDescriptor; -import org.argeo.slc.unit.AbstractSpringTestCase; - -public class SlcAgentDescriptorDaoJcrTest extends AbstractSpringTestCase { - // private final static Log log = LogFactory - // .getLog(SlcAgentDescriptorDaoJcrTest.class); - - private SlcAgentDescriptorDao slcAgentDescriptorDao; - private String host = "localhost"; - - @Override - protected void setUp() throws Exception { - super.setUp(); - slcAgentDescriptorDao = getBean(SlcAgentDescriptorDao.class); - } - - public void testZero() throws Exception { - SlcAgentDescriptor slcAgentDescriptor0 = new SlcAgentDescriptor(); - slcAgentDescriptor0.setHost(host); - slcAgentDescriptor0.setUuid(UUID.randomUUID().toString()); - } - - public void testExportXml() throws Exception { - SlcAgentDescriptor slcAgentDescriptor0 = new SlcAgentDescriptor(); - slcAgentDescriptor0.setHost(host); - - String agentID = UUID.randomUUID().toString(); - slcAgentDescriptor0.setUuid(agentID); - slcAgentDescriptorDao.create(slcAgentDescriptor0); - - Session session = getBean(Session.class); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - session.exportDocumentView("/slc", out, true, false); - log.debug("\n\n"+new String(out.toByteArray())+"\n\n"); - - } - - public void testCreate() throws Exception { - SlcAgentDescriptor slcAgentDescriptor0 = new SlcAgentDescriptor(); - slcAgentDescriptor0.setHost(host); - - String agentID = UUID.randomUUID().toString(); - slcAgentDescriptor0.setUuid(agentID); - slcAgentDescriptorDao.create(slcAgentDescriptor0); - - // JcrUtils.debug(session.getRootNode()); - - SlcAgentDescriptor slcAgentDescriptor1 = slcAgentDescriptorDao - .getAgentDescriptor(agentID); - // log.debug("expected agentID :"+agentID+ - // " . Retrieved one : "+slcAgentDescriptor1.getUuid()); - // TODO : compare retrieved AgentDescriptor with expected one. - assertEquals(agentID, slcAgentDescriptor1.getUuid()); - - slcAgentDescriptorDao.delete(agentID); - - } - - public void testList() throws Exception { - SlcAgentDescriptor slcAgentDescriptor0 = new SlcAgentDescriptor(); - SlcAgentDescriptor slcAgentDescriptor1 = new SlcAgentDescriptor(); - SlcAgentDescriptor slcAgentDescriptor2 = new SlcAgentDescriptor(); - - slcAgentDescriptor0.setHost(host); - slcAgentDescriptor1.setHost(host); - slcAgentDescriptor2.setHost(host); - - String agentID = UUID.randomUUID().toString(); - String agentID1 = UUID.randomUUID().toString(); - String agentID2 = UUID.randomUUID().toString(); - - slcAgentDescriptor0.setUuid(agentID); - slcAgentDescriptor1.setUuid(agentID1); - slcAgentDescriptor2.setUuid(agentID2); - - slcAgentDescriptorDao.create(slcAgentDescriptor0); - slcAgentDescriptorDao.create(slcAgentDescriptor1); - slcAgentDescriptorDao.create(slcAgentDescriptor2); - - // List list = - // slcAgentDescriptorDao.listSlcAgentDescriptors(); - } - -} diff --git a/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/SlcExecutionDaoJcrTest.java b/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/SlcExecutionDaoJcrTest.java deleted file mode 100644 index 8bad6475a..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/SlcExecutionDaoJcrTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.jcr.dao; - -import java.net.InetAddress; - -import javax.jcr.Session; - -import org.argeo.jcr.JcrUtils; -import org.argeo.slc.dao.process.SlcExecutionDao; -import org.argeo.slc.process.SlcExecution; -import org.argeo.slc.process.SlcExecutionStep; -import org.argeo.slc.unit.AbstractSpringTestCase; -import org.argeo.slc.unit.process.SlcExecutionTestUtils; - -public class SlcExecutionDaoJcrTest extends AbstractSpringTestCase { - private SlcExecutionDao slcExecutionDao; - private Session session; - private String host; - - @Override - protected void setUp() throws Exception { - super.setUp(); - slcExecutionDao = getBean(SlcExecutionDao.class); - session = getBean(Session.class); - host = "localhost"; - } - - public void testCreate() throws Exception { - SlcExecution slcExecution0 = SlcExecutionTestUtils - .createSimpleSlcExecution(); - slcExecution0.setHost(host); - slcExecutionDao.create(slcExecution0); - - SlcExecution slcExecution = SlcExecutionTestUtils - .createSlcExecutionWithRealizedFlows(); - slcExecution.setHost(host); - String uuid = slcExecution.getUuid(); - slcExecutionDao.create(slcExecution); - - JcrUtils.debug(session.getRootNode()); - - SlcExecution slcExecutionPersist = slcExecutionDao - .getSlcExecution(uuid); - SlcExecutionTestUtils.assertSlcExecution(slcExecution, - slcExecutionPersist); - } - - public void testUpdate() throws Exception { - SlcExecution slcExecution0 = SlcExecutionTestUtils - .createSimpleSlcExecution(); - slcExecution0.setHost(host); - slcExecutionDao.create(slcExecution0); - String uuid = slcExecution0.getUuid(); - - SlcExecution slcExecution = SlcExecutionTestUtils - .createSlcExecutionWithRealizedFlows(); - slcExecution.setUuid(uuid); - slcExecution.setHost(host); - slcExecution.getSteps().add(new SlcExecutionStep("My log")); - slcExecutionDao.update(slcExecution); - - JcrUtils.debug(session.getRootNode()); - - SlcExecution slcExecutionPersist = slcExecutionDao - .getSlcExecution(uuid); - SlcExecutionTestUtils.assertSlcExecution(slcExecution, - slcExecutionPersist); - } - - // // FIXME - // protected void tearDown() { - // try { - // super.tearDown(); - // } catch (Exception e) { - // log.debug("pbs Remain while closing jcr test env."); - // log.debug("Exc Name : " + e.getClass().getName()); - // } - // } -} diff --git a/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/TreeTestResultCollectionDaoJcrTest.java b/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/TreeTestResultCollectionDaoJcrTest.java deleted file mode 100644 index c902e98f5..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/TreeTestResultCollectionDaoJcrTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.jcr.dao; - -import java.util.Date; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.jcr.JcrUtils; -import org.argeo.slc.core.test.tree.TreeTestResult; -import org.argeo.slc.core.test.tree.TreeTestResultCollection; -import org.argeo.slc.dao.test.tree.TreeTestResultCollectionDao; -import org.argeo.slc.dao.test.tree.TreeTestResultDao; -import org.argeo.slc.unit.AbstractSpringTestCase; -import org.argeo.slc.unit.test.tree.TreeTestResultTestUtils; -import org.argeo.slc.unit.test.tree.UnitTestTreeUtil; - -public class TreeTestResultCollectionDaoJcrTest extends AbstractSpringTestCase { - private final static Log log = LogFactory - .getLog(TreeTestResultCollectionDaoJcrTest.class); - - private TreeTestResultCollectionDao ttrcDao; - private TreeTestResultDao ttrDao; - - @Override - protected void setUp() throws Exception { - super.setUp(); - ttrDao = getBean(TreeTestResultDao.class); - ttrcDao = getBean(TreeTestResultCollectionDao.class); - log.debug("Context Initialized"); - } - - @SuppressWarnings("restriction") - public void testScenario() { - String ttrcName = "testCollection"; - - TreeTestResult ttr1 = TreeTestResultTestUtils - .createCompleteTreeTestResult(); - ttrDao.create(ttr1); - - TreeTestResultCollection ttrc = new TreeTestResultCollection(ttrcName); - ttrcDao.create(ttrc); - ttrc.getResults().add(ttr1); - ttrcDao.update(ttrc); - - final TreeTestResult ttr2 = TreeTestResultTestUtils - .createCompleteTreeTestResult(); - ttrDao.create(ttr2); - - ttrc.getResults().add(ttr2); - ttrcDao.update(ttrc); - - ttrc.getResults().remove(ttr1); - ttrcDao.update(ttrc); - - final TreeTestResultCollection ttrcPersist = ttrcDao - .getTestResultCollection(ttrcName); - - assertEquals(1, ttrcPersist.getResults().size()); - TreeTestResult ttrFin = ttrcPersist.getResults().iterator().next(); - UnitTestTreeUtil.assertTreeTestResult(ttr2, ttrFin); - - } - - @SuppressWarnings("restriction") - public void testResultsWithSameCloseDate() { - String ttrcName = "testCollectionWithSameCloseDate"; - - Date closeDate = new Date(); - - // TTR1 - TreeTestResult ttr1 = TreeTestResultTestUtils - .createCompleteTreeTestResult(); - ttr1.setCloseDate(closeDate); - ttrDao.create(ttr1); - - // TTR2 - TreeTestResult ttr2 = TreeTestResultTestUtils - .createCompleteTreeTestResult(); - ttr2.setCloseDate(closeDate); - ttrDao.create(ttr2); - - // TTRC - TreeTestResultCollection ttrc = new TreeTestResultCollection(ttrcName); - ttrc.getResults().add(ttr1); - ttrc.getResults().add(ttr2); - ttrcDao.create(ttrc); - - final TreeTestResultCollection ttrcPersist = ttrcDao - .getTestResultCollection(ttrcName); - assertEquals(2, ttrcPersist.getResults().size()); - } -} diff --git a/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/TreeTestResultDaoJcrSimpleTest.java b/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/TreeTestResultDaoJcrSimpleTest.java deleted file mode 100644 index 9d761fd17..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/TreeTestResultDaoJcrSimpleTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.jcr.dao; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.slc.core.test.tree.TreeTestResult; -import org.argeo.slc.dao.test.tree.TreeTestResultDao; -import org.argeo.slc.unit.AbstractSpringTestCase; -import org.argeo.slc.unit.test.tree.TreeTestResultTestUtils; -import org.argeo.slc.unit.test.tree.UnitTestTreeUtil; - -public class TreeTestResultDaoJcrSimpleTest extends AbstractSpringTestCase { - private final static Log log = LogFactory - .getLog(TreeTestResultDaoJcrSimpleTest.class); - - private TreeTestResultDao ttrDao; - - @Override - protected void setUp() throws Exception { - super.setUp(); - ttrDao = getBean(TreeTestResultDao.class); - log.debug("Context Initialized"); - } - - @SuppressWarnings("restriction") - public void testCreate() { - TreeTestResult ttr = TreeTestResultTestUtils - .createComplexeTreeTestResult(); - ttrDao.create(ttr); - TreeTestResult ttrPersisted = ttrDao.getTestResult(ttr.getUuid()); - compareTestResult(ttr, ttrPersisted); - UnitTestTreeUtil.assertTreeTestResult(ttr, ttrPersisted); - - } - - @SuppressWarnings("restriction") - public void testCreate2() { - TreeTestResult ttr = TreeTestResultTestUtils - .createComplexeTreeTestResult(); - ttrDao.create(ttr); - TreeTestResult ttrPersisted = ttrDao.getTestResult(ttr.getUuid()); - compareTestResult(ttr, ttrPersisted); - UnitTestTreeUtil.assertTreeTestResult(ttr, ttrPersisted); - - } - - public static void compareTestResult(final TreeTestResult t1, - final TreeTestResult t2) { - - assertEquals(t1.getUuid(), t2.getUuid()); - assertEquals(t1.getCloseDate(), t2.getCloseDate()); - assertEquals(t1.getAttachments().size(), t2.getAttachments().size()); - assertEquals(t1.getAttributes().size(), t2.getAttributes().size()); - assertEquals(t1.getElements().size(), t2.getElements().size()); - // resultParts - assertEquals(t1.getResultParts().size(), t2.getResultParts().size()); - - // TODO Add more check. - } - -} diff --git a/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/TreeTestResultDaoJcrTest.java b/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/TreeTestResultDaoJcrTest.java deleted file mode 100644 index 8f7280d0a..000000000 --- a/runtime/org.argeo.slc.support.jcr/src/test/java/org/argeo/slc/jcr/dao/TreeTestResultDaoJcrTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.jcr.dao; - -import java.io.ByteArrayOutputStream; -import java.util.SortedMap; -import java.util.TreeMap; -import java.util.UUID; - -import javax.jcr.Session; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.slc.core.attachment.SimpleAttachment; -import org.argeo.slc.core.structure.tree.TreeSPath; -import org.argeo.slc.core.test.SimpleResultPart; -import org.argeo.slc.core.test.tree.TreeTestResult; -import org.argeo.slc.dao.test.tree.TreeTestResultDao; -import org.argeo.slc.unit.AbstractSpringTestCase; -import org.argeo.slc.unit.test.tree.TreeTestResultTestUtils; -import org.argeo.slc.unit.test.tree.UnitTestTreeUtil; - -public class TreeTestResultDaoJcrTest extends AbstractSpringTestCase { - private final static Log log = LogFactory - .getLog(TreeTestResultDaoJcrTest.class); - - private TreeTestResultDao ttrDao; - - @Override - protected void setUp() throws Exception { - super.setUp(); - ttrDao = getBean(TreeTestResultDao.class); - log.debug("Context Initialized"); - } - - public void testExportXml() throws Exception { - TreeTestResult ttr = TreeTestResultTestUtils - .createComplexeTreeTestResult(); - ttrDao.create(ttr); - - Session session = getBean(Session.class); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - session.exportDocumentView("/slc", out, true, false); - log.debug("\n\n"+new String(out.toByteArray())+"\n\n"); - } - - public void testCreate() { - TreeTestResult ttr = TreeTestResultTestUtils - .createComplexeTreeTestResult(); - ttrDao.create(ttr); - TreeTestResult ttrPersisted = ttrDao.getTestResult(ttr.getUuid()); - compareTestResult(ttr, ttrPersisted); - UnitTestTreeUtil.assertTreeTestResult(ttr, ttrPersisted); - } - - public void testUpdate() { - TreeTestResult ttr = TreeTestResultTestUtils - .createCompleteTreeTestResult(); - ttrDao.create(ttr); - SimpleAttachment sa = new SimpleAttachment( - UUID.randomUUID().toString(), "A new Attachment", "UTF8"); - // test if we can attach a new doc - ttrDao.addAttachment(ttr.getUuid(), sa); - - // test if an existing doc is not added 2 times. - TreeTestResult ttr2 = ttrDao.getTestResult(ttr.getUuid()); - ttrDao.addAttachment(ttr.getUuid(), sa); - TreeTestResult ttr3 = ttrDao.getTestResult(ttr.getUuid()); - assertEquals(ttr3.getAttachments().size(), ttr2.getAttachments().size()); - - // Test Add ResultPart - // Initializing context - SimpleResultPart resultPart = TreeTestResultTestUtils - .createSimpleResultPartFailed(); - TreeSPath path = new TreeSPath("/test1"); - ttrDao.addResultPart(ttr.getUuid(), path, resultPart, null); - - // TestAdd Attribute - SortedMap newAtt = new TreeMap(); - newAtt.put("NewTestCase", "NonSortedView"); - newAtt.put("NewTestCaseType", "csvdiff"); - ttrDao.updateAttributes(ttr.getUuid(), newAtt); - - ttr2 = ttrDao.getTestResult(ttr.getUuid()); - assertEquals(ttr.getAttributes().size() + 2, ttr2.getAttributes() - .size()); - assertEquals("csvdiff", ttr2.getAttributes().get("NewTestCaseType")); - - // Test update existing Attribute - ttrDao.updateAttributes(ttr.getUuid(), newAtt); - assertEquals(ttr.getAttributes().size() + 2, ttr2.getAttributes() - .size()); - - } - - public void testResultPartOnly() { - - TreeTestResult ttr = TreeTestResultTestUtils - .createComplexeTreeTestResult(); - - SimpleResultPart resultPart = TreeTestResultTestUtils - .createSimpleResultPartPassed(); - ttr.addResultPart(resultPart); - ttrDao.create(ttr); - TreeTestResult ttr2; - ttr2 = ttrDao.getTestResult(ttr.getUuid()); - assertEquals(ttr.getResultParts().size(), ttr2.getResultParts().size()); - } - - public static void compareTestResult(final TreeTestResult t1, - final TreeTestResult t2) { - - assertEquals(t1.getUuid(), t2.getUuid()); - assertEquals(t1.getCloseDate(), t2.getCloseDate()); - assertEquals(t1.getAttachments().size(), t2.getAttachments().size()); - assertEquals(t1.getAttributes().size(), t2.getAttributes().size()); - assertEquals(t1.getElements().size(), t2.getElements().size()); - // resultParts - assertEquals(t1.getResultParts().size(), t2.getResultParts().size()); - - // TODO Add more check. - } - -} diff --git a/runtime/org.argeo.slc.unit/src/main/java/org/argeo/slc/server/unit/AbstractHttpClientTestCase.java b/runtime/org.argeo.slc.unit/src/main/java/org/argeo/slc/server/unit/AbstractHttpClientTestCase.java deleted file mode 100644 index c6963e170..000000000 --- a/runtime/org.argeo.slc.unit/src/main/java/org/argeo/slc/server/unit/AbstractHttpClientTestCase.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.server.unit; - -import org.argeo.slc.msg.ExecutionAnswer; -import org.argeo.slc.server.client.SlcServerHttpClient; -import org.argeo.slc.unit.AbstractSpringTestCase; - -public abstract class AbstractHttpClientTestCase extends AbstractSpringTestCase { - private SlcServerHttpClient httpClient = null; - - protected void setUp() throws Exception { - super.setUp(); - httpClient = createHttpClient(); - httpClient.waitForServerToBeReady(); - } - - protected SlcServerHttpClient createHttpClient() { - SlcServerHttpClient httpClient = getBean(SlcServerHttpClient.class); - return httpClient; - } - - protected SlcServerHttpClient getHttpClient() { - return httpClient; - } - - protected void assertAnswerOk(ExecutionAnswer answer) { - if (!answer.isOk()) { - fail("Server execution answer is not ok: " + answer.getMessage()); - } - } -} diff --git a/runtime/org.argeo.slc.unit/src/main/java/org/argeo/slc/unit/test/tree/TreeTestResultTestUtils.java b/runtime/org.argeo.slc.unit/src/main/java/org/argeo/slc/unit/test/tree/TreeTestResultTestUtils.java deleted file mode 100644 index 2d1725887..000000000 --- a/runtime/org.argeo.slc.unit/src/main/java/org/argeo/slc/unit/test/tree/TreeTestResultTestUtils.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.unit.test.tree; - -import java.util.UUID; - - -import org.argeo.slc.build.Distribution; -import org.argeo.slc.core.attachment.SimpleAttachment; -import org.argeo.slc.core.structure.SimpleSElement; -import org.argeo.slc.core.structure.tree.TreeSPath; -import org.argeo.slc.core.structure.tree.TreeSRegistry; -import org.argeo.slc.core.test.SimpleResultPart; -import org.argeo.slc.core.test.SimpleTestRun; -import org.argeo.slc.core.test.tree.PartSubList; -import org.argeo.slc.core.test.tree.TreeTestResult; -import org.argeo.slc.deploy.DeployedSystem; -import org.argeo.slc.deploy.DeploymentData; -import org.argeo.slc.deploy.TargetData; -import org.argeo.slc.msg.test.tree.ResultPartRequest; -import org.argeo.slc.process.SlcExecution; -import org.argeo.slc.process.SlcExecutionStep; -import org.argeo.slc.test.TestStatus; -import org.argeo.slc.unit.process.SlcExecutionTestUtils; - -public abstract class TreeTestResultTestUtils { - - public static TreeTestResult createSimpleTreeTestResult() { - TreeTestResult treeTestResult = new TreeTestResult(); - treeTestResult.setUuid(UUID.randomUUID().toString()); - return treeTestResult; - } - - public static TreeTestResult createCompleteTreeTestResult() { - SlcExecution slcExecution = SlcExecutionTestUtils - .createSimpleSlcExecution(); - SlcExecutionStep step = new SlcExecutionStep("JUnit step"); - slcExecution.getSteps().add(step); - - TreeTestResult ttr = createMinimalConsistentTreeTestResult(slcExecution); - - ttr.addResultPart(createSimpleResultPartPassed()); - ttr.addResultPart(createSimpleResultPartFailed()); - ttr.addResultPart(createSimpleResultPartError()); - return ttr; - } - - public static TreeTestResult createComplexeTreeTestResult() { - SlcExecution slcExecution = SlcExecutionTestUtils - .createSimpleSlcExecution(); - SlcExecutionStep step = new SlcExecutionStep("JUnit step"); - slcExecution.getSteps().add(step); - - TreeTestResult ttr = createMinimalConsistentTreeTestResult(slcExecution); - - ttr.addResultPart(createSimpleResultPartPassed()); - ttr.addResultPart(createSimpleResultPartFailed()); - //ttr.addResultPart(createSimpleResultPartError()); - - SimpleAttachment sa = new SimpleAttachment(UUID.randomUUID().toString(),"AnAttachment","UTF8"); - SimpleAttachment sa2 = new SimpleAttachment(UUID.randomUUID().toString(),"AnOtherAttachment","UTF8"); - ttr.addAttachment(sa); - ttr.addAttachment(sa2); - return ttr; - } - - public static TreeTestResult createMinimalConsistentTreeTestResult( - SlcExecution slcExecution) { - SimpleTestRun testRun = new SimpleTestRun(); - testRun.setUuid(UUID.randomUUID().toString()); - - // Doesn't work in hibernate with such a path. - //String pathStr = "/fileDiff/testcases/issue"; - String pathStr = "/test"; - TreeSPath path = new TreeSPath(pathStr); - - TreeSRegistry registry = new TreeSRegistry(); - SimpleSElement elem = new SimpleSElement("Unit Test"); - elem.getTags().put("myTag", "myTagValue"); - registry.register(path, elem); - - TreeTestResult ttr = createSimpleTreeTestResult(); - ttr.getAttributes().put("testCase", "UNIT"); - - // Simulate test run - ttr.notifyCurrentPath(registry, path); - ttr.notifyTestRun(testRun); - testRun.setTestResult(ttr); - testRun.setDeployedSystem(new DeployedSystem() { - private String uuid = UUID.randomUUID().toString(); - - public String getDeployedSystemId() { - return uuid; - } - - public Distribution getDistribution() { - return null; - } - - public DeploymentData getDeploymentData() { - // TODO Auto-generated method stub - return null; - } - - public TargetData getTargetData() { - // TODO Auto-generated method stub - return null; - } - - }); - testRun.notifySlcExecution(slcExecution); - return ttr; - } - - public static SimpleResultPart createSimpleResultPartPassed() { - SimpleResultPart partPassed = new SimpleResultPart(); - String msgPassed = "message\nnew line"; - partPassed.setStatus(TestStatus.PASSED); - partPassed.setMessage(msgPassed); - return partPassed; - } - - public static SimpleResultPart createSimpleResultPartFailed() { - SimpleResultPart partFailed = new SimpleResultPart(); - String msgFailed = "too bad"; - partFailed.setStatus(TestStatus.FAILED); - partFailed.setMessage(msgFailed); - return partFailed; - } - - public static SimpleResultPart createSimpleResultPartError() { - SimpleResultPart partFailed = new SimpleResultPart(); - String msgFailed = "crashed\nanother line"; - partFailed.setStatus(TestStatus.ERROR); - partFailed.setMessage(msgFailed); - partFailed.setException(new Exception("Test Exception")); - return partFailed; - } - - public static ResultPartRequest createSimpleResultPartRequest( - TreeTestResult ttr) { - TreeSPath path = ttr.getCurrentPath(); - PartSubList lst = ttr.getResultParts().get(path); - SimpleResultPart part = (SimpleResultPart) lst.getParts().get(2); - - ResultPartRequest req = new ResultPartRequest(ttr, path, part); - req.setPath(ttr.getCurrentPath()); - - return req; - } - - private TreeTestResultTestUtils() { - - } -} diff --git a/runtime/org.argeo.slc.unit/src/main/java/org/argeo/slc/unit/test/tree/UnitTestTreeUtil.java b/runtime/org.argeo.slc.unit/src/main/java/org/argeo/slc/unit/test/tree/UnitTestTreeUtil.java deleted file mode 100644 index 257bfa246..000000000 --- a/runtime/org.argeo.slc.unit/src/main/java/org/argeo/slc/unit/test/tree/UnitTestTreeUtil.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2007-2012 Mathieu Baudier - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.argeo.slc.unit.test.tree; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertNull; -import static junit.framework.Assert.fail; -import static org.argeo.slc.unit.UnitUtils.assertDateSec; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.slc.core.structure.SimpleSElement; -import org.argeo.slc.core.structure.tree.TreeSPath; -import org.argeo.slc.core.test.SimpleResultPart; -import org.argeo.slc.core.test.tree.PartSubList; -import org.argeo.slc.core.test.tree.TreeTestResult; -import org.argeo.slc.test.TestResultPart; - -/** Utilities for unit tests. */ -public class UnitTestTreeUtil { - private final static Log log = LogFactory.getLog(UnitTestTreeUtil.class); - - public static void assertTreeTestResult(TreeTestResult expected, - TreeTestResult reached) { - assertEquals(expected.getUuid(), reached.getUuid()); - assertDateSec(expected.getCloseDate(), reached.getCloseDate()); - - // Attributes - //assertEquals(expected.getAttributes().size(), reached.getAttributes() - // .size()); - for (String key : expected.getAttributes().keySet()) { - String expectedValue = expected.getAttributes().get(key); - String reachedValue = reached.getAttributes().get(key); - assertNotNull(reachedValue); - assertEquals(expectedValue, reachedValue); - } - - // Result parts - assertEquals(expected.getResultParts().size(), reached.getResultParts() - .size()); - for (TreeSPath path : expected.getResultParts().keySet()) { - PartSubList lstExpected = expected.getResultParts().get(path); - PartSubList lstReached = expected.getResultParts().get(path); - if (lstReached == null) { - fail("No result for path " + path); - return; - } - assertPartSubList(lstExpected, lstReached); - } - - // Elements - assertEquals(expected.getElements().size(), reached.getElements() - .size()); - for (TreeSPath path : expected.getElements().keySet()) { - // String nameExpected = expected.getElements().get(path); - // String nameReached = expected.getElements().get(path); - SimpleSElement elemExpected = (SimpleSElement) expected - .getElements().get(path); - SimpleSElement elemReached = (SimpleSElement) expected - .getElements().get(path); - assertNotNull(elemReached); - assertElements(elemExpected, elemReached); - } - - } - - public static void assertElements(SimpleSElement expected, - SimpleSElement reached) { - assertEquals(expected.getLabel(), reached.getLabel()); - assertEquals(expected.getTags().size(), reached.getTags().size()); - for (String tagName : expected.getTags().keySet()) { - String expectedTagValue = expected.getTags().get(tagName); - String reachedTagValue = reached.getTags().get(tagName); - assertNotNull(reachedTagValue); - assertEquals(expectedTagValue, reachedTagValue); - } - } - - public static void assertPartSubList(PartSubList lstExpected, - PartSubList lstReached) { - assertEquals(lstExpected.getParts().size(), lstReached.getParts() - .size()); - for (int i = 0; i < lstExpected.getParts().size(); i++) { - assertPart(lstExpected.getParts().get(i), lstReached.getParts() - .get(i)); - } - } - - /** Asserts one part of a tree test result */ - public static void assertPart(TreeTestResult testResult, String pathStr, - int index, Integer status, String message) { - TreeSPath path = new TreeSPath(pathStr); - PartSubList list = testResult.getResultParts().get(path); - if (list == null) { - fail("No result for path " + path); - return; - } - if (index >= list.getParts().size()) { - fail("Not enough parts."); - } - SimpleResultPart part = (SimpleResultPart) list.getParts().get(index); - assertPart(part, status, message, null, part.getTestRunUuid(), true); - } - - public static void assertPart(TestResultPart expected, - TestResultPart reached) { - String expectedTestRunUuid = null; - if (expected instanceof SimpleResultPart) { - expectedTestRunUuid = ((SimpleResultPart) expected) - .getTestRunUuid(); - } - - assertPart(reached, expected.getStatus(), expected.getMessage(), - expected.getExceptionMessage(), expectedTestRunUuid, false); - } - - /** Assert one part of a tree test result. */ - private static void assertPart(TestResultPart part, Integer status, - String message, String exceptionDescription, - String expectedTestRunUuid, boolean skipExceptionMessage) { - assertEquals(status, part.getStatus()); - - if (message != null) { - if (log.isTraceEnabled()) { - log.trace("Expected message:" + message); - log.trace("Reached message:" + part.getMessage()); - } - assertEquals(message, part.getMessage()); - } - - if (!skipExceptionMessage) { - if (exceptionDescription == null) { - assertNull(part.getExceptionMessage()); - } else { - if (log.isTraceEnabled()) { - log.trace("Expected exception message:" - + exceptionDescription); - log.trace("Reached exception message:" - + part.getExceptionMessage()); - } - - assertEquals(exceptionDescription, part.getExceptionMessage()); - } - } - - if (expectedTestRunUuid != null) { - SimpleResultPart reachedPart = (SimpleResultPart) part; - assertNotNull(reachedPart.getTestRunUuid()); - assertEquals(expectedTestRunUuid, reachedPart.getTestRunUuid()); - } else { - if (part instanceof SimpleResultPart) { - assertNull(((SimpleResultPart) part).getTestRunUuid()); - } - - } - - } - - public static void describeTreeTestResult(TreeTestResult ttr) { - log.info("TreeTestResult #" + ttr.getUuid()); - log.info(" Close date: " + ttr.getCloseDate()); - log.info(" Attributes:"); - for (String key : ttr.getAttributes().keySet()) - log.info(" " + key + "=" + ttr.getAttributes().get(key)); - - log.info(" Result parts: (size=" + ttr.getResultParts().size() + ")"); - for (TreeSPath path : ttr.getResultParts().keySet()) { - log.info(" Path: " + path); - PartSubList lst = ttr.getResultParts().get(path); - for (TestResultPart part : lst.getParts()) - log.info(" " + part); - } - - log.info(" Elements: (size=" + ttr.getElements().size() + ")"); - for (TreeSPath path : ttr.getElements().keySet()) { - SimpleSElement elem = (SimpleSElement) ttr.getElements().get(path); - log.info(" Path: " + path + ", Element: " + elem.getLabel()); - for (String tag : elem.getTags().keySet()) - log.info(" " + tag + "=" + elem.getTags().get(tag)); - } - - } - - /** Makes sure this is a singleton */ - private UnitTestTreeUtil() { - - } -}