aboutsummaryrefslogtreecommitdiff
path: root/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java')
-rw-r--r--id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java111
1 files changed, 111 insertions, 0 deletions
diff --git a/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java b/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java
new file mode 100644
index 000000000..84581abe8
--- /dev/null
+++ b/id/server/modules/module-monitoring/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ *******************************************************************************/
+package at.gv.egovernment.moa.id.monitoring;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import at.gv.egovernment.moa.id.config.ConfigurationException;
+import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider;
+import at.gv.egovernment.moa.logging.Logger;
+import at.gv.egovernment.moa.util.FileUtils;
+
+public class TestManager {
+
+ private static TestManager instance;
+
+ private Map<String, TestModuleInterface> tests = new HashMap<String, TestModuleInterface>();
+
+ public static TestManager getInstance() throws ConfigurationException {
+ if (instance == null)
+ instance = new TestManager();
+
+ return instance;
+ }
+
+ private TestManager() throws ConfigurationException {
+
+ AuthConfigurationProvider config = AuthConfigurationProvider.getInstance();
+
+ //add Database test
+ DatabaseTestModule test1 = new DatabaseTestModule();
+ tests.put(test1.getName(), test1);
+
+ //add IdentityLink verification test
+ IdentityLinkTestModule test2 = new IdentityLinkTestModule();
+ String idlurl = FileUtils.makeAbsoluteURL(config.getMonitoringTestIdentityLinkURL(), config.getRootConfigFileDir());
+ try {
+ test2.initializeTest(0, idlurl);
+ tests.put(test2.getName(), test2);;
+
+ } catch (Exception e) {
+ Logger.warn("MOA-ID IdentityLink Test can not performed without IdentityLink. Insert IdentityLink file to MOA-ID configuration", e);
+ }
+ }
+
+ public List<String> executeTests() {
+ Logger.debug("Start MOA-ID-Auth testing");
+
+
+ List<String> errors;
+
+ for (TestModuleInterface test : tests.values()) {
+ try {
+ errors = test.performTests();
+ if (errors != null && errors.size() > 0)
+ return errors;
+
+ } catch (Exception e) {
+ Logger.warn("General Testing Eception during Test " + test.getClass() + ": ", e);
+ return Arrays.asList(e.getMessage());
+ }
+ }
+
+ return null;
+ }
+
+ public List<String> executeTest(String testname) {
+
+ TestModuleInterface test = tests.get(testname);
+
+ if (test != null) {
+ try {
+ return test.performTests();
+
+ } catch (Exception e) {
+ Logger.warn("General Testing Eception during Test " + test.getName() + ": ", e);
+ return Arrays.asList(e.getMessage());
+ }
+
+ } else {
+ Logger.info("TestModule with Name " + testname + " is not implemented");
+ return null;
+ }
+ }
+
+ public boolean existsModule(String modulename) {
+ return tests.containsKey(modulename);
+ }
+}