From ae1b5ddfcc58fb5018a0e7eac38e7a6f28b3ce22 Mon Sep 17 00:00:00 2001
From: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
Date: Thu, 15 Aug 2024 17:33:26 +0100
Subject: [PATCH 1/8] Refactoring of framework test runner so it can have a
single unit test running through it all
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
---
build-locally.sh | 30 +--
.../dev.galasa.framework/build.gradle | 2 +-
.../dev/galasa/framework/BundleManager.java | 27 +++
.../java/dev/galasa/framework/Framework.java | 7 +-
.../framework/FrameworkInitialisation.java | 143 +++++++-------
.../framework/GenericMethodWrapper.java | 2 +-
.../framework/IAnnotationExtractor.java | 12 ++
.../dev/galasa/framework/IBundleManager.java | 29 +++
.../galasa/framework/ITestRunManagers.java | 37 ++++
.../framework/ITestRunnerDataProvider.java | 27 +++
.../galasa/framework/TestClassWrapper.java | 2 +-
.../galasa/framework/TestMethodWrapper.java | 2 +-
.../dev/galasa/framework/TestRunManagers.java | 20 +-
.../java/dev/galasa/framework/TestRunner.java | 99 ++++++----
.../framework/TestRunnerDataProvider.java | 100 ++++++++++
.../runner/RealAnnotationExtractor.java | 20 ++
.../framework/spi/IShutableFramework.java | 10 +
.../galasa/framework/MyActualTestClass.java | 13 ++
.../dev/galasa/framework/TestTestRunner.java | 184 ++++++++++++++++++
.../directory/DirectoryFileSystemTest.java | 4 +-
.../ras/directory/RASGetRunsTest.java | 2 -
.../galasa/framework/mocks/MockBundle.java | 183 +++++++++++++++++
.../framework/mocks/MockBundleContext.java | 34 ++--
.../framework/mocks/MockBundleManager.java | 43 ++++
...ockIConfigurationPropertyStoreService.java | 61 ++++++
.../mocks/MockIDynamicStatusStoreService.java | 109 +++++++++++
.../framework/mocks/MockIFrameworkRuns.java | 89 +++++++++
.../mocks/MockIResultArchiveStore.java | 79 ++++++++
.../framework/mocks/MockMavenRepository.java | 38 ++++
.../framework/mocks/MockRepository.java | 39 ++++
.../framework/mocks/MockRepositoryAdmin.java | 96 +++++++++
.../galasa/framework/mocks/MockResolver.java | 106 ++++++++++
.../galasa/framework/mocks/MockResource.java | 81 ++++++++
.../dev/galasa/framework/mocks/MockRun.java | 143 ++++++++++++++
.../mocks/MockShutableFramework.java | 168 ++++++++++++++++
.../framework/mocks/MockTestRunManagers.java | 128 ++++++++++++
.../mocks/MockTestRunnerDataProvider.java | 89 +++++++++
.../framework/spi/AbstractManagerTest.java | 4 +-
.../framework/spi/TestFieldAnnotation.java | 2 -
.../framework/spi/TestFieldAnnotation2.java | 2 -
.../spi/language/gherkin/MockRun.java | 60 ++----
.../gherkin/xform/TestParseTreeTransform.java | 1 -
.../test/java/test/fpf/ExceptionsTest.java | 3 +-
.../test/fpf/FrameworkPropertyFileTest.java | 1 -
44 files changed, 2120 insertions(+), 211 deletions(-)
create mode 100644 galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/BundleManager.java
create mode 100644 galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IAnnotationExtractor.java
create mode 100644 galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IBundleManager.java
create mode 100644 galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunManagers.java
create mode 100644 galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunnerDataProvider.java
create mode 100644 galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java
create mode 100644 galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/runner/RealAnnotationExtractor.java
create mode 100644 galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/IShutableFramework.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/MyActualTestClass.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/TestTestRunner.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundle.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleManager.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIConfigurationPropertyStoreService.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIDynamicStatusStoreService.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIFrameworkRuns.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIResultArchiveStore.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockMavenRepository.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockRepository.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockRepositoryAdmin.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockResolver.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockResource.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockRun.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockShutableFramework.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunManagers.java
create mode 100644 galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunnerDataProvider.java
diff --git a/build-locally.sh b/build-locally.sh
index 57f85d5be..50e989f1b 100755
--- a/build-locally.sh
+++ b/build-locally.sh
@@ -48,26 +48,16 @@ blue=$(tput setaf 25)
# Headers and Logging
#
#-----------------------------------------------------------------------------------------
-underline() { printf "${underline}${bold}%s${reset}\n" "$@"
-}
-h1() { printf "\n${underline}${bold}${blue}%s${reset}\n" "$@"
-}
-h2() { printf "\n${underline}${bold}${white}%s${reset}\n" "$@"
-}
-debug() { printf "${white}%s${reset}\n" "$@"
-}
-info() { printf "${white}➜ %s${reset}\n" "$@"
-}
-success() { printf "${green}✔ %s${reset}\n" "$@"
-}
-error() { printf "${red}✖ %s${reset}\n" "$@"
-}
-warn() { printf "${tan}➜ %s${reset}\n" "$@"
-}
-bold() { printf "${bold}%s${reset}\n" "$@"
-}
-note() { printf "\n${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@"
-}
+underline() { printf "${underline}${bold}%s${reset}\n" "$@" ;}
+h1() { printf "\n${underline}${bold}${blue}%s${reset}\n" "$@" ;}
+h2() { printf "\n${underline}${bold}${white}%s${reset}\n" "$@" ;}
+debug() { printf "${white}%s${reset}\n" "$@" ;}
+info() { printf "${white}➜ %s${reset}\n" "$@" ;}
+success() { printf "${green}✔ %s${reset}\n" "$@" ;}
+error() { printf "${red}✖ %s${reset}\n" "$@" ;}
+warn() { printf "${tan}➜ %s${reset}\n" "$@" ;}
+bold() { printf "${bold}%s${reset}\n" "$@" ;}
+note() { printf "\n${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@" ;}
#-----------------------------------------------------------------------------------------
# Functions
diff --git a/galasa-parent/dev.galasa.framework/build.gradle b/galasa-parent/dev.galasa.framework/build.gradle
index 0b99f459b..9425b7a2b 100644
--- a/galasa-parent/dev.galasa.framework/build.gradle
+++ b/galasa-parent/dev.galasa.framework/build.gradle
@@ -7,7 +7,7 @@ description = 'Galasa Framework'
// Note: The following line is changed by the set-version.sh script.
// It is also read by other build scrips as required.
-version = "0.36.0"
+version = "0.37.0"
dependencies {
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/BundleManager.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/BundleManager.java
new file mode 100644
index 000000000..e367a28de
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/BundleManager.java
@@ -0,0 +1,27 @@
+package dev.galasa.framework;
+
+import org.apache.felix.bundlerepository.RepositoryAdmin;
+import org.osgi.framework.BundleContext;
+
+import dev.galasa.framework.spi.FrameworkException;
+
+public class BundleManager implements IBundleManager {
+
+ @Override
+ public boolean isBundleActive(BundleContext bundleContext, String bundleSymbolicName) {
+ return BundleManagement.isBundleActive(bundleContext, bundleSymbolicName);
+ }
+
+ @Override
+ public void loadAllGherkinManagerBundles(RepositoryAdmin repositoryAdmin, BundleContext bundleContext)
+ throws FrameworkException {
+ BundleManagement.loadAllGherkinManagerBundles(repositoryAdmin, bundleContext);
+ }
+
+ @Override
+ public void loadBundle(RepositoryAdmin repositoryAdmin, BundleContext bundleContext, String bundleSymbolicName)
+ throws FrameworkException {
+ BundleManagement.loadBundle(repositoryAdmin, bundleContext, bundleSymbolicName);
+ }
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/Framework.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/Framework.java
index 4b23aa91a..ee0f53d10 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/Framework.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/Framework.java
@@ -37,7 +37,7 @@
import dev.galasa.framework.spi.creds.ICredentialsStore;
@Component(immediate = true, scope = ServiceScope.SINGLETON)
-public class Framework implements IFramework {
+public class Framework implements IShutableFramework {
private final static Log logger = LogFactory.getLog(Framework.class);
@@ -391,6 +391,11 @@ public void installLogCapture() {
}
+ @Override
+ public void shutdown() throws FrameworkException {
+ shutdown(null);
+ }
+
public void shutdown(Log shutdownLogger) throws FrameworkException {
if (isShutdown()) {
return;
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FrameworkInitialisation.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FrameworkInitialisation.java
index 6394aef25..e768f22db 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FrameworkInitialisation.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FrameworkInitialisation.java
@@ -65,75 +65,6 @@ public FrameworkInitialisation(
getBundleContext(), new FileSystem(), new SystemEnvironment());
}
-
-
- private static BundleContext getBundleContext() {
- return FrameworkUtil.getBundle(FrameworkInitialisation.class).getBundleContext();
- }
-
- /**
- * Obtain the location of the galasa home directory
- * @return a String representing the location of the users Galasa home directory
- */
- public String getGalasaHome(Environment env) {
- // 1st: If GALASA_HOME is set as a system property then use that,
- // 2nd: If GALASA_HOME is set as a system environment variable, then use that.
- // 3rd: otherwise we use the calling users' home folder.
- String GALASA_HOME = "GALASA_HOME";
- String home = env.getProperty(GALASA_HOME);
- if( (home == null) || (home.trim().isEmpty())) {
- home = env.getenv(GALASA_HOME);
- if( (home == null) || (home.trim().isEmpty())) {
- String userHome = env.getProperty(USER_HOME);
- if ( userHome != null ) {
- logger.info("System property "+USER_HOME+" ("+userHome+") used to set value of home location.");
- home = userHome + "/.galasa";
- } else {
- // On windows, the USERPROFILE environment variable will be set to C:/User/Name or similar.
- String userProfile = env.getenv("USERPROFILE");
- if (userProfile != null) {
- logger.info("System property USERPROFILE ("+userProfile+") used to set value of home location.");
- home = userProfile + "/.galasa";
- } else {
- // Just in case, fall back on a trusty default.
- logger.info("Defaulting home to ~/.galasa");
- home = "~/.galasa";
- }
- }
-
- } else {
- logger.info("Environment variable GALASA_HOME used to set value of home location.");
- }
- } else {
- logger.info("System property GALASA_HOME used to set value of home location.");
- // The system property value may be surrounded by " characters.
- // If so, strip them off.
- // We allow this because a path with strings in would be split
- // into separate system properties otherwise.
- home = stripLeadingAndTrailingQuotes(home);
- }
- logger.info("Galasa home location is "+home);
-
- return home;
- }
-
- /**
- * String the first double-quote and the last double-quote off
- * the begining and end of a string.
- * @param input
- * @return The stripped (or unaltered) string.
- */
- String stripLeadingAndTrailingQuotes(String input ) {
- String output = input ;
- if (output.startsWith("\"")) {
- output = output.replaceFirst("\"", "");
- }
- if (output.endsWith("\"")) {
- output = output.substring(0,output.length()-1);
- }
- return output;
- }
-
public FrameworkInitialisation(
Properties bootstrapProperties,
Properties overrideProperties,
@@ -228,6 +159,76 @@ public FrameworkInitialisation(
}
}
+
+ private static BundleContext getBundleContext() {
+ return FrameworkUtil.getBundle(FrameworkInitialisation.class).getBundleContext();
+ }
+
+ /**
+ * Obtain the location of the galasa home directory
+ * @return a String representing the location of the users Galasa home directory
+ */
+ public String getGalasaHome(Environment env) {
+ // 1st: If GALASA_HOME is set as a system property then use that,
+ // 2nd: If GALASA_HOME is set as a system environment variable, then use that.
+ // 3rd: otherwise we use the calling users' home folder.
+ String GALASA_HOME = "GALASA_HOME";
+ String home = env.getProperty(GALASA_HOME);
+ if( (home == null) || (home.trim().isEmpty())) {
+ home = env.getenv(GALASA_HOME);
+ if( (home == null) || (home.trim().isEmpty())) {
+ String userHome = env.getProperty(USER_HOME);
+ if ( userHome != null ) {
+ logger.info("System property "+USER_HOME+" ("+userHome+") used to set value of home location.");
+ home = userHome + "/.galasa";
+ } else {
+ // On windows, the USERPROFILE environment variable will be set to C:/User/Name or similar.
+ String userProfile = env.getenv("USERPROFILE");
+ if (userProfile != null) {
+ logger.info("System property USERPROFILE ("+userProfile+") used to set value of home location.");
+ home = userProfile + "/.galasa";
+ } else {
+ // Just in case, fall back on a trusty default.
+ logger.info("Defaulting home to ~/.galasa");
+ home = "~/.galasa";
+ }
+ }
+
+ } else {
+ logger.info("Environment variable GALASA_HOME used to set value of home location.");
+ }
+ } else {
+ logger.info("System property GALASA_HOME used to set value of home location.");
+ // The system property value may be surrounded by " characters.
+ // If so, strip them off.
+ // We allow this because a path with strings in would be split
+ // into separate system properties otherwise.
+ home = stripLeadingAndTrailingQuotes(home);
+ }
+ logger.info("Galasa home location is "+home);
+
+ return home;
+ }
+
+ /**
+ * String the first double-quote and the last double-quote off
+ * the begining and end of a string.
+ * @param input
+ * @return The stripped (or unaltered) string.
+ */
+ String stripLeadingAndTrailingQuotes(String input ) {
+ String output = input ;
+ if (output.startsWith("\"")) {
+ output = output.replaceFirst("\"", "");
+ }
+ if (output.endsWith("\"")) {
+ output = output.substring(0,output.length()-1);
+ }
+ return output;
+ }
+
+
+
/**
* Submit the run and return the run name.
*
@@ -400,6 +401,10 @@ public void registerEventsService(@NotNull IEventsService eventsService) throws
return this.framework;
}
+ public @NotNull IShutableFramework getShutableFramework() {
+ return this.framework;
+ }
+
public void shutdownFramework() {
try {
this.framework.shutdown(null);
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/GenericMethodWrapper.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/GenericMethodWrapper.java
index 0792754ba..f2256f0bf 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/GenericMethodWrapper.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/GenericMethodWrapper.java
@@ -60,7 +60,7 @@ public GenericMethodWrapper(Method excecutionMethod, Class> testClass, Type ty
* @param testMethod the test method if the execution method is @Before or @After
* @throws TestRunException The failure thrown by the test run
*/
- public void invoke(@NotNull TestRunManagers managers, Object testClassObject, GenericMethodWrapper testMethod) throws TestRunException {
+ public void invoke(@NotNull ITestRunManagers managers, Object testClassObject, GenericMethodWrapper testMethod) throws TestRunException {
try {
String methodType = ",type=" + type.toString();
Result ignored = managers.anyReasonTestMethodShouldBeIgnored(new GalasaMethod(this.excecutionMethod, null));
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IAnnotationExtractor.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IAnnotationExtractor.java
new file mode 100644
index 000000000..2e93f6fb7
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IAnnotationExtractor.java
@@ -0,0 +1,12 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework;
+
+import java.lang.annotation.Annotation;
+
+public interface IAnnotationExtractor {
+ public B getAnnotation (Class testClass, Class annotationClass);
+}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IBundleManager.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IBundleManager.java
new file mode 100644
index 000000000..502611cb4
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IBundleManager.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework;
+
+import org.apache.felix.bundlerepository.RepositoryAdmin;
+import org.osgi.framework.BundleContext;
+
+import dev.galasa.framework.spi.FrameworkException;
+
+/**
+ * Allows for some control over loading extra bundles, and seeing if bundles are already loaded.
+ */
+public interface IBundleManager {
+ /**
+ * Is the supplied active in the OSGi framework
+ * @param bundleContext
+ * @param bundleSymbolicName
+ * @return true if it is ib the or false
+ */
+ public boolean isBundleActive(BundleContext bundleContext, String bundleSymbolicName);
+
+ public void loadAllGherkinManagerBundles(RepositoryAdmin repositoryAdmin, BundleContext bundleContext) throws FrameworkException;
+
+ public void loadBundle(RepositoryAdmin repositoryAdmin, BundleContext bundleContext, String bundleSymbolicName) throws FrameworkException;
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunManagers.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunManagers.java
new file mode 100644
index 000000000..c583c8ecb
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunManagers.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework;
+
+import java.util.List;
+
+import javax.validation.constraints.NotNull;
+
+import dev.galasa.framework.spi.FrameworkException;
+import dev.galasa.framework.spi.IManager;
+import dev.galasa.framework.spi.Result;
+import dev.galasa.framework.spi.language.GalasaMethod;
+
+public interface ITestRunManagers {
+ public boolean anyReasonTestClassShouldBeIgnored() throws FrameworkException ;
+ public List getActiveManagers();
+ public void provisionGenerate() throws FrameworkException ;
+ public void provisionBuild() throws FrameworkException ;
+ public void testClassResult(@NotNull Result finalResult, Throwable finalException);
+
+ public Result endOfTestClass(@NotNull Result result, Throwable currentException) throws FrameworkException ;
+
+ public void endOfTestRun();
+ public void provisionStart() throws FrameworkException;
+ public void shutdown();
+ public void startOfTestClass() throws FrameworkException;
+ public void provisionDiscard();
+ public void provisionStop();
+ public Result anyReasonTestMethodShouldBeIgnored(@NotNull GalasaMethod galasaMethod) throws FrameworkException;
+ public void fillAnnotatedFields(Object testClassObject) throws FrameworkException;
+ public void startOfTestMethod(@NotNull GalasaMethod galasaMethod) throws FrameworkException;
+ public Result endOfTestMethod(@NotNull GalasaMethod galasaMethod, @NotNull Result currentResult, Throwable currentException)
+ throws FrameworkException ;
+}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunnerDataProvider.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunnerDataProvider.java
new file mode 100644
index 000000000..e48cdce64
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunnerDataProvider.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework;
+
+import java.util.Properties;
+
+import dev.galasa.framework.spi.IConfigurationPropertyStoreService;
+import dev.galasa.framework.spi.IDynamicStatusStoreService;
+import dev.galasa.framework.spi.IResultArchiveStore;
+import dev.galasa.framework.spi.IRun;
+import dev.galasa.framework.spi.IShutableFramework;
+import dev.galasa.framework.spi.language.GalasaTest;
+
+public interface ITestRunnerDataProvider {
+ public IRun getRun();
+ public IConfigurationPropertyStoreService getCPS();
+ public IDynamicStatusStoreService getDSS();
+ public IResultArchiveStore getRAS();
+ public IShutableFramework getFramework();
+ public IBundleManager getBundleManager();
+ public IAnnotationExtractor getAnnotationExtractor();
+ public Properties getOverrideProperties();
+ public ITestRunManagers createTestRunManagers(GalasaTest galasaTest) throws TestRunException;
+}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestClassWrapper.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestClassWrapper.java
index ed29710d3..66c3c897b 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestClassWrapper.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestClassWrapper.java
@@ -181,7 +181,7 @@ public void instantiateTestClass() throws TestRunException {
*
* @throws TestRunException
*/
- public void runTestMethods(@NotNull TestRunManagers managers, IDynamicStatusStoreService dss, String runName) throws TestRunException {
+ public void runTestMethods(@NotNull ITestRunManagers managers, IDynamicStatusStoreService dss, String runName) throws TestRunException {
logger.info(LOG_STARTING + LOG_START_LINE + LOG_ASTERS + LOG_START_LINE + "*** Start of test class "
+ testClass.getName() + LOG_START_LINE + LOG_ASTERS);
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestMethodWrapper.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestMethodWrapper.java
index 0b62fe408..7d4ceacae 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestMethodWrapper.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestMethodWrapper.java
@@ -46,7 +46,7 @@ protected TestMethodWrapper(Method testMethod, Class> testClass, ArrayList activeManagers = new ArrayList<>();
private final List activeManagersReversed = new ArrayList<>();
@@ -456,6 +456,7 @@ private String getBundleStateLabel(Bundle bundle) {
}
}
+ @Override
public boolean anyReasonTestClassShouldBeIgnored() throws FrameworkException {
for (IManager manager : activeManagers) {
try {
@@ -471,6 +472,7 @@ public boolean anyReasonTestClassShouldBeIgnored() throws FrameworkException {
return false;
}
+ @Override
public void provisionGenerate() throws FrameworkException {
for (IManager manager : activeManagers) {
try {
@@ -484,6 +486,7 @@ public void provisionGenerate() throws FrameworkException {
}
}
+ @Override
public void provisionBuild() throws FrameworkException {
for (IManager manager : activeManagers) {
try {
@@ -495,6 +498,7 @@ public void provisionBuild() throws FrameworkException {
}
}
+ @Override
public void provisionStart() throws FrameworkException {
for (IManager manager : activeManagers) {
try {
@@ -507,18 +511,21 @@ public void provisionStart() throws FrameworkException {
}
}
+ @Override
public void provisionStop() {
for (IManager manager : activeManagersReversed) {
manager.provisionStop();
}
}
+ @Override
public void provisionDiscard() {
for (IManager manager : activeManagersReversed) {
manager.provisionDiscard();
}
}
+ @Override
public void startOfTestClass() throws FrameworkException {
for (IManager manager : activeManagers) {
try {
@@ -530,6 +537,7 @@ public void startOfTestClass() throws FrameworkException {
}
}
+ @Override
public Result anyReasonTestMethodShouldBeIgnored(@NotNull GalasaMethod galasaMethod) throws FrameworkException {
for (IManager manager : activeManagers) {
try {
@@ -544,6 +552,7 @@ public Result anyReasonTestMethodShouldBeIgnored(@NotNull GalasaMethod galasaMet
return null;
}
+ @Override
public void fillAnnotatedFields(Object testClassObject) throws FrameworkException {
for (IManager manager : activeManagers) {
try {
@@ -555,6 +564,7 @@ public void fillAnnotatedFields(Object testClassObject) throws FrameworkExceptio
}
}
+ @Override
public void startOfTestMethod(@NotNull GalasaMethod galasaMethod) throws FrameworkException {
for (IManager manager : activeManagers) {
try {
@@ -566,6 +576,7 @@ public void startOfTestMethod(@NotNull GalasaMethod galasaMethod) throws Framewo
}
}
+ @Override
public Result endOfTestMethod(@NotNull GalasaMethod galasaMethod, @NotNull Result currentResult, Throwable currentException)
throws FrameworkException {
Result newResult = null;
@@ -585,6 +596,7 @@ public Result endOfTestMethod(@NotNull GalasaMethod galasaMethod, @NotNull Resul
return newResult;
}
+ @Override
public Result endOfTestClass(@NotNull Result result, Throwable currentException) throws FrameworkException {
Result newResult = null;
@@ -604,6 +616,7 @@ public Result endOfTestClass(@NotNull Result result, Throwable currentException)
return newResult;
}
+ @Override
public void testClassResult(@NotNull Result finalResult, Throwable finalException) {
for (IManager manager : activeManagers) {
try {
@@ -614,18 +627,21 @@ public void testClassResult(@NotNull Result finalResult, Throwable finalExceptio
}
}
+ @Override
public void endOfTestRun() {
for (IManager manager : activeManagers) {
manager.endOfTestRun();
}
}
+ @Override
public void shutdown() {
for (IManager manager : activeManagersReversed) {
manager.shutdown();
}
}
-
+
+ @Override
public List getActiveManagers() {
return this.activeManagers;
}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
index 7b9ea744b..1ac7246ee 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
@@ -47,6 +47,7 @@
import dev.galasa.framework.spi.IManager;
import dev.galasa.framework.spi.IResultArchiveStore;
import dev.galasa.framework.spi.IRun;
+import dev.galasa.framework.spi.IShutableFramework;
import dev.galasa.framework.spi.Result;
import dev.galasa.framework.spi.ResultArchiveStoreException;
import dev.galasa.framework.spi.SharedEnvironmentRunType;
@@ -68,16 +69,17 @@ private enum RunType {
SHARED_ENVIRONMENT_DISCARD
}
-
private Log logger = LogFactory.getLog(TestRunner.class);
private BundleContext bundleContext;
+ // Field is protected so unit tests can inject a value here.
@Reference(cardinality = ReferenceCardinality.OPTIONAL)
- private RepositoryAdmin repositoryAdmin;
+ protected RepositoryAdmin repositoryAdmin;
+ // Field is protected so unit tests can inject a value here.
@Reference(cardinality = ReferenceCardinality.OPTIONAL)
- private IMavenRepository mavenRepository;
+ protected IMavenRepository mavenRepository;
private TestRunHeartbeat heartbeat;
@@ -93,10 +95,12 @@ private enum RunType {
private boolean isRunOK = true;
private boolean resourcesAvailable = true;
- private IFramework framework;
+ private IShutableFramework framework;
+ private IBundleManager bundleManager;
private boolean produceEvents;
+
/**
* Run the supplied test class
*
@@ -105,20 +109,20 @@ private enum RunType {
* @throws TestRunException
*/
public void runTest(Properties bootstrapProperties, Properties overrideProperties) throws TestRunException {
+ TestRunnerDataProvider data = new TestRunnerDataProvider(bootstrapProperties, overrideProperties);
+ runTest(data);
+ }
- // *** Initialise the framework services
- FrameworkInitialisation frameworkInitialisation = null;
- try {
- frameworkInitialisation = new FrameworkInitialisation(bootstrapProperties, overrideProperties, true);
- cps = frameworkInitialisation.getFramework().getConfigurationPropertyService("framework");
- dss = frameworkInitialisation.getFramework().getDynamicStatusStoreService("framework");
- run = frameworkInitialisation.getFramework().getTestRun();
- ras = frameworkInitialisation.getFramework().getResultArchiveStore();
- } catch (Exception e) {
- throw new TestRunException("Unable to initialise the Framework Services", e);
- }
+ public void runTest( ITestRunnerDataProvider dataProvider ) throws TestRunException {
+
+ this.run = dataProvider.getRun() ;
+ this.framework = dataProvider.getFramework();
+ this.cps = dataProvider.getCPS();
+ this.ras = dataProvider.getRAS();
+ this.dss = dataProvider.getDSS();
+ this.bundleManager = dataProvider.getBundleManager();
- this.framework = frameworkInitialisation.getFramework();
+ Properties overrideProperties = dataProvider.getOverrideProperties();
try {
this.produceEvents = isProduceEventsFeatureFlagTrue();
@@ -126,7 +130,6 @@ public void runTest(Properties bootstrapProperties, Properties overridePropertie
throw new TestRunException("Problem reading the CPS property to check if framework event production has been activated.");
}
- IRun run = this.framework.getTestRun();
if (run == null) {
throw new TestRunException("Unable to locate run properties");
}
@@ -181,7 +184,7 @@ public void runTest(Properties bootstrapProperties, Properties overridePropertie
} catch (Exception e) {
logger.error("Unable to load stream " + stream + " settings", e);
updateStatus(TestRunLifecycleStatus.FINISHED, "finished");
- frameworkInitialisation.shutdownFramework();
+ shutdownFramework();
return;
}
}
@@ -208,7 +211,7 @@ public void runTest(Properties bootstrapProperties, Properties overridePropertie
} catch (MalformedURLException e) {
logger.error("Unable to add remote maven repository " + testRepository, e);
updateStatus(TestRunLifecycleStatus.FINISHED, "finished");
- frameworkInitialisation.shutdownFramework();
+ shutdownFramework();
return;
}
}
@@ -226,17 +229,17 @@ public void runTest(Properties bootstrapProperties, Properties overridePropertie
} catch (Exception e) {
logger.error("Unable to load specified OBR " + testOBR, e);
updateStatus(TestRunLifecycleStatus.FINISHED, "finished");
- frameworkInitialisation.shutdownFramework();
+ shutdownFramework();
return;
}
}
try {
- BundleManagement.loadBundle(repositoryAdmin, bundleContext, testBundleName);
+ this.bundleManager.loadBundle(repositoryAdmin, bundleContext, testBundleName);
} catch (Exception e) {
logger.error("Unable to load the test bundle " + testBundleName, e);
updateStatus(TestRunLifecycleStatus.FINISHED, "finished");
- frameworkInitialisation.shutdownFramework();
+ shutdownFramework();
return;
}
@@ -248,15 +251,16 @@ public void runTest(Properties bootstrapProperties, Properties overridePropertie
} catch(Throwable t) {
logger.error("Problem locating test " + testBundleName + "/" + testClassName, t);
updateStatus(TestRunLifecycleStatus.FINISHED, "finished");
- frameworkInitialisation.shutdownFramework();
+ shutdownFramework();
return;
}
logger.debug("Getting test annotations..");
- Test testAnnotation = testClass.getAnnotation(Test.class);
+ IAnnotationExtractor annotationExtractor = dataProvider.getAnnotationExtractor();
+ Test testAnnotation = annotationExtractor.getAnnotation( testClass , Test.class);
logger.debug("Test annotations.. got");
- SharedEnvironment sharedEnvironmentAnnotation = testClass.getAnnotation(SharedEnvironment.class);
+ SharedEnvironment sharedEnvironmentAnnotation = annotationExtractor.getAnnotation( testClass, SharedEnvironment.class);
logger.debug("Checking testAnnotation and sharedEnvironmentAnnotation");
if (testAnnotation == null && sharedEnvironmentAnnotation == null) {
@@ -318,7 +322,7 @@ public void runTest(Properties bootstrapProperties, Properties overridePropertie
} catch (DynamicStatusStoreException e1) {
String msg = "DynamicStatusStoreException Exception caught. "+e1.getMessage()+" Shutting down and Re-throwing.";
logger.error(msg);
- frameworkInitialisation.shutdownFramework();
+ shutdownFramework();
throw new TestRunException("Unable to initialise the heartbeat");
}
@@ -338,7 +342,7 @@ public void runTest(Properties bootstrapProperties, Properties overridePropertie
String msg = "DynamicStatusStoreException Exception caught. "+e.getMessage()+" Shutting down and Re-throwing.";
logger.error(msg);
deleteRunProperties(this.framework);
- frameworkInitialisation.shutdownFramework();
+ shutdownFramework();
throw new TestRunException("Unable to set the shared environment expire time",e);
}
}
@@ -358,13 +362,14 @@ public void runTest(Properties bootstrapProperties, Properties overridePropertie
logger.debug("Bundle is loaded ok.");
// *** Initialise the Managers ready for the test run
- TestRunManagers managers = null;
+ ITestRunManagers managers = null;
try {
- managers = new TestRunManagers(this.framework, new GalasaTest(testClass));
- } catch (FrameworkException e) {
- String msg = "FrameworkException Exception caught. "+e.getMessage()+" Shutting down and Re-throwing.";
+ GalasaTest galasaTest = new GalasaTest(testClass);
+ managers = dataProvider.createTestRunManagers(galasaTest);
+ } catch (TestRunException e) {
+ String msg = "Exception Exception caught. "+e.getMessage()+" Shutting down and Re-throwing.";
logger.error(msg);
- frameworkInitialisation.shutdownFramework();
+ shutdownFramework();
throw new TestRunException("Problem initialising the Managers for a test run", e);
}
@@ -375,7 +380,7 @@ public void runTest(Properties bootstrapProperties, Properties overridePropertie
logger.debug("managers.anyReasonTestClassShouldBeIgnored() is true. Shutting down.");
stopHeartbeat();
updateStatus(TestRunLifecycleStatus.FINISHED, "finished");
- frameworkInitialisation.shutdownFramework();
+ shutdownFramework();
return; // TODO handle ignored classes
}
} catch (FrameworkException e) {
@@ -459,7 +464,7 @@ public void runTest(Properties bootstrapProperties, Properties overridePropertie
stopHeartbeat();
// *** Record all the CPS properties that were accessed
- recordCPSProperties(frameworkInitialisation);
+ recordCPSProperties();
// *** If this was a local run, then we will want to remove the run properties
// from the DSS immediately
@@ -474,7 +479,7 @@ public void runTest(Properties bootstrapProperties, Properties overridePropertie
deleteRunProperties(this.framework);
}
} else if (this.runType == RunType.SHARED_ENVIRONMENT_BUILD) {
- recordCPSProperties(frameworkInitialisation);
+ recordCPSProperties();
updateStatus(TestRunLifecycleStatus.UP, "built");
} else {
logger.error("Unrecognised end condition");
@@ -484,7 +489,7 @@ public void runTest(Properties bootstrapProperties, Properties overridePropertie
managers.shutdown();
logger.debug("Cleaning up framework...");
- frameworkInitialisation.shutdownFramework();
+ shutdownFramework();
}
private boolean isProduceEventsFeatureFlagTrue() throws ConfigurationPropertyStoreException {
@@ -497,7 +502,7 @@ private boolean isProduceEventsFeatureFlagTrue() throws ConfigurationPropertySto
return produceEvents;
}
- private void generateEnvironment(TestClassWrapper testClassWrapper, TestRunManagers managers) throws TestRunException {
+ private void generateEnvironment(TestClassWrapper testClassWrapper, ITestRunManagers managers) throws TestRunException {
if(isRunOK){
try {
updateStatus(TestRunLifecycleStatus.GENERATING, null);
@@ -520,7 +525,7 @@ private void generateEnvironment(TestClassWrapper testClassWrapper, TestRunManag
}
- private void createEnvironment(TestClassWrapper testClassWrapper, TestRunManagers managers) throws TestRunException {
+ private void createEnvironment(TestClassWrapper testClassWrapper, ITestRunManagers managers) throws TestRunException {
if (!isRunOK) {
return;
}
@@ -553,7 +558,7 @@ private void createEnvironment(TestClassWrapper testClassWrapper, TestRunManager
}
- private void discardEnvironment(TestRunManagers managers) {
+ private void discardEnvironment(ITestRunManagers managers) {
if (this.runType != RunType.SHARED_ENVIRONMENT_BUILD) {
logger.info("Starting Provision Discard phase");
managers.provisionDiscard();
@@ -561,7 +566,7 @@ private void discardEnvironment(TestRunManagers managers) {
}
- private void runEnvironment(TestClassWrapper testClassWrapper, TestRunManagers managers) throws TestRunException {
+ private void runEnvironment(TestClassWrapper testClassWrapper, ITestRunManagers managers) throws TestRunException {
if (isRunOK) {
try {
if (this.runType != RunType.SHARED_ENVIRONMENT_DISCARD) {
@@ -589,7 +594,7 @@ private void runEnvironment(TestClassWrapper testClassWrapper, TestRunManagers m
return;
}
- private void stopEnvironment(TestRunManagers managers) {
+ private void stopEnvironment(ITestRunManagers managers) {
if (this.runType != RunType.SHARED_ENVIRONMENT_BUILD) {
logger.info("Starting Provision Stop phase");
managers.provisionStop();
@@ -597,7 +602,7 @@ private void stopEnvironment(TestRunManagers managers) {
}
- private void runTestClassWrapper(TestClassWrapper testClassWrapper, TestRunManagers managers) throws TestRunException {
+ private void runTestClassWrapper(TestClassWrapper testClassWrapper, ITestRunManagers managers) throws TestRunException {
// Do nothing if the test run has already failed on setup.
if (isRunOK) {
@@ -817,7 +822,7 @@ public IConfigurationPropertyStoreService getCPS() {
return this.cps;
}
- private void recordCPSProperties(FrameworkInitialisation frameworkInitialisation) {
+ private void recordCPSProperties() {
try {
Properties record = this.framework.getRecordProperties();
@@ -856,4 +861,12 @@ private void recordCPSProperties(FrameworkInitialisation frameworkInitialisation
}
}
+ private void shutdownFramework() {
+ try {
+ this.framework.shutdown();
+ } catch(Exception e) {
+ logger.fatal("Problem shutting down the Galasa framework",e);
+ }
+ }
+
}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java
new file mode 100644
index 000000000..02ae796be
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework;
+
+import java.util.Properties;
+
+import dev.galasa.framework.internal.runner.RealAnnotationExtractor;
+import dev.galasa.framework.spi.FrameworkException;
+import dev.galasa.framework.spi.IConfigurationPropertyStoreService;
+import dev.galasa.framework.spi.IDynamicStatusStoreService;
+import dev.galasa.framework.spi.IResultArchiveStore;
+import dev.galasa.framework.spi.IRun;
+import dev.galasa.framework.spi.IShutableFramework;
+import dev.galasa.framework.spi.language.GalasaTest;
+
+public class TestRunnerDataProvider implements ITestRunnerDataProvider {
+
+ private IConfigurationPropertyStoreService cps;
+ private IDynamicStatusStoreService dss;
+ private IResultArchiveStore ras;
+ private IRun run;
+ private IShutableFramework framework;
+ private Properties overrideProperties;
+
+ public TestRunnerDataProvider(Properties bootstrapProperties, Properties overrideProperties) throws TestRunException {
+
+ FrameworkInitialisation frameworkInitialisation = null;
+ try {
+ boolean isThisATestRun = true ;
+ frameworkInitialisation = new FrameworkInitialisation(bootstrapProperties, overrideProperties, isThisATestRun);
+ framework = frameworkInitialisation.getShutableFramework();
+ cps = framework.getConfigurationPropertyService("framework");
+ dss = framework.getDynamicStatusStoreService("framework");
+ } catch (Exception e) {
+ throw new TestRunException("Unable to initialise the Framework Services", e);
+ }
+
+ run = framework.getTestRun();
+ ras = framework.getResultArchiveStore();
+
+ this.overrideProperties = overrideProperties;
+
+ }
+
+ @Override
+ public IRun getRun() {
+ return this.run;
+ }
+
+ @Override
+ public IConfigurationPropertyStoreService getCPS() {
+ return this.cps;
+ }
+
+ @Override
+ public IDynamicStatusStoreService getDSS() {
+ return this.dss;
+ }
+
+ @Override
+ public IResultArchiveStore getRAS() {
+ return this.ras;
+ }
+
+ @Override
+ public IShutableFramework getFramework() {
+ return this.framework;
+ }
+
+ @Override
+ public IBundleManager getBundleManager() {
+ return new BundleManager();
+ }
+
+ @Override
+ public IAnnotationExtractor getAnnotationExtractor() {
+ return new RealAnnotationExtractor();
+ }
+
+ @Override
+ public Properties getOverrideProperties() {
+ return this.overrideProperties;
+ }
+
+ @Override
+ public ITestRunManagers createTestRunManagers(GalasaTest galasaTest) throws TestRunException {
+ ITestRunManagers managers ;
+ try {
+ managers = new TestRunManagers(this.framework, galasaTest);
+ } catch (FrameworkException e) {
+ String msg = "FrameworkException Exception caught. "+e.getMessage();
+ throw new TestRunException(msg,e);
+ }
+ return managers;
+ }
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/runner/RealAnnotationExtractor.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/runner/RealAnnotationExtractor.java
new file mode 100644
index 000000000..eda63d59f
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/runner/RealAnnotationExtractor.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.internal.runner;
+
+import java.lang.annotation.Annotation;
+
+import dev.galasa.framework.IAnnotationExtractor;
+
+public class RealAnnotationExtractor implements IAnnotationExtractor {
+
+ @Override
+ public B getAnnotation (Class testClass, Class annotationClass) {
+ B result = testClass.getAnnotation(annotationClass);
+ return result;
+ }
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/IShutableFramework.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/IShutableFramework.java
new file mode 100644
index 000000000..1dc16badf
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/IShutableFramework.java
@@ -0,0 +1,10 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.spi;
+
+public interface IShutableFramework extends IFramework {
+ public void shutdown() throws FrameworkException ;
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/MyActualTestClass.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/MyActualTestClass.java
new file mode 100644
index 000000000..dfb1f6c61
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/MyActualTestClass.java
@@ -0,0 +1,13 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework;
+
+@dev.galasa.Test()
+class MyActualTestClass {
+ @dev.galasa.Test()
+ public void myTestMethod() {
+ }
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/TestTestRunner.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/TestTestRunner.java
new file mode 100644
index 000000000..e67301e03
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/TestTestRunner.java
@@ -0,0 +1,184 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.lang.annotation.Annotation;
+import java.util.*;
+
+import javax.validation.constraints.NotNull;
+import org.apache.felix.bundlerepository.Repository;
+import org.apache.felix.bundlerepository.Resolver;
+import org.apache.felix.bundlerepository.Resource;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.InvalidSyntaxException;
+import dev.galasa.framework.maven.repository.spi.IMavenRepository;
+import dev.galasa.framework.mocks.*;
+import dev.galasa.framework.spi.*;
+import dev.galasa.framework.spi.teststructure.TestStructure;
+
+public class TestTestRunner {
+
+ @Test
+ public void testCanCreateRunnerOK() throws Exception {
+ new TestRunner();
+ }
+
+ @Test
+ public void testCanRunTestRunnerOK() throws Exception {
+
+ String TEST_STREAM_REPO_URL = "http://myhost/myRepositoryForMyRun";
+ String TEST_BUNDLE_NAME = "myTestBundle";
+ String TEST_CLASS_NAME = MyActualTestClass.class.getName();
+ String TEST_RUN_NAME = "myTestRun";
+ String TEST_STREAM = "myStreamForMyRun";
+ String TEST_STREAM_OBR = "http://myhost/myObrForMyRun";
+ String TEST_REQUESTOR_NAME = "daffyduck";
+ boolean TEST_IS_LOCAL_RUN_TRUE = true;
+ boolean IGNORE_TEST_CLASS_FALSE = false;
+
+ Properties overrideProps = new Properties();
+ MockIResultArchiveStore ras = new MockIResultArchiveStore("myRunId");
+
+ MockIDynamicStatusStoreService dss = new MockIDynamicStatusStoreService() {
+ @Override
+ public Map getPrefix(@NotNull String keyPrefix) throws DynamicStatusStoreException {
+ return new HashMap();
+ }
+
+ @Override
+ public void put(@NotNull String key, @NotNull String value) throws DynamicStatusStoreException {
+ // Do nothing.
+ }
+ };
+
+ IRun run = new MockRun(
+ TEST_BUNDLE_NAME,
+ TEST_CLASS_NAME ,
+ TEST_RUN_NAME,
+ TEST_STREAM,
+ TEST_STREAM_OBR ,
+ TEST_STREAM_REPO_URL,
+ TEST_REQUESTOR_NAME,
+ TEST_IS_LOCAL_RUN_TRUE
+ );
+
+
+ MockIFrameworkRuns frameworkRuns = new MockIFrameworkRuns( "myRunsGroup", List.of(run));
+
+ MockShutableFramework framework = new MockShutableFramework(ras,dss,TEST_RUN_NAME, run, frameworkRuns );
+ IConfigurationPropertyStoreService cps = new MockIConfigurationPropertyStoreService();
+
+
+
+ IMavenRepository mockMavenRepo = new MockMavenRepository();
+
+ Repository repo1 = new MockRepository(TEST_STREAM_REPO_URL);
+ List repositories = List.of(repo1);
+
+ boolean IS_RESOLVER_GOING_TO_RESOLVE_TEST_BUNDLE = true;
+ Resolver resolver = new MockResolver( IS_RESOLVER_GOING_TO_RESOLVE_TEST_BUNDLE );
+ Resource mockResource = new MockResource(TEST_STREAM_OBR);
+
+ MockRepositoryAdmin mockRepoAdmin = new MockRepositoryAdmin(repositories, resolver) {
+ @Override
+ public Resource[] discoverResources(String filterExpr) throws InvalidSyntaxException {
+ Resource[] results = new Resource[1];
+ results[0] = mockResource ;
+ return results;
+ }
+ };
+
+ MockBundleManager mockBundleManager = new MockBundleManager();
+
+ Map> servicesMap = new HashMap<>();
+
+ Map> loadedClasses = Map.of( TEST_CLASS_NAME , MyActualTestClass.class );
+ MockBundle myBundle1 = new MockBundle( loadedClasses , TEST_BUNDLE_NAME );
+ List bundles = List.of(myBundle1);
+ MockBundleContext mockBundleContext = new MockBundleContext(servicesMap, bundles);
+
+
+ class MockAnnotationExtractor implements IAnnotationExtractor {
+
+ Map annotationToReturnMap = new HashMap<>();
+
+ public void addAnnotation( Class testClass, Class annotationClass , B toReturn) {
+ String key = testClass.getName()+"-"+annotationClass.getName();
+ annotationToReturnMap.put( key, toReturn );
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public B getAnnotation(Class testClass, Class annotationClass) {
+ String key = testClass.getName()+"-"+annotationClass.getName();
+ // The following type-cast is unsafe, or would be were we not in full control of all the
+ // inputs and outputs in a unit test setting...
+ return (B) annotationToReturnMap.get(key);
+ }
+ }
+
+ MockAnnotationExtractor mockAnnotationExtractor = new MockAnnotationExtractor();
+ dev.galasa.Test annotationToReturn = MyActualTestClass.class.getAnnotation(dev.galasa.Test.class);
+ assertThat(annotationToReturn).isNotNull();
+
+ mockAnnotationExtractor.addAnnotation(
+ MyActualTestClass.class,
+ dev.galasa.Test.class,
+ annotationToReturn
+ );
+
+ TestRunner runner = new TestRunner();
+ runner.mavenRepository = mockMavenRepo;
+ runner.repositoryAdmin = mockRepoAdmin;
+
+ // Inject the bundle context before we run the test.
+ runner.activate(mockBundleContext);
+
+ Result testResult = Result.passed();
+
+ MockTestRunManagers mockTestRunManagers = new MockTestRunManagers(IGNORE_TEST_CLASS_FALSE, testResult );
+
+ MockTestRunnerDataProvider testRunData = new MockTestRunnerDataProvider(
+ cps,
+ dss,
+ ras,
+ run,
+ framework,
+ overrideProps,
+ mockAnnotationExtractor,
+ mockBundleManager,
+ mockTestRunManagers
+ );
+
+ // When...
+ runner.runTest(testRunData);
+
+ /// Then...
+ List rasHistory = ras.getTestStructureHistory();
+ assertThat(rasHistory).hasSize(9).extracting("status").contains("finished","finished");
+
+ assertThat(framework.isShutDown()).isTrue();
+
+ assertThat(mockBundleManager.getLoadedBundleSymbolicNames()).hasSize(1);
+
+ assertThat(mockTestRunManagers.calledCountEndOfTestRun).as("End of test run was not announced").isEqualTo(1);
+ assertThat(dss.data).as("dss was not left in an empty state!").isEmpty();
+ assertThat(mockTestRunManagers.calledCountShudown).as("Manager not shut down").isEqualTo(1);
+ assertThat(mockTestRunManagers.calledCountProvisionGenerate).as("Manager not given a chance to provision").isEqualTo(1);
+ assertThat(mockTestRunManagers.calledCountProvisionBuild).as("Manager not get a chance to build").isEqualTo(1);
+ assertThat(mockTestRunManagers.calledCountProvisionStart).as("Manager not get a chance to start").isEqualTo(1);
+ assertThat(mockTestRunManagers.calledCountProvisionDiscard).as("Managers not given an chance to discard the provisioning.").isEqualTo(1);
+ assertThat(mockTestRunManagers.calledCountProvisionStop).isEqualTo(1);
+ assertThat(mockTestRunManagers.calledCountStartOfTestClass).isEqualTo(1);
+ assertThat(mockTestRunManagers.calledCountEndOfTestClass).isEqualTo(1);
+ assertThat(mockTestRunManagers.calledCountEndOfTestRun).isEqualTo(1);
+ assertThat(mockTestRunManagers.calledCountAnyReasonTestMethodShouldBeIgnored).isEqualTo(1);
+ }
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/internal/ras/directory/DirectoryFileSystemTest.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/internal/ras/directory/DirectoryFileSystemTest.java
index 3c7613333..153b67016 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/internal/ras/directory/DirectoryFileSystemTest.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/internal/ras/directory/DirectoryFileSystemTest.java
@@ -28,8 +28,6 @@
import org.junit.Before;
import org.junit.Test;
-import dev.galasa.framework.internal.ras.directory.DirectoryRASFileSystem;
-import dev.galasa.framework.internal.ras.directory.DirectoryRASFileSystemProvider;
import dev.galasa.ResultArchiveStoreContentType;
import dev.galasa.ResultArchiveStoreFileAttributeView;
@@ -156,7 +154,7 @@ public void testDirectoryStream() throws IOException {
int count = 0;
try (DirectoryStream ds = Files.newDirectoryStream(rasTestDirectory)) {
- for (final Path entry : Files.newDirectoryStream(rasTestDirectory)) {
+ for (final Path entry : ds) {
count++;
files.remove(entry.toString());
}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/internal/ras/directory/RASGetRunsTest.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/internal/ras/directory/RASGetRunsTest.java
index 20a35082f..bdef6714d 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/internal/ras/directory/RASGetRunsTest.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/internal/ras/directory/RASGetRunsTest.java
@@ -14,8 +14,6 @@
import org.junit.Before;
import org.junit.Test;
-import dev.galasa.framework.internal.ras.directory.DirectoryRASDirectoryService;
-import dev.galasa.framework.internal.ras.directory.DirectoryRASRunResult;
import dev.galasa.framework.spi.IRunResult;
import dev.galasa.framework.spi.ResultArchiveStoreException;
import dev.galasa.framework.spi.ras.IRasSearchCriteria;
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundle.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundle.java
new file mode 100644
index 000000000..fd0e630c7
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundle.java
@@ -0,0 +1,183 @@
+package dev.galasa.framework.mocks;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.cert.X509Certificate;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+
+public class MockBundle implements Bundle {
+
+ private Map> loadedClasses ;
+ private String symbolicName ;
+
+ /**
+ *
+ * @param loadedClasses The classes which could be returned from loadClass(name). The key to the map is the name.
+ */
+ public MockBundle( Map> loadedClasses , String symbolicName) {
+ this.loadedClasses = loadedClasses ;
+ this.symbolicName = symbolicName;
+ }
+
+ @Override
+ public Class> loadClass(String name) throws ClassNotFoundException {
+ return loadedClasses.get(name);
+ }
+
+ @Override
+ public String getSymbolicName() {
+ return this.symbolicName;
+ }
+
+ //------------------- Unimplemented methods below ----------------------
+
+ @Override
+ public int compareTo(Bundle o) {
+ throw new UnsupportedOperationException("Unimplemented method 'compareTo'");
+ }
+
+ @Override
+ public int getState() {
+ throw new UnsupportedOperationException("Unimplemented method 'getState'");
+ }
+
+ @Override
+ public void start(int options) throws BundleException {
+ throw new UnsupportedOperationException("Unimplemented method 'start'");
+ }
+
+ @Override
+ public void start() throws BundleException {
+ throw new UnsupportedOperationException("Unimplemented method 'start'");
+ }
+
+ @Override
+ public void stop(int options) throws BundleException {
+ throw new UnsupportedOperationException("Unimplemented method 'stop'");
+ }
+
+ @Override
+ public void stop() throws BundleException {
+ throw new UnsupportedOperationException("Unimplemented method 'stop'");
+ }
+
+ @Override
+ public void update(InputStream input) throws BundleException {
+ throw new UnsupportedOperationException("Unimplemented method 'update'");
+ }
+
+ @Override
+ public void update() throws BundleException {
+ throw new UnsupportedOperationException("Unimplemented method 'update'");
+ }
+
+ @Override
+ public void uninstall() throws BundleException {
+ throw new UnsupportedOperationException("Unimplemented method 'uninstall'");
+ }
+
+ @Override
+ public Dictionary getHeaders() {
+ throw new UnsupportedOperationException("Unimplemented method 'getHeaders'");
+ }
+
+ @Override
+ public long getBundleId() {
+ throw new UnsupportedOperationException("Unimplemented method 'getBundleId'");
+ }
+
+ @Override
+ public String getLocation() {
+ throw new UnsupportedOperationException("Unimplemented method 'getLocation'");
+ }
+
+ @Override
+ public ServiceReference>[] getRegisteredServices() {
+ throw new UnsupportedOperationException("Unimplemented method 'getRegisteredServices'");
+ }
+
+ @Override
+ public ServiceReference>[] getServicesInUse() {
+ throw new UnsupportedOperationException("Unimplemented method 'getServicesInUse'");
+ }
+
+ @Override
+ public boolean hasPermission(Object permission) {
+ throw new UnsupportedOperationException("Unimplemented method 'hasPermission'");
+ }
+
+ @Override
+ public URL getResource(String name) {
+ throw new UnsupportedOperationException("Unimplemented method 'getResource'");
+ }
+
+ @Override
+ public Dictionary getHeaders(String locale) {
+ throw new UnsupportedOperationException("Unimplemented method 'getHeaders'");
+ }
+
+
+
+
+ @Override
+ public Enumeration getResources(String name) throws IOException {
+ throw new UnsupportedOperationException("Unimplemented method 'getResources'");
+ }
+
+ @Override
+ public Enumeration getEntryPaths(String path) {
+ throw new UnsupportedOperationException("Unimplemented method 'getEntryPaths'");
+ }
+
+ @Override
+ public URL getEntry(String path) {
+ throw new UnsupportedOperationException("Unimplemented method 'getEntry'");
+ }
+
+ @Override
+ public long getLastModified() {
+ throw new UnsupportedOperationException("Unimplemented method 'getLastModified'");
+ }
+
+ @Override
+ public Enumeration findEntries(String path, String filePattern, boolean recurse) {
+ throw new UnsupportedOperationException("Unimplemented method 'findEntries'");
+ }
+
+ @Override
+ public BundleContext getBundleContext() {
+ throw new UnsupportedOperationException("Unimplemented method 'getBundleContext'");
+ }
+
+ @Override
+ public Map> getSignerCertificates(int signersType) {
+ throw new UnsupportedOperationException("Unimplemented method 'getSignerCertificates'");
+ }
+
+ @Override
+ public Version getVersion() {
+ throw new UnsupportedOperationException("Unimplemented method 'getVersion'");
+ }
+
+ @Override
+ public A adapt(Class type) {
+ throw new UnsupportedOperationException("Unimplemented method 'adapt'");
+ }
+
+ @Override
+ public File getDataFile(String filename) {
+ throw new UnsupportedOperationException("Unimplemented method 'getDataFile'");
+ }
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleContext.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleContext.java
index e4a0e6a04..44d8d5c7f 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleContext.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleContext.java
@@ -5,35 +5,31 @@
*/
package dev.galasa.framework.mocks;
-import java.io.File;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Dictionary;
-import java.util.Map;
+import java.io.*;
+import java.util.*;
import java.util.Map.Entry;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.BundleListener;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceObjects;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.*;
public class MockBundleContext implements BundleContext{
private Map> services ;
+ private List loadedBundles;
+
/**
* @param services A map. The key is the interface/class name.
*/
public MockBundleContext(Map> services) {
+ this(services,new ArrayList<>());
+ }
+
+ public MockBundleContext(
+ Map> services,
+ List loadedBundles
+ ) {
this.services = services;
+ this.loadedBundles = loadedBundles;
}
@Override
@@ -63,7 +59,9 @@ public Bundle getBundle(long id) {
@Override
public Bundle[] getBundles() {
- throw new UnsupportedOperationException("Unimplemented method 'getBundles'");
+ Bundle[] result = new Bundle[loadedBundles.size()];
+ loadedBundles.toArray(result);
+ return result;
}
@Override
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleManager.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleManager.java
new file mode 100644
index 000000000..3c4b3748c
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleManager.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.mocks;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.felix.bundlerepository.RepositoryAdmin;
+import org.osgi.framework.BundleContext;
+
+import dev.galasa.framework.IBundleManager;
+import dev.galasa.framework.spi.FrameworkException;
+
+public class MockBundleManager implements IBundleManager {
+
+ List loadedSymbolicNames = new ArrayList();
+
+ @Override
+ public void loadBundle(RepositoryAdmin repositoryAdmin, BundleContext bundleContext, String bundleSymbolicName)
+ throws FrameworkException {
+ this.loadedSymbolicNames.add(bundleSymbolicName);
+ }
+
+ public List getLoadedBundleSymbolicNames() {
+ return this.loadedSymbolicNames;
+ }
+
+ @Override
+ public boolean isBundleActive(BundleContext bundleContext, String bundleSymbolicName) {
+ throw new UnsupportedOperationException("Unimplemented method 'isBundleActive'");
+ }
+
+ @Override
+ public void loadAllGherkinManagerBundles(RepositoryAdmin repositoryAdmin, BundleContext bundleContext)
+ throws FrameworkException {
+ throw new UnsupportedOperationException("Unimplemented method 'loadAllGherkinManagerBundles'");
+ }
+
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIConfigurationPropertyStoreService.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIConfigurationPropertyStoreService.java
new file mode 100644
index 000000000..a7fa2c158
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIConfigurationPropertyStoreService.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.mocks;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Null;
+
+import dev.galasa.framework.spi.ConfigurationPropertyStoreException;
+import dev.galasa.framework.spi.IConfigurationPropertyStoreService;
+
+public class MockIConfigurationPropertyStoreService implements IConfigurationPropertyStoreService {
+
+ @Override
+ public @Null String getProperty(@NotNull String prefix, @NotNull String suffix, String... infixes)
+ throws ConfigurationPropertyStoreException {
+ return null ;
+ }
+
+ @Override
+ public @NotNull Map getPrefixedProperties(@NotNull String prefix)
+ throws ConfigurationPropertyStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'getPrefixedProperties'");
+ }
+
+ @Override
+ public void setProperty(@NotNull String name, @NotNull String value) throws ConfigurationPropertyStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'setProperty'");
+ }
+
+ @Override
+ public void deleteProperty(@NotNull String name) throws ConfigurationPropertyStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'deleteProperty'");
+ }
+
+ @Override
+ public Map getAllProperties() throws ConfigurationPropertyStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'getAllProperties'");
+ }
+
+ @Override
+ public String[] reportPropertyVariants(@NotNull String prefix, @NotNull String suffix, String... infixes) {
+ throw new UnsupportedOperationException("Unimplemented method 'reportPropertyVariants'");
+ }
+
+ @Override
+ public String reportPropertyVariantsString(@NotNull String prefix, @NotNull String suffix, String... infixes) {
+ throw new UnsupportedOperationException("Unimplemented method 'reportPropertyVariantsString'");
+ }
+
+ @Override
+ public List getCPSNamespaces() throws ConfigurationPropertyStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'getCPSNamespaces'");
+ }
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIDynamicStatusStoreService.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIDynamicStatusStoreService.java
new file mode 100644
index 000000000..594fd6663
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIDynamicStatusStoreService.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.mocks;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Null;
+
+import dev.galasa.framework.spi.DynamicStatusStoreException;
+import dev.galasa.framework.spi.DynamicStatusStoreMatchException;
+import dev.galasa.framework.spi.IDssAction;
+import dev.galasa.framework.spi.IDynamicResource;
+import dev.galasa.framework.spi.IDynamicRun;
+import dev.galasa.framework.spi.IDynamicStatusStoreService;
+import dev.galasa.framework.spi.IDynamicStatusStoreWatcher;
+
+public class MockIDynamicStatusStoreService implements IDynamicStatusStoreService {
+
+ public Map data = new HashMap<>();
+
+ @Override
+ public boolean putSwap(@NotNull String key, String oldValue, @NotNull String newValue) {
+ data.put(key,newValue);
+ return true;
+ }
+
+ @Override
+ public void delete(@NotNull String key) throws DynamicStatusStoreException {
+ data.remove(key);
+ }
+
+ // ------------------- un-implemented methods follow --------------------
+
+ @Override
+ public void put(@NotNull String key, @NotNull String value) throws DynamicStatusStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'put'");
+ }
+
+ @Override
+ public void put(@NotNull Map keyValues) throws DynamicStatusStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'put'");
+ }
+
+
+ @Override
+ public boolean putSwap(@NotNull String key, String oldValue, @NotNull String newValue,
+ @NotNull Map others) throws DynamicStatusStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'putSwap'");
+ }
+
+ @Override
+ public @Null String get(@NotNull String key) throws DynamicStatusStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'get'");
+ }
+
+ @Override
+ public @NotNull Map getPrefix(@NotNull String keyPrefix) throws DynamicStatusStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'getPrefix'");
+ }
+
+ @Override
+ public void delete(@NotNull Set keys) throws DynamicStatusStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'delete'");
+ }
+
+ @Override
+ public void deletePrefix(@NotNull String keyPrefix) throws DynamicStatusStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'deletePrefix'");
+ }
+
+ @Override
+ public void performActions(IDssAction... actions)
+ throws DynamicStatusStoreException, DynamicStatusStoreMatchException {
+ throw new UnsupportedOperationException("Unimplemented method 'performActions'");
+ }
+
+ @Override
+ public UUID watch(IDynamicStatusStoreWatcher watcher, String key) throws DynamicStatusStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'watch'");
+ }
+
+ @Override
+ public UUID watchPrefix(IDynamicStatusStoreWatcher watcher, String keyPrefix) throws DynamicStatusStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'watchPrefix'");
+ }
+
+ @Override
+ public void unwatch(UUID watchId) throws DynamicStatusStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'unwatch'");
+ }
+
+ @Override
+ public IDynamicResource getDynamicResource(String resourceKey) {
+ throw new UnsupportedOperationException("Unimplemented method 'getDynamicResource'");
+ }
+
+ @Override
+ public IDynamicRun getDynamicRun() throws DynamicStatusStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'getDynamicRun'");
+ }
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIFrameworkRuns.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIFrameworkRuns.java
new file mode 100644
index 000000000..7852fe9b4
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIFrameworkRuns.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.mocks;
+
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.validation.constraints.NotNull;
+
+import dev.galasa.framework.spi.DynamicStatusStoreException;
+import dev.galasa.framework.spi.FrameworkException;
+import dev.galasa.framework.spi.IFrameworkRuns;
+import dev.galasa.framework.spi.IRun;
+
+public class MockIFrameworkRuns implements IFrameworkRuns{
+ protected String groupName;
+ List runs ;
+
+
+ public MockIFrameworkRuns(@NotNull String groupName, List runs) {
+ this.groupName = groupName;
+ this.runs = runs;
+ }
+
+ public MockIFrameworkRuns(List runs) {
+ this.runs = runs;
+ }
+
+ @Override
+ public @NotNull List getActiveRuns() throws FrameworkException {
+ throw new UnsupportedOperationException("Unimplemented method 'getActiveRuns'");
+ }
+
+ @Override
+ public @NotNull List getQueuedRuns() throws FrameworkException {
+ throw new UnsupportedOperationException("Unimplemented method 'getQueuedRuns'");
+ }
+
+ @Override
+ public @NotNull List getAllRuns() throws FrameworkException {
+ throw new UnsupportedOperationException("Unimplemented method 'getAllRuns'");
+ }
+
+ @Override
+ public @NotNull List getAllGroupedRuns(@NotNull String groupName) throws FrameworkException {
+ if(groupName.equals("invalid")){
+ throw new FrameworkException("exceptioninvalid group");
+ }else if (groupName.equals("nullgroup")){
+ return null;
+ }
+ return this.runs;
+ }
+
+ @Override
+ public @NotNull Set getActiveRunNames() throws FrameworkException {
+ throw new UnsupportedOperationException("Unimplemented method 'getActiveRunNames'");
+ }
+
+ @Override
+ public @NotNull IRun submitRun(String type, String requestor, String bundleName, String testName, String groupName,
+ String mavenRepository, String obr, String stream, boolean local, boolean trace, Properties overrides,
+ SharedEnvironmentPhase sharedEnvironmentPhase, String sharedEnvironmentRunName, String language)
+ throws FrameworkException {
+ if (stream.equals("null")){
+ throw new FrameworkException(language);
+ }
+
+ throw new FrameworkException("Method not implemented in mock class.");
+ }
+
+ @Override
+ public boolean delete(String runname) throws DynamicStatusStoreException {
+ return true;
+ }
+
+ @Override
+ public IRun getRun(String runname) throws DynamicStatusStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'getRun'");
+ }
+
+ @Override
+ public boolean reset(String runname) throws DynamicStatusStoreException {
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIResultArchiveStore.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIResultArchiveStore.java
new file mode 100644
index 000000000..ec36a8081
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIResultArchiveStore.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.mocks;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.validation.constraints.NotNull;
+
+import dev.galasa.framework.spi.IResultArchiveStore;
+import dev.galasa.framework.spi.IResultArchiveStoreDirectoryService;
+import dev.galasa.framework.spi.ResultArchiveStoreException;
+import dev.galasa.framework.spi.teststructure.TestStructure;
+import static org.assertj.core.api.Assertions.*;
+
+
+public class MockIResultArchiveStore implements IResultArchiveStore {
+
+ List testStructureHistory = new ArrayList<>();
+ private String runId ;
+
+ public MockIResultArchiveStore(String runId) {
+ this.runId = runId;
+ }
+
+ @Override
+ public void updateTestStructure(@NotNull TestStructure testStructure) throws ResultArchiveStoreException {
+ assertThat(testStructure).isNotNull();
+ testStructureHistory.add(testStructure);
+ }
+
+ @Override
+ public String calculateRasRunId() {
+ return this.runId;
+ }
+
+ public List getTestStructureHistory() {
+ return this.testStructureHistory;
+ }
+
+ @Override
+ public void flush() {
+ // Do nothing.
+ }
+
+ // --------------- un-implemented methods follow --------------------
+
+ @Override
+ public void writeLog(@NotNull String message) throws ResultArchiveStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'writeLog'");
+ }
+
+ @Override
+ public void writeLog(@NotNull List messages) throws ResultArchiveStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'writeLog'");
+ }
+
+ @Override
+ public Path getStoredArtifactsRoot() {
+ throw new UnsupportedOperationException("Unimplemented method 'getStoredArtifactsRoot'");
+ }
+
+
+
+ @Override
+ public void shutdown() {
+ throw new UnsupportedOperationException("Unimplemented method 'shutdown'");
+ }
+
+ @Override
+ public @NotNull List getDirectoryServices() {
+ throw new UnsupportedOperationException("Unimplemented method 'getDirectoryServices'");
+ }
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockMavenRepository.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockMavenRepository.java
new file mode 100644
index 000000000..c2e4706ae
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockMavenRepository.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.mocks;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import dev.galasa.framework.maven.repository.spi.IMavenRepository;
+
+public class MockMavenRepository implements IMavenRepository {
+
+ List remoteRepoUrls = new ArrayList<>();
+
+ @Override
+ public URL getLocalRepository() {
+ throw new UnsupportedOperationException("Unimplemented method 'getLocalRepository'");
+ }
+
+ @Override
+ public List getRemoteRepositories() {
+ return remoteRepoUrls;
+ }
+
+ @Override
+ public void setRepositories(URL localRepository, List remoteRepositories) {
+ throw new UnsupportedOperationException("Unimplemented method 'setRepositories'");
+ }
+
+ @Override
+ public void addRemoteRepository(URL remoteRepository) {
+ remoteRepoUrls.add(remoteRepository);
+ }
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockRepository.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockRepository.java
new file mode 100644
index 000000000..1e46bca86
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockRepository.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.mocks;
+
+import org.apache.felix.bundlerepository.Repository;
+import org.apache.felix.bundlerepository.Resource;
+
+public class MockRepository implements Repository {
+
+ private String uri ;
+
+ public MockRepository(String uri) {
+ this.uri = uri;
+ }
+
+ @Override
+ public String getURI() {
+ return this.uri;
+ }
+
+ @Override
+ public Resource[] getResources() {
+ throw new UnsupportedOperationException("Unimplemented method 'getResources'");
+ }
+
+ @Override
+ public String getName() {
+ throw new UnsupportedOperationException("Unimplemented method 'getName'");
+ }
+
+ @Override
+ public long getLastModified() {
+ throw new UnsupportedOperationException("Unimplemented method 'getLastModified'");
+ }
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockRepositoryAdmin.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockRepositoryAdmin.java
new file mode 100644
index 000000000..c5a0092da
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockRepositoryAdmin.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.mocks;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.felix.bundlerepository.DataModelHelper;
+import org.apache.felix.bundlerepository.Repository;
+import org.apache.felix.bundlerepository.RepositoryAdmin;
+import org.apache.felix.bundlerepository.Requirement;
+import org.apache.felix.bundlerepository.Resolver;
+import org.apache.felix.bundlerepository.Resource;
+import org.osgi.framework.InvalidSyntaxException;
+
+public class MockRepositoryAdmin implements RepositoryAdmin {
+
+ private List repositoryUrls = new ArrayList<>();
+ private Resolver resolver ;
+
+ private Map repoisotoryURLMap = new HashMap();
+
+ public MockRepositoryAdmin(List repositories, Resolver resolver) {
+ for( Repository repo : repositories) {
+ String key = repo.getURI().toString();
+ repoisotoryURLMap.put(key,repo);
+ }
+ this.resolver = resolver;
+ }
+
+ @Override
+ public Repository addRepository(String repository) throws Exception {
+ this.repositoryUrls.add(new URL(repository));
+ return repoisotoryURLMap.get(repository);
+ }
+
+ @Override
+ public Repository addRepository(URL repositoryUrl) throws Exception {
+ this.repositoryUrls.add(repositoryUrl);
+ return repoisotoryURLMap.get(repositoryUrl.toString());
+ }
+
+ @Override
+ public Resolver resolver() {
+ return resolver;
+ }
+
+ // ----------------- un-implemented methdos follow --------------------
+
+ @Override
+ public Resource[] discoverResources(String filterExpr) throws InvalidSyntaxException {
+ throw new UnsupportedOperationException("Unimplemented method 'discoverResources'");
+ }
+
+ @Override
+ public Resource[] discoverResources(Requirement[] requirements) {
+ throw new UnsupportedOperationException("Unimplemented method 'discoverResources'");
+ }
+
+ @Override
+ public Resolver resolver(Repository[] repositories) {
+ throw new UnsupportedOperationException("Unimplemented method 'resolver'");
+ }
+
+ @Override
+ public boolean removeRepository(String repository) {
+ throw new UnsupportedOperationException("Unimplemented method 'removeRepository'");
+ }
+
+ @Override
+ public Repository[] listRepositories() {
+ throw new UnsupportedOperationException("Unimplemented method 'listRepositories'");
+ }
+
+ @Override
+ public Repository getSystemRepository() {
+ throw new UnsupportedOperationException("Unimplemented method 'getSystemRepository'");
+ }
+
+ @Override
+ public Repository getLocalRepository() {
+ throw new UnsupportedOperationException("Unimplemented method 'getLocalRepository'");
+ }
+
+ @Override
+ public DataModelHelper getHelper() {
+ throw new UnsupportedOperationException("Unimplemented method 'getHelper'");
+ }
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockResolver.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockResolver.java
new file mode 100644
index 000000000..197da1560
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockResolver.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.mocks;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.felix.bundlerepository.Capability;
+import org.apache.felix.bundlerepository.InterruptedResolutionException;
+import org.apache.felix.bundlerepository.Reason;
+import org.apache.felix.bundlerepository.Requirement;
+import org.apache.felix.bundlerepository.Resolver;
+import org.apache.felix.bundlerepository.Resource;
+
+public class MockResolver implements Resolver {
+
+ List resources = new ArrayList();
+
+ boolean isResolveOK ;
+
+ public MockResolver(boolean isResolveOK) {
+ this.isResolveOK = isResolveOK ;
+ }
+
+ @Override
+ public void add(Resource resource) {
+ this.resources.add(resource);
+ }
+
+ @Override
+ public boolean resolve() throws InterruptedResolutionException {
+ return this.isResolveOK;
+ }
+
+ @Override
+ public Resource[] getRequiredResources() {
+ Resource[] results = new Resource[resources.size()];
+ int i=0;
+ for (Resource r : resources) {
+ results[i] = r ;
+ i+=1;
+ }
+ return results;
+ }
+
+ @Override
+ public Resource[] getOptionalResources() {
+ return new Resource[0];
+ }
+
+ @Override
+ public void deploy(int flags) {
+ // Do nothing.
+ }
+
+ // -------------- un-implemented methods follow --------------------------
+
+ @Override
+ public Resource[] getAddedResources() {
+ throw new UnsupportedOperationException("Unimplemented method 'getAddedResources'");
+ }
+
+ @Override
+ public void add(Requirement requirement) {
+ throw new UnsupportedOperationException("Unimplemented method 'add'");
+ }
+
+ @Override
+ public Requirement[] getAddedRequirements() {
+ throw new UnsupportedOperationException("Unimplemented method 'getAddedRequirements'");
+ }
+
+ @Override
+ public void addGlobalCapability(Capability capability) {
+ throw new UnsupportedOperationException("Unimplemented method 'addGlobalCapability'");
+ }
+
+ @Override
+ public Capability[] getGlobalCapabilities() {
+ throw new UnsupportedOperationException("Unimplemented method 'getGlobalCapabilities'");
+ }
+
+ @Override
+ public boolean resolve(int flags) throws InterruptedResolutionException {
+ throw new UnsupportedOperationException("Unimplemented method 'resolve'");
+ }
+
+
+
+
+
+ @Override
+ public Reason[] getReason(Resource resource) {
+ throw new UnsupportedOperationException("Unimplemented method 'getReason'");
+ }
+
+ @Override
+ public Reason[] getUnsatisfiedRequirements() {
+ throw new UnsupportedOperationException("Unimplemented method 'getUnsatisfiedRequirements'");
+ }
+
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockResource.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockResource.java
new file mode 100644
index 000000000..f5fdd6bb9
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockResource.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.mocks;
+
+import java.util.Map;
+
+import org.apache.felix.bundlerepository.Capability;
+import org.apache.felix.bundlerepository.Requirement;
+import org.apache.felix.bundlerepository.Resource;
+import org.osgi.framework.Version;
+
+public class MockResource implements Resource {
+
+ String uri;
+
+ public MockResource(String uri) {
+ this.uri = uri ;
+ }
+
+ @Override
+ public String getURI() {
+ return this.uri;
+ }
+
+ // -------------- un-implemented methods follow --------------------------
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Map getProperties() {
+ throw new UnsupportedOperationException("Unimplemented method 'getProperties'");
+ }
+
+ @Override
+ public String getId() {
+ throw new UnsupportedOperationException("Unimplemented method 'getId'");
+ }
+
+ @Override
+ public String getSymbolicName() {
+ throw new UnsupportedOperationException("Unimplemented method 'getSymbolicName'");
+ }
+
+ @Override
+ public Version getVersion() {
+ throw new UnsupportedOperationException("Unimplemented method 'getVersion'");
+ }
+
+ @Override
+ public String getPresentationName() {
+ throw new UnsupportedOperationException("Unimplemented method 'getPresentationName'");
+ }
+
+ @Override
+ public Long getSize() {
+ throw new UnsupportedOperationException("Unimplemented method 'getSize'");
+ }
+
+ @Override
+ public String[] getCategories() {
+ throw new UnsupportedOperationException("Unimplemented method 'getCategories'");
+ }
+
+ @Override
+ public Capability[] getCapabilities() {
+ throw new UnsupportedOperationException("Unimplemented method 'getCapabilities'");
+ }
+
+ @Override
+ public Requirement[] getRequirements() {
+ throw new UnsupportedOperationException("Unimplemented method 'getRequirements'");
+ }
+
+ @Override
+ public boolean isLocal() {
+ throw new UnsupportedOperationException("Unimplemented method 'isLocal'");
+ }
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockRun.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockRun.java
new file mode 100644
index 000000000..48cd7764e
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockRun.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.mocks;
+
+import java.time.Instant;
+
+import dev.galasa.api.run.Run;
+import dev.galasa.framework.spi.IRun;
+
+public class MockRun implements IRun {
+ private String testBundleName;
+ private String testClassName;
+ private String testRunName;
+ private String testStream;
+ private String testStreamOBR;
+ private String testStreamRepoUrl;
+ private String requestorName ;
+ private boolean isRunLocal;
+
+ public MockRun(String testBundleName,
+ String testClassName, String testRunName , String testStream, String testStreamOBR, String testStreamRepoUrl, String requestorName, boolean isRunLocal ) {
+ this.testBundleName = testBundleName;
+ this.testClassName = testClassName ;
+ this.testRunName = testRunName;
+ this.testStream = testStream;
+ this.testStreamOBR = testStreamOBR;
+ this.testStreamRepoUrl = testStreamRepoUrl;
+ this.requestorName = requestorName;
+ this.isRunLocal = isRunLocal;
+ }
+
+ @Override
+ public String getTestBundleName() {
+ return this.testBundleName;
+ }
+
+ @Override
+ public String getTestClassName() {
+ return this.testClassName;
+ }
+
+ @Override
+ public String getName() {
+ return this.testRunName;
+ }
+
+ @Override
+ public String getStream() {
+ return this.testStream;
+ }
+
+ @Override
+ public Instant getQueued() {
+ return Instant.now();
+ }
+
+ @Override
+ public String getRequestor() {
+ return this.requestorName;
+ }
+
+ @Override
+ public String getRepository() {
+ return this.testStreamRepoUrl;
+ }
+
+ @Override
+ public String getOBR() {
+ return this.testStreamOBR;
+ }
+
+
+ @Override
+ public boolean isLocal() {
+ return this.isRunLocal ;
+ }
+
+ // ------------- un-implemented methods follow ----------------
+
+ @Override
+ public Instant getHeartbeat() {
+ throw new UnsupportedOperationException("Unimplemented method 'getHeartbeat'");
+ }
+
+ @Override
+ public String getType() {
+ throw new UnsupportedOperationException("Unimplemented method 'getType'");
+ }
+
+ @Override
+ public String getTest() {
+ throw new UnsupportedOperationException("Unimplemented method 'getTest'");
+ }
+
+ @Override
+ public String getStatus() {
+ throw new UnsupportedOperationException("Unimplemented method 'getStatus'");
+ }
+
+ @Override
+ public String getGroup() {
+ throw new UnsupportedOperationException("Unimplemented method 'getGroup'");
+ }
+
+ @Override
+ public boolean isTrace() {
+ throw new UnsupportedOperationException("Unimplemented method 'isTrace'");
+ }
+
+ @Override
+ public Instant getFinished() {
+ throw new UnsupportedOperationException("Unimplemented method 'getFinished'");
+ }
+
+ @Override
+ public Instant getWaitUntil() {
+ throw new UnsupportedOperationException("Unimplemented method 'getWaitUntil'");
+ }
+
+ @Override
+ public Run getSerializedRun() {
+ throw new UnsupportedOperationException("Unimplemented method 'getSerializedRun'");
+ }
+
+ @Override
+ public String getResult() {
+ throw new UnsupportedOperationException("Unimplemented method 'getResult'");
+ }
+
+ @Override
+ public boolean isSharedEnvironment() {
+ throw new UnsupportedOperationException("Unimplemented method 'isSharedEnvironment'");
+ }
+
+ @Override
+ public String getGherkin() {
+ throw new UnsupportedOperationException("Unimplemented method 'getGherkin'");
+ }
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockShutableFramework.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockShutableFramework.java
new file mode 100644
index 000000000..929a54115
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockShutableFramework.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.mocks;
+
+import java.net.URL;
+import java.util.Properties;
+import java.util.Random;
+
+import javax.validation.constraints.NotNull;
+
+import dev.galasa.framework.spi.Api;
+import dev.galasa.framework.spi.ConfigurationPropertyStoreException;
+import dev.galasa.framework.spi.FrameworkException;
+import dev.galasa.framework.spi.ICertificateStoreService;
+import dev.galasa.framework.spi.IConfidentialTextService;
+import dev.galasa.framework.spi.IConfigurationPropertyStoreService;
+import dev.galasa.framework.spi.IDynamicStatusStoreService;
+import dev.galasa.framework.spi.IEventsService;
+import dev.galasa.framework.spi.IFrameworkRuns;
+import dev.galasa.framework.spi.IResourcePoolingService;
+import dev.galasa.framework.spi.IResultArchiveStore;
+import dev.galasa.framework.spi.IRun;
+import dev.galasa.framework.spi.IShutableFramework;
+import dev.galasa.framework.spi.SharedEnvironmentRunType;
+import dev.galasa.framework.spi.auth.IAuthStore;
+import dev.galasa.framework.spi.auth.IAuthStoreService;
+import dev.galasa.framework.spi.creds.CredentialsException;
+import dev.galasa.framework.spi.creds.ICredentialsService;
+
+import static org.assertj.core.api.Assertions.*;
+
+public class MockShutableFramework implements IShutableFramework {
+
+ private boolean isShutDown = false;
+ private IResultArchiveStore ras ;
+ private IDynamicStatusStoreService dss ;
+ private String testRunName ;
+ private IRun run;
+ private IFrameworkRuns frameworkRuns;
+
+ public MockShutableFramework(
+ IResultArchiveStore ras,
+ IDynamicStatusStoreService dss,
+ String testRunName,
+ IRun run,
+ IFrameworkRuns frameworkRuns
+ ) {
+ this.ras = ras ;
+ this.dss = dss ;
+ this.testRunName = testRunName;
+ this.run = run;
+ this.frameworkRuns = frameworkRuns;
+ }
+
+ public boolean isShutDown() {
+ return this.isShutDown ;
+ }
+
+ @Override
+ public void shutdown() throws FrameworkException {
+ assertThat(this.isShutDown).as("Framework was shut down twice!").isFalse();
+ this.isShutDown = true ;
+ }
+
+ @Override
+ public @NotNull IResultArchiveStore getResultArchiveStore() {
+ return this.ras;
+ }
+
+
+ @Override
+ public @NotNull IDynamicStatusStoreService getDynamicStatusStoreService(@NotNull String namespace) {
+ return this.dss;
+ }
+
+ @Override
+ public String getTestRunName() {
+ return this.testRunName;
+ }
+
+ @Override
+ public IRun getTestRun() {
+ return run;
+ }
+
+ @Override
+ public IFrameworkRuns getFrameworkRuns() throws FrameworkException {
+ return frameworkRuns ;
+ }
+
+ // ----------------- un-implemented methods follow -------------------
+
+ @Override
+ public void setFrameworkProperties(Properties overrideProperties) {
+ throw new UnsupportedOperationException("Unimplemented method 'setFrameworkProperties'");
+ }
+
+ @Override
+ public boolean isInitialised() {
+ throw new UnsupportedOperationException("Unimplemented method 'isInitialised'");
+ }
+
+ @Override
+ public @NotNull IConfigurationPropertyStoreService getConfigurationPropertyService(@NotNull String namespace)
+ throws ConfigurationPropertyStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'getConfigurationPropertyService'");
+ }
+
+ @Override
+ public @NotNull ICertificateStoreService getCertificateStoreService() {
+ throw new UnsupportedOperationException("Unimplemented method 'getCertificateStoreService'");
+ }
+
+ @Override
+ public @NotNull IAuthStore getAuthStore() {
+ throw new UnsupportedOperationException("Unimplemented method 'getAuthStore'");
+ }
+
+ @Override
+ public @NotNull IAuthStoreService getAuthStoreService() {
+ throw new UnsupportedOperationException("Unimplemented method 'getAuthStoreService'");
+ }
+
+ @Override
+ public @NotNull IResourcePoolingService getResourcePoolingService() {
+ throw new UnsupportedOperationException("Unimplemented method 'getResourcePoolingService'");
+ }
+
+ @Override
+ public @NotNull IConfidentialTextService getConfidentialTextService() {
+ throw new UnsupportedOperationException("Unimplemented method 'getConfidentialTextService'");
+ }
+
+ @Override
+ public @NotNull IEventsService getEventsService() {
+ throw new UnsupportedOperationException("Unimplemented method 'getEventsService'");
+ }
+
+ @Override
+ public @NotNull ICredentialsService getCredentialsService() throws CredentialsException {
+ throw new UnsupportedOperationException("Unimplemented method 'getCredentialsService'");
+ }
+
+ @Override
+ public Random getRandom() {
+ throw new UnsupportedOperationException("Unimplemented method 'getRandom'");
+ }
+
+ @Override
+ public Properties getRecordProperties() {
+ throw new UnsupportedOperationException("Unimplemented method 'getRecordProperties'");
+ }
+
+ @Override
+ public URL getApiUrl(@NotNull Api api) throws FrameworkException {
+ throw new UnsupportedOperationException("Unimplemented method 'getApiUrl'");
+ }
+
+ @Override
+ public SharedEnvironmentRunType getSharedEnvironmentRunType() throws ConfigurationPropertyStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'getSharedEnvironmentRunType'");
+ }
+
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunManagers.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunManagers.java
new file mode 100644
index 000000000..4048fca65
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunManagers.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package dev.galasa.framework.mocks;
+
+import java.util.List;
+
+import javax.validation.constraints.NotNull;
+
+import dev.galasa.framework.ITestRunManagers;
+import dev.galasa.framework.spi.FrameworkException;
+import dev.galasa.framework.spi.IManager;
+import dev.galasa.framework.spi.Result;
+import dev.galasa.framework.spi.language.GalasaMethod;
+
+public class MockTestRunManagers implements ITestRunManagers {
+
+ private boolean ignoreTestClass ;
+
+ public int calledCountEndOfTestRun = 0 ;
+ public int calledCountShudown = 0;
+ public int calledCountProvisionGenerate = 0;
+ public int calledCountProvisionBuild = 0;
+ public int calledCountProvisionStart = 0 ;
+ public int calledCountProvisionDiscard = 0 ;
+ public int calledCountProvisionStop = 0 ;
+ public int calledCountStartOfTestClass = 0 ;
+ public int calledCountEndOfTestClass = 0 ;
+ public int calledCountTestClassResult = 0 ;
+ public int calledCountAnyReasonTestMethodShouldBeIgnored = 0 ;
+
+ private Result resultToReturn ;
+
+ public MockTestRunManagers( boolean ignoreTestClass , Result resultToReturn ) {
+ this.ignoreTestClass = ignoreTestClass ;
+ this.resultToReturn = resultToReturn;
+ }
+
+ @Override
+ public boolean anyReasonTestClassShouldBeIgnored() throws FrameworkException {
+ return ignoreTestClass;
+ }
+
+ @Override
+ public void endOfTestRun() {
+ calledCountEndOfTestRun+=1;
+ }
+
+ @Override
+ public void shutdown() {
+ calledCountShudown +=1;
+ }
+
+ @Override
+ public void provisionGenerate() throws FrameworkException {
+ calledCountProvisionGenerate +=1;
+ }
+
+ @Override
+ public void provisionBuild() throws FrameworkException {
+ calledCountProvisionBuild +=1 ;
+ }
+
+ @Override
+ public void provisionStart() throws FrameworkException {
+ calledCountProvisionStart +=1;
+ }
+
+ @Override
+ public void provisionDiscard() {
+ calledCountProvisionDiscard+=1;
+ }
+
+ @Override
+ public void provisionStop() {
+ calledCountProvisionStop +=1;
+ }
+
+ @Override
+ public void startOfTestClass() throws FrameworkException {
+ calledCountStartOfTestClass +=1;
+ }
+
+ @Override
+ public Result endOfTestClass(@NotNull Result result, Throwable currentException) throws FrameworkException {
+ calledCountEndOfTestClass +=1;
+ return resultToReturn;
+ }
+
+ @Override
+ public void testClassResult(@NotNull Result finalResult, Throwable finalException) {
+ calledCountTestClassResult +=1;
+ }
+
+ @Override
+ public Result anyReasonTestMethodShouldBeIgnored(@NotNull GalasaMethod galasaMethod) throws FrameworkException {
+ calledCountAnyReasonTestMethodShouldBeIgnored +=1;
+ return this.resultToReturn;
+ }
+
+ // ----------------- un-implemented methods follow -------------------
+
+ @Override
+ public List getActiveManagers() {
+ throw new UnsupportedOperationException("Unimplemented method 'getActiveManagers'");
+ }
+
+
+
+ @Override
+ public void fillAnnotatedFields(Object testClassObject) throws FrameworkException {
+ throw new UnsupportedOperationException("Unimplemented method 'fillAnnotatedFields'");
+ }
+
+ @Override
+ public void startOfTestMethod(@NotNull GalasaMethod galasaMethod) throws FrameworkException {
+ throw new UnsupportedOperationException("Unimplemented method 'startOfTestMethod'");
+ }
+
+ @Override
+ public Result endOfTestMethod(@NotNull GalasaMethod galasaMethod, @NotNull Result currentResult,
+ Throwable currentException) throws FrameworkException {
+ throw new UnsupportedOperationException("Unimplemented method 'endOfTestMethod'");
+ }
+
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunnerDataProvider.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunnerDataProvider.java
new file mode 100644
index 000000000..2dd76bc0d
--- /dev/null
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunnerDataProvider.java
@@ -0,0 +1,89 @@
+package dev.galasa.framework.mocks;
+
+import java.util.Properties;
+
+import dev.galasa.framework.IAnnotationExtractor;
+import dev.galasa.framework.IBundleManager;
+import dev.galasa.framework.ITestRunManagers;
+import dev.galasa.framework.ITestRunnerDataProvider;
+import dev.galasa.framework.TestRunException;
+import dev.galasa.framework.spi.IConfigurationPropertyStoreService;
+import dev.galasa.framework.spi.IDynamicStatusStoreService;
+import dev.galasa.framework.spi.IResultArchiveStore;
+import dev.galasa.framework.spi.IRun;
+import dev.galasa.framework.spi.IShutableFramework;
+import dev.galasa.framework.spi.language.GalasaTest;
+
+public class MockTestRunnerDataProvider implements ITestRunnerDataProvider {
+
+ private IConfigurationPropertyStoreService cps;
+ private IDynamicStatusStoreService dss;
+ private IResultArchiveStore ras;
+ private IRun run;
+ private IShutableFramework framework;
+ private Properties overrideProperties;
+
+ private IAnnotationExtractor annotationExtractor;
+ private IBundleManager bundleManager;
+ private ITestRunManagers testRunManagers;
+
+ public MockTestRunnerDataProvider(
+ IConfigurationPropertyStoreService cps,
+ IDynamicStatusStoreService dss,
+ IResultArchiveStore ras,
+ IRun run,
+ IShutableFramework framework,
+ Properties overrideProperties,
+ IAnnotationExtractor annotationExtractor,
+ IBundleManager bundleManager,
+ ITestRunManagers testRunManagers
+ ) {
+ this.cps = cps;
+ this.dss = dss;
+ this.ras = ras;
+ this.framework = framework;
+ this.run = run;
+ this.overrideProperties = overrideProperties;
+ this.bundleManager = bundleManager ;
+ this.annotationExtractor = annotationExtractor;
+ this.testRunManagers = testRunManagers ;
+ }
+
+ @Override
+ public IRun getRun() {
+ return run ;
+ }
+ @Override
+ public IConfigurationPropertyStoreService getCPS() {
+ return cps;
+ }
+ @Override
+ public IDynamicStatusStoreService getDSS() {
+ return dss;
+ }
+ @Override
+ public IResultArchiveStore getRAS() {
+ return ras;
+ }
+ @Override
+ public IShutableFramework getFramework() {
+ return framework;
+ }
+ @Override
+ public IBundleManager getBundleManager() {
+ return bundleManager;
+ }
+ @Override
+ public IAnnotationExtractor getAnnotationExtractor() {
+ return annotationExtractor;
+ }
+ @Override
+ public Properties getOverrideProperties() {
+ return overrideProperties;
+ }
+
+ @Override
+ public ITestRunManagers createTestRunManagers(GalasaTest galasaTest) throws TestRunException {
+ return testRunManagers ;
+ }
+}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/AbstractManagerTest.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/AbstractManagerTest.java
index 8cea907bd..d4d585e5e 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/AbstractManagerTest.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/AbstractManagerTest.java
@@ -69,7 +69,7 @@ public void provisionGenerate() throws ManagerException, ResourceUnavailableExce
@GenerateAnnotatedField(annotation = TestFieldAnnotation.class)
public Long createLong(Field field, List annotations) {
- return new Long(5);
+ return 5L;
}
@GenerateAnnotatedField(annotation = TestFieldAnnotation.class)
@@ -116,7 +116,7 @@ public void testFillingAnnotatedFields()
Assert.assertNull("field5 is present, shouldnt be", testClass.field5);
Assert.assertNotNull("field6 is missing", testClass.field6);
- Assert.assertEquals("field1 filled incorrect", new Long(5), testClass.field1);
+ Assert.assertEquals("field1 filled incorrect", (Long)5L, testClass.field1);
Assert.assertEquals("field2 filled incorrect", "boo", testClass.field2);
Assert.assertEquals("field6 filled incorrect", "eeeeek", testClass.field6);
}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/TestFieldAnnotation.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/TestFieldAnnotation.java
index e66db9aab..202218485 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/TestFieldAnnotation.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/TestFieldAnnotation.java
@@ -11,8 +11,6 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import dev.galasa.framework.spi.ValidAnnotatedFields;
-
@Retention(RUNTIME)
@Target(FIELD)
@ValidAnnotatedFields({ String.class, Long.class })
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/TestFieldAnnotation2.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/TestFieldAnnotation2.java
index 177081b36..49f4c584f 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/TestFieldAnnotation2.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/TestFieldAnnotation2.java
@@ -11,8 +11,6 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import dev.galasa.framework.spi.ValidAnnotatedFields;
-
@Retention(RUNTIME)
@Target(FIELD)
@ValidAnnotatedFields({ String.class, Long.class })
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/language/gherkin/MockRun.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/language/gherkin/MockRun.java
index ec563fe3b..d8d5c594e 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/language/gherkin/MockRun.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/language/gherkin/MockRun.java
@@ -26,122 +26,102 @@ public void setGherkin(String featureText) {
@Override
public String getName() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getName'");
+ throw new UnsupportedOperationException("Unimplemented method 'getName'");
}
@Override
public Instant getHeartbeat() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getHeartbeat'");
+ throw new UnsupportedOperationException("Unimplemented method 'getHeartbeat'");
}
@Override
public String getType() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getType'");
+ throw new UnsupportedOperationException("Unimplemented method 'getType'");
}
@Override
public String getTest() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getTest'");
+ throw new UnsupportedOperationException("Unimplemented method 'getTest'");
}
@Override
public String getStatus() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getStatus'");
+ throw new UnsupportedOperationException("Unimplemented method 'getStatus'");
}
@Override
public String getRequestor() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getRequestor'");
+ throw new UnsupportedOperationException("Unimplemented method 'getRequestor'");
}
@Override
public String getStream() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getStream'");
+ throw new UnsupportedOperationException("Unimplemented method 'getStream'");
}
@Override
public String getTestBundleName() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getTestBundleName'");
+ throw new UnsupportedOperationException("Unimplemented method 'getTestBundleName'");
}
@Override
public String getTestClassName() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getTestClassName'");
+ throw new UnsupportedOperationException("Unimplemented method 'getTestClassName'");
}
@Override
public boolean isLocal() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'isLocal'");
+ throw new UnsupportedOperationException("Unimplemented method 'isLocal'");
}
@Override
public String getGroup() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getGroup'");
+ throw new UnsupportedOperationException("Unimplemented method 'getGroup'");
}
@Override
public Instant getQueued() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getQueued'");
+ throw new UnsupportedOperationException("Unimplemented method 'getQueued'");
}
@Override
public String getRepository() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getRepository'");
+ throw new UnsupportedOperationException("Unimplemented method 'getRepository'");
}
@Override
public String getOBR() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getOBR'");
+ throw new UnsupportedOperationException("Unimplemented method 'getOBR'");
}
@Override
public boolean isTrace() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'isTrace'");
+ throw new UnsupportedOperationException("Unimplemented method 'isTrace'");
}
@Override
public Instant getFinished() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getFinished'");
+ throw new UnsupportedOperationException("Unimplemented method 'getFinished'");
}
@Override
public Instant getWaitUntil() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getWaitUntil'");
+ throw new UnsupportedOperationException("Unimplemented method 'getWaitUntil'");
}
@Override
public Run getSerializedRun() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getSerializedRun'");
+ throw new UnsupportedOperationException("Unimplemented method 'getSerializedRun'");
}
@Override
public String getResult() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'getResult'");
+ throw new UnsupportedOperationException("Unimplemented method 'getResult'");
}
@Override
public boolean isSharedEnvironment() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Unimplemented method 'isSharedEnvironment'");
+ throw new UnsupportedOperationException("Unimplemented method 'isSharedEnvironment'");
}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/language/gherkin/xform/TestParseTreeTransform.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/language/gherkin/xform/TestParseTreeTransform.java
index f522b1700..46541902d 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/language/gherkin/xform/TestParseTreeTransform.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/spi/language/gherkin/xform/TestParseTreeTransform.java
@@ -11,7 +11,6 @@
import dev.galasa.framework.spi.language.gherkin.GherkinFeature;
import dev.galasa.framework.spi.language.gherkin.GherkinMethod;
import dev.galasa.framework.spi.language.gherkin.parser.*;
-import dev.galasa.framework.spi.language.gherkin.xform.ParseTreeTransform;
import java.util.List;
import org.junit.Test;
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/test/fpf/ExceptionsTest.java b/galasa-parent/dev.galasa.framework/src/test/java/test/fpf/ExceptionsTest.java
index 1f7868ffb..36eea2ecd 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/test/fpf/ExceptionsTest.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/test/fpf/ExceptionsTest.java
@@ -110,7 +110,7 @@ public void testExceptionOfNOfileExists() {
boolean caught = false;
File nOfile = new File("/tmp/nope");
try {
- FrameworkPropertyFile fpf = new FrameworkPropertyFile(nOfile.toURI());
+ new FrameworkPropertyFile(nOfile.toURI()); // Return value not used by this test.
} catch (FrameworkPropertyFileException e) {
caught = true;
}
@@ -310,6 +310,7 @@ public void testNonUsedImpletmentedMethods() throws FrameworkPropertyFileExcepti
*/
private static class Watcher implements IFrameworkPropertyFileWatcher {
+ // TODO: What is this doing ?
private Event event;
private String key;
private String newValue;
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/test/fpf/FrameworkPropertyFileTest.java b/galasa-parent/dev.galasa.framework/src/test/java/test/fpf/FrameworkPropertyFileTest.java
index 6d9a2a59a..ed3123510 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/test/fpf/FrameworkPropertyFileTest.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/test/fpf/FrameworkPropertyFileTest.java
@@ -547,7 +547,6 @@ public void testAtomicSetMapWithNullOldvalue()
public void testAddNewWatchAndLookForDelete()
throws FrameworkPropertyFileException, URISyntaxException, IOException, InterruptedException {
String key = "watchTest";
- String newValue = "AreYouWatching";
String oldValue = "no";
URI file = testProp.toURI();
From f312d70682165f772e4a0fe2074eca79e345b3de Mon Sep 17 00:00:00 2001
From: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
Date: Fri, 16 Aug 2024 17:01:07 +0100
Subject: [PATCH 2/8] unit tests run clean, real tests fail.
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
---
.../java/dev/galasa/framework/FileSystem.java | 13 ++++++++++
.../dev/galasa/framework/IFileSystem.java | 7 +++++
.../framework/ITestRunnerDataProvider.java | 1 +
.../java/dev/galasa/framework/TestRunner.java | 17 +++++++-----
.../framework/TestRunnerDataProvider.java | 11 ++++++++
.../dev/galasa/framework/TestTestRunner.java | 10 ++++---
.../framework/mocks/MockBundleContext.java | 2 ++
.../framework/mocks/MockBundleManager.java | 4 ++-
.../framework/mocks/MockFileSystem.java | 22 ++++++++++++++++
.../mocks/MockFileSystemProvider.java | 2 +-
.../mocks/MockIDynamicStatusStoreService.java | 10 ++++---
.../mocks/MockIResultArchiveStore.java | 26 ++++++++++++-------
.../dev/galasa/framework/mocks/MockPath.java | 12 +++++----
.../mocks/MockShutableFramework.java | 12 ++++-----
.../mocks/MockTestRunnerDataProvider.java | 11 +++++++-
15 files changed, 121 insertions(+), 39 deletions(-)
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FileSystem.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FileSystem.java
index f2d506e57..e45f88277 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FileSystem.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FileSystem.java
@@ -9,8 +9,11 @@
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.attribute.FileAttribute;
import java.util.stream.Stream;
+import dev.galasa.ResultArchiveStoreContentType;
+
public class FileSystem implements IFileSystem {
public FileSystem() {
}
@@ -64,4 +67,14 @@ public String probeContentType(Path path) throws IOException {
}
return contentType;
}
+
+ @Override
+ public Path createFile(Path path, FileAttribute>... attrs) throws IOException {
+ return Files.createFile(path, attrs);
+ }
+
+ @Override
+ public void write(Path path, byte[] bytes) throws IOException {
+ Files.write(path,bytes);
+ }
}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IFileSystem.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IFileSystem.java
index e1f369376..f3898ee09 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IFileSystem.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IFileSystem.java
@@ -8,8 +8,11 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
+import java.nio.file.attribute.FileAttribute;
import java.util.stream.Stream;
+import dev.galasa.ResultArchiveStoreContentType;
+
public interface IFileSystem {
void createDirectories(Path folderPath ) throws IOException;
@@ -29,4 +32,8 @@ public interface IFileSystem {
String probeContentType(Path artifactPath) throws IOException;
InputStream newInputStream(Path folderPath) throws IOException;
+
+ Path createFile(Path path, FileAttribute>... attrs) throws IOException;
+
+ void write(Path rasProperties, byte[] bytes) throws IOException ;
}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunnerDataProvider.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunnerDataProvider.java
index e48cdce64..6df13d808 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunnerDataProvider.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunnerDataProvider.java
@@ -24,4 +24,5 @@ public interface ITestRunnerDataProvider {
public IAnnotationExtractor getAnnotationExtractor();
public Properties getOverrideProperties();
public ITestRunManagers createTestRunManagers(GalasaTest galasaTest) throws TestRunException;
+ public IFileSystem getFileSystem();
}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
index 1ac7246ee..d894e1959 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
@@ -100,6 +100,8 @@ private enum RunType {
private boolean produceEvents;
+ private IFileSystem fileSystem;
+
/**
* Run the supplied test class
@@ -121,6 +123,7 @@ public void runTest( ITestRunnerDataProvider dataProvider ) throws TestRunExcep
this.ras = dataProvider.getRAS();
this.dss = dataProvider.getDSS();
this.bundleManager = dataProvider.getBundleManager();
+ this.fileSystem = dataProvider.getFileSystem();
Properties overrideProperties = dataProvider.getOverrideProperties();
@@ -351,9 +354,9 @@ public void runTest( ITestRunnerDataProvider dataProvider ) throws TestRunExcep
updateStatus(TestRunLifecycleStatus.STARTED, "started");
// *** Try to load the Core Manager bundle, even if the test doesn't use it, and if not already active
- if (!BundleManagement.isBundleActive(bundleContext, "dev.galasa.core.manager")) {
+ if (!bundleManager.isBundleActive(bundleContext, "dev.galasa.core.manager")) {
try {
- BundleManagement.loadBundle(repositoryAdmin, bundleContext, "dev.galasa.core.manager");
+ bundleManager.loadBundle(repositoryAdmin, bundleContext, "dev.galasa.core.manager");
} catch (FrameworkException e) {
logger.warn("Tried to load the Core Manager bundle, but failed, test can continue without it",e);
}
@@ -464,7 +467,7 @@ public void runTest( ITestRunnerDataProvider dataProvider ) throws TestRunExcep
stopHeartbeat();
// *** Record all the CPS properties that were accessed
- recordCPSProperties();
+ recordCPSProperties(this.fileSystem);
// *** If this was a local run, then we will want to remove the run properties
// from the DSS immediately
@@ -479,7 +482,7 @@ public void runTest( ITestRunnerDataProvider dataProvider ) throws TestRunExcep
deleteRunProperties(this.framework);
}
} else if (this.runType == RunType.SHARED_ENVIRONMENT_BUILD) {
- recordCPSProperties();
+ recordCPSProperties(this.fileSystem);
updateStatus(TestRunLifecycleStatus.UP, "built");
} else {
logger.error("Unrecognised end condition");
@@ -822,7 +825,7 @@ public IConfigurationPropertyStoreService getCPS() {
return this.cps;
}
- private void recordCPSProperties() {
+ private void recordCPSProperties(IFileSystem fileSystem) {
try {
Properties record = this.framework.getRecordProperties();
@@ -854,8 +857,8 @@ private void recordCPSProperties() {
IResultArchiveStore ras = this.framework.getResultArchiveStore();
Path rasRoot = ras.getStoredArtifactsRoot();
Path rasProperties = rasRoot.resolve("framework").resolve("cps_record.properties");
- Files.createFile(rasProperties, ResultArchiveStoreContentType.TEXT);
- Files.write(rasProperties, sb.toString().getBytes(StandardCharsets.UTF_8));
+ fileSystem.createFile(rasProperties, ResultArchiveStoreContentType.TEXT);
+ fileSystem.write(rasProperties, sb.toString().getBytes(StandardCharsets.UTF_8));
} catch (Exception e) {
logger.error("Failed to save the recorded properties", e);
}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java
index 02ae796be..223b2a690 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java
@@ -7,6 +7,9 @@
import java.util.Properties;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import dev.galasa.framework.internal.runner.RealAnnotationExtractor;
import dev.galasa.framework.spi.FrameworkException;
import dev.galasa.framework.spi.IConfigurationPropertyStoreService;
@@ -24,7 +27,9 @@ public class TestRunnerDataProvider implements ITestRunnerDataProvider {
private IRun run;
private IShutableFramework framework;
private Properties overrideProperties;
+ private IFileSystem fileSystem;
+ private Log logger = LogFactory.getLog(TestRunnerDataProvider.class);
public TestRunnerDataProvider(Properties bootstrapProperties, Properties overrideProperties) throws TestRunException {
FrameworkInitialisation frameworkInitialisation = null;
@@ -40,6 +45,7 @@ public TestRunnerDataProvider(Properties bootstrapProperties, Properties overrid
run = framework.getTestRun();
ras = framework.getResultArchiveStore();
+ fileSystem = new FileSystem();
this.overrideProperties = overrideProperties;
@@ -97,4 +103,9 @@ public ITestRunManagers createTestRunManagers(GalasaTest galasaTest) throws Test
return managers;
}
+ @Override
+ public IFileSystem getFileSystem() {
+ return this.fileSystem;
+ }
+
}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/TestTestRunner.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/TestTestRunner.java
index e67301e03..652ac5505 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/TestTestRunner.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/TestTestRunner.java
@@ -42,8 +42,9 @@ public void testCanRunTestRunnerOK() throws Exception {
boolean TEST_IS_LOCAL_RUN_TRUE = true;
boolean IGNORE_TEST_CLASS_FALSE = false;
+ MockFileSystem mockFileSystem = new MockFileSystem();
Properties overrideProps = new Properties();
- MockIResultArchiveStore ras = new MockIResultArchiveStore("myRunId");
+ MockIResultArchiveStore ras = new MockIResultArchiveStore("myRunId", mockFileSystem );
MockIDynamicStatusStoreService dss = new MockIDynamicStatusStoreService() {
@Override
@@ -153,7 +154,8 @@ public B getAnnotation(Class testClass, Class an
overrideProps,
mockAnnotationExtractor,
mockBundleManager,
- mockTestRunManagers
+ mockTestRunManagers,
+ mockFileSystem
);
// When...
@@ -165,10 +167,10 @@ public B getAnnotation(Class testClass, Class an
assertThat(framework.isShutDown()).isTrue();
- assertThat(mockBundleManager.getLoadedBundleSymbolicNames()).hasSize(1);
+ assertThat(mockBundleManager.getLoadedBundleSymbolicNames()).hasSize(2).contains("myTestBundle","dev.galasa.core.manager");
assertThat(mockTestRunManagers.calledCountEndOfTestRun).as("End of test run was not announced").isEqualTo(1);
- assertThat(dss.data).as("dss was not left in an empty state!").isEmpty();
+ assertThat(dss.data).as("dss had more than metrics debris inside").hasSize(1).containsKey("metrics.runs.local");
assertThat(mockTestRunManagers.calledCountShudown).as("Manager not shut down").isEqualTo(1);
assertThat(mockTestRunManagers.calledCountProvisionGenerate).as("Manager not given a chance to provision").isEqualTo(1);
assertThat(mockTestRunManagers.calledCountProvisionBuild).as("Manager not get a chance to build").isEqualTo(1);
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleContext.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleContext.java
index 44d8d5c7f..84cc4eade 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleContext.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleContext.java
@@ -31,6 +31,8 @@ public MockBundleContext(
this.services = services;
this.loadedBundles = loadedBundles;
}
+
+ // --------------- un-implemented methods follow --------------------
@Override
public String getProperty(String key) {
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleManager.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleManager.java
index 3c4b3748c..012deb837 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleManager.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleManager.java
@@ -30,9 +30,11 @@ public List getLoadedBundleSymbolicNames() {
@Override
public boolean isBundleActive(BundleContext bundleContext, String bundleSymbolicName) {
- throw new UnsupportedOperationException("Unimplemented method 'isBundleActive'");
+ return loadedSymbolicNames.contains(bundleSymbolicName);
}
+ // --------------- un-implemented methods follow --------------------
+
@Override
public void loadAllGherkinManagerBundles(RepositoryAdmin repositoryAdmin, BundleContext bundleContext)
throws FrameworkException {
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockFileSystem.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockFileSystem.java
index e863a1c9d..1ad8d4fba 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockFileSystem.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockFileSystem.java
@@ -12,6 +12,7 @@
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.WatchService;
+import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.UserPrincipalLookupService;
import java.nio.file.spi.FileSystemProvider;
import java.util.*;
@@ -185,6 +186,25 @@ public InputStream newInputStream(Path folderPath) throws IOException {
return null;
}
+ @Override
+ public Path createFile(Path path, FileAttribute>... attrs) throws IOException {
+ createFile(path);
+ return path;
+ }
+
+ @Override
+ public void write(Path path, byte[] bytes) throws IOException {
+ Node node = this.files.get(path.toString());
+ if (node != null) {
+ node.contents = bytes;
+ } else {
+ createNode(path, false);
+ write(path,bytes);
+ }
+ }
+
+ // -------------- Un-implemented methods follow ------------------
+
@Override
public void close() throws IOException {
throw new UnsupportedOperationException("Unimplemented method 'close'");
@@ -234,4 +254,6 @@ public UserPrincipalLookupService getUserPrincipalLookupService() {
public WatchService newWatchService() throws IOException {
throw new UnsupportedOperationException("Unimplemented method 'newWatchService'");
}
+
+
}
\ No newline at end of file
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockFileSystemProvider.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockFileSystemProvider.java
index 578ded29e..e5da8051a 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockFileSystemProvider.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockFileSystemProvider.java
@@ -77,7 +77,7 @@ public DirectoryStream newDirectoryStream(Path dir, Filter super Path> f
@Override
public SeekableByteChannel newByteChannel(Path path, Set extends OpenOption> options, FileAttribute>... attrs) throws IOException {
if (!mockFS.exists(path)) {
- throw new IOException("File not found!");
+ throw new IOException("File not found! "+path.toString());
}
byte[] contents = mockFS.getContentsAsBytes(path);
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIDynamicStatusStoreService.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIDynamicStatusStoreService.java
index 594fd6663..c77eee0d8 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIDynamicStatusStoreService.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIDynamicStatusStoreService.java
@@ -36,6 +36,11 @@ public void delete(@NotNull String key) throws DynamicStatusStoreException {
data.remove(key);
}
+ @Override
+ public @Null String get(@NotNull String key) throws DynamicStatusStoreException {
+ return data.get(key);
+ }
+
// ------------------- un-implemented methods follow --------------------
@Override
@@ -55,10 +60,7 @@ public boolean putSwap(@NotNull String key, String oldValue, @NotNull String new
throw new UnsupportedOperationException("Unimplemented method 'putSwap'");
}
- @Override
- public @Null String get(@NotNull String key) throws DynamicStatusStoreException {
- throw new UnsupportedOperationException("Unimplemented method 'get'");
- }
+
@Override
public @NotNull Map getPrefix(@NotNull String keyPrefix) throws DynamicStatusStoreException {
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIResultArchiveStore.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIResultArchiveStore.java
index ec36a8081..ad8439f0a 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIResultArchiveStore.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIResultArchiveStore.java
@@ -21,16 +21,21 @@
public class MockIResultArchiveStore implements IResultArchiveStore {
List testStructureHistory = new ArrayList<>();
+ MockFileSystem mockFS ;
+ StringBuffer runLog = new StringBuffer();
private String runId ;
- public MockIResultArchiveStore(String runId) {
+ public MockIResultArchiveStore(String runId, MockFileSystem mockFileSystem) {
this.runId = runId;
+ this.mockFS = mockFileSystem;
}
@Override
public void updateTestStructure(@NotNull TestStructure testStructure) throws ResultArchiveStoreException {
assertThat(testStructure).isNotNull();
testStructureHistory.add(testStructure);
+
+ mockFS.setFileContents(mockFS.getPath("/my/stored/artifacts/root/framework/cps_record.properties"), "Dummy test content");
}
@Override
@@ -44,24 +49,27 @@ public List getTestStructureHistory() {
@Override
public void flush() {
- // Do nothing.
+ Path logFilePath = mockFS.getPath("/my/stored/artifacts/root/run.log");
+ mockFS.setFileContents(logFilePath, runLog.toString());
}
- // --------------- un-implemented methods follow --------------------
-
@Override
- public void writeLog(@NotNull String message) throws ResultArchiveStoreException {
- throw new UnsupportedOperationException("Unimplemented method 'writeLog'");
+ public Path getStoredArtifactsRoot() {
+ return mockFS.getPath("/my/stored/artifacts/root");
}
@Override
public void writeLog(@NotNull List messages) throws ResultArchiveStoreException {
- throw new UnsupportedOperationException("Unimplemented method 'writeLog'");
+ for (String line : messages) {
+ runLog.append(line);
+ }
}
+ // --------------- un-implemented methods follow --------------------
+
@Override
- public Path getStoredArtifactsRoot() {
- throw new UnsupportedOperationException("Unimplemented method 'getStoredArtifactsRoot'");
+ public void writeLog(@NotNull String message) throws ResultArchiveStoreException {
+ throw new UnsupportedOperationException("Unimplemented method 'writeLog'");
}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockPath.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockPath.java
index d3a2d4511..c473ae898 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockPath.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockPath.java
@@ -59,6 +59,13 @@ public Path getFileName() {
return null;
}
+ @Override
+ public Path resolve(Path other) {
+ return new MockPath(this.path + "/" + other.toString(), fileSystem );
+ }
+
+
+
@Override
public boolean isAbsolute() {
throw new UnsupportedOperationException("Unimplemented method 'isAbsolute'");
@@ -100,11 +107,6 @@ public Path normalize() {
throw new UnsupportedOperationException("Unimplemented method 'normalize'");
}
- @Override
- public Path resolve(Path other) {
- throw new UnsupportedOperationException("Unimplemented method 'resolve'");
- }
-
@Override
public Path relativize(Path other) {
throw new UnsupportedOperationException("Unimplemented method 'relativize'");
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockShutableFramework.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockShutableFramework.java
index 929a54115..05de9c495 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockShutableFramework.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockShutableFramework.java
@@ -91,6 +91,11 @@ public IFrameworkRuns getFrameworkRuns() throws FrameworkException {
return frameworkRuns ;
}
+ @Override
+ public Properties getRecordProperties() {
+ return new Properties();
+ }
+
// ----------------- un-implemented methods follow -------------------
@Override
@@ -148,13 +153,6 @@ public boolean isInitialised() {
public Random getRandom() {
throw new UnsupportedOperationException("Unimplemented method 'getRandom'");
}
-
- @Override
- public Properties getRecordProperties() {
- throw new UnsupportedOperationException("Unimplemented method 'getRecordProperties'");
- }
-
- @Override
public URL getApiUrl(@NotNull Api api) throws FrameworkException {
throw new UnsupportedOperationException("Unimplemented method 'getApiUrl'");
}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunnerDataProvider.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunnerDataProvider.java
index 2dd76bc0d..fee58ac22 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunnerDataProvider.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunnerDataProvider.java
@@ -4,6 +4,7 @@
import dev.galasa.framework.IAnnotationExtractor;
import dev.galasa.framework.IBundleManager;
+import dev.galasa.framework.IFileSystem;
import dev.galasa.framework.ITestRunManagers;
import dev.galasa.framework.ITestRunnerDataProvider;
import dev.galasa.framework.TestRunException;
@@ -26,6 +27,7 @@ public class MockTestRunnerDataProvider implements ITestRunnerDataProvider {
private IAnnotationExtractor annotationExtractor;
private IBundleManager bundleManager;
private ITestRunManagers testRunManagers;
+ private IFileSystem fileSystem;
public MockTestRunnerDataProvider(
IConfigurationPropertyStoreService cps,
@@ -36,7 +38,8 @@ public MockTestRunnerDataProvider(
Properties overrideProperties,
IAnnotationExtractor annotationExtractor,
IBundleManager bundleManager,
- ITestRunManagers testRunManagers
+ ITestRunManagers testRunManagers,
+ IFileSystem fileSystem
) {
this.cps = cps;
this.dss = dss;
@@ -47,6 +50,7 @@ public MockTestRunnerDataProvider(
this.bundleManager = bundleManager ;
this.annotationExtractor = annotationExtractor;
this.testRunManagers = testRunManagers ;
+ this.fileSystem = fileSystem;
}
@Override
@@ -86,4 +90,9 @@ public Properties getOverrideProperties() {
public ITestRunManagers createTestRunManagers(GalasaTest galasaTest) throws TestRunException {
return testRunManagers ;
}
+
+ @Override
+ public IFileSystem getFileSystem() {
+ return this.fileSystem;
+ }
}
From 4f7708e3f639bb7e1e6aff36c626827a280083bc Mon Sep 17 00:00:00 2001
From: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
Date: Mon, 19 Aug 2024 16:52:28 +0100
Subject: [PATCH 3/8] real tests are running again.
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
---
.gitignore | 2 ++
.../src/main/java/dev/galasa/framework/Framework.java | 8 +++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index a7de08156..84239bae4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,3 +38,5 @@ temp/
# Ignore the OpenAPI spec that is automatically placed into the
# resources folder to be served up by the OpenAPI servlet
**/dev.galasa.framework.api.openapi.servlet/**/openapi.yaml
+
+run-test.sh
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/Framework.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/Framework.java
index ee0f53d10..b45d0cf67 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/Framework.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/Framework.java
@@ -36,8 +36,14 @@
import dev.galasa.framework.spi.creds.ICredentialsService;
import dev.galasa.framework.spi.creds.ICredentialsStore;
+// I know that the IFramework class isn't strictly necessary, but it does seem to make a
+// difference to whether the OSGi framework can load it or not.
+// Something about it only looking for implementations of IFramework explicitly, rather than
+// looking for all the things which are super-interfaces of IFramework also.
+// So we leave in the IFramework below, and supress any warning we might get.
+@SuppressWarnings("unused")
@Component(immediate = true, scope = ServiceScope.SINGLETON)
-public class Framework implements IShutableFramework {
+public class Framework implements IFramework, IShutableFramework {
private final static Log logger = LogFactory.getLog(Framework.class);
From 367896cf9ec34252d1cd1a5f59ab615d907b6c6c Mon Sep 17 00:00:00 2001
From: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
Date: Tue, 20 Aug 2024 09:33:30 +0100
Subject: [PATCH 4/8] unit testing java test runner. Updating based on comments
in PR 618
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
---
.../dev/galasa/framework/BundleManager.java | 5 +
.../framework/IAnnotationExtractor.java | 16 ++-
.../java/dev/galasa/framework/TestRunner.java | 1 -
.../framework/TestRunnerDataProvider.java | 11 +-
.../framework/mocks/MockBundleContext.java | 130 +++++++++---------
5 files changed, 86 insertions(+), 77 deletions(-)
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/BundleManager.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/BundleManager.java
index e367a28de..36d8a6bff 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/BundleManager.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/BundleManager.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright contributors to the Galasa project
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
package dev.galasa.framework;
import org.apache.felix.bundlerepository.RepositoryAdmin;
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IAnnotationExtractor.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IAnnotationExtractor.java
index 2e93f6fb7..536809e89 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IAnnotationExtractor.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IAnnotationExtractor.java
@@ -7,6 +7,20 @@
import java.lang.annotation.Annotation;
-public interface IAnnotationExtractor {
+/**
+ * Something which can extract annotations from something can be an AnnotationExtractor
+ */
+public interface IAnnotationExtractor {
+ /**
+ * @param The type of testclass we are extracting something from.
+ * This will vary wildly based on what the users' test class is.
+ * @param The annotation type we want to extract.
+ * Having this as a generic type allows this logic to be used for
+ * any of the annotations we want to extract.
+ * B must extend Annotation.
+ * @param testClass The test class we want annotations extracted from.
+ * @param annotationClass The annotation class we want to use.
+ * @return An instance of the annotationClass, extracted from the test class.
+ */
public B getAnnotation (Class testClass, Class annotationClass);
}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
index d894e1959..d111e781c 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
@@ -8,7 +8,6 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java
index 223b2a690..3e9cab4e4 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java
@@ -7,16 +7,8 @@
import java.util.Properties;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import dev.galasa.framework.internal.runner.RealAnnotationExtractor;
-import dev.galasa.framework.spi.FrameworkException;
-import dev.galasa.framework.spi.IConfigurationPropertyStoreService;
-import dev.galasa.framework.spi.IDynamicStatusStoreService;
-import dev.galasa.framework.spi.IResultArchiveStore;
-import dev.galasa.framework.spi.IRun;
-import dev.galasa.framework.spi.IShutableFramework;
+import dev.galasa.framework.spi.*;
import dev.galasa.framework.spi.language.GalasaTest;
public class TestRunnerDataProvider implements ITestRunnerDataProvider {
@@ -29,7 +21,6 @@ public class TestRunnerDataProvider implements ITestRunnerDataProvider {
private Properties overrideProperties;
private IFileSystem fileSystem;
- private Log logger = LogFactory.getLog(TestRunnerDataProvider.class);
public TestRunnerDataProvider(Properties bootstrapProperties, Properties overrideProperties) throws TestRunException {
FrameworkInitialisation frameworkInitialisation = null;
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleContext.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleContext.java
index 84cc4eade..f8fd5b786 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleContext.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockBundleContext.java
@@ -31,7 +31,70 @@ public MockBundleContext(
this.services = services;
this.loadedBundles = loadedBundles;
}
+
+ @Override
+ public Bundle[] getBundles() {
+ Bundle[] result = new Bundle[loadedBundles.size()];
+ loadedBundles.toArray(result);
+ return result;
+ }
+ @Override
+ public ServiceReference>[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
+ int count = 0;
+ for( Entry> entry : this.services.entrySet() ) {
+ if(entry.getKey().equals(clazz)) {
+ count++;
+ }
+ }
+
+ ServiceReference>[] allServiceReferences = new ServiceReference>[count];
+
+ int i=0;
+ for( Entry> entry : this.services.entrySet() ) {
+ if(entry.getKey().equals(clazz)) {
+ allServiceReferences[i] = entry.getValue();
+ i++;
+ }
+ }
+
+ return allServiceReferences;
+ }
+
+ @Override
+ public ServiceReference> getServiceReference(String clazz) {
+ // logger.info("getServiceReference(String clazz="+clazz+")");
+ ServiceReference> ref = this.services.get(clazz);
+ return ref;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public ServiceReference getServiceReference(Class clazz) {
+ // logger.info("getServiceReference(Class clazz="+clazz.getName()+")");
+ String className = clazz.getName();
+ ServiceReference result ;
+
+ ServiceReference> rawRef = getServiceReference(className);
+
+ result = (ServiceReference)rawRef;
+ return result;
+ }
+
+ @Override
+ public Collection> getServiceReferences(Class clazz, String filter)
+ throws InvalidSyntaxException {
+ throw new UnsupportedOperationException("Unimplemented method 'getServiceReferences'");
+ }
+
+ @Override
+ public S getService(ServiceReference reference) {
+ // logger.info("getService(ServiceReference reference="+reference.getClass().getName()+")");
+
+ S result = ((MockServiceReference)reference).getService();
+ return result;
+ }
+
// --------------- un-implemented methods follow --------------------
@Override
@@ -58,14 +121,7 @@ public Bundle installBundle(String location) throws BundleException {
public Bundle getBundle(long id) {
throw new UnsupportedOperationException("Unimplemented method 'getBundle'");
}
-
- @Override
- public Bundle[] getBundles() {
- Bundle[] result = new Bundle[loadedBundles.size()];
- loadedBundles.toArray(result);
- return result;
- }
-
+
@Override
public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException {
throw new UnsupportedOperationException("Unimplemented method 'addServiceListener'");
@@ -90,7 +146,7 @@ public void addBundleListener(BundleListener listener) {
public void removeBundleListener(BundleListener listener) {
throw new UnsupportedOperationException("Unimplemented method 'removeBundleListener'");
}
-
+
@Override
public void addFrameworkListener(FrameworkListener listener) {
throw new UnsupportedOperationException("Unimplemented method 'addFrameworkListener'");
@@ -127,62 +183,6 @@ public ServiceReference>[] getServiceReferences(String clazz, String filter) t
throw new UnsupportedOperationException("Unimplemented method 'getServiceReferences'");
}
- @Override
- public ServiceReference>[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
- int count = 0;
- for( Entry> entry : this.services.entrySet() ) {
- if(entry.getKey().equals(clazz)) {
- count++;
- }
- }
-
- ServiceReference>[] allServiceReferences = new ServiceReference>[count];
-
- int i=0;
- for( Entry> entry : this.services.entrySet() ) {
- if(entry.getKey().equals(clazz)) {
- allServiceReferences[i] = entry.getValue();
- i++;
- }
- }
-
- return allServiceReferences;
- }
-
- @Override
- public ServiceReference> getServiceReference(String clazz) {
- // logger.info("getServiceReference(String clazz="+clazz+")");
- ServiceReference> ref = this.services.get(clazz);
- return ref;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public ServiceReference getServiceReference(Class clazz) {
- // logger.info("getServiceReference(Class clazz="+clazz.getName()+")");
- String className = clazz.getName();
- ServiceReference result ;
-
- ServiceReference> rawRef = getServiceReference(className);
-
- result = (ServiceReference)rawRef;
- return result;
- }
-
- @Override
- public Collection> getServiceReferences(Class clazz, String filter)
- throws InvalidSyntaxException {
- throw new UnsupportedOperationException("Unimplemented method 'getServiceReferences'");
- }
-
- @Override
- public S getService(ServiceReference reference) {
- // logger.info("getService(ServiceReference reference="+reference.getClass().getName()+")");
-
- S result = ((MockServiceReference)reference).getService();
- return result;
- }
-
@Override
public boolean ungetService(ServiceReference> reference) {
throw new UnsupportedOperationException("Unimplemented method 'ungetService'");
From e879574991f2be50974ef8e3c5237000881aaff3 Mon Sep 17 00:00:00 2001
From: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
Date: Tue, 20 Aug 2024 10:48:07 +0100
Subject: [PATCH 5/8] moved bundleManager into internal package
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
---
.../src/main/java/dev/galasa/framework/FileSystem.java | 2 --
.../java/dev/galasa/framework/TestRunnerDataProvider.java | 1 +
.../galasa/framework/{ => internal/runner}/BundleManager.java | 4 +++-
3 files changed, 4 insertions(+), 3 deletions(-)
rename galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/{ => internal/runner}/BundleManager.java (88%)
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FileSystem.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FileSystem.java
index e45f88277..01c028524 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FileSystem.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FileSystem.java
@@ -12,8 +12,6 @@
import java.nio.file.attribute.FileAttribute;
import java.util.stream.Stream;
-import dev.galasa.ResultArchiveStoreContentType;
-
public class FileSystem implements IFileSystem {
public FileSystem() {
}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java
index 3e9cab4e4..26d991137 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java
@@ -7,6 +7,7 @@
import java.util.Properties;
+import dev.galasa.framework.internal.runner.BundleManager;
import dev.galasa.framework.internal.runner.RealAnnotationExtractor;
import dev.galasa.framework.spi.*;
import dev.galasa.framework.spi.language.GalasaTest;
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/BundleManager.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/runner/BundleManager.java
similarity index 88%
rename from galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/BundleManager.java
rename to galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/runner/BundleManager.java
index 36d8a6bff..b3dab7125 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/BundleManager.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/runner/BundleManager.java
@@ -3,11 +3,13 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
-package dev.galasa.framework;
+package dev.galasa.framework.internal.runner;
import org.apache.felix.bundlerepository.RepositoryAdmin;
import org.osgi.framework.BundleContext;
+import dev.galasa.framework.BundleManagement;
+import dev.galasa.framework.IBundleManager;
import dev.galasa.framework.spi.FrameworkException;
public class BundleManager implements IBundleManager {
From 803971709470e3d0d0a232160fbffcb73ac98361 Mon Sep 17 00:00:00 2001
From: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
Date: Tue, 20 Aug 2024 10:51:07 +0100
Subject: [PATCH 6/8] moving some classes to the internal package
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
---
.../main/java/dev/galasa/framework/TestRunner.java | 1 +
.../runner}/TestRunnerDataProvider.java | 13 ++++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
rename galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/{ => internal/runner}/TestRunnerDataProvider.java (86%)
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
index d111e781c..6675d05a9 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
@@ -33,6 +33,7 @@
import dev.galasa.ResultArchiveStoreContentType;
import dev.galasa.SharedEnvironment;
import dev.galasa.Test;
+import dev.galasa.framework.internal.runner.TestRunnerDataProvider;
import dev.galasa.framework.maven.repository.spi.IMavenRepository;
import dev.galasa.framework.spi.AbstractManager;
import dev.galasa.framework.spi.ConfigurationPropertyStoreException;
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/runner/TestRunnerDataProvider.java
similarity index 86%
rename from galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java
rename to galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/runner/TestRunnerDataProvider.java
index 26d991137..5e8f5aa11 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunnerDataProvider.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/runner/TestRunnerDataProvider.java
@@ -3,12 +3,19 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
-package dev.galasa.framework;
+package dev.galasa.framework.internal.runner;
import java.util.Properties;
-import dev.galasa.framework.internal.runner.BundleManager;
-import dev.galasa.framework.internal.runner.RealAnnotationExtractor;
+import dev.galasa.framework.FileSystem;
+import dev.galasa.framework.FrameworkInitialisation;
+import dev.galasa.framework.IAnnotationExtractor;
+import dev.galasa.framework.IBundleManager;
+import dev.galasa.framework.IFileSystem;
+import dev.galasa.framework.ITestRunManagers;
+import dev.galasa.framework.ITestRunnerDataProvider;
+import dev.galasa.framework.TestRunException;
+import dev.galasa.framework.TestRunManagers;
import dev.galasa.framework.spi.*;
import dev.galasa.framework.spi.language.GalasaTest;
From fb3d9aaf156b9072c9c6780e8cd598a3de1bff1c Mon Sep 17 00:00:00 2001
From: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
Date: Tue, 20 Aug 2024 13:00:50 +0100
Subject: [PATCH 7/8] move some classes into the internal package.
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
---
.../src/main/java/dev/galasa/framework/Framework.java | 2 +-
.../dev/galasa/framework/FrameworkInitialisation.java | 2 +-
.../src/main/java/dev/galasa/framework/IFileSystem.java | 2 --
.../dev/galasa/framework/ITestRunnerDataProvider.java | 4 ++--
.../src/main/java/dev/galasa/framework/TestRunner.java | 4 ++--
.../framework/internal/runner/TestRunnerDataProvider.java | 4 ++--
.../{IShutableFramework.java => IShuttableFramework.java} | 2 +-
.../dev/galasa/framework/mocks/MockShutableFramework.java | 4 ++--
.../framework/mocks/MockTestRunnerDataProvider.java | 8 ++++----
9 files changed, 15 insertions(+), 17 deletions(-)
rename galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/{IShutableFramework.java => IShuttableFramework.java} (76%)
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/Framework.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/Framework.java
index b45d0cf67..f12e59bfc 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/Framework.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/Framework.java
@@ -43,7 +43,7 @@
// So we leave in the IFramework below, and supress any warning we might get.
@SuppressWarnings("unused")
@Component(immediate = true, scope = ServiceScope.SINGLETON)
-public class Framework implements IFramework, IShutableFramework {
+public class Framework implements IFramework, IShuttableFramework {
private final static Log logger = LogFactory.getLog(Framework.class);
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FrameworkInitialisation.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FrameworkInitialisation.java
index e768f22db..b614aec57 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FrameworkInitialisation.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/FrameworkInitialisation.java
@@ -401,7 +401,7 @@ public void registerEventsService(@NotNull IEventsService eventsService) throws
return this.framework;
}
- public @NotNull IShutableFramework getShutableFramework() {
+ public @NotNull IShuttableFramework getShutableFramework() {
return this.framework;
}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IFileSystem.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IFileSystem.java
index f3898ee09..bed3d5ab2 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IFileSystem.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IFileSystem.java
@@ -11,8 +11,6 @@
import java.nio.file.attribute.FileAttribute;
import java.util.stream.Stream;
-import dev.galasa.ResultArchiveStoreContentType;
-
public interface IFileSystem {
void createDirectories(Path folderPath ) throws IOException;
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunnerDataProvider.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunnerDataProvider.java
index 6df13d808..ddae251b5 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunnerDataProvider.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/ITestRunnerDataProvider.java
@@ -11,7 +11,7 @@
import dev.galasa.framework.spi.IDynamicStatusStoreService;
import dev.galasa.framework.spi.IResultArchiveStore;
import dev.galasa.framework.spi.IRun;
-import dev.galasa.framework.spi.IShutableFramework;
+import dev.galasa.framework.spi.IShuttableFramework;
import dev.galasa.framework.spi.language.GalasaTest;
public interface ITestRunnerDataProvider {
@@ -19,7 +19,7 @@ public interface ITestRunnerDataProvider {
public IConfigurationPropertyStoreService getCPS();
public IDynamicStatusStoreService getDSS();
public IResultArchiveStore getRAS();
- public IShutableFramework getFramework();
+ public IShuttableFramework getFramework();
public IBundleManager getBundleManager();
public IAnnotationExtractor getAnnotationExtractor();
public Properties getOverrideProperties();
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
index 6675d05a9..f1590594c 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java
@@ -47,7 +47,7 @@
import dev.galasa.framework.spi.IManager;
import dev.galasa.framework.spi.IResultArchiveStore;
import dev.galasa.framework.spi.IRun;
-import dev.galasa.framework.spi.IShutableFramework;
+import dev.galasa.framework.spi.IShuttableFramework;
import dev.galasa.framework.spi.Result;
import dev.galasa.framework.spi.ResultArchiveStoreException;
import dev.galasa.framework.spi.SharedEnvironmentRunType;
@@ -95,7 +95,7 @@ private enum RunType {
private boolean isRunOK = true;
private boolean resourcesAvailable = true;
- private IShutableFramework framework;
+ private IShuttableFramework framework;
private IBundleManager bundleManager;
private boolean produceEvents;
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/runner/TestRunnerDataProvider.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/runner/TestRunnerDataProvider.java
index 5e8f5aa11..80cac9368 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/runner/TestRunnerDataProvider.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/runner/TestRunnerDataProvider.java
@@ -25,7 +25,7 @@ public class TestRunnerDataProvider implements ITestRunnerDataProvider {
private IDynamicStatusStoreService dss;
private IResultArchiveStore ras;
private IRun run;
- private IShutableFramework framework;
+ private IShuttableFramework framework;
private Properties overrideProperties;
private IFileSystem fileSystem;
@@ -71,7 +71,7 @@ public IResultArchiveStore getRAS() {
}
@Override
- public IShutableFramework getFramework() {
+ public IShuttableFramework getFramework() {
return this.framework;
}
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/IShutableFramework.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/IShuttableFramework.java
similarity index 76%
rename from galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/IShutableFramework.java
rename to galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/IShuttableFramework.java
index 1dc16badf..d45eba589 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/IShutableFramework.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/IShuttableFramework.java
@@ -5,6 +5,6 @@
*/
package dev.galasa.framework.spi;
-public interface IShutableFramework extends IFramework {
+public interface IShuttableFramework extends IFramework {
public void shutdown() throws FrameworkException ;
}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockShutableFramework.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockShutableFramework.java
index 05de9c495..10e2cfe83 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockShutableFramework.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockShutableFramework.java
@@ -23,7 +23,7 @@
import dev.galasa.framework.spi.IResourcePoolingService;
import dev.galasa.framework.spi.IResultArchiveStore;
import dev.galasa.framework.spi.IRun;
-import dev.galasa.framework.spi.IShutableFramework;
+import dev.galasa.framework.spi.IShuttableFramework;
import dev.galasa.framework.spi.SharedEnvironmentRunType;
import dev.galasa.framework.spi.auth.IAuthStore;
import dev.galasa.framework.spi.auth.IAuthStoreService;
@@ -32,7 +32,7 @@
import static org.assertj.core.api.Assertions.*;
-public class MockShutableFramework implements IShutableFramework {
+public class MockShutableFramework implements IShuttableFramework {
private boolean isShutDown = false;
private IResultArchiveStore ras ;
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunnerDataProvider.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunnerDataProvider.java
index fee58ac22..bac716ec9 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunnerDataProvider.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockTestRunnerDataProvider.java
@@ -12,7 +12,7 @@
import dev.galasa.framework.spi.IDynamicStatusStoreService;
import dev.galasa.framework.spi.IResultArchiveStore;
import dev.galasa.framework.spi.IRun;
-import dev.galasa.framework.spi.IShutableFramework;
+import dev.galasa.framework.spi.IShuttableFramework;
import dev.galasa.framework.spi.language.GalasaTest;
public class MockTestRunnerDataProvider implements ITestRunnerDataProvider {
@@ -21,7 +21,7 @@ public class MockTestRunnerDataProvider implements ITestRunnerDataProvider {
private IDynamicStatusStoreService dss;
private IResultArchiveStore ras;
private IRun run;
- private IShutableFramework framework;
+ private IShuttableFramework framework;
private Properties overrideProperties;
private IAnnotationExtractor annotationExtractor;
@@ -34,7 +34,7 @@ public MockTestRunnerDataProvider(
IDynamicStatusStoreService dss,
IResultArchiveStore ras,
IRun run,
- IShutableFramework framework,
+ IShuttableFramework framework,
Properties overrideProperties,
IAnnotationExtractor annotationExtractor,
IBundleManager bundleManager,
@@ -70,7 +70,7 @@ public IResultArchiveStore getRAS() {
return ras;
}
@Override
- public IShutableFramework getFramework() {
+ public IShuttableFramework getFramework() {
return framework;
}
@Override
From 3e4beeaaab1a5842afbbf2ed333837beadeae893 Mon Sep 17 00:00:00 2001
From: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
Date: Tue, 20 Aug 2024 16:29:00 +0100
Subject: [PATCH 8/8] fixes from review comments on PR 618
Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com>
---
.../dev/galasa/framework/IBundleManager.java | 2 +-
.../spi/teststructure/TestStructure.java | 35 +++++++++-
.../dev/galasa/framework/TestTestRunner.java | 65 ++++++++++++++++++-
.../mocks/MockIDynamicStatusStoreService.java | 31 +++++++--
.../mocks/MockIResultArchiveStore.java | 3 +-
5 files changed, 128 insertions(+), 8 deletions(-)
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IBundleManager.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IBundleManager.java
index 502611cb4..86649528b 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IBundleManager.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/IBundleManager.java
@@ -18,7 +18,7 @@ public interface IBundleManager {
* Is the supplied active in the OSGi framework
* @param bundleContext
* @param bundleSymbolicName
- * @return true if it is ib the or false
+ * @return true if it is active or false otherwise.
*/
public boolean isBundleActive(BundleContext bundleContext, String bundleSymbolicName);
diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/teststructure/TestStructure.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/teststructure/TestStructure.java
index d1ed151ad..d77d587d5 100644
--- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/teststructure/TestStructure.java
+++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/spi/teststructure/TestStructure.java
@@ -6,7 +6,7 @@
package dev.galasa.framework.spi.teststructure;
import java.time.Instant;
-import java.util.List;
+import java.util.*;
import javax.validation.constraints.NotNull;
@@ -42,6 +42,39 @@ public class TestStructure {
private List artifactRecordIds;
+ public TestStructure() {
+ }
+
+ public TestStructure( TestStructure source ) {
+ if (source!=null) {
+ this.runName = source.runName;
+ this.bundle = source.bundle;
+ this.testName = source.testName;
+ this.testShortName = source.testShortName;
+ this.requestor = source.requestor;
+ this.status = source.status;
+ this.result = source.result;
+ this.queued = source.queued;
+ this.endTime = source.endTime;
+ if (source.methods != null) {
+ this.methods = new ArrayList();
+ this.methods.addAll(source.methods);
+ }
+ if (source.gherkinMethods!= null) {
+ this.gherkinMethods = new ArrayList();
+ this.gherkinMethods.addAll(source.gherkinMethods);
+ }
+ if (source.logRecordIds != null) {
+ this.logRecordIds = new ArrayList();
+ this.logRecordIds.addAll(source.logRecordIds);
+ }
+ if (source.artifactRecordIds != null ) {
+ this.artifactRecordIds = new ArrayList();
+ this.artifactRecordIds.addAll(source.artifactRecordIds);
+ }
+ }
+ }
+
public String getBundle() {
return bundle;
}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/TestTestRunner.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/TestTestRunner.java
index 652ac5505..5428330a3 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/TestTestRunner.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/TestTestRunner.java
@@ -162,8 +162,71 @@ public B getAnnotation(Class testClass, Class an
runner.runTest(testRunData);
/// Then...
+
+ // Check the RAS history
List rasHistory = ras.getTestStructureHistory();
- assertThat(rasHistory).hasSize(9).extracting("status").contains("finished","finished");
+ assertThat(rasHistory).hasSize(9);
+
+ // initial setup.
+ assertThat(rasHistory.get(0)).extracting("runName","bundle", "testName", "testShortName", "requestor", "status", "result")
+ .containsExactly("myTestRun",null,null, null, "daffyduck", null,null);
+
+ // status = started
+ assertThat(rasHistory.get(1)).extracting("runName","bundle", "testName", "testShortName", "requestor", "status", "result")
+ .containsExactly("myTestRun",null,null, null, "daffyduck", "started",null);
+
+ // status = generating
+ assertThat(rasHistory.get(2)).extracting("runName","bundle", "testName", "testShortName", "requestor", "status", "result")
+ .containsExactly("myTestRun","myTestBundle","dev.galasa.framework.MyActualTestClass", "MyActualTestClass", "daffyduck", "generating",null);
+
+ // status = building
+ assertThat(rasHistory.get(3)).extracting("runName","bundle", "testName", "testShortName", "requestor", "status", "result")
+ .containsExactly("myTestRun","myTestBundle","dev.galasa.framework.MyActualTestClass", "MyActualTestClass", "daffyduck", "building",null);
+
+ // status = provstart
+ assertThat(rasHistory.get(4)).extracting("runName","bundle", "testName", "testShortName", "requestor", "status", "result")
+ .containsExactly("myTestRun","myTestBundle","dev.galasa.framework.MyActualTestClass", "MyActualTestClass", "daffyduck", "provstart",null);
+
+ // status = running
+ assertThat(rasHistory.get(5)).extracting("runName","bundle", "testName", "testShortName", "requestor", "status", "result")
+ .containsExactly("myTestRun","myTestBundle","dev.galasa.framework.MyActualTestClass", "MyActualTestClass", "daffyduck", "running",null);
+
+ // status = rundone
+ assertThat(rasHistory.get(6)).extracting("runName","bundle", "testName", "testShortName", "requestor", "status", "result")
+ .containsExactly("myTestRun","myTestBundle","dev.galasa.framework.MyActualTestClass", "MyActualTestClass", "daffyduck", "rundone","Passed");
+
+ // status = ending
+ assertThat(rasHistory.get(7)).extracting("runName","bundle", "testName", "testShortName", "requestor", "status", "result")
+ .containsExactly("myTestRun","myTestBundle","dev.galasa.framework.MyActualTestClass", "MyActualTestClass", "daffyduck", "ending","Passed");
+
+ // status = finished
+ assertThat(rasHistory.get(8)).extracting("runName","bundle", "testName", "testShortName", "requestor", "status", "result")
+ .containsExactly("myTestRun","myTestBundle","dev.galasa.framework.MyActualTestClass", "MyActualTestClass", "daffyduck", "finished","Passed");
+
+
+ // Check the DSS history
+ assertThat(dss.history).as("history of activity within the DSS indicates it was used an unexpected number of times").hasSize(7);
+
+ assertThat(dss.history.get(0)).extracting("operation","key")
+ .containsExactly(MockIDynamicStatusStoreService.DssHistoryRecordType.PUT, "run.myTestRun.heartbeat");
+
+ assertThat(dss.history.get(1)).extracting("operation","key")
+ .containsExactly(MockIDynamicStatusStoreService.DssHistoryRecordType.PUT, "run.myTestRun.heartbeat");
+
+ assertThat(dss.history.get(2)).extracting("operation","key")
+ .containsExactly(MockIDynamicStatusStoreService.DssHistoryRecordType.PUT, "metrics.runs.local");
+
+ assertThat(dss.history.get(3)).extracting("operation","key")
+ .containsExactly(MockIDynamicStatusStoreService.DssHistoryRecordType.DELETE, "run.myTestRun.method.name");
+
+ assertThat(dss.history.get(4)).extracting("operation","key")
+ .containsExactly(MockIDynamicStatusStoreService.DssHistoryRecordType.DELETE, "run.myTestRun.method.total");
+
+ assertThat(dss.history.get(5)).extracting("operation","key")
+ .containsExactly(MockIDynamicStatusStoreService.DssHistoryRecordType.DELETE, "run.myTestRun.method.current");
+
+ assertThat(dss.history.get(6)).extracting("operation","key")
+ .containsExactly(MockIDynamicStatusStoreService.DssHistoryRecordType.DELETE, "run.myTestRun.heartbeat");
assertThat(framework.isShutDown()).isTrue();
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIDynamicStatusStoreService.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIDynamicStatusStoreService.java
index c77eee0d8..9e26adf80 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIDynamicStatusStoreService.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIDynamicStatusStoreService.java
@@ -5,10 +5,9 @@
*/
package dev.galasa.framework.mocks;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
+
+import java.util.*;
+import java.util.Map.Entry;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
@@ -23,16 +22,40 @@
public class MockIDynamicStatusStoreService implements IDynamicStatusStoreService {
+ public static enum DssHistoryRecordType {
+ PUT, DELETE
+ }
+
+ public static class DssHistoryRecord {
+ public DssHistoryRecordType operation ;
+ public String key ;
+ public String value;
+
+ public DssHistoryRecord(DssHistoryRecordType operation, String key) {
+ this(operation,key,null);
+ }
+
+ public DssHistoryRecord(DssHistoryRecordType operation, String key, String value) {
+ this.operation = operation;
+ this.key = key;
+ this.value = value;
+ }
+ }
+
+ public List history = new ArrayList<>();
+
public Map data = new HashMap<>();
@Override
public boolean putSwap(@NotNull String key, String oldValue, @NotNull String newValue) {
+ history.add( new DssHistoryRecord(DssHistoryRecordType.PUT, key , newValue));
data.put(key,newValue);
return true;
}
@Override
public void delete(@NotNull String key) throws DynamicStatusStoreException {
+ history.add( new DssHistoryRecord(DssHistoryRecordType.DELETE, key ));
data.remove(key);
}
diff --git a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIResultArchiveStore.java b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIResultArchiveStore.java
index ad8439f0a..31092c555 100644
--- a/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIResultArchiveStore.java
+++ b/galasa-parent/dev.galasa.framework/src/test/java/dev/galasa/framework/mocks/MockIResultArchiveStore.java
@@ -33,7 +33,8 @@ public MockIResultArchiveStore(String runId, MockFileSystem mockFileSystem) {
@Override
public void updateTestStructure(@NotNull TestStructure testStructure) throws ResultArchiveStoreException {
assertThat(testStructure).isNotNull();
- testStructureHistory.add(testStructure);
+ TestStructure historyRecord = new TestStructure(testStructure);
+ testStructureHistory.add(historyRecord);
mockFS.setFileContents(mockFS.getPath("/my/stored/artifacts/root/framework/cps_record.properties"), "Dummy test content");
}