--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.execution;
+
+import java.io.File;
+import java.nio.file.Path;
+
+/** Provides write access to resources during execution */
+public interface ExecutionResources {
+ /** The base directory where this execution can write */
+ public File getWritableBaseDir();
+
+ /** Allocates a local file in the writable area and return it as a resource. */
+ public Path getWritableResource(String relativePath);
+
+ /**
+ * Allocates a local file in the writable area and return it as a fully
+ * qualified OS path.
+ */
+ public String getWritableOsPath(String relativePath);
+
+ /**
+ * Allocates a local file in the writable area and return it as a {@link File}.
+ */
+ public File getWritableOsFile(String relativePath);
+
+ /**
+ * Returns the resource as a file path. If the resource is not writable it is
+ * copied as a file in the writable area and the path to this local file is
+ * returned.
+ */
+ public String getAsOsPath(Path resource, Boolean overwrite);
+}
<artifactId>org.argeo.slc.repo</artifactId>
<version>2.1.17-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.argeo.slc</groupId>
+ <artifactId>org.argeo.slc.spring</artifactId>
+ <version>2.1.17-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.argeo.slc</groupId>
<artifactId>org.argeo.slc.server.repo</artifactId>
<name>SLC Factory</name>
<dependencies>
<!-- SLC -->
+ <dependency>
+ <groupId>org.argeo.slc</groupId>
+ <artifactId>org.argeo.slc.runtime</artifactId>
+ <version>2.1.17-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.argeo.slc</groupId>
<artifactId>org.argeo.slc.repo</artifactId>
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
import org.argeo.slc.rpmfactory.RpmFactory;
+import org.argeo.slc.runtime.tasks.SystemCall;
/** Build an RPM in mock. */
public class BuildInMock implements Runnable {
import org.apache.commons.logging.LogFactory;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
import org.argeo.slc.rpmfactory.RpmFactory;
+import org.argeo.slc.runtime.tasks.SystemCall;
/**
* Gather RPMs from various sources (local builds or third party) into a
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
import org.argeo.slc.rpmfactory.RpmFactory;
+import org.argeo.slc.runtime.tasks.SystemCall;
/** Releases the content of staging to a public repository. */
public class ReleaseStaging implements Runnable {
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcConstants;
import org.argeo.slc.SlcException;
-import org.argeo.slc.core.execution.tasks.SystemCall;
import org.argeo.slc.repo.NodeIndexerVisitor;
import org.argeo.slc.repo.RpmIndexer;
import org.argeo.slc.rpmfactory.RpmFactory;
import org.argeo.slc.rpmfactory.RpmRepository;
+import org.argeo.slc.runtime.tasks.SystemCall;
/**
* Defines a build environment. This information is typically used by other
<artifactId>org.argeo.slc.api</artifactId>
<version>2.1.17-SNAPSHOT</version>
</dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.spring</artifactId>
- <version>2.1.17-SNAPSHOT</version>
- </dependency>
<!-- Commons -->
<dependency>
--- /dev/null
+/*\r
+ * Copyright 2002-2007 the original author or authors.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.argeo.slc.repo.internal.springutil;\r
+\r
+/**\r
+ * PathMatcher implementation for Ant-style path patterns. Examples are provided\r
+ * below.\r
+ *\r
+ * <p>\r
+ * Part of this mapping code has been kindly borrowed from\r
+ * <a href="http://ant.apache.org">Apache Ant</a>.\r
+ *\r
+ * <p>\r
+ * The mapping matches URLs using the following rules:<br>\r
+ * <ul>\r
+ * <li>? matches one character</li>\r
+ * <li>* matches zero or more characters</li>\r
+ * <li>** matches zero or more 'directories' in a path</li>\r
+ * </ul>\r
+ *\r
+ * <p>\r
+ * Some examples:<br>\r
+ * <ul>\r
+ * <li><code>com/t?st.jsp</code> - matches <code>com/test.jsp</code> but also\r
+ * <code>com/tast.jsp</code> or <code>com/txst.jsp</code></li>\r
+ * <li><code>com/*.jsp</code> - matches all <code>.jsp</code> files in the\r
+ * <code>com</code> directory</li>\r
+ * <li><code>com/**/test.jsp</code> - matches all <code>test.jsp</code>\r
+ * files underneath the <code>com</code> path</li>\r
+ * <li><code>org/springframework/**/*.jsp</code> - matches all\r
+ * <code>.jsp</code> files underneath the <code>org/springframework</code>\r
+ * path</li>\r
+ * <li><code>org/**/servlet/bla.jsp</code> - matches\r
+ * <code>org/springframework/servlet/bla.jsp</code> but also\r
+ * <code>org/springframework/testing/servlet/bla.jsp</code> and\r
+ * <code>org/servlet/bla.jsp</code></li>\r
+ * </ul>\r
+ *\r
+ * @author Alef Arendsen\r
+ * @author Juergen Hoeller\r
+ * @author Rob Harrop\r
+ * @since 16.07.2003\r
+ */\r
+public class AntPathMatcher implements PathMatcher {\r
+\r
+ /** Default path separator: "/" */\r
+ public static final String DEFAULT_PATH_SEPARATOR = "/";\r
+\r
+ private String pathSeparator = DEFAULT_PATH_SEPARATOR;\r
+\r
+ /**\r
+ * Set the path separator to use for pattern parsing. Default is "/", as in Ant.\r
+ */\r
+ public void setPathSeparator(String pathSeparator) {\r
+ this.pathSeparator = (pathSeparator != null ? pathSeparator : DEFAULT_PATH_SEPARATOR);\r
+ }\r
+\r
+ public boolean isPattern(String path) {\r
+ return (path.indexOf('*') != -1 || path.indexOf('?') != -1);\r
+ }\r
+\r
+ public boolean match(String pattern, String path) {\r
+ return doMatch(pattern, path, true);\r
+ }\r
+\r
+ public boolean matchStart(String pattern, String path) {\r
+ return doMatch(pattern, path, false);\r
+ }\r
+\r
+ /**\r
+ * Actually match the given <code>path</code> against the given\r
+ * <code>pattern</code>.\r
+ * \r
+ * @param pattern the pattern to match against\r
+ * @param path the path String to test\r
+ * @param fullMatch whether a full pattern match is required (else a pattern\r
+ * match as far as the given base path goes is sufficient)\r
+ * @return <code>true</code> if the supplied <code>path</code> matched,\r
+ * <code>false</code> if it didn't\r
+ */\r
+ protected boolean doMatch(String pattern, String path, boolean fullMatch) {\r
+ if (path.startsWith(this.pathSeparator) != pattern.startsWith(this.pathSeparator)) {\r
+ return false;\r
+ }\r
+\r
+// String[] pattDirs = StringUtils.tokenizeToStringArray(pattern, this.pathSeparator);\r
+// String[] pathDirs = StringUtils.tokenizeToStringArray(path, this.pathSeparator);\r
+ // mbaudier - 2020-03-13 : Use standard Java call:\r
+ String[] pattDirs = pattern.split(this.pathSeparator);\r
+ String[] pathDirs = path.split(this.pathSeparator);\r
+\r
+ int pattIdxStart = 0;\r
+ int pattIdxEnd = pattDirs.length - 1;\r
+ int pathIdxStart = 0;\r
+ int pathIdxEnd = pathDirs.length - 1;\r
+\r
+ // Match all elements up to the first **\r
+ while (pattIdxStart <= pattIdxEnd && pathIdxStart <= pathIdxEnd) {\r
+ String patDir = pattDirs[pattIdxStart];\r
+ if ("**".equals(patDir)) {\r
+ break;\r
+ }\r
+ if (!matchStrings(patDir, pathDirs[pathIdxStart])) {\r
+ return false;\r
+ }\r
+ pattIdxStart++;\r
+ pathIdxStart++;\r
+ }\r
+\r
+ if (pathIdxStart > pathIdxEnd) {\r
+ // Path is exhausted, only match if rest of pattern is * or **'s\r
+ if (pattIdxStart > pattIdxEnd) {\r
+ return (pattern.endsWith(this.pathSeparator) ? path.endsWith(this.pathSeparator)\r
+ : !path.endsWith(this.pathSeparator));\r
+ }\r
+ if (!fullMatch) {\r
+ return true;\r
+ }\r
+ if (pattIdxStart == pattIdxEnd && pattDirs[pattIdxStart].equals("*") && path.endsWith(this.pathSeparator)) {\r
+ return true;\r
+ }\r
+ for (int i = pattIdxStart; i <= pattIdxEnd; i++) {\r
+ if (!pattDirs[i].equals("**")) {\r
+ return false;\r
+ }\r
+ }\r
+ return true;\r
+ } else if (pattIdxStart > pattIdxEnd) {\r
+ // String not exhausted, but pattern is. Failure.\r
+ return false;\r
+ } else if (!fullMatch && "**".equals(pattDirs[pattIdxStart])) {\r
+ // Path start definitely matches due to "**" part in pattern.\r
+ return true;\r
+ }\r
+\r
+ // up to last '**'\r
+ while (pattIdxStart <= pattIdxEnd && pathIdxStart <= pathIdxEnd) {\r
+ String patDir = pattDirs[pattIdxEnd];\r
+ if (patDir.equals("**")) {\r
+ break;\r
+ }\r
+ if (!matchStrings(patDir, pathDirs[pathIdxEnd])) {\r
+ return false;\r
+ }\r
+ pattIdxEnd--;\r
+ pathIdxEnd--;\r
+ }\r
+ if (pathIdxStart > pathIdxEnd) {\r
+ // String is exhausted\r
+ for (int i = pattIdxStart; i <= pattIdxEnd; i++) {\r
+ if (!pattDirs[i].equals("**")) {\r
+ return false;\r
+ }\r
+ }\r
+ return true;\r
+ }\r
+\r
+ while (pattIdxStart != pattIdxEnd && pathIdxStart <= pathIdxEnd) {\r
+ int patIdxTmp = -1;\r
+ for (int i = pattIdxStart + 1; i <= pattIdxEnd; i++) {\r
+ if (pattDirs[i].equals("**")) {\r
+ patIdxTmp = i;\r
+ break;\r
+ }\r
+ }\r
+ if (patIdxTmp == pattIdxStart + 1) {\r
+ // '**/**' situation, so skip one\r
+ pattIdxStart++;\r
+ continue;\r
+ }\r
+ // Find the pattern between padIdxStart & padIdxTmp in str between\r
+ // strIdxStart & strIdxEnd\r
+ int patLength = (patIdxTmp - pattIdxStart - 1);\r
+ int strLength = (pathIdxEnd - pathIdxStart + 1);\r
+ int foundIdx = -1;\r
+\r
+ strLoop: for (int i = 0; i <= strLength - patLength; i++) {\r
+ for (int j = 0; j < patLength; j++) {\r
+ String subPat = (String) pattDirs[pattIdxStart + j + 1];\r
+ String subStr = (String) pathDirs[pathIdxStart + i + j];\r
+ if (!matchStrings(subPat, subStr)) {\r
+ continue strLoop;\r
+ }\r
+ }\r
+ foundIdx = pathIdxStart + i;\r
+ break;\r
+ }\r
+\r
+ if (foundIdx == -1) {\r
+ return false;\r
+ }\r
+\r
+ pattIdxStart = patIdxTmp;\r
+ pathIdxStart = foundIdx + patLength;\r
+ }\r
+\r
+ for (int i = pattIdxStart; i <= pattIdxEnd; i++) {\r
+ if (!pattDirs[i].equals("**")) {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ * Tests whether or not a string matches against a pattern. The pattern may\r
+ * contain two special characters:<br>\r
+ * '*' means zero or more characters<br>\r
+ * '?' means one and only one character\r
+ * \r
+ * @param pattern pattern to match against. Must not be <code>null</code>.\r
+ * @param str string which must be matched against the pattern. Must not be\r
+ * <code>null</code>.\r
+ * @return <code>true</code> if the string matches against the pattern, or\r
+ * <code>false</code> otherwise.\r
+ */\r
+ private boolean matchStrings(String pattern, String str) {\r
+ char[] patArr = pattern.toCharArray();\r
+ char[] strArr = str.toCharArray();\r
+ int patIdxStart = 0;\r
+ int patIdxEnd = patArr.length - 1;\r
+ int strIdxStart = 0;\r
+ int strIdxEnd = strArr.length - 1;\r
+ char ch;\r
+\r
+ boolean containsStar = false;\r
+ for (int i = 0; i < patArr.length; i++) {\r
+ if (patArr[i] == '*') {\r
+ containsStar = true;\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (!containsStar) {\r
+ // No '*'s, so we make a shortcut\r
+ if (patIdxEnd != strIdxEnd) {\r
+ return false; // Pattern and string do not have the same size\r
+ }\r
+ for (int i = 0; i <= patIdxEnd; i++) {\r
+ ch = patArr[i];\r
+ if (ch != '?') {\r
+ if (ch != strArr[i]) {\r
+ return false;// Character mismatch\r
+ }\r
+ }\r
+ }\r
+ return true; // String matches against pattern\r
+ }\r
+\r
+ if (patIdxEnd == 0) {\r
+ return true; // Pattern contains only '*', which matches anything\r
+ }\r
+\r
+ // Process characters before first star\r
+ while ((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd) {\r
+ if (ch != '?') {\r
+ if (ch != strArr[strIdxStart]) {\r
+ return false;// Character mismatch\r
+ }\r
+ }\r
+ patIdxStart++;\r
+ strIdxStart++;\r
+ }\r
+ if (strIdxStart > strIdxEnd) {\r
+ // All characters in the string are used. Check if only '*'s are\r
+ // left in the pattern. If so, we succeeded. Otherwise failure.\r
+ for (int i = patIdxStart; i <= patIdxEnd; i++) {\r
+ if (patArr[i] != '*') {\r
+ return false;\r
+ }\r
+ }\r
+ return true;\r
+ }\r
+\r
+ // Process characters after last star\r
+ while ((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) {\r
+ if (ch != '?') {\r
+ if (ch != strArr[strIdxEnd]) {\r
+ return false;// Character mismatch\r
+ }\r
+ }\r
+ patIdxEnd--;\r
+ strIdxEnd--;\r
+ }\r
+ if (strIdxStart > strIdxEnd) {\r
+ // All characters in the string are used. Check if only '*'s are\r
+ // left in the pattern. If so, we succeeded. Otherwise failure.\r
+ for (int i = patIdxStart; i <= patIdxEnd; i++) {\r
+ if (patArr[i] != '*') {\r
+ return false;\r
+ }\r
+ }\r
+ return true;\r
+ }\r
+\r
+ // process pattern between stars. padIdxStart and patIdxEnd point\r
+ // always to a '*'.\r
+ while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) {\r
+ int patIdxTmp = -1;\r
+ for (int i = patIdxStart + 1; i <= patIdxEnd; i++) {\r
+ if (patArr[i] == '*') {\r
+ patIdxTmp = i;\r
+ break;\r
+ }\r
+ }\r
+ if (patIdxTmp == patIdxStart + 1) {\r
+ // Two stars next to each other, skip the first one.\r
+ patIdxStart++;\r
+ continue;\r
+ }\r
+ // Find the pattern between padIdxStart & padIdxTmp in str between\r
+ // strIdxStart & strIdxEnd\r
+ int patLength = (patIdxTmp - patIdxStart - 1);\r
+ int strLength = (strIdxEnd - strIdxStart + 1);\r
+ int foundIdx = -1;\r
+ strLoop: for (int i = 0; i <= strLength - patLength; i++) {\r
+ for (int j = 0; j < patLength; j++) {\r
+ ch = patArr[patIdxStart + j + 1];\r
+ if (ch != '?') {\r
+ if (ch != strArr[strIdxStart + i + j]) {\r
+ continue strLoop;\r
+ }\r
+ }\r
+ }\r
+\r
+ foundIdx = strIdxStart + i;\r
+ break;\r
+ }\r
+\r
+ if (foundIdx == -1) {\r
+ return false;\r
+ }\r
+\r
+ patIdxStart = patIdxTmp;\r
+ strIdxStart = foundIdx + patLength;\r
+ }\r
+\r
+ // All characters in the string are used. Check if only '*'s are left\r
+ // in the pattern. If so, we succeeded. Otherwise failure.\r
+ for (int i = patIdxStart; i <= patIdxEnd; i++) {\r
+ if (patArr[i] != '*') {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ * Given a pattern and a full path, determine the pattern-mapped part.\r
+ * <p>\r
+ * For example:\r
+ * <ul>\r
+ * <li>'<code>/docs/cvs/commit.html</code>' and\r
+ * '<code>/docs/cvs/commit.html</code> to ''</li>\r
+ * <li>'<code>/docs/*</code>' and '<code>/docs/cvs/commit</code> to\r
+ * '<code>cvs/commit</code>'</li>\r
+ * <li>'<code>/docs/cvs/*.html</code>' and '<code>/docs/cvs/commit.html</code>\r
+ * to '<code>commit.html</code>'</li>\r
+ * <li>'<code>/docs/**</code>' and '<code>/docs/cvs/commit</code> to\r
+ * '<code>cvs/commit</code>'</li>\r
+ * <li>'<code>/docs/**\/*.html</code>' and '<code>/docs/cvs/commit.html</code>\r
+ * to '<code>cvs/commit.html</code>'</li>\r
+ * <li>'<code>/*.html</code>' and '<code>/docs/cvs/commit.html</code> to\r
+ * '<code>docs/cvs/commit.html</code>'</li>\r
+ * <li>'<code>*.html</code>' and '<code>/docs/cvs/commit.html</code> to\r
+ * '<code>/docs/cvs/commit.html</code>'</li>\r
+ * <li>'<code>*</code>' and '<code>/docs/cvs/commit.html</code> to\r
+ * '<code>/docs/cvs/commit.html</code>'</li>\r
+ * </ul>\r
+ * <p>\r
+ * Assumes that {@link #match} returns <code>true</code> for\r
+ * '<code>pattern</code>' and '<code>path</code>', but does <strong>not</strong>\r
+ * enforce this.\r
+ */\r
+ public String extractPathWithinPattern(String pattern, String path) {\r
+// String[] patternParts = StringUtils.tokenizeToStringArray(pattern, this.pathSeparator);\r
+// String[] pathParts = StringUtils.tokenizeToStringArray(path, this.pathSeparator);\r
+ // mbaudier - 2020-03-13 : Use standard Java call:\r
+ String[] patternParts = pattern.split(this.pathSeparator);\r
+ String[] pathParts = path.split(this.pathSeparator);\r
+\r
+ StringBuffer buffer = new StringBuffer();\r
+\r
+ // Add any path parts that have a wildcarded pattern part.\r
+ int puts = 0;\r
+ for (int i = 0; i < patternParts.length; i++) {\r
+ String patternPart = patternParts[i];\r
+ if ((patternPart.indexOf('*') > -1 || patternPart.indexOf('?') > -1) && pathParts.length >= i + 1) {\r
+ if (puts > 0 || (i == 0 && !pattern.startsWith(this.pathSeparator))) {\r
+ buffer.append(this.pathSeparator);\r
+ }\r
+ buffer.append(pathParts[i]);\r
+ puts++;\r
+ }\r
+ }\r
+\r
+ // Append any trailing path parts.\r
+ for (int i = patternParts.length; i < pathParts.length; i++) {\r
+ if (puts > 0 || i > 0) {\r
+ buffer.append(this.pathSeparator);\r
+ }\r
+ buffer.append(pathParts[i]);\r
+ }\r
+\r
+ return buffer.toString();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright 2002-2007 the original author or authors.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.argeo.slc.repo.internal.springutil;\r
+\r
+/**\r
+ * Strategy interface for <code>String</code>-based path matching.\r
+ * \r
+ * <p>Used by <code>org.springframework.core.io.support.PathMatchingResourcePatternResolver</code>,\r
+ * {@link org.springframework.web.servlet.handler.AbstractUrlHandlerMapping},\r
+ * {@link org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver},\r
+ * and {@link org.springframework.web.servlet.mvc.WebContentInterceptor}.\r
+ *\r
+ * <p>The default implementation is {@link AntPathMatcher}, supporting the\r
+ * Ant-style pattern syntax.\r
+ *\r
+ * @author Juergen Hoeller\r
+ * @since 1.2\r
+ * @see AntPathMatcher\r
+ */\r
+public interface PathMatcher {\r
+\r
+ /**\r
+ * Does the given <code>path</code> represent a pattern that can be matched\r
+ * by an implementation of this interface?\r
+ * <p>If the return value is <code>false</code>, then the {@link #match}\r
+ * method does not have to be used because direct equality comparisons\r
+ * on the static path Strings will lead to the same result.\r
+ * @param path the path String to check\r
+ * @return <code>true</code> if the given <code>path</code> represents a pattern\r
+ */\r
+ boolean isPattern(String path);\r
+\r
+ /**\r
+ * Match the given <code>path</code> against the given <code>pattern</code>,\r
+ * according to this PathMatcher's matching strategy.\r
+ * @param pattern the pattern to match against\r
+ * @param path the path String to test\r
+ * @return <code>true</code> if the supplied <code>path</code> matched,\r
+ * <code>false</code> if it didn't\r
+ */\r
+ boolean match(String pattern, String path);\r
+\r
+ /**\r
+ * Match the given <code>path</code> against the corresponding part of the given\r
+ * <code>pattern</code>, according to this PathMatcher's matching strategy.\r
+ * <p>Determines whether the pattern at least matches as far as the given base\r
+ * path goes, assuming that a full path may then match as well.\r
+ * @param pattern the pattern to match against\r
+ * @param path the path String to test\r
+ * @return <code>true</code> if the supplied <code>path</code> matched,\r
+ * <code>false</code> if it didn't\r
+ */\r
+ boolean matchStart(String pattern, String path);\r
+\r
+ /**\r
+ * Given a pattern and a full path, determine the pattern-mapped part.\r
+ * <p>This method is supposed to find out which part of the path is matched\r
+ * dynamically through an actual pattern, that is, it strips off a statically\r
+ * defined leading path from the given full path, returning only the actually\r
+ * pattern-matched part of the path.\r
+ * <p>For example: For "myroot/*.html" as pattern and "myroot/myfile.html"\r
+ * as full path, this method should return "myfile.html". The detailed\r
+ * determination rules are specified to this PathMatcher's matching strategy.\r
+ * <p>A simple implementation may return the given full path as-is in case\r
+ * of an actual pattern, and the empty String in case of the pattern not\r
+ * containing any dynamic parts (i.e. the <code>pattern</code> parameter being\r
+ * a static path that wouldn't qualify as an actual {@link #isPattern pattern}).\r
+ * A sophisticated implementation will differentiate between the static parts\r
+ * and the dynamic parts of the given path pattern.\r
+ * @param pattern the path pattern\r
+ * @param path the full path to introspect\r
+ * @return the pattern-mapped part of the given <code>path</code>\r
+ * (never <code>null</code>)\r
+ */\r
+ String extractPathWithinPattern(String pattern, String path);\r
+\r
+}\r
import org.argeo.slc.build.License;
import org.argeo.slc.repo.OsgiFactory;
import org.argeo.slc.repo.RepoUtils;
+import org.argeo.slc.repo.internal.springutil.AntPathMatcher;
+import org.argeo.slc.repo.internal.springutil.PathMatcher;
import org.argeo.slc.repo.maven.ArtifactIdComparator;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
-import org.springframework.util.AntPathMatcher;
-import org.springframework.util.PathMatcher;
import aQute.bnd.osgi.Jar;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.osgi.framework.Version;
-import org.springframework.beans.factory.BeanNameAware;
import aQute.bnd.osgi.Builder;
import aQute.bnd.osgi.Constants;
import aQute.bnd.osgi.Jar;
/** Utilities around the BND library, which manipulates OSGi metadata. */
-public class BndWrapper implements Constants, CategoryNameVersion, Distribution, BeanNameAware {
+public class BndWrapper implements Constants, CategoryNameVersion, Distribution {
private final static Log log = LogFactory.getLog(BndWrapper.class);
private String groupId;
this.bndProperties = bndProperties;
}
- public void setBeanName(String name) {
- if (this.name == null) {
- this.name = name;
- } else {
- if (!name.contains("#"))
- log.warn("Using explicitely set name " + this.name + " and not bean name " + name);
- }
- }
-
public String getGroupId() {
return groupId;
}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.runtime.tasks;
+
+import org.argeo.slc.test.TestResult;
+
+public class CloseTestResult implements Runnable {
+ private TestResult testResult;
+
+ public void run() {
+ testResult.close();
+ }
+
+ public void setTestResult(TestResult testResult) {
+ this.testResult = testResult;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.runtime.tasks;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+
+public class Echo implements Runnable {
+ private final static Log defaultLog = LogFactory.getLog(Echo.class);
+ private Path writeTo = null;
+
+ private Log log;
+ private Object message;
+
+ public void run() {
+ log().info(message);
+
+ if (writeTo != null) {
+ try {
+ File file = writeTo.toFile();
+ if (log().isDebugEnabled())
+ log().debug("Write to " + file);
+ if (message != null)
+ FileUtils.writeStringToFile(file, message.toString());
+ } catch (IOException e) {
+ throw new SlcException("Could not write to " + writeTo, e);
+ }
+ }
+ }
+
+ private Log log() {
+ return log != null ? log : defaultLog;
+ }
+
+ public void setMessage(Object message) {
+ this.message = message;
+ }
+
+ public void setWriteTo(Path writeTo) {
+ this.writeTo = writeTo;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.runtime.tasks;
+
+import org.argeo.slc.SlcException;
+
+/** Conditional execution */
+public class If implements Runnable {
+ private Boolean is;
+ private Boolean not;
+ private Runnable then;
+ private Runnable els;
+
+ public void run() {
+ if (is == null && not == null)
+ throw new SlcException("No condition set");
+ if (is != null && not != null)
+ throw new SlcException("Both is and not cannot be set");
+
+ boolean bool = (is != null ? is : !not);
+ if (bool) {
+ if (then != null)
+ then.run();
+ } else {
+ if (els != null)
+ els.run();
+ }
+
+ }
+
+ public void setIs(Boolean bool) {
+ this.is = bool;
+ }
+
+ public void setThen(Runnable then) {
+ this.then = then;
+ }
+
+ public void setEls(Runnable els) {
+ this.els = els;
+ }
+
+ public Boolean getNot() {
+ return not;
+ }
+
+ public void setNot(Boolean not) {
+ this.not = not;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.runtime.tasks;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.argeo.slc.SlcException;
+
+/** A Java Virtual Machine process. */
+public class JvmProcess extends SystemCall {
+ private Properties systemProperties = new Properties();
+ private List<Path> classpath = new ArrayList<Path>();
+ private List<Path> pBootClasspath = new ArrayList<Path>();
+ private Path jvm = null;
+ private String mainClass;
+ private String mainJar;
+ private List<String> jvmArgs = new ArrayList<String>();
+ private List<String> args = new ArrayList<String>();
+
+ private String systemPropertiesFileProperty = null;
+ private String systemPropertiesFileDir = null;
+ private String systemPropertiesFileName = null;
+
+ public void init() throws Exception {
+ List<Object> command = new ArrayList<Object>();
+ if (jvm != null)
+ command.add(asFile(jvm).getPath());
+ else
+ command.add("java");
+
+ if (pBootClasspath.size() > 0) {
+ StringBuffer buf = new StringBuffer("-Xbootclasspath/p:");
+ Boolean first = true;
+ for (Path res : pBootClasspath) {
+ if (first)
+ first = false;
+ else
+ buf.append(File.pathSeparatorChar);
+
+ buf.append(asFile(res));
+ }
+ command.add(buf.toString());
+ }
+
+ for (String jvmArg : jvmArgs) {
+ command.add(jvmArg);
+ }
+
+ if (classpath.size() > 0) {
+ command.add("-cp");
+ StringBuffer buf = new StringBuffer("");
+ for (Path res : classpath) {
+ if (buf.length() != 0)
+ buf.append(File.pathSeparatorChar);
+ buf.append(asFile(res));
+ }
+ command.add(buf.toString());
+ }
+
+ if (systemPropertiesFileProperty == null) {
+ // pass system properties as argument
+ for (Map.Entry<Object, Object> entry : systemProperties.entrySet()) {
+ command.add("-D" + entry.getKey() + "=" + entry.getValue());
+ }
+ } else {
+ // write system properties in a file to work around OS limitations
+ // with command line (e.g. Win XP)
+ String dir = systemPropertiesFileDir;
+ if (dir == null)
+ dir = getExecDirToUse();
+ String fileName = systemPropertiesFileName;
+ if (fileName == null)
+ fileName = systemPropertiesFileProperty + ".properties";
+
+ // Write file
+ FileOutputStream fos = null;
+ File file = new File(dir + File.separator + fileName);
+ try {
+
+ if (!file.getParentFile().exists())
+ file.getParentFile().mkdirs();
+ fos = new FileOutputStream(file);
+ systemProperties.store(fos, "Automatically generated by " + getClass());
+ command.add("-D" + systemPropertiesFileProperty + "=" + file.getCanonicalPath());
+ } catch (IOException e) {
+ throw new SlcException("Cannot write to system properties to " + file, e);
+ } finally {
+ IOUtils.closeQuietly(fos);
+ }
+ }
+
+ // Program
+ if (mainClass != null) {
+ command.add(mainClass);
+ } else if (mainJar != null) {
+ command.add("-jar");
+ command.add(mainJar);
+ } else {
+ throw new SlcException("No main class or jar defined");
+ }
+
+ for (String arg : args) {
+ command.add(arg);
+ }
+
+ setCommand(command);
+ }
+
+ protected File asFile(Path res) {
+ File file = res.toFile();
+ if (!file.exists())
+ return copyToTempFile(res);
+ else
+ return res.toFile();
+ }
+
+ protected File copyToTempFile(Path res) {
+ File tempFile;
+ FileOutputStream fos;
+ try {
+ tempFile = File.createTempFile("slcJvmProcess-", res.getFileName().toString());
+ tempFile.deleteOnExit();
+ fos = new FileOutputStream(tempFile);
+ IOUtils.copy(Files.newInputStream(res), fos);
+ } catch (IOException e) {
+ throw new SlcException("Cannot copy " + res + " to temp file.", e);
+ }
+ IOUtils.closeQuietly(fos);
+ return tempFile;
+ }
+
+ /** Append the argument (for chaining) */
+ @Override
+ public SystemCall arg(String arg) {
+ args.add(arg);
+ return this;
+ }
+
+ /** Append the argument (for chaining) */
+ @Override
+ public SystemCall arg(String arg, String value) {
+ args.add(arg);
+ args.add(value);
+ return this;
+ }
+
+ public Properties getSystemProperties() {
+ return systemProperties;
+ }
+
+ public void setSystemProperties(Properties systemProperties) {
+ this.systemProperties = systemProperties;
+ }
+
+ public List<Path> getClasspath() {
+ return classpath;
+ }
+
+ public void setClasspath(List<Path> classpath) {
+ this.classpath = classpath;
+ }
+
+ public List<Path> getPBootClasspath() {
+ return pBootClasspath;
+ }
+
+ public void setPBootClasspath(List<Path> bootClasspath) {
+ pBootClasspath = bootClasspath;
+ }
+
+ public Path getJvm() {
+ return jvm;
+ }
+
+ public void setJvm(Path jvm) {
+ this.jvm = jvm;
+ }
+
+ public String getMainClass() {
+ return mainClass;
+ }
+
+ public void setMainClass(String mainClass) {
+ this.mainClass = mainClass;
+ }
+
+ public String getMainJar() {
+ return mainJar;
+ }
+
+ public void setMainJar(String mainJar) {
+ this.mainJar = mainJar;
+ }
+
+ public List<String> getJvmArgs() {
+ return jvmArgs;
+ }
+
+ public void setJvmArgs(List<String> jvmArgs) {
+ this.jvmArgs = jvmArgs;
+ }
+
+ public List<String> getArgs() {
+ return args;
+ }
+
+ public void setArgs(List<String> args) {
+ this.args = args;
+ }
+
+ public void setSystemPropertiesFileProperty(String systemPropertiesFilePropertyName) {
+ this.systemPropertiesFileProperty = systemPropertiesFilePropertyName;
+ }
+
+ public void setSystemPropertiesFileDir(String systemPropertiesFileDir) {
+ this.systemPropertiesFileDir = systemPropertiesFileDir;
+ }
+
+ public void setSystemPropertiesFileName(String systemPropertiesFileName) {
+ this.systemPropertiesFileName = systemPropertiesFileName;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.runtime.tasks;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.security.auth.callback.CallbackHandler;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteException;
+import org.apache.commons.exec.ExecuteResultHandler;
+import org.apache.commons.exec.ExecuteStreamHandler;
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.LogOutputStream;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.commons.exec.ShutdownHookProcessDestroyer;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.UnsupportedException;
+import org.argeo.slc.execution.ExecutionResources;
+import org.argeo.slc.runtime.test.SimpleResultPart;
+import org.argeo.slc.test.TestResult;
+import org.argeo.slc.test.TestStatus;
+
+/** Execute an OS specific system call. */
+public class SystemCall implements Runnable {
+ public final static String LOG_STDOUT = "System.out";
+
+ private final Log log = LogFactory.getLog(getClass());
+
+ private String execDir;
+
+ private String cmd = null;
+ private List<Object> command = null;
+
+ private Executor executor = new DefaultExecutor();
+ private Boolean synchronous = true;
+
+ private String stdErrLogLevel = "ERROR";
+ private String stdOutLogLevel = "INFO";
+
+ private Path stdOutFile = null;
+ private Path stdErrFile = null;
+
+ private Path stdInFile = null;
+ /**
+ * If no {@link #stdInFile} provided, writing to this stream will write to the
+ * stdin of the process.
+ */
+ private OutputStream stdInSink = null;
+
+ private Boolean redirectStdOut = false;
+
+ private List<SystemCallOutputListener> outputListeners = Collections
+ .synchronizedList(new ArrayList<SystemCallOutputListener>());
+
+ private Map<String, List<Object>> osCommands = new HashMap<String, List<Object>>();
+ private Map<String, String> osCmds = new HashMap<String, String>();
+ private Map<String, String> environmentVariables = new HashMap<String, String>();
+
+ private Boolean logCommand = false;
+ private Boolean redirectStreams = true;
+ private Boolean exceptionOnFailed = true;
+ private Boolean mergeEnvironmentVariables = true;
+
+// private Authentication authentication;
+
+ private String osConsole = null;
+ private String generateScript = null;
+
+ /** 24 hours */
+ private Long watchdogTimeout = 24 * 60 * 60 * 1000l;
+
+ private TestResult testResult;
+
+ private ExecutionResources executionResources;
+
+ /** Sudo the command, as root if empty or as user if not. */
+ private String sudo = null;
+ // TODO make it more secure and robust, test only once
+ private final String sudoPrompt = UUID.randomUUID().toString();
+ private String askPassProgram = "/usr/libexec/openssh/ssh-askpass";
+ @SuppressWarnings("unused")
+ private boolean firstLine = true;
+ @SuppressWarnings("unused")
+ private CallbackHandler callbackHandler;
+ /** Chroot to the this path (must not be empty) */
+ private String chroot = null;
+
+ // Current
+ /** Current watchdog, null if process is completed */
+ ExecuteWatchdog currentWatchdog = null;
+
+ /** Empty constructor */
+ public SystemCall() {
+
+ }
+
+ /**
+ * Constructor based on the provided command list.
+ *
+ * @param command the command list
+ */
+ public SystemCall(List<Object> command) {
+ this.command = command;
+ }
+
+ /**
+ * Constructor based on the provided command.
+ *
+ * @param cmd the command. If the provided string contains no space a command
+ * list is initialized with the argument as first component (useful
+ * for chained construction)
+ */
+ public SystemCall(String cmd) {
+ if (cmd.indexOf(' ') < 0) {
+ command = new ArrayList<Object>();
+ command.add(cmd);
+ } else {
+ this.cmd = cmd;
+ }
+ }
+
+ /** Executes the system call. */
+ public void run() {
+// authentication = SecurityContextHolder.getContext().getAuthentication();
+
+ // Manage streams
+ Writer stdOutWriter = null;
+ OutputStream stdOutputStream = null;
+ Writer stdErrWriter = null;
+ InputStream stdInStream = null;
+ if (stdOutFile != null)
+ if (redirectStdOut)
+ stdOutputStream = createOutputStream(stdOutFile);
+ else
+ stdOutWriter = createWriter(stdOutFile, true);
+
+ if (stdErrFile != null) {
+ stdErrWriter = createWriter(stdErrFile, true);
+ } else {
+ if (stdOutFile != null && !redirectStdOut)
+ stdErrWriter = createWriter(stdOutFile, true);
+ }
+
+ try {
+ if (stdInFile != null)
+ stdInStream = Files.newInputStream(stdInFile);
+ else {
+ stdInStream = new PipedInputStream();
+ stdInSink = new PipedOutputStream((PipedInputStream) stdInStream);
+ }
+ } catch (IOException e2) {
+ throw new SlcException("Cannot open a stream for " + stdInFile, e2);
+ }
+
+ if (log.isTraceEnabled()) {
+ log.debug("os.name=" + System.getProperty("os.name"));
+ log.debug("os.arch=" + System.getProperty("os.arch"));
+ log.debug("os.version=" + System.getProperty("os.version"));
+ }
+
+ // Execution directory
+ File dir = new File(getExecDirToUse());
+ // if (!dir.exists())
+ // dir.mkdirs();
+
+ // Watchdog to check for lost processes
+ Executor executorToUse;
+ if (executor != null)
+ executorToUse = executor;
+ else
+ executorToUse = new DefaultExecutor();
+ executorToUse.setWatchdog(createWatchdog());
+
+ if (redirectStreams) {
+ // Redirect standard streams
+ executorToUse.setStreamHandler(
+ createExecuteStreamHandler(stdOutWriter, stdOutputStream, stdErrWriter, stdInStream));
+ } else {
+ // Dummy stream handler (otherwise pump is used)
+ executorToUse.setStreamHandler(new DummyexecuteStreamHandler());
+ }
+
+ executorToUse.setProcessDestroyer(new ShutdownHookProcessDestroyer());
+ executorToUse.setWorkingDirectory(dir);
+
+ // Command line to use
+ final CommandLine commandLine = createCommandLine();
+ if (logCommand)
+ log.info("Execute command:\n" + commandLine + "\n in working directory: \n" + dir + "\n");
+
+ // Env variables
+ Map<String, String> environmentVariablesToUse = null;
+ environmentVariablesToUse = new HashMap<String, String>();
+ if (mergeEnvironmentVariables)
+ environmentVariablesToUse.putAll(System.getenv());
+ if (environmentVariables.size() > 0)
+ environmentVariablesToUse.putAll(environmentVariables);
+
+ // Execute
+ ExecuteResultHandler executeResultHandler = createExecuteResultHandler(commandLine);
+
+ //
+ // THE EXECUTION PROPER
+ //
+ try {
+ if (synchronous)
+ try {
+ int exitValue = executorToUse.execute(commandLine, environmentVariablesToUse);
+ executeResultHandler.onProcessComplete(exitValue);
+ } catch (ExecuteException e1) {
+ if (e1.getExitValue() == Executor.INVALID_EXITVALUE) {
+ Thread.currentThread().interrupt();
+ return;
+ }
+ // Sleep 1s in order to make sure error logs are flushed
+ Thread.sleep(1000);
+ executeResultHandler.onProcessFailed(e1);
+ }
+ else
+ executorToUse.execute(commandLine, environmentVariablesToUse, executeResultHandler);
+ } catch (SlcException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new SlcException("Could not execute command " + commandLine, e);
+ } finally {
+ IOUtils.closeQuietly(stdOutWriter);
+ IOUtils.closeQuietly(stdErrWriter);
+ IOUtils.closeQuietly(stdInStream);
+ IOUtils.closeQuietly(stdInSink);
+ }
+
+ }
+
+ public synchronized String function() {
+ final StringBuffer buf = new StringBuffer("");
+ SystemCallOutputListener tempOutputListener = new SystemCallOutputListener() {
+ private Long lineCount = 0l;
+
+ public void newLine(SystemCall systemCall, String line, Boolean isError) {
+ if (!isError) {
+ if (lineCount != 0l)
+ buf.append('\n');
+ buf.append(line);
+ lineCount++;
+ }
+ }
+ };
+ addOutputListener(tempOutputListener);
+ run();
+ removeOutputListener(tempOutputListener);
+ return buf.toString();
+ }
+
+ public String asCommand() {
+ return createCommandLine().toString();
+ }
+
+ @Override
+ public String toString() {
+ return asCommand();
+ }
+
+ /**
+ * Build a command line based on the properties. Can be overridden by specific
+ * command wrappers.
+ */
+ protected CommandLine createCommandLine() {
+ // Check if an OS specific command overrides
+ String osName = System.getProperty("os.name");
+ List<Object> commandToUse = null;
+ if (osCommands.containsKey(osName))
+ commandToUse = osCommands.get(osName);
+ else
+ commandToUse = command;
+ String cmdToUse = null;
+ if (osCmds.containsKey(osName))
+ cmdToUse = osCmds.get(osName);
+ else
+ cmdToUse = cmd;
+
+ CommandLine commandLine = null;
+
+ // Which command definition to use
+ if (commandToUse == null && cmdToUse == null)
+ throw new SlcException("Please specify a command.");
+ else if (commandToUse != null && cmdToUse != null)
+ throw new SlcException("Specify the command either as a line or as a list.");
+ else if (cmdToUse != null) {
+ if (chroot != null && !chroot.trim().equals(""))
+ cmdToUse = "chroot \"" + chroot + "\" " + cmdToUse;
+ if (sudo != null) {
+ environmentVariables.put("SUDO_ASKPASS", askPassProgram);
+ if (!sudo.trim().equals(""))
+ cmdToUse = "sudo -p " + sudoPrompt + " -u " + sudo + " " + cmdToUse;
+ else
+ cmdToUse = "sudo -p " + sudoPrompt + " " + cmdToUse;
+ }
+
+ // GENERATE COMMAND LINE
+ commandLine = CommandLine.parse(cmdToUse);
+ } else if (commandToUse != null) {
+ if (commandToUse.size() == 0)
+ throw new SlcException("Command line is empty.");
+
+ if (chroot != null && sudo != null) {
+ commandToUse.add(0, "chroot");
+ commandToUse.add(1, chroot);
+ }
+
+ if (sudo != null) {
+ environmentVariables.put("SUDO_ASKPASS", askPassProgram);
+ commandToUse.add(0, "sudo");
+ commandToUse.add(1, "-p");
+ commandToUse.add(2, sudoPrompt);
+ if (!sudo.trim().equals("")) {
+ commandToUse.add(3, "-u");
+ commandToUse.add(4, sudo);
+ }
+ }
+
+ // GENERATE COMMAND LINE
+ commandLine = new CommandLine(commandToUse.get(0).toString());
+
+ for (int i = 1; i < commandToUse.size(); i++) {
+ if (log.isTraceEnabled())
+ log.debug(commandToUse.get(i));
+ commandLine.addArgument(commandToUse.get(i).toString());
+ }
+ } else {
+ // all cases covered previously
+ throw new UnsupportedException();
+ }
+
+ if (generateScript != null) {
+ File scriptFile = new File(getExecDirToUse() + File.separator + generateScript);
+ try {
+ FileUtils.writeStringToFile(scriptFile,
+ (osConsole != null ? osConsole + " " : "") + commandLine.toString());
+ } catch (IOException e) {
+ throw new SlcException("Could not generate script " + scriptFile, e);
+ }
+ commandLine = new CommandLine(scriptFile);
+ } else {
+ if (osConsole != null)
+ commandLine = CommandLine.parse(osConsole + " " + commandLine.toString());
+ }
+
+ return commandLine;
+ }
+
+ /**
+ * Creates a {@link PumpStreamHandler} which redirects streams to the custom
+ * logging mechanism.
+ */
+ protected ExecuteStreamHandler createExecuteStreamHandler(final Writer stdOutWriter,
+ final OutputStream stdOutputStream, final Writer stdErrWriter, final InputStream stdInStream) {
+
+ // Log writers
+ OutputStream stdout = stdOutputStream != null ? stdOutputStream : new LogOutputStream() {
+ protected void processLine(String line, int level) {
+ // if (firstLine) {
+ // if (sudo != null && callbackHandler != null
+ // && line.startsWith(sudoPrompt)) {
+ // try {
+ // PasswordCallback pc = new PasswordCallback(
+ // "sudo password", false);
+ // Callback[] cbs = { pc };
+ // callbackHandler.handle(cbs);
+ // char[] pwd = pc.getPassword();
+ // char[] arr = Arrays.copyOf(pwd,
+ // pwd.length + 1);
+ // arr[arr.length - 1] = '\n';
+ // IOUtils.write(arr, stdInSink);
+ // stdInSink.flush();
+ // } catch (Exception e) {
+ // throw new SlcException(
+ // "Cannot retrieve sudo password", e);
+ // }
+ // }
+ // firstLine = false;
+ // }
+
+ if (line != null && !line.trim().equals(""))
+ logStdOut(line);
+
+ if (stdOutWriter != null)
+ appendLineToFile(stdOutWriter, line);
+ }
+ };
+
+ OutputStream stderr = new LogOutputStream() {
+ protected void processLine(String line, int level) {
+ if (line != null && !line.trim().equals(""))
+ logStdErr(line);
+ if (stdErrWriter != null)
+ appendLineToFile(stdErrWriter, line);
+ }
+ };
+
+ PumpStreamHandler pumpStreamHandler = new PumpStreamHandler(stdout, stderr, stdInStream) {
+
+ @Override
+ public void stop() throws IOException {
+ // prevents the method to block when joining stdin
+ if (stdInSink != null)
+ IOUtils.closeQuietly(stdInSink);
+
+ super.stop();
+ }
+ };
+ return pumpStreamHandler;
+ }
+
+ /** Creates the default {@link ExecuteResultHandler}. */
+ protected ExecuteResultHandler createExecuteResultHandler(final CommandLine commandLine) {
+ return new ExecuteResultHandler() {
+
+ public void onProcessComplete(int exitValue) {
+ String msg = "System call '" + commandLine + "' properly completed.";
+ if (log.isTraceEnabled())
+ log.trace(msg);
+ if (testResult != null) {
+ forwardPath(testResult);
+ testResult.addResultPart(new SimpleResultPart(TestStatus.PASSED, msg));
+ }
+ releaseWatchdog();
+ }
+
+ public void onProcessFailed(ExecuteException e) {
+
+ String msg = "System call '" + commandLine + "' failed.";
+ if (testResult != null) {
+ forwardPath(testResult);
+ testResult.addResultPart(new SimpleResultPart(TestStatus.ERROR, msg, e));
+ } else {
+ if (exceptionOnFailed)
+ throw new SlcException(msg, e);
+ else
+ log.error(msg, e);
+ }
+ releaseWatchdog();
+ }
+ };
+ }
+
+ @Deprecated
+ protected void forwardPath(TestResult testResult) {
+ // TODO: allocate a TreeSPath
+ }
+
+ /**
+ * Shortcut method getting the execDir to use
+ */
+ protected String getExecDirToUse() {
+ try {
+ if (execDir != null) {
+ return execDir;
+ }
+ return System.getProperty("user.dir");
+ } catch (Exception e) {
+ throw new SlcException("Cannot find exec dir", e);
+ }
+ }
+
+ protected void logStdOut(String line) {
+ for (SystemCallOutputListener outputListener : outputListeners)
+ outputListener.newLine(this, line, false);
+ log(stdOutLogLevel, line);
+ }
+
+ protected void logStdErr(String line) {
+ for (SystemCallOutputListener outputListener : outputListeners)
+ outputListener.newLine(this, line, true);
+ log(stdErrLogLevel, line);
+ }
+
+ /** Log from the underlying streams. */
+ protected void log(String logLevel, String line) {
+ // TODO optimize
+// if (SecurityContextHolder.getContext().getAuthentication() == null) {
+// SecurityContextHolder.getContext()
+// .setAuthentication(authentication);
+// }
+
+ if ("ERROR".equals(logLevel))
+ log.error(line);
+ else if ("WARN".equals(logLevel))
+ log.warn(line);
+ else if ("INFO".equals(logLevel))
+ log.info(line);
+ else if ("DEBUG".equals(logLevel))
+ log.debug(line);
+ else if ("TRACE".equals(logLevel))
+ log.trace(line);
+ else if (LOG_STDOUT.equals(logLevel))
+ System.out.println(line);
+ else if ("System.err".equals(logLevel))
+ System.err.println(line);
+ else
+ throw new SlcException("Unknown log level " + logLevel);
+ }
+
+ /** Append line to a log file. */
+ protected void appendLineToFile(Writer writer, String line) {
+ try {
+ writer.append(line).append('\n');
+ } catch (IOException e) {
+ log.error("Cannot write to log file", e);
+ }
+ }
+
+ /** Creates the writer for the output/err files. */
+ protected Writer createWriter(Path target, Boolean append) {
+ FileWriter writer = null;
+ try {
+
+ final File file;
+ if (executionResources != null)
+ file = new File(executionResources.getAsOsPath(target, true));
+ else
+ file = target.toFile();
+ writer = new FileWriter(file, append);
+ } catch (IOException e) {
+ log.error("Cannot get file for " + target, e);
+ IOUtils.closeQuietly(writer);
+ }
+ return writer;
+ }
+
+ /** Creates an outputstream for the output/err files. */
+ protected OutputStream createOutputStream(Path target) {
+ FileOutputStream out = null;
+ try {
+
+ final File file;
+ if (executionResources != null)
+ file = new File(executionResources.getAsOsPath(target, true));
+ else
+ file = target.toFile();
+ out = new FileOutputStream(file, false);
+ } catch (IOException e) {
+ log.error("Cannot get file for " + target, e);
+ IOUtils.closeQuietly(out);
+ }
+ return out;
+ }
+
+ /** Append the argument (for chaining) */
+ public SystemCall arg(String arg) {
+ if (command == null)
+ command = new ArrayList<Object>();
+ command.add(arg);
+ return this;
+ }
+
+ /** Append the argument (for chaining) */
+ public SystemCall arg(String arg, String value) {
+ if (command == null)
+ command = new ArrayList<Object>();
+ command.add(arg);
+ command.add(value);
+ return this;
+ }
+
+ // CONTROL
+ public synchronized Boolean isRunning() {
+ return currentWatchdog != null;
+ }
+
+ private synchronized ExecuteWatchdog createWatchdog() {
+// if (currentWatchdog != null)
+// throw new SlcException("A process is already being monitored");
+ currentWatchdog = new ExecuteWatchdog(watchdogTimeout);
+ return currentWatchdog;
+ }
+
+ private synchronized void releaseWatchdog() {
+ currentWatchdog = null;
+ }
+
+ public synchronized void kill() {
+ if (currentWatchdog != null)
+ currentWatchdog.destroyProcess();
+ }
+
+ /** */
+ public void setCmd(String command) {
+ this.cmd = command;
+ }
+
+ public void setCommand(List<Object> command) {
+ this.command = command;
+ }
+
+ public void setExecDir(String execdir) {
+ this.execDir = execdir;
+ }
+
+ public void setStdErrLogLevel(String stdErrLogLevel) {
+ this.stdErrLogLevel = stdErrLogLevel;
+ }
+
+ public void setStdOutLogLevel(String stdOutLogLevel) {
+ this.stdOutLogLevel = stdOutLogLevel;
+ }
+
+ public void setSynchronous(Boolean synchronous) {
+ this.synchronous = synchronous;
+ }
+
+ public void setOsCommands(Map<String, List<Object>> osCommands) {
+ this.osCommands = osCommands;
+ }
+
+ public void setOsCmds(Map<String, String> osCmds) {
+ this.osCmds = osCmds;
+ }
+
+ public void setEnvironmentVariables(Map<String, String> environmentVariables) {
+ this.environmentVariables = environmentVariables;
+ }
+
+ public Map<String, String> getEnvironmentVariables() {
+ return environmentVariables;
+ }
+
+ public void setWatchdogTimeout(Long watchdogTimeout) {
+ this.watchdogTimeout = watchdogTimeout;
+ }
+
+ public void setStdOutFile(Path stdOutFile) {
+ this.stdOutFile = stdOutFile;
+ }
+
+ public void setStdErrFile(Path stdErrFile) {
+ this.stdErrFile = stdErrFile;
+ }
+
+ public void setStdInFile(Path stdInFile) {
+ this.stdInFile = stdInFile;
+ }
+
+ public void setTestResult(TestResult testResult) {
+ this.testResult = testResult;
+ }
+
+ public void setLogCommand(Boolean logCommand) {
+ this.logCommand = logCommand;
+ }
+
+ public void setRedirectStreams(Boolean redirectStreams) {
+ this.redirectStreams = redirectStreams;
+ }
+
+ public void setExceptionOnFailed(Boolean exceptionOnFailed) {
+ this.exceptionOnFailed = exceptionOnFailed;
+ }
+
+ public void setMergeEnvironmentVariables(Boolean mergeEnvironmentVariables) {
+ this.mergeEnvironmentVariables = mergeEnvironmentVariables;
+ }
+
+ public void setOsConsole(String osConsole) {
+ this.osConsole = osConsole;
+ }
+
+ public void setGenerateScript(String generateScript) {
+ this.generateScript = generateScript;
+ }
+
+ public void setExecutionResources(ExecutionResources executionResources) {
+ this.executionResources = executionResources;
+ }
+
+ public void setRedirectStdOut(Boolean redirectStdOut) {
+ this.redirectStdOut = redirectStdOut;
+ }
+
+ public void addOutputListener(SystemCallOutputListener outputListener) {
+ outputListeners.add(outputListener);
+ }
+
+ public void removeOutputListener(SystemCallOutputListener outputListener) {
+ outputListeners.remove(outputListener);
+ }
+
+ public void setOutputListeners(List<SystemCallOutputListener> outputListeners) {
+ this.outputListeners = outputListeners;
+ }
+
+ public void setExecutor(Executor executor) {
+ this.executor = executor;
+ }
+
+ public void setSudo(String sudo) {
+ this.sudo = sudo;
+ }
+
+ public void setCallbackHandler(CallbackHandler callbackHandler) {
+ this.callbackHandler = callbackHandler;
+ }
+
+ public void setChroot(String chroot) {
+ this.chroot = chroot;
+ }
+
+ private class DummyexecuteStreamHandler implements ExecuteStreamHandler {
+
+ public void setProcessErrorStream(InputStream is) throws IOException {
+ }
+
+ public void setProcessInputStream(OutputStream os) throws IOException {
+ }
+
+ public void setProcessOutputStream(InputStream is) throws IOException {
+ }
+
+ public void start() throws IOException {
+ }
+
+ public void stop() {
+ }
+
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.runtime.tasks;
+
+public interface SystemCallOutputListener {
+ public void newLine(SystemCall systemCall, String line, Boolean isError);
+}
--- /dev/null
+/*\r
+ * Copyright (C) 2007-2012 Argeo GmbH\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.argeo.slc.runtime.test;\r
+\r
+import org.argeo.slc.test.TestData;\r
+\r
+public class BasicTestData implements TestData {\r
+ private Object expected;\r
+ private Object reached;\r
+\r
+ public Object getExpected() {\r
+ return expected;\r
+ }\r
+\r
+ public void setExpected(Object expected) {\r
+ this.expected = expected;\r
+ }\r
+\r
+ public Object getReached() {\r
+ return reached;\r
+ }\r
+\r
+ public void setReached(Object reached) {\r
+ this.reached = reached;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (C) 2007-2012 Argeo GmbH\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.argeo.slc.runtime.test;\r
+\r
+import org.argeo.slc.SlcException;\r
+import org.argeo.slc.test.IncompatibleTestDataException;\r
+import org.argeo.slc.test.TestData;\r
+import org.argeo.slc.test.TestDefinition;\r
+import org.argeo.slc.test.TestResult;\r
+import org.argeo.slc.test.TestRun;\r
+import org.argeo.slc.test.TestStatus;\r
+import org.argeo.slc.test.context.ContextAware;\r
+\r
+/** Understands basic test data and context aware test data. */\r
+public class BasicTestDefinition implements TestDefinition {\r
+\r
+ public void execute(TestRun testRun) {\r
+ if (testRun.<TestData> getTestData() instanceof BasicTestData) {\r
+ BasicTestData testData = testRun.getTestData();\r
+ TestResult result = testRun.getTestResult();\r
+\r
+ if (result == null)\r
+ throw new SlcException("No test result defined.");\r
+\r
+ try {\r
+ if (testData.getExpected().equals(testData.getReached())) {\r
+ result.addResultPart(new SimpleResultPart(\r
+ TestStatus.PASSED, "Reached and expected equals"));\r
+ } else {\r
+ result.addResultPart(new SimpleResultPart(\r
+ TestStatus.FAILED, "Expected "\r
+ + testData.getExpected() + " but reached "\r
+ + testData.getReached()));\r
+ }\r
+ } catch (Exception e) {\r
+ result.addResultPart(new SimpleResultPart(TestStatus.ERROR,\r
+ "Could not compare", e));\r
+ }\r
+ } else if (testRun.<TestData> getTestData() instanceof ContextAware) {\r
+ TestData testData = testRun.getTestData();\r
+ ContextUtils.compareReachedExpected((ContextAware) testData,\r
+ testRun.getTestResult());\r
+ } else {\r
+ throw new IncompatibleTestDataException(testRun);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (C) 2007-2012 Argeo GmbH\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.argeo.slc.runtime.test;\r
+\r
+import java.util.Map;\r
+import java.util.TreeMap;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.argeo.slc.test.TestResult;\r
+import org.argeo.slc.test.TestStatus;\r
+import org.argeo.slc.test.context.ContextAware;\r
+import org.argeo.slc.test.context.ParentContextAware;\r
+\r
+/** Utilities for comparing and synchronising contexts. */\r
+public class ContextUtils {\r
+ private final static Log log = LogFactory.getLog(ContextUtils.class);\r
+\r
+ public static void compareReachedExpected(ContextAware contextAware,\r
+ TestResult testResult) {\r
+ for (String key : contextAware.getExpectedValues().keySet()) {\r
+\r
+ // Compare expected values with reached ones\r
+ Object expectedValue = contextAware.getExpectedValues().get(key);\r
+\r
+ if (expectedValue.toString().equals(\r
+ contextAware.getContextSkipFlag())) {\r
+ if (log.isDebugEnabled())\r
+ log.debug("Skipped check for key '" + key + "'");\r
+ continue;\r
+ }\r
+\r
+ if (contextAware.getValues().containsKey(key)) {\r
+ Object reachedValue = contextAware.getValues().get(key);\r
+\r
+ if (expectedValue.equals(contextAware.getContextAnyFlag())) {\r
+ testResult.addResultPart(new SimpleResultPart(\r
+ TestStatus.PASSED, "Expected any value for key '"\r
+ + key + "'"));\r
+ } else if (expectedValue.equals(reachedValue)) {\r
+ testResult.addResultPart(new SimpleResultPart(\r
+ TestStatus.PASSED, "Values matched for key '" + key\r
+ + "'"));\r
+ } else {\r
+ testResult.addResultPart(new SimpleResultPart(\r
+ TestStatus.FAILED, "Mismatch for key '" + key\r
+ + "': expected '" + expectedValue\r
+ + "' but reached '" + reachedValue + "'"));\r
+ }\r
+ } else {\r
+ testResult.addResultPart(new SimpleResultPart(\r
+ TestStatus.FAILED, "No value reached for key '" + key\r
+ + "'"));\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Makes sure that all children and sub-children of parent share the same\r
+ * maps for values and expected values.\r
+ */\r
+ public static void synchronize(ParentContextAware parent) {\r
+ Map<String, Object> expectedValuesCommon = new TreeMap<String, Object>(\r
+ parent.getExpectedValues());\r
+ synchronize(parent, expectedValuesCommon);\r
+ if (log.isDebugEnabled())\r
+ log.debug("Synchronized context " + parent);\r
+\r
+ }\r
+\r
+ private static void synchronize(ParentContextAware parent,\r
+ Map<String, Object> expectedValuesCommon) {\r
+ for (ContextAware child : parent.getChildContexts()) {\r
+ // Values\r
+ putNotContained(parent.getValues(), child.getValues());\r
+ child.setValues(parent.getValues());\r
+\r
+ // Expected Values\r
+ // Expected values reference is not overridden: each child has its\r
+ // own expected values map.\r
+ overrideContained(expectedValuesCommon, child.getExpectedValues());\r
+\r
+ // Creates a new Map in order not to disturb other context using the\r
+ // same keys\r
+ Map<String, Object> expectedValuesCommonChild = new TreeMap<String, Object>(\r
+ expectedValuesCommon);\r
+ putNotContained(expectedValuesCommonChild,\r
+ child.getExpectedValues());\r
+\r
+ if (child instanceof ParentContextAware) {\r
+ // Recursive sync\r
+ synchronize((ParentContextAware) child,\r
+ expectedValuesCommonChild);\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ /**\r
+ * Put into common map the values from child map which are not already\r
+ * defined in common map.\r
+ */\r
+ public static void putNotContained(Map<String, Object> commonMap,\r
+ Map<String, Object> childMap) {\r
+ for (String key : childMap.keySet()) {\r
+ if (!commonMap.containsKey(key)) {\r
+ commonMap.put(key, childMap.get(key));\r
+ }\r
+ }\r
+ }\r
+\r
+ /** Overrides child map values with the values already set in common map */\r
+ public static void overrideContained(Map<String, Object> commonMap,\r
+ Map<String, Object> childMap) {\r
+ for (String key : childMap.keySet()) {\r
+ if (commonMap.containsKey(key)) {\r
+ childMap.put(key, commonMap.get(key));\r
+ }\r
+ }\r
+ }\r
+\r
+ /** Makes sure this cannot be instantiated. */\r
+ private ContextUtils() {\r
+\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (C) 2007-2012 Argeo GmbH\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.argeo.slc.runtime.test;\r
+\r
+import java.io.Serializable;\r
+\r
+import org.argeo.slc.test.TestResultPart;\r
+import org.argeo.slc.test.TestRun;\r
+import org.argeo.slc.test.TestRunAware;\r
+import org.argeo.slc.test.TestStatus;\r
+\r
+/**\r
+ * <p>\r
+ * Basic implementation of a result part, implementing the standard three status\r
+ * approach for test results.\r
+ * </p>\r
+ * \r
+ * @see TestStatus\r
+ */\r
+public class SimpleResultPart implements TestResultPart, TestStatus,\r
+ TestRunAware, Serializable {\r
+ private static final long serialVersionUID = 6669675957685071901L;\r
+\r
+ private Long tid;\r
+\r
+ private String testRunUuid;\r
+\r
+ /** The status. Default to ERROR since it should always be explicitely set. */\r
+ private Integer status = ERROR;\r
+ private String message;\r
+ private String exceptionMessage;\r
+\r
+ public SimpleResultPart() {\r
+ }\r
+\r
+ public SimpleResultPart(Integer status, String message) {\r
+ this(status, message, null);\r
+ }\r
+\r
+ public SimpleResultPart(Integer status, String message, Exception exception) {\r
+ this.status = status;\r
+ this.message = message;\r
+ setException(exception);\r
+ }\r
+\r
+ public String getMessage() {\r
+ return message;\r
+ }\r
+\r
+ public void setMessage(String message) {\r
+ this.message = message;\r
+ }\r
+\r
+ public void setStatus(Integer status) {\r
+ this.status = status;\r
+ }\r
+\r
+ public Integer getStatus() {\r
+ return status;\r
+ }\r
+\r
+ public String getExceptionMessage() {\r
+ return exceptionMessage;\r
+ }\r
+\r
+ public void setException(Exception exception) {\r
+ if (exception == null)\r
+ return;\r
+\r
+ StringBuffer buf = new StringBuffer("");\r
+ buf.append(exception.toString());\r
+ buf.append('\n');\r
+ for (StackTraceElement elem : exception.getStackTrace()) {\r
+ buf.append('\t').append(elem.toString()).append('\n');\r
+ }\r
+\r
+ if (exception.getCause() != null)\r
+ addRootCause(buf, exception.getCause());\r
+\r
+ this.exceptionMessage = buf.toString();\r
+ }\r
+\r
+ protected void addRootCause(StringBuffer buf, Throwable cause) {\r
+ if (cause == null)\r
+ return;\r
+\r
+ buf.append("Caused by: " + cause.getMessage());\r
+ for (StackTraceElement elem : cause.getStackTrace()) {\r
+ buf.append('\t').append(elem.toString()).append('\n');\r
+ }\r
+\r
+ if (cause.getCause() != null) {\r
+ addRootCause(buf, cause.getCause());\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuffer buf = new StringBuffer("");\r
+ buf.append(SlcTestUtils.statusToString(status));\r
+ if (status == PASSED || status == FAILED) {\r
+ buf.append(' ');\r
+ } else if (status == ERROR) {\r
+ buf.append(" ");\r
+ }\r
+ buf.append(message);\r
+ return buf.toString();\r
+ }\r
+\r
+ /** @deprecated */\r
+ Long getTid() {\r
+ return tid;\r
+ }\r
+\r
+ /** @deprecated */\r
+ void setTid(Long tid) {\r
+ this.tid = tid;\r
+ }\r
+\r
+ public String getTestRunUuid() {\r
+ return testRunUuid;\r
+ }\r
+\r
+ /** For ORM */\r
+ public void setTestRunUuid(String testRunUuid) {\r
+ this.testRunUuid = testRunUuid;\r
+ }\r
+\r
+ public void notifyTestRun(TestRun testRun) {\r
+ testRunUuid = testRun.getUuid();\r
+ }\r
+\r
+ public void setExceptionMessage(String exceptionMessage) {\r
+ this.exceptionMessage = exceptionMessage;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (C) 2007-2012 Argeo GmbH\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.argeo.slc.runtime.test;\r
+\r
+import java.util.Date;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.TreeMap;\r
+import java.util.UUID;\r
+import java.util.Vector;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.argeo.slc.SlcException;\r
+import org.argeo.slc.test.TestResult;\r
+import org.argeo.slc.test.TestResultPart;\r
+import org.argeo.slc.test.TestRun;\r
+\r
+/**\r
+ * Basic implementation of a test result containing only a list of result parts.\r
+ */\r
+public class SimpleTestResult implements TestResult {\r
+ private static Log log = LogFactory.getLog(SimpleTestResult.class);\r
+\r
+ private String uuid;\r
+ private String currentTestRunUuid;\r
+\r
+ private Boolean throwError = true;\r
+\r
+ private Date closeDate;\r
+ private List<TestResultPart> parts = new Vector<TestResultPart>();\r
+\r
+ private Map<String, String> attributes = new TreeMap<String, String>();\r
+\r
+ public void addResultPart(TestResultPart part) {\r
+ if (throwError && part.getStatus() == ERROR) {\r
+ throw new SlcException(\r
+ "There was an error in the underlying test: "\r
+ + part.getExceptionMessage());\r
+ }\r
+ parts.add(part);\r
+ if (log.isDebugEnabled())\r
+ log.debug(part);\r
+ }\r
+\r
+ public void close() {\r
+ parts.clear();\r
+ closeDate = new Date();\r
+ }\r
+\r
+ public List<TestResultPart> getParts() {\r
+ return parts;\r
+ }\r
+\r
+ public Date getCloseDate() {\r
+ return closeDate;\r
+ }\r
+\r
+ public void setThrowError(Boolean throwError) {\r
+ this.throwError = throwError;\r
+ }\r
+\r
+ public void notifyTestRun(TestRun testRun) {\r
+ currentTestRunUuid = testRun.getUuid();\r
+ }\r
+\r
+ public String getUuid() {\r
+ if (uuid == null) {\r
+ uuid = UUID.randomUUID().toString();\r
+ }\r
+ return uuid;\r
+ }\r
+\r
+ public void setUuid(String uuid) {\r
+ this.uuid = uuid;\r
+ }\r
+\r
+ public String getCurrentTestRunUuid() {\r
+ return currentTestRunUuid;\r
+ }\r
+\r
+ public Map<String, String> getAttributes() {\r
+ return attributes;\r
+ }\r
+\r
+ public void setAttributes(Map<String, String> attributes) {\r
+ this.attributes = attributes;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (C) 2007-2012 Argeo GmbH\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.argeo.slc.runtime.test;\r
+\r
+import java.util.UUID;\r
+\r
+import org.argeo.slc.deploy.DeployedSystem;\r
+import org.argeo.slc.test.ExecutableTestRun;\r
+import org.argeo.slc.test.TestData;\r
+import org.argeo.slc.test.TestDefinition;\r
+import org.argeo.slc.test.TestResult;\r
+import org.argeo.slc.test.WritableTestRun;\r
+\r
+/**\r
+ * A basic bean implementation of a <code>WritableTestRun</code>, holding\r
+ * references to the various parts of a test run.\r
+ */\r
+public class SimpleTestRun implements WritableTestRun, ExecutableTestRun {\r
+ private String uuid;\r
+\r
+ // private String slcExecutionUuid;\r
+ // private String slcExecutionStepUuid;\r
+\r
+ private DeployedSystem deployedSystem;\r
+ private TestData testData;\r
+ private TestDefinition testDefinition;\r
+ private TestResult testResult;\r
+\r
+ /** Executes the underlying test definition. */\r
+ public void run() {\r
+ uuid = UUID.randomUUID().toString();\r
+ if (testResult != null)\r
+ testResult.notifyTestRun(this);\r
+\r
+ testDefinition.execute(this);\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public <T extends DeployedSystem> T getDeployedSystem() {\r
+ return (T) deployedSystem;\r
+ }\r
+\r
+ public void setDeployedSystem(DeployedSystem deployedSystem) {\r
+ this.deployedSystem = deployedSystem;\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public <T extends TestData> T getTestData() {\r
+ return (T) testData;\r
+ }\r
+\r
+ public void setTestData(TestData testData) {\r
+ this.testData = testData;\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public <T extends TestDefinition> T getTestDefinition() {\r
+ return (T) testDefinition;\r
+ }\r
+\r
+ public void setTestDefinition(TestDefinition testDefinition) {\r
+ this.testDefinition = testDefinition;\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public <T extends TestResult> T getTestResult() {\r
+ return (T) testResult;\r
+ }\r
+\r
+ public void setTestResult(TestResult testResult) {\r
+ this.testResult = testResult;\r
+ }\r
+\r
+ public String getUuid() {\r
+ return uuid;\r
+ }\r
+\r
+ public void setUuid(String uuid) {\r
+ this.uuid = uuid;\r
+ }\r
+\r
+ // public String getSlcExecutionUuid() {\r
+ // return slcExecutionUuid;\r
+ // }\r
+ //\r
+ // public void setSlcExecutionUuid(String slcExecutionUuid) {\r
+ // this.slcExecutionUuid = slcExecutionUuid;\r
+ // }\r
+ //\r
+ // public String getSlcExecutionStepUuid() {\r
+ // return slcExecutionStepUuid;\r
+ // }\r
+ //\r
+ // public void setSlcExecutionStepUuid(String slcExecutionStepUuid) {\r
+ // this.slcExecutionStepUuid = slcExecutionStepUuid;\r
+ // }\r
+}\r
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.runtime.test;
+
+import org.argeo.slc.SlcException;
+import org.argeo.slc.test.TestStatus;
+
+public abstract class SlcTestUtils {
+ public static String statusToString(Integer status) {
+ if (status.equals(TestStatus.PASSED)) {
+ return TestStatus.STATUSSTR_PASSED;
+ } else if (status.equals(TestStatus.FAILED)) {
+ return TestStatus.STATUSSTR_FAILED;
+ } else if (status.equals(TestStatus.ERROR)) {
+ return TestStatus.STATUSSTR_ERROR;
+ } else {
+ throw new SlcException("Unrecognized status " + status);
+ }
+ }
+
+ public static Integer stringToStatus(String statusStr) {
+ if (statusStr.equals(TestStatus.STATUSSTR_PASSED)) {
+ return TestStatus.PASSED;
+ } else if (statusStr.equals(TestStatus.STATUSSTR_FAILED)) {
+ return TestStatus.FAILED;
+ } else if (statusStr.equals(TestStatus.STATUSSTR_ERROR)) {
+ return TestStatus.ERROR;
+ } else {
+ throw new SlcException("Unrecognized status string " + statusStr);
+ }
+ }
+
+ private SlcTestUtils() {
+
+ }
+
+}
--- /dev/null
+/*\r
+ * Copyright (C) 2007-2012 Argeo GmbH\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.argeo.slc.runtime.test;\r
+\r
+import org.argeo.slc.UnsupportedException;\r
+import org.argeo.slc.test.TestData;\r
+import org.argeo.slc.test.TestDataProvider;\r
+\r
+/** Utilities for dealing with test datas. */\r
+public class TestDataUtils {\r
+ /** Extracts the test data from the given provider. */\r
+ public static <T extends TestData> T getFromProvider(Object obj,\r
+ Class<T> clss, String key) {\r
+ if (obj instanceof TestDataProvider) {\r
+ TestDataProvider testDataProvider = (TestDataProvider) obj;\r
+ return testDataProvider.getTestData(clss, key);\r
+ } else {\r
+ throw new UnsupportedException("test data provider", obj);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Extracts the test data from the given provider using <code>null</code>\r
+ * as key.\r
+ */\r
+ public static <T extends TestData> T getFromProvider(Object obj,\r
+ Class<T> clss) {\r
+ return getFromProvider(obj, clss, null);\r
+ }\r
+\r
+ /**\r
+ * Returns it self after making the proper checks. Used for test data being\r
+ * their own data providers.\r
+ */\r
+ @SuppressWarnings("unchecked")\r
+ public static <T extends TestData> T getItSelf(Class<T> clss,\r
+ TestData testDataObject) {\r
+ if (clss.isAssignableFrom(testDataObject.getClass())) {\r
+ return (T) testDataObject;\r
+ } else {\r
+ throw new UnsupportedException("test data", testDataObject);\r
+ }\r
+\r
+ }\r
+\r
+ /** Makes sure this is an utility class. */\r
+ private TestDataUtils() {\r
+\r
+ }\r
+}\r
Import-Package: javax.jcr.nodetype,\
javax.jcr.security,\
org.argeo.api,\
+aQute.bnd.osgi,\
org.apache.tools.ant.*;resolution:="optional",\
junit.framework;resolution:="optional",\
org.osgi.*;version=0.0.0,\
\r
import org.apache.commons.logging.Log;\r
import org.apache.commons.logging.LogFactory;\r
-import org.argeo.slc.core.test.SimpleTestResult;\r
import org.argeo.slc.execution.ExecutionContext;\r
import org.argeo.slc.execution.ExecutionFlow;\r
+import org.argeo.slc.runtime.test.SimpleTestResult;\r
import org.argeo.slc.test.TestResultPart;\r
import org.argeo.slc.test.TestStatus;\r
import org.springframework.context.ConfigurableApplicationContext;\r
import java.util.HashMap;\r
import java.util.Map;\r
\r
-import org.argeo.slc.core.test.SimpleTestResult;\r
import org.argeo.slc.execution.ExecutionContext;\r
import org.argeo.slc.execution.ExecutionFlow;\r
+import org.argeo.slc.runtime.test.SimpleTestResult;\r
import org.argeo.slc.test.TestStatus;\r
import org.springframework.beans.factory.BeanCreationException;\r
import org.springframework.context.ConfigurableApplicationContext;\r
*/
package org.argeo.slc.core.execution;
-import org.argeo.slc.core.test.SimpleTestResult;
import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.runtime.test.SimpleTestResult;
import org.argeo.slc.test.TestStatus;
import org.springframework.context.ConfigurableApplicationContext;
\r
<import resource="imports.xml" /> \r
\r
- <bean id="myTestRunTemplate" class="org.argeo.slc.core.test.SimpleTestRun" abstract="true">\r
+ <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
<property name="testDefinition" ref="basic.testDef" />\r
<property name="testResult" ref="myTestResult"/>\r
</bean> \r
</bean>\r
\r
\r
- <bean id="simpleMap.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="simpleMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<map>\r
<entry key="key1" value="myValue_myValue" />\r
</property>\r
</bean>\r
\r
- <bean id="cascadingMap.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="cascadingMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<map>\r
<entry key="key3">\r
</property>\r
</bean> \r
\r
- <bean id="simpleList.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="simpleList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<list>\r
<value>myValue</value>\r
</property>\r
</bean> \r
\r
- <bean id="cascadingList.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="cascadingList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<list>\r
<list>\r
</property>\r
</bean> \r
\r
- <bean id="simpleSet.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="simpleSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<set>\r
<value>myValue</value>\r
</property>\r
</bean> \r
\r
- <bean id="cascadingSet.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="cascadingSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<set>\r
<set>\r
</property>\r
</bean> \r
\r
- <bean id="cascadingListMap.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="cascadingListMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<list>\r
<map>\r
</property>\r
</bean> \r
\r
- <bean id="cascadingSetMap.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="cascadingSetMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<set>\r
<map>\r
</property>\r
</bean> \r
\r
- <bean id="cascadingComplex.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="cascadingComplex.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<set>\r
<map>\r
</property>\r
</bean> \r
\r
- <bean id="basic.testDef" class="org.argeo.slc.core.test.BasicTestDefinition">\r
+ <bean id="basic.testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition">\r
</bean> \r
\r
\r
value="testKey=@{testKey}" />\r
</bean>\r
\r
- <bean id="myTestResult" class="org.argeo.slc.core.test.SimpleTestResult" />\r
+ <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
\r
</beans>
\ No newline at end of file
\r
<import resource="imports.xml" /> \r
\r
- <bean id="myTestRunTemplate" class="org.argeo.slc.core.test.SimpleTestRun" abstract="true">\r
+ <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
<property name="testDefinition" ref="basic.testDef" />\r
<property name="testResult" ref="myTestResult"/>\r
</bean> \r
</bean> \r
\r
\r
- <bean id="simpleMap.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="simpleMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<map>\r
<entry key="key1" value="myValue_myValue" />\r
</property>\r
</bean>\r
\r
- <bean id="cascadingMap.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="cascadingMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<map>\r
<entry key="key3">\r
</property>\r
</bean> \r
\r
- <bean id="simpleList.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="simpleList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<list>\r
<value>myValue</value>\r
</property>\r
</bean> \r
\r
- <bean id="cascadingList.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="cascadingList.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<list>\r
<list>\r
</property>\r
</bean> \r
\r
- <bean id="simpleSet.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="simpleSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<set>\r
<value>myValue</value>\r
</property>\r
</bean> \r
\r
- <bean id="cascadingSet.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="cascadingSet.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<set>\r
<set>\r
</property>\r
</bean> \r
\r
- <bean id="cascadingListMap.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="cascadingListMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<list>\r
<map>\r
</property>\r
</bean> \r
\r
- <bean id="cascadingSetMap.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="cascadingSetMap.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<set>\r
<map>\r
</property>\r
</bean> \r
\r
- <bean id="cascadingComplex.testData" class="org.argeo.slc.core.test.BasicTestData" scope="prototype">\r
+ <bean id="cascadingComplex.testData" class="org.argeo.slc.runtime.test.BasicTestData" scope="prototype">\r
<property name="expected">\r
<set>\r
<map>\r
</property>\r
</bean> \r
\r
- <bean id="basic.testDef" class="org.argeo.slc.core.test.BasicTestDefinition">\r
+ <bean id="basic.testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition">\r
</bean> \r
\r
\r
value="testKey=@{testKey}" />\r
</bean>\r
\r
- <bean id="myTestResult" class="org.argeo.slc.core.test.SimpleTestResult" />\r
+ <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
\r
</beans>
\ No newline at end of file
\r
<import resource="imports.xml" /> \r
\r
- <bean id="myTestResult" class="org.argeo.slc.core.test.SimpleTestResult" />\r
+ <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
\r
- <bean id="myTestDef" class="org.argeo.slc.core.test.BasicTestDefinition" />\r
+ <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
\r
- <bean id="myTestRunTemplate" class="org.argeo.slc.core.test.SimpleTestRun" abstract="true">\r
+ <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
<property name="testDefinition" ref="myTestDef" />\r
<property name="testResult" ref="myTestResult"/>\r
</bean> \r
</bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="file1" />\r
<property name="reached" value="@{fileName}" />\r
</bean>\r
p:isParameter="true" p:isFrozen="true" />\r
</entry>\r
<entry key="testData1">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.core.test.BasicTestData"\r
+ <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
p:isParameter="true" p:isFrozen="true" />\r
</entry>\r
<entry key="testData2">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.core.test.BasicTestData"\r
+ <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
p:isParameter="true" p:isFrozen="true" />\r
</entry>\r
<entry key="testedComponentId">\r
<bean class="org.argeo.slc.core.execution.ExceptionIfInitCalledTwice" />\r
</entry>\r
<entry key="testData1">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="toto" />\r
<property name="reached" value="toto" />\r
</bean>\r
</entry>\r
<entry key="testData2">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="tata" />\r
<property name="reached" value="toto" />\r
</bean>\r
<constructor-arg value="testData2" />\r
</bean>\r
\r
- <bean id="parameterRef.testResult" class="org.argeo.slc.core.test.SimpleTestResult" />\r
+ <bean id="parameterRef.testResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
\r
- <bean id="parameterRef.testRun" class="org.argeo.slc.core.test.SimpleTestRun"\r
+ <bean id="parameterRef.testRun" class="org.argeo.slc.runtime.test.SimpleTestRun"\r
abstract="true">\r
<property name="testResult" ref="parameterRef.testResult" />\r
<property name="testDefinition">\r
- <bean class="org.argeo.slc.core.test.BasicTestDefinition" />\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
</property>\r
</bean>\r
\r
\r
<import resource="imports.xml" /> \r
\r
- <bean id="myTestResult" class="org.argeo.slc.core.test.SimpleTestResult" />\r
+ <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
\r
- <bean id="myTestDef" class="org.argeo.slc.core.test.BasicTestDefinition" />\r
+ <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
\r
<bean id="echo1" parent="task.echo">\r
<property name="message" value="From minimal" />\r
</bean>\r
\r
- <bean id="myTestRunTemplate" class="org.argeo.slc.core.test.SimpleTestRun" abstract="true">\r
+ <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
<property name="testDefinition" ref="myTestDef" />\r
<property name="testResult" ref="myTestResult"/>\r
</bean> \r
<bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="da1" />\r
<property name="reached" value="@{p1}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="va2" />\r
<property name="reached" value="@{p2}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="da3" />\r
<property name="reached" value="@{p3}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="va4" />\r
<property name="reached" value="@{p4}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="da5" />\r
<property name="reached" value="@{p5}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="va6" />\r
<property name="reached" value="@{p6}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="da1" />\r
<property name="reached" value="@{p1}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="va2" />\r
<property name="reached" value="@{p2}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="da3" />\r
<property name="reached" value="@{p3}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="va4" />\r
<property name="reached" value="@{p4}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="da5" />\r
<property name="reached" value="@{p5}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="va6" />\r
<property name="reached" value="@{p6}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p7=@{p7}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="vb7" />\r
<property name="reached" value="@{p7}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p8=@{p8}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="db8" />\r
<property name="reached" value="@{p8}" />\r
</bean>\r
<bean parent="task.echo" scope="execution"><property name="message" value="p1=@{p1}" /><aop:scoped-proxy /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData" scope="execution">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
<property name="expected" value="e1" />\r
<property name="reached" value="@{p1}" />\r
<aop:scoped-proxy />\r
<bean parent="task.echo" scope="execution"><property name="message" value="p2=@{p2}" /><aop:scoped-proxy /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData" scope="execution">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
<property name="expected" value="e2" />\r
<property name="reached" value="@{p2}" />\r
<aop:scoped-proxy />\r
<bean parent="task.echo" scope="execution"><property name="message" value="p3=@{p3}" /><aop:scoped-proxy /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData" scope="execution">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
<property name="expected" value="e3" />\r
<property name="reached" value="@{p3}" />\r
<aop:scoped-proxy />\r
<bean parent="task.echo" scope="execution"><property name="message" value="p4=@{p4}" /><aop:scoped-proxy /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData" scope="execution">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
<property name="expected" value="e4" />\r
<property name="reached" value="@{p4}" />\r
<aop:scoped-proxy />\r
<bean parent="task.echo" scope="execution"><property name="message" value="p5=@{p5}" /><aop:scoped-proxy /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData" scope="execution">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
<property name="expected" value="e5" />\r
<property name="reached" value="@{p5}" />\r
<aop:scoped-proxy />\r
<bean parent="task.echo" scope="execution"><property name="message" value="p6=@{p6}" /><aop:scoped-proxy /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData" scope="execution">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
<property name="expected" value="e6" />\r
<property name="reached" value="@{p6}" />\r
<aop:scoped-proxy />\r
<bean parent="task.echo" scope="execution"><property name="message" value="p7=@{p7}" /><aop:scoped-proxy /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData" scope="execution">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
<property name="expected" value="vb7" />\r
<property name="reached" value="@{p7}" />\r
<aop:scoped-proxy />\r
<bean parent="task.echo" scope="execution"><property name="message" value="p8=@{p8}" /><aop:scoped-proxy /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData" scope="execution">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
<property name="expected" value="db8" />\r
<property name="reached" value="@{p8}" />\r
<aop:scoped-proxy />\r
\r
<import resource="imports.xml" /> \r
\r
- <bean id="myTestResult" class="org.argeo.slc.core.test.SimpleTestResult" />\r
+ <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
\r
- <bean id="myTestDef" class="org.argeo.slc.core.test.BasicTestDefinition" />\r
+ <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
\r
<bean id="echo1" parent="task.echo">\r
<property name="message" value="From minimal" />\r
</bean>\r
\r
- <bean id="myTestRunTemplate" class="org.argeo.slc.core.test.SimpleTestRun" abstract="true">\r
+ <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
<property name="testDefinition" ref="myTestDef" />\r
<property name="testResult" ref="myTestResult"/>\r
</bean> \r
<bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="da1" />\r
<property name="reached" value="@{p1}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="va2" />\r
<property name="reached" value="@{p2}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="da3" />\r
<property name="reached" value="@{p3}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="va4" />\r
<property name="reached" value="@{p4}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="da5" />\r
<property name="reached" value="@{p5}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="va6" />\r
<property name="reached" value="@{p6}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p1=@{p1}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="da1" />\r
<property name="reached" value="@{p1}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p2=@{p2}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="va2" />\r
<property name="reached" value="@{p2}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p3=@{p3}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="da3" />\r
<property name="reached" value="@{p3}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p4=@{p4}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="va4" />\r
<property name="reached" value="@{p4}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p5=@{p5}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="da5" />\r
<property name="reached" value="@{p5}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p6=@{p6}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="va6" />\r
<property name="reached" value="@{p6}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p7=@{p7}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="vb7" />\r
<property name="reached" value="@{p7}" />\r
</bean>\r
<bean parent="task.echo"><property name="message" value="p8=@{p8}" /></bean>\r
<bean parent="myTestRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="db8" />\r
<property name="reached" value="@{p8}" />\r
</bean>\r
\r
<import resource="imports.xml" /> \r
\r
- <bean id="myTestResult" class="org.argeo.slc.core.test.SimpleTestResult" />\r
+ <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
\r
- <bean id="myTestDef" class="org.argeo.slc.core.test.BasicTestDefinition" />\r
+ <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
\r
- <bean id="myTestRunTemplate" class="org.argeo.slc.core.test.SimpleTestRun" abstract="true">\r
+ <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
<property name="testDefinition" ref="myTestDef" />\r
<property name="testResult" ref="myTestResult"/>\r
</bean> \r
p:type="integer" />\r
</entry>\r
<entry key="testData1">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.core.test.BasicTestData"\r
+ <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
p:isParameter="true" p:isFrozen="true" />\r
</entry>\r
</map>\r
<map>\r
<entry key="testedComponentId" value="200" />\r
<entry key="testData1">\r
- <bean class="org.argeo.slc.core.test.BasicTestData" scope="execution">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
<aop:scoped-proxy/>\r
<property name="expected" value="tata101" />\r
<property name="reached" value="tata@{testedComponentId}" />\r
<property name="attributes">\r
<map>\r
<entry key="testData1">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.core.test.BasicTestData"\r
+ <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
p:isParameter="true" p:isFrozen="true" />\r
</entry>\r
</map>\r
<constructor-arg>\r
<map>\r
<entry key="testData1">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected" value="tata100" />\r
<property name="reached" value="tata100" />\r
</bean>\r
\r
<import resource="imports.xml" /> \r
\r
- <bean id="myTestResult" class="org.argeo.slc.core.test.SimpleTestResult" />\r
+ <bean id="myTestResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
\r
- <bean id="myTestDef" class="org.argeo.slc.core.test.BasicTestDefinition" />\r
+ <bean id="myTestDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
\r
- <bean id="myTestRunTemplate" class="org.argeo.slc.core.test.SimpleTestRun" abstract="true">\r
+ <bean id="myTestRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
<property name="testDefinition" ref="myTestDef" />\r
<property name="testResult" ref="myTestResult"/>\r
</bean> \r
p:type="integer" />\r
</entry>\r
<entry key="testData1">\r
- <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.core.test.BasicTestData"\r
+ <bean parent="specAttr.ref" p:targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
p:isParameter="true" p:isFrozen="true" />\r
</entry>\r
</map>\r
<map>\r
<entry key="testedComponentId" value="200" />\r
<entry key="testData1">\r
- <bean class="org.argeo.slc.core.test.BasicTestData" scope="execution">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData" scope="execution">\r
<aop:scoped-proxy/>\r
<property name="expected" value="tata101" />\r
<property name="reached" value="tata@{testedComponentId}" />\r
package org.argeo.slc.core.execution.xml;
import org.argeo.slc.core.execution.AbstractExecutionFlowTestCase;
-import org.argeo.slc.core.test.SimpleTestResult;
import org.argeo.slc.execution.ExecutionContext;
import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.runtime.test.SimpleTestResult;
import org.springframework.context.ConfigurableApplicationContext;
public abstract class FlowNamespaceTest extends AbstractExecutionFlowTestCase {
<import resource="classpath:org/argeo/slc/core/execution/spring.xml" />\r
<import resource="classpath:/org/argeo/slc/core/test/spring.xml" />\r
\r
- <bean id="testResult" class="org.argeo.slc.core.test.SimpleTestResult" />\r
+ <bean id="testResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
\r
- <bean id="testDef" class="org.argeo.slc.core.test.BasicTestDefinition" />\r
+ <bean id="testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
\r
- <bean id="testRunTemplate" class="org.argeo.slc.core.test.SimpleTestRun" abstract="true">\r
+ <bean id="testRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
<property name="testDefinition" ref="testDef" />\r
<property name="testResult" ref="testResult"/>\r
</bean> \r
\r
<bean parent="testRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<flow:variable/>\r
<property name="expected" value="@{param1}" />\r
<property name="reached" value="@{param2}" />\r
<arg name="hide" value="202" />\r
<arg name="refWithoutValue">\r
<beans:bean id="testDataOk" p:expected="tata" p:reached="tata"\r
- class="org.argeo.slc.core.test.BasicTestData" />\r
+ class="org.argeo.slc.runtime.test.BasicTestData" />\r
</arg>\r
</flow>\r
</beans:beans>\r
isParameter="true" type="integer" />\r
<primitive name="hide" value="300" isParameter="true" type="integer"\r
isHidden="true" />\r
- <ref name="refWithValue" targetClass="org.argeo.slc.core.test.BasicTestData"\r
+ <ref name="refWithValue" targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
isParameter="true" ref="testDataNok" />\r
- <ref name="refWithoutValue" targetClass="org.argeo.slc.core.test.BasicTestData" />\r
- <ref name="refWithoutValueFrozen" targetClass="org.argeo.slc.core.test.BasicTestData"\r
+ <ref name="refWithoutValue" targetClass="org.argeo.slc.runtime.test.BasicTestData" />\r
+ <ref name="refWithoutValueFrozen" targetClass="org.argeo.slc.runtime.test.BasicTestData"\r
isParameter="true" isFrozen="true">\r
<value>\r
- <beans:bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <beans:bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<aop:scoped-proxy />\r
<beans:property name="expected" value="tata" />\r
<beans:property name="reached" value="tata" />\r
<beans:ref bean="testRun" />\r
</flow>\r
\r
- <beans:bean id="testDataOk" class="org.argeo.slc.core.test.BasicTestData">\r
+ <beans:bean id="testDataOk" class="org.argeo.slc.runtime.test.BasicTestData">\r
<aop:scoped-proxy />\r
<beans:property name="expected" value="tata" />\r
<beans:property name="reached" value="tata" />\r
</beans:bean>\r
\r
- <beans:bean id="testDataNok" class="org.argeo.slc.core.test.BasicTestData">\r
+ <beans:bean id="testDataNok" class="org.argeo.slc.runtime.test.BasicTestData">\r
<aop:scoped-proxy />\r
<beans:property name="expected" value="tata" />\r
<beans:property name="reached" value="toto" />\r
<import resource="classpath:org/argeo/slc/core/execution/spring.xml" />\r
<import resource="classpath:/org/argeo/slc/core/test/spring.xml" />\r
\r
- <bean id="testResult" class="org.argeo.slc.core.test.SimpleTestResult" />\r
+ <bean id="testResult" class="org.argeo.slc.runtime.test.SimpleTestResult" />\r
\r
- <bean id="testDef" class="org.argeo.slc.core.test.BasicTestDefinition" />\r
+ <bean id="testDef" class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
\r
- <bean id="testRunTemplate" class="org.argeo.slc.core.test.SimpleTestRun" abstract="true">\r
+ <bean id="testRunTemplate" class="org.argeo.slc.runtime.test.SimpleTestRun" abstract="true">\r
<property name="testDefinition" ref="testDef" />\r
<property name="testResult" ref="testResult"/>\r
</bean> \r
\r
<bean parent="testRunTemplate">\r
<property name="testData">\r
- <bean class="org.argeo.slc.core.test.BasicTestData">\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestData">\r
<property name="expected">\r
<flow:param name="list1"/>\r
</property>\r
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd\r
http://www.argeo.org/schema/slc-flow http://www.argeo.org/schema/slc-flow-0.12.xsd">\r
\r
- <bean id="testRun" class="org.argeo.slc.core.test.SimpleTestRun">\r
+ <bean id="testRun" class="org.argeo.slc.runtime.test.SimpleTestRun">\r
<property name="testDefinition">\r
- <bean class="org.argeo.slc.core.test.BasicTestDefinition" />\r
+ <bean class="org.argeo.slc.runtime.test.BasicTestDefinition" />\r
</property>\r
<property name="testData">\r
<flow:param name="refWithValue" />\r
\r
import java.util.List;\r
\r
-import org.argeo.slc.core.test.SimpleTestResult;\r
+import org.argeo.slc.runtime.test.ContextUtils;\r
+import org.argeo.slc.runtime.test.SimpleTestResult;\r
import org.argeo.slc.test.TestResultPart;\r
import org.argeo.slc.test.TestStatus;\r
import org.argeo.slc.test.context.ContextAware;\r
<artifactId>org.argeo.slc.jcr</artifactId>
<version>2.1.17-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.argeo.slc</groupId>
+ <artifactId>org.argeo.slc.repo</artifactId>
+ <version>2.1.17-SNAPSHOT</version>
+ </dependency>
<!-- Spring -->
<dependency>
import org.argeo.slc.SlcException;
import org.argeo.slc.UnsupportedException;
import org.argeo.slc.core.execution.ExecutionResources;
-import org.argeo.slc.core.test.SimpleResultPart;
+import org.argeo.slc.runtime.test.SimpleResultPart;
import org.argeo.slc.test.TestResult;
import org.argeo.slc.test.TestStatus;
import org.springframework.core.io.Resource;
+++ /dev/null
-/*\r
- * Copyright (C) 2007-2012 Argeo GmbH\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.argeo.slc.core.test;\r
-\r
-import org.argeo.slc.test.TestData;\r
-\r
-public class BasicTestData implements TestData {\r
- private Object expected;\r
- private Object reached;\r
-\r
- public Object getExpected() {\r
- return expected;\r
- }\r
-\r
- public void setExpected(Object expected) {\r
- this.expected = expected;\r
- }\r
-\r
- public Object getReached() {\r
- return reached;\r
- }\r
-\r
- public void setReached(Object reached) {\r
- this.reached = reached;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright (C) 2007-2012 Argeo GmbH\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.argeo.slc.core.test;\r
-\r
-import org.argeo.slc.SlcException;\r
-import org.argeo.slc.core.test.context.ContextUtils;\r
-import org.argeo.slc.test.IncompatibleTestDataException;\r
-import org.argeo.slc.test.TestData;\r
-import org.argeo.slc.test.TestDefinition;\r
-import org.argeo.slc.test.TestResult;\r
-import org.argeo.slc.test.TestRun;\r
-import org.argeo.slc.test.TestStatus;\r
-import org.argeo.slc.test.context.ContextAware;\r
-\r
-/** Understands basic test data and context aware test data. */\r
-public class BasicTestDefinition implements TestDefinition {\r
-\r
- public void execute(TestRun testRun) {\r
- if (testRun.<TestData> getTestData() instanceof BasicTestData) {\r
- BasicTestData testData = testRun.getTestData();\r
- TestResult result = testRun.getTestResult();\r
-\r
- if (result == null)\r
- throw new SlcException("No test result defined.");\r
-\r
- try {\r
- if (testData.getExpected().equals(testData.getReached())) {\r
- result.addResultPart(new SimpleResultPart(\r
- TestStatus.PASSED, "Reached and expected equals"));\r
- } else {\r
- result.addResultPart(new SimpleResultPart(\r
- TestStatus.FAILED, "Expected "\r
- + testData.getExpected() + " but reached "\r
- + testData.getReached()));\r
- }\r
- } catch (Exception e) {\r
- result.addResultPart(new SimpleResultPart(TestStatus.ERROR,\r
- "Could not compare", e));\r
- }\r
- } else if (testRun.<TestData> getTestData() instanceof ContextAware) {\r
- TestData testData = testRun.getTestData();\r
- ContextUtils.compareReachedExpected((ContextAware) testData,\r
- testRun.getTestResult());\r
- } else {\r
- throw new IncompatibleTestDataException(testRun);\r
- }\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Copyright (C) 2007-2012 Argeo GmbH\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.argeo.slc.core.test;\r
-\r
-import java.io.Serializable;\r
-\r
-import org.argeo.slc.test.TestResultPart;\r
-import org.argeo.slc.test.TestRun;\r
-import org.argeo.slc.test.TestRunAware;\r
-import org.argeo.slc.test.TestStatus;\r
-\r
-/**\r
- * <p>\r
- * Basic implementation of a result part, implementing the standard three status\r
- * approach for test results.\r
- * </p>\r
- * \r
- * @see TestStatus\r
- */\r
-public class SimpleResultPart implements TestResultPart, TestStatus,\r
- TestRunAware, Serializable {\r
- private static final long serialVersionUID = 6669675957685071901L;\r
-\r
- private Long tid;\r
-\r
- private String testRunUuid;\r
-\r
- /** The status. Default to ERROR since it should always be explicitely set. */\r
- private Integer status = ERROR;\r
- private String message;\r
- private String exceptionMessage;\r
-\r
- public SimpleResultPart() {\r
- }\r
-\r
- public SimpleResultPart(Integer status, String message) {\r
- this(status, message, null);\r
- }\r
-\r
- public SimpleResultPart(Integer status, String message, Exception exception) {\r
- this.status = status;\r
- this.message = message;\r
- setException(exception);\r
- }\r
-\r
- public String getMessage() {\r
- return message;\r
- }\r
-\r
- public void setMessage(String message) {\r
- this.message = message;\r
- }\r
-\r
- public void setStatus(Integer status) {\r
- this.status = status;\r
- }\r
-\r
- public Integer getStatus() {\r
- return status;\r
- }\r
-\r
- public String getExceptionMessage() {\r
- return exceptionMessage;\r
- }\r
-\r
- public void setException(Exception exception) {\r
- if (exception == null)\r
- return;\r
-\r
- StringBuffer buf = new StringBuffer("");\r
- buf.append(exception.toString());\r
- buf.append('\n');\r
- for (StackTraceElement elem : exception.getStackTrace()) {\r
- buf.append('\t').append(elem.toString()).append('\n');\r
- }\r
-\r
- if (exception.getCause() != null)\r
- addRootCause(buf, exception.getCause());\r
-\r
- this.exceptionMessage = buf.toString();\r
- }\r
-\r
- protected void addRootCause(StringBuffer buf, Throwable cause) {\r
- if (cause == null)\r
- return;\r
-\r
- buf.append("Caused by: " + cause.getMessage());\r
- for (StackTraceElement elem : cause.getStackTrace()) {\r
- buf.append('\t').append(elem.toString()).append('\n');\r
- }\r
-\r
- if (cause.getCause() != null) {\r
- addRootCause(buf, cause.getCause());\r
- }\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- StringBuffer buf = new StringBuffer("");\r
- buf.append(SlcTestUtils.statusToString(status));\r
- if (status == PASSED || status == FAILED) {\r
- buf.append(' ');\r
- } else if (status == ERROR) {\r
- buf.append(" ");\r
- }\r
- buf.append(message);\r
- return buf.toString();\r
- }\r
-\r
- /** @deprecated */\r
- Long getTid() {\r
- return tid;\r
- }\r
-\r
- /** @deprecated */\r
- void setTid(Long tid) {\r
- this.tid = tid;\r
- }\r
-\r
- public String getTestRunUuid() {\r
- return testRunUuid;\r
- }\r
-\r
- /** For ORM */\r
- public void setTestRunUuid(String testRunUuid) {\r
- this.testRunUuid = testRunUuid;\r
- }\r
-\r
- public void notifyTestRun(TestRun testRun) {\r
- testRunUuid = testRun.getUuid();\r
- }\r
-\r
- public void setExceptionMessage(String exceptionMessage) {\r
- this.exceptionMessage = exceptionMessage;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright (C) 2007-2012 Argeo GmbH\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.argeo.slc.core.test;\r
-\r
-import java.util.Date;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.TreeMap;\r
-import java.util.UUID;\r
-import java.util.Vector;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.argeo.slc.SlcException;\r
-import org.argeo.slc.test.TestResult;\r
-import org.argeo.slc.test.TestResultPart;\r
-import org.argeo.slc.test.TestRun;\r
-\r
-/**\r
- * Basic implementation of a test result containing only a list of result parts.\r
- */\r
-public class SimpleTestResult implements TestResult {\r
- private static Log log = LogFactory.getLog(SimpleTestResult.class);\r
-\r
- private String uuid;\r
- private String currentTestRunUuid;\r
-\r
- private Boolean throwError = true;\r
-\r
- private Date closeDate;\r
- private List<TestResultPart> parts = new Vector<TestResultPart>();\r
-\r
- private Map<String, String> attributes = new TreeMap<String, String>();\r
-\r
- public void addResultPart(TestResultPart part) {\r
- if (throwError && part.getStatus() == ERROR) {\r
- throw new SlcException(\r
- "There was an error in the underlying test: "\r
- + part.getExceptionMessage());\r
- }\r
- parts.add(part);\r
- if (log.isDebugEnabled())\r
- log.debug(part);\r
- }\r
-\r
- public void close() {\r
- parts.clear();\r
- closeDate = new Date();\r
- }\r
-\r
- public List<TestResultPart> getParts() {\r
- return parts;\r
- }\r
-\r
- public Date getCloseDate() {\r
- return closeDate;\r
- }\r
-\r
- public void setThrowError(Boolean throwError) {\r
- this.throwError = throwError;\r
- }\r
-\r
- public void notifyTestRun(TestRun testRun) {\r
- currentTestRunUuid = testRun.getUuid();\r
- }\r
-\r
- public String getUuid() {\r
- if (uuid == null) {\r
- uuid = UUID.randomUUID().toString();\r
- }\r
- return uuid;\r
- }\r
-\r
- public void setUuid(String uuid) {\r
- this.uuid = uuid;\r
- }\r
-\r
- public String getCurrentTestRunUuid() {\r
- return currentTestRunUuid;\r
- }\r
-\r
- public Map<String, String> getAttributes() {\r
- return attributes;\r
- }\r
-\r
- public void setAttributes(Map<String, String> attributes) {\r
- this.attributes = attributes;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright (C) 2007-2012 Argeo GmbH\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.argeo.slc.core.test;\r
-\r
-import java.util.UUID;\r
-\r
-import org.argeo.slc.deploy.DeployedSystem;\r
-import org.argeo.slc.test.ExecutableTestRun;\r
-import org.argeo.slc.test.TestData;\r
-import org.argeo.slc.test.TestDefinition;\r
-import org.argeo.slc.test.TestResult;\r
-import org.argeo.slc.test.WritableTestRun;\r
-\r
-/**\r
- * A basic bean implementation of a <code>WritableTestRun</code>, holding\r
- * references to the various parts of a test run.\r
- */\r
-public class SimpleTestRun implements WritableTestRun, ExecutableTestRun {\r
- private String uuid;\r
-\r
- // private String slcExecutionUuid;\r
- // private String slcExecutionStepUuid;\r
-\r
- private DeployedSystem deployedSystem;\r
- private TestData testData;\r
- private TestDefinition testDefinition;\r
- private TestResult testResult;\r
-\r
- /** Executes the underlying test definition. */\r
- public void run() {\r
- uuid = UUID.randomUUID().toString();\r
- if (testResult != null)\r
- testResult.notifyTestRun(this);\r
-\r
- testDefinition.execute(this);\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- public <T extends DeployedSystem> T getDeployedSystem() {\r
- return (T) deployedSystem;\r
- }\r
-\r
- public void setDeployedSystem(DeployedSystem deployedSystem) {\r
- this.deployedSystem = deployedSystem;\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- public <T extends TestData> T getTestData() {\r
- return (T) testData;\r
- }\r
-\r
- public void setTestData(TestData testData) {\r
- this.testData = testData;\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- public <T extends TestDefinition> T getTestDefinition() {\r
- return (T) testDefinition;\r
- }\r
-\r
- public void setTestDefinition(TestDefinition testDefinition) {\r
- this.testDefinition = testDefinition;\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- public <T extends TestResult> T getTestResult() {\r
- return (T) testResult;\r
- }\r
-\r
- public void setTestResult(TestResult testResult) {\r
- this.testResult = testResult;\r
- }\r
-\r
- public String getUuid() {\r
- return uuid;\r
- }\r
-\r
- public void setUuid(String uuid) {\r
- this.uuid = uuid;\r
- }\r
-\r
- // public String getSlcExecutionUuid() {\r
- // return slcExecutionUuid;\r
- // }\r
- //\r
- // public void setSlcExecutionUuid(String slcExecutionUuid) {\r
- // this.slcExecutionUuid = slcExecutionUuid;\r
- // }\r
- //\r
- // public String getSlcExecutionStepUuid() {\r
- // return slcExecutionStepUuid;\r
- // }\r
- //\r
- // public void setSlcExecutionStepUuid(String slcExecutionStepUuid) {\r
- // this.slcExecutionStepUuid = slcExecutionStepUuid;\r
- // }\r
-}\r
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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;
-
-import org.argeo.slc.SlcException;
-import org.argeo.slc.test.TestStatus;
-
-public abstract class SlcTestUtils {
- public static String statusToString(Integer status) {
- if (status.equals(TestStatus.PASSED)) {
- return TestStatus.STATUSSTR_PASSED;
- } else if (status.equals(TestStatus.FAILED)) {
- return TestStatus.STATUSSTR_FAILED;
- } else if (status.equals(TestStatus.ERROR)) {
- return TestStatus.STATUSSTR_ERROR;
- } else {
- throw new SlcException("Unrecognized status " + status);
- }
- }
-
- public static Integer stringToStatus(String statusStr) {
- if (statusStr.equals(TestStatus.STATUSSTR_PASSED)) {
- return TestStatus.PASSED;
- } else if (statusStr.equals(TestStatus.STATUSSTR_FAILED)) {
- return TestStatus.FAILED;
- } else if (statusStr.equals(TestStatus.STATUSSTR_ERROR)) {
- return TestStatus.ERROR;
- } else {
- throw new SlcException("Unrecognized status string " + statusStr);
- }
- }
-
- private SlcTestUtils() {
-
- }
-
-}
+++ /dev/null
-/*\r
- * Copyright (C) 2007-2012 Argeo GmbH\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.argeo.slc.core.test;\r
-\r
-import org.argeo.slc.UnsupportedException;\r
-import org.argeo.slc.test.TestData;\r
-import org.argeo.slc.test.TestDataProvider;\r
-\r
-/** Utilities for dealing with test datas. */\r
-public class TestDataUtils {\r
- /** Extracts the test data from the given provider. */\r
- public static <T extends TestData> T getFromProvider(Object obj,\r
- Class<T> clss, String key) {\r
- if (obj instanceof TestDataProvider) {\r
- TestDataProvider testDataProvider = (TestDataProvider) obj;\r
- return testDataProvider.getTestData(clss, key);\r
- } else {\r
- throw new UnsupportedException("test data provider", obj);\r
- }\r
- }\r
-\r
- /**\r
- * Extracts the test data from the given provider using <code>null</code>\r
- * as key.\r
- */\r
- public static <T extends TestData> T getFromProvider(Object obj,\r
- Class<T> clss) {\r
- return getFromProvider(obj, clss, null);\r
- }\r
-\r
- /**\r
- * Returns it self after making the proper checks. Used for test data being\r
- * their own data providers.\r
- */\r
- @SuppressWarnings("unchecked")\r
- public static <T extends TestData> T getItSelf(Class<T> clss,\r
- TestData testDataObject) {\r
- if (clss.isAssignableFrom(testDataObject.getClass())) {\r
- return (T) testDataObject;\r
- } else {\r
- throw new UnsupportedException("test data", testDataObject);\r
- }\r
-\r
- }\r
-\r
- /** Makes sure this is an utility class. */\r
- private TestDataUtils() {\r
-\r
- }\r
-}\r
+++ /dev/null
-/*\r
- * Copyright (C) 2007-2012 Argeo GmbH\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.argeo.slc.core.test.context;\r
-\r
-import java.util.Map;\r
-import java.util.TreeMap;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.argeo.slc.core.test.SimpleResultPart;\r
-import org.argeo.slc.test.TestResult;\r
-import org.argeo.slc.test.TestStatus;\r
-import org.argeo.slc.test.context.ContextAware;\r
-import org.argeo.slc.test.context.ParentContextAware;\r
-\r
-/** Utilities for comparing and synchronising contexts. */\r
-public class ContextUtils {\r
- private final static Log log = LogFactory.getLog(ContextUtils.class);\r
-\r
- public static void compareReachedExpected(ContextAware contextAware,\r
- TestResult testResult) {\r
- for (String key : contextAware.getExpectedValues().keySet()) {\r
-\r
- // Compare expected values with reached ones\r
- Object expectedValue = contextAware.getExpectedValues().get(key);\r
-\r
- if (expectedValue.toString().equals(\r
- contextAware.getContextSkipFlag())) {\r
- if (log.isDebugEnabled())\r
- log.debug("Skipped check for key '" + key + "'");\r
- continue;\r
- }\r
-\r
- if (contextAware.getValues().containsKey(key)) {\r
- Object reachedValue = contextAware.getValues().get(key);\r
-\r
- if (expectedValue.equals(contextAware.getContextAnyFlag())) {\r
- testResult.addResultPart(new SimpleResultPart(\r
- TestStatus.PASSED, "Expected any value for key '"\r
- + key + "'"));\r
- } else if (expectedValue.equals(reachedValue)) {\r
- testResult.addResultPart(new SimpleResultPart(\r
- TestStatus.PASSED, "Values matched for key '" + key\r
- + "'"));\r
- } else {\r
- testResult.addResultPart(new SimpleResultPart(\r
- TestStatus.FAILED, "Mismatch for key '" + key\r
- + "': expected '" + expectedValue\r
- + "' but reached '" + reachedValue + "'"));\r
- }\r
- } else {\r
- testResult.addResultPart(new SimpleResultPart(\r
- TestStatus.FAILED, "No value reached for key '" + key\r
- + "'"));\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * Makes sure that all children and sub-children of parent share the same\r
- * maps for values and expected values.\r
- */\r
- public static void synchronize(ParentContextAware parent) {\r
- Map<String, Object> expectedValuesCommon = new TreeMap<String, Object>(\r
- parent.getExpectedValues());\r
- synchronize(parent, expectedValuesCommon);\r
- if (log.isDebugEnabled())\r
- log.debug("Synchronized context " + parent);\r
-\r
- }\r
-\r
- private static void synchronize(ParentContextAware parent,\r
- Map<String, Object> expectedValuesCommon) {\r
- for (ContextAware child : parent.getChildContexts()) {\r
- // Values\r
- putNotContained(parent.getValues(), child.getValues());\r
- child.setValues(parent.getValues());\r
-\r
- // Expected Values\r
- // Expected values reference is not overridden: each child has its\r
- // own expected values map.\r
- overrideContained(expectedValuesCommon, child.getExpectedValues());\r
-\r
- // Creates a new Map in order not to disturb other context using the\r
- // same keys\r
- Map<String, Object> expectedValuesCommonChild = new TreeMap<String, Object>(\r
- expectedValuesCommon);\r
- putNotContained(expectedValuesCommonChild,\r
- child.getExpectedValues());\r
-\r
- if (child instanceof ParentContextAware) {\r
- // Recursive sync\r
- synchronize((ParentContextAware) child,\r
- expectedValuesCommonChild);\r
- }\r
- }\r
-\r
- }\r
-\r
- /**\r
- * Put into common map the values from child map which are not already\r
- * defined in common map.\r
- */\r
- public static void putNotContained(Map<String, Object> commonMap,\r
- Map<String, Object> childMap) {\r
- for (String key : childMap.keySet()) {\r
- if (!commonMap.containsKey(key)) {\r
- commonMap.put(key, childMap.get(key));\r
- }\r
- }\r
- }\r
-\r
- /** Overrides child map values with the values already set in common map */\r
- public static void overrideContained(Map<String, Object> commonMap,\r
- Map<String, Object> childMap) {\r
- for (String key : childMap.keySet()) {\r
- if (commonMap.containsKey(key)) {\r
- childMap.put(key, commonMap.get(key));\r
- }\r
- }\r
- }\r
-\r
- /** Makes sure this cannot be instantiated. */\r
- private ContextUtils() {\r
-\r
- }\r
-}\r
*/\r
package org.argeo.slc.core.test.context;\r
\r
-import org.argeo.slc.core.test.TestDataUtils;\r
+import org.argeo.slc.runtime.test.TestDataUtils;\r
import org.argeo.slc.test.TestData;\r
import org.argeo.slc.test.TestDataProvider;\r
\r
import java.util.TreeMap;\r
\r
import org.argeo.slc.SlcException;\r
+import org.argeo.slc.runtime.test.ContextUtils;\r
import org.argeo.slc.test.context.ContextAware;\r
import org.argeo.slc.test.context.ParentContextAware;\r
import org.springframework.beans.factory.InitializingBean;\r
import java.util.List;\r
import java.util.Vector;\r
\r
+import org.argeo.slc.runtime.test.ContextUtils;\r
import org.argeo.slc.test.context.ContextAware;\r
import org.argeo.slc.test.context.ParentContextAware;\r
import org.springframework.beans.factory.InitializingBean;\r
--- /dev/null
+package org.argeo.slc.spring.repo.osgi;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.BeanNameAware;
+
+public class BndWrapper extends org.argeo.slc.repo.osgi.BndWrapper implements BeanNameAware {
+ private final static Log log = LogFactory.getLog(BndWrapper.class);
+
+ @Override
+ public void setBeanName(String name) {
+ if (getName() == null) {
+ setName(name);
+ } else {
+ if (!name.contains("#"))
+ log.warn("Using explicitely set name " + getName() + " and not bean name " + name);
+ }
+ }
+
+}
--- /dev/null
+package org.argeo.slc.spring.repo.osgi;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.BeanNameAware;
+
+public class MavenWrapper extends org.argeo.slc.repo.osgi.MavenWrapper implements BeanNameAware {
+ private final static Log log = LogFactory.getLog(MavenWrapper.class);
+
+ @Override
+ public void setBeanName(String name) {
+ if (getName() == null) {
+ setName(name);
+ } else {
+ if (!name.contains("#"))
+ log.warn("Using explicitely set name " + getName() + " and not bean name " + name);
+ }
+ }
+
+}
--- /dev/null
+package org.argeo.slc.spring.repo.osgi;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.BeanNameAware;
+
+public class UriWrapper extends org.argeo.slc.repo.osgi.UriWrapper implements BeanNameAware {
+ private final static Log log = LogFactory.getLog(UriWrapper.class);
+
+ @Override
+ public void setBeanName(String name) {
+ if (getName() == null) {
+ setName(name);
+ } else {
+ if (!name.contains("#"))
+ log.warn("Using explicitely set name " + getName() + " and not bean name " + name);
+ }
+ }
+
+}
import java.util.Map;
import org.argeo.slc.core.execution.DefaultExecutionSpec;
-import org.argeo.slc.core.test.BasicTestData;
import org.argeo.slc.execution.ExecutionFlowDescriptor;
import org.argeo.slc.execution.ExecutionSpecAttribute;
import org.argeo.slc.execution.RefSpecAttribute;
import org.argeo.slc.primitive.PrimitiveAccessor;
import org.argeo.slc.primitive.PrimitiveSpecAttribute;
import org.argeo.slc.primitive.PrimitiveValue;
+import org.argeo.slc.runtime.test.BasicTestData;
public class ExecutionFlowDescriptorTestUtils {
public static ExecutionFlowDescriptor createSimpleExecutionFlowDescriptor() {